shader: lower RDNA2 scalar comparison instructions #494

Manually merged
github merged 1 commit from gh-pr/494/head into gh-pr/494/base 2026-11-26 21:56:30 +00:00
Owner

@⁠agilesh08 on GitHub · 2026-11-22 07:39 UTC · original
agilesh08:feat/shader-sopc-comparisons → main · +121 −6 · 5 files · 1 commits · merged 2026-11-22 08:11 UTC

## Change

Lowers 18 RDNA2 SOPC comparison and bit-test instructions in tools/pixel_aot.py across gfx1013 and gfx1030:

  • 32-bit signed comparisons: s_cmp_eq_i32, s_cmp_lg_i32, s_cmp_gt_i32, s_cmp_ge_i32, s_cmp_lt_i32, s_cmp_le_i32 (casting via HLSL asint).
  • 32-bit unsigned comparisons: s_cmp_eq_u32, s_cmp_lg_u32, s_cmp_gt_u32, s_cmp_ge_u32, s_cmp_lt_u32, s_cmp_le_u32.
  • 64-bit scalar comparisons: s_cmp_eq_u64, s_cmp_lg_u64 (evaluating both low and high dwords across even-aligned SGPR pairs).
  • 32-bit bit tests: s_bitcmp0_b32, s_bitcmp1_b32 (masking by src1 & 31u).
  • 64-bit bit tests: s_bitcmp0_b64, s_bitcmp1_b64 (selecting low or high dword via bit 5 and testing bit index).

Updates SCC tracking so subsequent s_cmov_b64 selects correctly, rejects out-of-range registers (s106), unaligned pairs (s[65:66]), and unsupported comparison types (s_cmp_gt_u64, s_cmp_eq_i64).

Verification

  • python -B tests/rdna2_tools_check.py: 28 passed on Windows (including test_sopc_opcode_table_synthetic_forms).
  • python -B tests/pixel_aot_check.py: passed on Windows (asserts all 18 forms in ACCEPTED, verifies generated HLSL expressions, rejects out-of-range registers and unaligned pairs).
  • python -B tests/form_coverage_check.py: passed on Windows (asserts all 18 SOPC forms map into both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv).
  • All 21 platform-independent Python checks: 21 passed (0 failures).
  • git -c core.whitespace=cr-at-eol diff --check: 0 errors.
  • Note: Local host lacks dxc.exe; DXBC compilation and D3D12/WARP offscreen readback run in GitHub Actions CI (windows.yml).

Evidence and follow-up

Adds unit test sopc_group() in tests/pixel_aot_check.py and test_sopc_opcode_table_synthetic_forms in tests/rdna2_tools_check.py. No copyrighted assets or external shader binaries are included.

Assisted by AI.

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.
**@⁠agilesh08** on GitHub · 2026-11-22 07:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/494) `agilesh08:feat/shader-sopc-comparisons` → `main` · +121 −6 · 5 files · 1 commits · merged 2026-11-22 08:11 UTC ## Change Lowers 18 RDNA2 SOPC comparison and bit-test instructions in `tools/pixel_aot.py` across `gfx1013` and `gfx1030`: - 32-bit signed comparisons: `s_cmp_eq_i32`, `s_cmp_lg_i32`, `s_cmp_gt_i32`, `s_cmp_ge_i32`, `s_cmp_lt_i32`, `s_cmp_le_i32` (casting via HLSL `asint`). - 32-bit unsigned comparisons: `s_cmp_eq_u32`, `s_cmp_lg_u32`, `s_cmp_gt_u32`, `s_cmp_ge_u32`, `s_cmp_lt_u32`, `s_cmp_le_u32`. - 64-bit scalar comparisons: `s_cmp_eq_u64`, `s_cmp_lg_u64` (evaluating both low and high dwords across even-aligned SGPR pairs). - 32-bit bit tests: `s_bitcmp0_b32`, `s_bitcmp1_b32` (masking by `src1 & 31u`). - 64-bit bit tests: `s_bitcmp0_b64`, `s_bitcmp1_b64` (selecting low or high dword via bit 5 and testing bit index). Updates SCC tracking so subsequent `s_cmov_b64` selects correctly, rejects out-of-range registers (`s106`), unaligned pairs (`s[65:66]`), and unsupported comparison types (`s_cmp_gt_u64`, `s_cmp_eq_i64`). ## Verification - `python -B tests/rdna2_tools_check.py`: 28 passed on Windows (including `test_sopc_opcode_table_synthetic_forms`). - `python -B tests/pixel_aot_check.py`: passed on Windows (asserts all 18 forms in `ACCEPTED`, verifies generated HLSL expressions, rejects out-of-range registers and unaligned pairs). - `python -B tests/form_coverage_check.py`: passed on Windows (asserts all 18 SOPC forms map into both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`). - All 21 platform-independent Python checks: 21 passed (0 failures). - `git -c core.whitespace=cr-at-eol diff --check`: 0 errors. - *Note:* Local host lacks `dxc.exe`; DXBC compilation and D3D12/WARP offscreen readback run in GitHub Actions CI (`windows.yml`). ## Evidence and follow-up Adds unit test `sopc_group()` in `tests/pixel_aot_check.py` and `test_sopc_opcode_table_synthetic_forms` in `tests/rdna2_tools_check.py`. No copyrighted assets or external shader binaries are included. Assisted by AI. ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:56:29 +00:00
github manually merged commit 13249f86ec into gh-pr/494/base 2026-11-26 21:56:30 +00:00
Author
Owner

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

Reviewed 13249f8. Independently translated each of the 18 SOPC forms, consumed its SCC with s_cmov_b64, compiled the result with DXC and checked the exported pixels with offscreen_check on WARP. Four constant sets per instruction (72 draws) matched the CPU reference, including signed versus unsigned ordering, a differing high dword and bit indices beyond 31. This measures the new operations separately so a later SCC writer cannot mask an earlier one.

**@⁠R0Y00** on GitHub · 2026-11-22 08:11 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/494#pullrequestreview-6011174324) · **approved these changes** Reviewed 13249f8. Independently translated each of the 18 SOPC forms, consumed its SCC with s_cmov_b64, compiled the result with DXC and checked the exported pixels with offscreen_check on WARP. Four constant sets per instruction (72 draws) matched the CPU reference, including signed versus unsigned ordering, a differing high dword and bit indices beyond 31. This measures the new operations separately so a later SCC writer cannot mask an earlier one.
This discussion has been locked. Commenting is limited to contributors.
No description provided.