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

Merged
Its3rr0rsWRLD merged 3 commits from upstream-pr/337 into main 2026-11-22 08:21:11 +00:00
Its3rr0rsWRLD commented 2026-11-21 22:36:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T22:36:58Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535303834 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/337). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T22:36:58Z. --- ## 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
upstream-sync closed this pull request 2026-11-24 06:42:29 +00:00
R0Y00 commented 2026-11-24 06:42:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T08:16:26Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6011189651 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/337#pullrequestreview-6011189651). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T08:16:26Z. **Review:** APPROVED --- 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 commented 2026-11-24 06:48:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T08:20:07Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7076454655 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/337#issuecomment-7076454655). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T08:20:07Z. --- 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.
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!332
No description provided.