shader: lower v_pk_mul_lo_u16, v_pk_mad_u16 and v_pk_mad_i16 in the direct compute path #3092

Manually merged
github merged 1 commit from github-bot/gh-3092 into gh-pr/3092/base 2026-11-27 15:39:02 +00:00 AGit
Owner

@⁠R0D4X on GitHub · 2026-11-27 14:56 UTC · original
R0D4X:feat/native-pk-mul-mad-16 → main · +253 −0 · 4 files · 1 commits · merged 2026-11-27 15:31 UTC

Fixes #3090. Refs #2935.

What this changes

  • Lowers gfx1013 VOP3P v_pk_mul_lo_u16 (0x01), v_pk_mad_u16 (0x09), and v_pk_mad_i16 (0x00) in src/gfx1013_direct_compute.inl:
    • Supports 2-source (op_sel[1:0]/op_sel_hi[1:0]) and 3-source (op_sel[2:0]/op_sel_hi[2:0]) lane selection.
    • v_pk_mul_lo_u16 wraps each 16-bit product modulo 2^16 and refuses clamp, op_sel[2], and nonzero src2.
    • v_pk_mad_u16 and v_pk_mad_i16 wrap modulo 2^16 when unclamped, or saturate each lane to [0, 65535] / [-32768, 32767] when clamp is set; neg_lo/neg_hi are refused on all three opcodes with unsupported packed 16-bit mul/mad operand modifiers.

Tests & docs added

  • tests/native_pk_mul_mad_16_check.py & tests/cmake/native_pk_mul_mad_16.cmake: DXIL compile & disassembly controls, five modifier/reserved-bit refusal encodings, and native_store_replay hardware dispatches (dense, sparse EXEC, and no-clamp negative control across 8 patterns x 4 forms = 2,048 words + 16 guards).
  • docs/experiments/native-pk-mul-mad-16.md: semantics and reproduction commands.

Verification

Commit: 5534e16c on Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK & DXC 10.0.26100.0, NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2124), SM 6.6 wave32:

  • ctest --preset dev --no-tests=error -R '^native_pk_mul_mad_16_|^native_packed_dot4_' -V: 4/4 passed, 0 skipped
    • native_pk_mul_mad_16_hardware: sparse=False and sparse=True matched 2048 result words and 16 guards; no-clamp control differed on 638 words.
  • ctest --preset release --no-tests=error -R '^native_pk_mul_mad_16_|^native_packed_dot4_': 4/4 passed, 0 skipped
  • Repo checks (docs_links_check.py, bidi_controls_check.py, git diff --check): all passed.

Scope: Covers synthetic v_pk_mul_lo_u16, v_pk_mad_u16, and v_pk_mad_i16 wave32 compute fixtures through compile_dxil and native_store_replay; does not establish full-title startup or runtime execution.

