shader: lower v_dot2c_f32_f16 in direct Compute and Pixel DXIL #3257

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/3257 into main 2026-11-28 04:14:49 +00:00
legacy-code-archaeologist commented 2026-11-28 02:19:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-28T02:19:19Z.


Lowers plain VOP2 v_dot2c_f32_f16 (0x02) in direct Compute and Pixel DXIL on top of the merged v_dot2_f32_f16 path (#3239).

Fixes #3256. Refs #2935.

Summary

  • src/gfx1013_direct_compute.inl:
    • Extended DirectCompute::float_alu() to handle v_dot2c_f32_f16: enforces Encoding::Vop2 with zero modifiers (refusing _e64 / wide, subword, dpp_control, permuted, abs, neg, clamp, scale), accepts packed f16x2 inline/SGPR/VGPR/literal src0 and VGPR vsrc1, reads the initial binary32 accumulator from i.dst, fixes op_sel = 0 and op_sel_hi = 3, and reuses the legacyF16ToF32 + fmul + fadd + keep_subnormal binary32 subnormal preservation and 0x8000ffu mode gate.
    • Added op.name == "v_dot2c_f32_f16" to half_binary = true in DirectCompute::lower() so s_round_mode, s_denorm_mode, s_setreg, and conditional mode writes gate v_dot2c_f32_f16 identically to v_dot2_f32_f16.
  • tests/native_dot2c_f32_f16_check.py, tests/cmake/native_packed_dot2c_f16.cmake:
    • 19 cases: VGPR basic/cancel, back-to-back multi-accumulate into vdst, vdst aliasing src0 and vsrc1, SGPR/literal src0, inline binary16 float/integer constants (0.5, 1.0, -1.0, 0), binary16 subnormals, binary32 subnormal accumulators (0x00000001, 0x80400000, nonzero-dot rounding), partial EXEC_LO (0xAAAAAAAA) lane preservation, signed zero, Inf, and NaN.
    • 9 refusals: _e64 (0xD5020000), DPP16, DPP8, SDWA, vcc_lo src0, s_round_mode 0x4, s_denorm_mode 0x3, s_denorm_mode 0xC, and conditional mode write.

Verification (dev and release /O2, Windows 10.0.26100)

  • ctest --preset dev --no-tests=error -V -R '^native_packed_dot2c?_f16_' & ctest --preset release --no-tests=error -V -R '^native_packed_dot2c?_f16_':
    • native_packed_dot2c_f16_ir: Passed (19 cases matched exact model; 9 refusals matched).
    • native_packed_dot2c_f16_controls: Passed (19 cases compiled to DXIL; 9 refusals verified).
    • native_packed_dot2c_f16_pixel_warp: Passed (Microsoft Basic Render Driver 10.0.26100.9711, 4 quad draws matched; debug_layer=unavailable).
    • native_packed_dot2c_f16_pixel_hardware: Passed (4 quad draws matched; host hardware pixel adapter is NVIDIA Quadro M1000M, 32.0.15.7371, debug_layer=unavailable).
    • native_packed_dot2c_f16_compute_hardware: Skipped (77) (Intel(R) HD Graphics 530, vendor 8086, device 191b, driver 31.0.101.2111 lacks SM 6.6 wave32 — needs testing on a wave32-capable GPU).
    • native_packed_dot2_f16_{ir,controls,pixel_warp,pixel_hardware}: Passed (30 cases, 10 refusals, 7 quad draws); _compute_hardware skipped (77, Intel HD 530).
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 71/71 passed (0 skips).
  • Sensitivity mutants caught (rc=8): forcing op_sel_hi = 0 for dot2c failed native_packed_dot2c_f16_ir; dropping keep_subnormal for dot2c failed native_packed_dot2c_f16_pixel_warp (0x00000001/0x80400000 flushed to 0); removing v_dot2c_f32_f16 from half_binary failed native_packed_dot2c_f16_ir.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5535750964 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3257). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-28T02:19:19Z. --- Lowers plain VOP2 `v_dot2c_f32_f16` (`0x02`) in direct Compute and Pixel DXIL on top of the merged `v_dot2_f32_f16` path (#3239). Fixes #3256. Refs #2935. ### Summary - **`src/gfx1013_direct_compute.inl`:** - Extended `DirectCompute::float_alu()` to handle `v_dot2c_f32_f16`: enforces `Encoding::Vop2` with zero modifiers (refusing `_e64` / `wide`, `subword`, `dpp_control`, `permuted`, `abs`, `neg`, `clamp`, `scale`), accepts packed `f16x2` inline/SGPR/VGPR/literal `src0` and VGPR `vsrc1`, reads the initial binary32 accumulator from `i.dst`, fixes `op_sel = 0` and `op_sel_hi = 3`, and reuses the `legacyF16ToF32` + `fmul` + `fadd` + `keep_subnormal` binary32 subnormal preservation and `0x8000ffu` mode gate. - Added `op.name == "v_dot2c_f32_f16"` to `half_binary = true` in `DirectCompute::lower()` so `s_round_mode`, `s_denorm_mode`, `s_setreg`, and conditional mode writes gate `v_dot2c_f32_f16` identically to `v_dot2_f32_f16`. - **`tests/native_dot2c_f32_f16_check.py`, `tests/cmake/native_packed_dot2c_f16.cmake`:** - `19` cases: VGPR basic/cancel, back-to-back multi-accumulate into `vdst`, `vdst` aliasing `src0` and `vsrc1`, SGPR/literal `src0`, inline binary16 float/integer constants (`0.5`, `1.0`, `-1.0`, `0`), binary16 subnormals, binary32 subnormal accumulators (`0x00000001`, `0x80400000`, nonzero-dot rounding), partial `EXEC_LO` (`0xAAAAAAAA`) lane preservation, signed zero, Inf, and NaN. - `9` refusals: `_e64` (`0xD5020000`), DPP16, DPP8, SDWA, `vcc_lo` `src0`, `s_round_mode 0x4`, `s_denorm_mode 0x3`, `s_denorm_mode 0xC`, and conditional mode write. ### Verification (`dev` and `release` `/O2`, Windows `10.0.26100`) - `ctest --preset dev --no-tests=error -V -R '^native_packed_dot2c?_f16_'` & `ctest --preset release --no-tests=error -V -R '^native_packed_dot2c?_f16_'`: - `native_packed_dot2c_f16_ir`: **Passed** (`19` cases matched exact model; `9` refusals matched). - `native_packed_dot2c_f16_controls`: **Passed** (`19` cases compiled to DXIL; `9` refusals verified). - `native_packed_dot2c_f16_pixel_warp`: **Passed** (`Microsoft Basic Render Driver` `10.0.26100.9711`, `4` quad draws matched; `debug_layer=unavailable`). - `native_packed_dot2c_f16_pixel_hardware`: **Passed** (`4` quad draws matched; host hardware pixel adapter is `NVIDIA Quadro M1000M`, `32.0.15.7371`, `debug_layer=unavailable`). - `native_packed_dot2c_f16_compute_hardware`: **Skipped (`77`)** (`Intel(R) HD Graphics 530`, vendor `8086`, device `191b`, driver `31.0.101.2111` lacks SM 6.6 wave32 — needs testing on a wave32-capable GPU). - `native_packed_dot2_f16_{ir,controls,pixel_warp,pixel_hardware}`: **Passed** (`30` cases, `10` refusals, `7` quad draws); `_compute_hardware` skipped (`77`, Intel HD 530). - `ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure`: **71/71 passed** (`0` skips). - Sensitivity mutants caught (`rc=8`): forcing `op_sel_hi = 0` for `dot2c` failed `native_packed_dot2c_f16_ir`; dropping `keep_subnormal` for `dot2c` failed `native_packed_dot2c_f16_pixel_warp` (`0x00000001`/`0x80400000` flushed to `0`); removing `v_dot2c_f32_f16` from `half_binary` failed `native_packed_dot2c_f16_ir`. AI-assisted.
pigalot commented 2026-11-28 04:13:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T04:13:13Z.

Review: APPROVED


Independently reviewed 870b15d2 integrated over main fbef6381 (tree e0bef3e6). The merge is clean, and git diff --cached --check is clean.

What I traced. VOP2 v_dot2c_f32_f16 reuses the v_dot2_f32_f16 lowering, with these differences:

  • the halves are fixed (op_sel = 0, op_sel_hi = 3), so lows are paired with lows and highs with highs;
  • there are no modifiers;
  • the accumulator is read from D (read(i.dst), where the VOP2 decoder has i.dst = 256 + vdst).

It joins half_binary, so the s_round_mode, s_denorm_mode and s_setreg gates apply to it as they do to v_dot2_f32_f16. vcc_lo and the other special sources stay refused through half_pair.

What I ran. I built compile_dxil native_store_replay native_compute_ir_dump offscreen_check in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_packed_dot2c?_f16_.+$'

The _hardware tests ran at -j 1. All 10 pass in Debug and in Release /O2, with no skips:

  • native_packed_dot2c_f16_ir: 19 cases and 9 refusals.
  • native_packed_dot2c_f16_controls: 19 compiled and 9 refusals.
  • native_packed_dot2c_f16_pixel_warp and native_packed_dot2c_f16_pixel_hardware: 4 quad draws each.
  • native_packed_dot2c_f16_compute_hardware: "19 cases matched across 2x32 lanes and guards" on the RTX 5090. The description says this test skipped on the author's GPU, so this is its first wave32 run.
  • The native_packed_dot2_f16_* neighbours: 30 cases, 10 refusals, 7 quad draws.

The 79 ^native_.*_(controls|ir)$ tests pass in dev.

Negative control and mutants. Each mutant was rebuilt in dev and run against all five new tests:

Mutant Result
src/gfx1013_direct_compute.inl back to main killed in all five: "direct DXIL lowering for v_dot2c_f32_f16"
op_sel_hi = 0 (high pair reads low halves) killed: _ir, _pixel_warp, both hardware tests
op_sel = 1 (pair 0 reads src0's high half) killed: _ir, _pixel_warp, both hardware tests
accumulator read from src[2] instead of D killed: _ir, _pixel_warp, both hardware tests
v_dot2c_f32_f16 left out of half_binary killed: _ir, _controls (mode refusal 5)
_e64 / wide encoding accepted killed: _ir, _controls (refusal 0)

Afterwards I restored and rebuilt. The restored build passes again, and git diff --quiet is clean.

Verdict: approve on 870b15d2.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10; wave32; D3D12 debug layer enabled in the pixel tests.
CI: Build and test on Windows passes on 870b15d2.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6095722593 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3257#pullrequestreview-6095722593). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T04:13:13Z. **Review:** APPROVED --- Independently reviewed `870b15d2` integrated over `main` `fbef6381` (tree `e0bef3e6`). The merge is clean, and `git diff --cached --check` is clean. **What I traced.** VOP2 `v_dot2c_f32_f16` reuses the `v_dot2_f32_f16` lowering, with these differences: - the halves are fixed (`op_sel = 0`, `op_sel_hi = 3`), so lows are paired with lows and highs with highs; - there are no modifiers; - the accumulator is read from D (`read(i.dst)`, where the VOP2 decoder has `i.dst = 256 + vdst`). It joins `half_binary`, so the `s_round_mode`, `s_denorm_mode` and `s_setreg` gates apply to it as they do to `v_dot2_f32_f16`. `vcc_lo` and the other special sources stay refused through `half_pair`. **What I ran.** I built `compile_dxil native_store_replay native_compute_ir_dump offscreen_check` in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^native_packed_dot2c?_f16_.+$' ``` The `_hardware` tests ran at `-j 1`. All 10 pass in Debug and in Release `/O2`, with no skips: - `native_packed_dot2c_f16_ir`: 19 cases and 9 refusals. - `native_packed_dot2c_f16_controls`: 19 compiled and 9 refusals. - `native_packed_dot2c_f16_pixel_warp` and `native_packed_dot2c_f16_pixel_hardware`: 4 quad draws each. - `native_packed_dot2c_f16_compute_hardware`: "19 cases matched across 2x32 lanes and guards" on the RTX 5090. The description says this test skipped on the author's GPU, so this is its first wave32 run. - The `native_packed_dot2_f16_*` neighbours: 30 cases, 10 refusals, 7 quad draws. The 79 `^native_.*_(controls|ir)$` tests pass in `dev`. **Negative control and mutants.** Each mutant was rebuilt in `dev` and run against all five new tests: | Mutant | Result | |---|---| | `src/gfx1013_direct_compute.inl` back to `main` | killed in all five: "direct DXIL lowering for v_dot2c_f32_f16" | | `op_sel_hi = 0` (high pair reads low halves) | killed: `_ir`, `_pixel_warp`, both hardware tests | | `op_sel = 1` (pair 0 reads src0's high half) | killed: `_ir`, `_pixel_warp`, both hardware tests | | accumulator read from `src[2]` instead of D | killed: `_ir`, `_pixel_warp`, both hardware tests | | `v_dot2c_f32_f16` left out of `half_binary` | killed: `_ir`, `_controls` (mode refusal 5) | | `_e64` / wide encoding accepted | killed: `_ir`, `_controls` (refusal 0) | Afterwards I restored and rebuilt. The restored build passes again, and `git diff --quiet` is clean. **Verdict:** approve on `870b15d2`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10; wave32; D3D12 debug layer enabled in the pixel tests. CI: `Build and test on Windows` passes on `870b15d2`. This reply was AI-assisted.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3257
No description provided.