shader: lower SDWA forms of the f32 comparisons in pixel_aot #337

Manually merged
github merged 3 commits from gh-pr/337/head into gh-pr/337/base 2026-11-26 21:44:10 +00:00
Owner

@⁠Its3rr0rsWRLD on GitHub · 2026-11-21 22:36 UTC · original
Its3rr0rsWRLD:shader/sdwa-cmp → main · +46 −2 · 3 files · 3 commits · merged 2026-11-22 08:21 UTC

Change

This lowers the SDWA forms of the 16 v_cmp_*_f32 predicates when both src0_sel and src1_sel are DWORD. With whole-dword selections an SDWA compare reads its operands exactly as the e32/e64 form does, so the new branch produces the same condition tracking and the same HLSL. A byte or word selection would compare a zero-extended field as binary32, which depends on the unmeasured binary32 denormal mode, so those forms are refused. LLVM 15 prints the mask as vcc_lo/sN in wave32 and vcc/s[N:N+1] in wave64. Both go through the existing LANE_MASK handling.

This is independent of #329 and #334. It touches neither their helpers nor the lines they edit.

Verification

Commit b860dd5 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V
  • pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed on WARP 10.0.26100.9818.
  • Each test runs 74 draws with this change and 54 on b860dd5. The 20 extra draws are the four predicate groups × five input pairs below. Every draw reports debug_errors=0 and max_absolute_error=0.
  • tests/pixel_aot_check.py binary passes with the four SDWA predicate groups added to the binary fixtures: LLVM 15.0.6 llvm-mc and llvm-objcopy, disassembled through libLLVM-17.so and libLLVM-18.so on Linux. The controls, tests/docs_links_check.py and tests/bidi_controls_check.py pass.

Evidence and follow-up

predicate_group(first, sdwa=True) writes the same four compares as the existing groups in SDWA form, with an SGPR src0. The new draw check repeats the existing inputs for every group: less, equal (-0 and +0), greater, and NaN on either side. A reference that inverts each group's unordered result must report pixel_mismatch, and it does. A control asserts that the translated HLSL is identical to the e32 groups and that a WORD_1 selection is refused. The translator on b860dd5 rejects the SDWA compares.

Not covered: v_cmpx_*_f32_sdwa, which writes EXEC, and v_cmp_class_f32_sdwa, which would follow #293.

This branch merges cleanly with #288, #293, #324, #329 and #334.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc

**@⁠Its3rr0rsWRLD** on GitHub · 2026-11-21 22:36 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/337) `Its3rr0rsWRLD:shader/sdwa-cmp` → `main` · +46 −2 · 3 files · 3 commits · merged 2026-11-22 08:21 UTC ## Change This lowers the SDWA forms of the 16 `v_cmp_*_f32` predicates when both `src0_sel` and `src1_sel` are `DWORD`. With whole-dword selections an SDWA compare reads its operands exactly as the e32/e64 form does, so the new branch produces the same condition tracking and the same HLSL. A byte or word selection would compare a zero-extended field as binary32, which depends on the unmeasured binary32 denormal mode, so those forms are refused. LLVM 15 prints the mask as `vcc_lo`/`sN` in wave32 and `vcc`/`s[N:N+1]` in wave64. Both go through the existing `LANE_MASK` handling. This is independent of #329 and #334. It touches neither their helpers nor the lines they edit. ## Verification Commit b860dd5 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` - `pixel_aot_hardware`: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed on WARP 10.0.26100.9818. - Each test runs 74 draws with this change and 54 on b860dd5. The 20 extra draws are the four predicate groups × five input pairs below. Every draw reports `debug_errors=0` and `max_absolute_error=0`. - `tests/pixel_aot_check.py binary` passes with the four SDWA predicate groups added to the binary fixtures: LLVM 15.0.6 `llvm-mc` and `llvm-objcopy`, disassembled through `libLLVM-17.so` and `libLLVM-18.so` on Linux. The controls, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. ## Evidence and follow-up `predicate_group(first, sdwa=True)` writes the same four compares as the existing groups in SDWA form, with an SGPR `src0`. The new draw check repeats the existing inputs for every group: less, equal (-0 and +0), greater, and NaN on either side. A reference that inverts each group's unordered result must report `pixel_mismatch`, and it does. A control asserts that the translated HLSL is identical to the e32 groups and that a `WORD_1` selection is refused. The translator on b860dd5 rejects the SDWA compares. Not covered: `v_cmpx_*_f32_sdwa`, which writes EXEC, and `v_cmp_class_f32_sdwa`, which would follow #293. This branch merges cleanly with #288, #293, #324, #329 and #334. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
Lower v_cmp_*_f32_sdwa with whole-dword selections as the e32/e64 comparisons and refuse byte and word selections. The 16-predicate draws are repeated with the SDWA forms, including NaN on either side, and the four groups join the gfx1013 binary fixtures.

AI-assisted: yes (Claude Opus 5.5)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:44:07 +00:00
github manually merged commit f2507616b8 into gh-pr/337/base 2026-11-26 21:44:10 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 08:20 UTC · original

The physical GPU also passed check_sdwa_predicate_draws at f250761 on Windows 11 25H2 build 26200.9974, NVIDIA GeForce RTX 4060 Laptop GPU, driver 32.0.16.1656, D3D12 debug layer enabled. All 20 positive draws had maximum absolute error 0 across 4,096 pixels (16,384 channels per draw), with zero debug warnings or errors. The four deliberately inverted unordered references were detected.

**@⁠R0Y00** on GitHub · 2026-11-22 08:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/337#issuecomment-7076454655) The physical GPU also passed check_sdwa_predicate_draws at f250761 on Windows 11 25H2 build 26200.9974, NVIDIA GeForce RTX 4060 Laptop GPU, driver 32.0.16.1656, D3D12 debug layer enabled. All 20 positive draws had maximum absolute error 0 across 4,096 pixels (16,384 channels per draw), with zero debug warnings or errors. The four deliberately inverted unordered references were detected.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-22 08:16 UTC · original · approved these changes

Reviewed and integrated main at f250761. Preserved both the SCC tests and the SDWA fixture. On Windows I ran the merged pixel controls and check_sdwa_predicate_draws with the Windows SDK DXC and Microsoft WARP (driver 10.0.26100.9818, debug layer enabled). All 20 positive draws matched the reference over 4,096 pixels each, including unordered comparisons; the inverted unordered controls reported the expected mismatches. The added translator pattern stays limited to full-dword selectors.

**@⁠R0Y00** on GitHub · 2026-11-22 08:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/337#pullrequestreview-6011189651) · **approved these changes** Reviewed and integrated main at f250761. Preserved both the SCC tests and the SDWA fixture. On Windows I ran the merged pixel controls and check_sdwa_predicate_draws with the Windows SDK DXC and Microsoft WARP (driver 10.0.26100.9818, debug layer enabled). All 20 positive draws matched the reference over 4,096 pixels each, including unordered comparisons; the inverted unordered controls reported the expected mismatches. The added translator pattern stays limited to full-dword selectors.
This discussion has been locked. Commenting is limited to contributors.
No description provided.