**@⁠R0D4X** on GitHub · 2026-11-27 14:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3092) `R0D4X:feat/native-pk-mul-mad-16` → `main` · +253 −0 · 4 files · 1 commits · merged 2026-11-27 15:31 UTC Fixes #3090. Refs #2935. ## What this changes - Lowers gfx1013 VOP3P `v_pk_mul_lo_u16` (`0x01`), `v_pk_mad_u16` (`0x09`), and `v_pk_mad_i16` (`0x00`) in `src/gfx1013_direct_compute.inl`: - Supports 2-source (`op_sel[1:0]`/`op_sel_hi[1:0]`) and 3-source (`op_sel[2:0]`/`op_sel_hi[2:0]`) lane selection. - `v_pk_mul_lo_u16` wraps each 16-bit product modulo 2^16 and refuses `clamp`, `op_sel[2]`, and nonzero `src2`. - `v_pk_mad_u16` and `v_pk_mad_i16` wrap modulo 2^16 when unclamped, or saturate each lane to `[0, 65535]` / `[-32768, 32767]` when `clamp` is set; `neg_lo`/`neg_hi` are refused on all three opcodes with `unsupported packed 16-bit mul/mad operand modifiers`. ## Tests & docs added - `tests/native_pk_mul_mad_16_check.py` & `tests/cmake/native_pk_mul_mad_16.cmake`: DXIL compile & disassembly controls, five modifier/reserved-bit refusal encodings, and `native_store_replay` hardware dispatches (dense, sparse `EXEC`, and no-clamp negative control across 8 patterns x 4 forms = 2,048 words + 16 guards). - `docs/experiments/native-pk-mul-mad-16.md`: semantics and reproduction commands. ## Verification Commit: `5534e16c` on Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK & DXC `10.0.26100.0`, `NVIDIA GeForce RTX 5080` (`10de:2c02`, driver `32.0.16.2124`), SM 6.6 wave32: - `ctest --preset dev --no-tests=error -R '^native_pk_mul_mad_16_|^native_packed_dot4_' -V`: 4/4 passed, 0 skipped - `native_pk_mul_mad_16_hardware`: `sparse=False` and `sparse=True` matched 2048 result words and 16 guards; no-clamp control differed on 638 words. - `ctest --preset release --no-tests=error -R '^native_pk_mul_mad_16_|^native_packed_dot4_'`: 4/4 passed, 0 skipped - Repo checks (`docs_links_check.py`, `bidi_controls_check.py`, `git diff --check`): all passed. *Scope:* Covers synthetic `v_pk_mul_lo_u16`, `v_pk_mad_u16`, and `v_pk_mad_i16` wave32 compute fixtures through `compile_dxil` and `native_store_replay`; does not establish full-title startup or runtime execution.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:57:21 +00:00
github-bot changed target branch from main to gh-pr/3092/base 2026-11-27 15:39:01 +00:00
github manually merged commit 5534e16cb3 into gh-pr/3092/base 2026-11-27 15:39:02 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-27 15:30 UTC · original · approved these changes

Independent validation of 5534e16c on main 7a12818c (tree 020ae0d02e70cf68ac8efa9074c5b02c5323b7ac). Both packed halves use their own selections. Multiplication and addition fit in a 32-bit intermediate for the supported signed and unsigned forms, and clamp applies after the multiply-add. This integration does not include #3088.

Built compile_dxil native_store_replay and ran ctest --test-dir <build> --no-tests=error -j 1 -V -R '^native_(pk_mul_mad_16|int16_ternary|packed_dot2|mul24)_(controls|hardware)$'. Debug and Release /O2 each passed 8/8 with zero skips. Full and sparse EXEC matched 2,048 result words and 16 guards; removing clamp changed 638 words. The five modifier refusal controls passed. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK DXC 10.0.26100, replay debug layer off. The wave32 replay is hardware-only.

**@⁠R0Y00** on GitHub · 2026-11-27 15:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3092#pullrequestreview-6090384200) · **approved these changes** Independent validation of `5534e16c` on `main` `7a12818c` (tree `020ae0d02e70cf68ac8efa9074c5b02c5323b7ac`). Both packed halves use their own selections. Multiplication and addition fit in a 32-bit intermediate for the supported signed and unsigned forms, and clamp applies after the multiply-add. This integration does not include #3088. Built `compile_dxil native_store_replay` and ran `ctest --test-dir <build> --no-tests=error -j 1 -V -R '^native_(pk_mul_mad_16|int16_ternary|packed_dot2|mul24)_(controls|hardware)$'`. Debug and Release `/O2` each passed 8/8 with zero skips. Full and sparse EXEC matched 2,048 result words and 16 guards; removing clamp changed 638 words. The five modifier refusal controls passed. Windows 11 26200.9974, RTX 4060 Laptop driver 32.0.16.1656, SDK DXC 10.0.26100, replay debug layer off. The wave32 replay is hardware-only.
This discussion has been locked. Commenting is limited to contributors.
No description provided.