shader: lower RDNA2 scalar shifted additions in pixel_aot #581

Merged
stan495 merged 1 commit from upstream-pr/587 into main 2026-11-22 15:29:32 +00:00
stan495 commented 2026-11-22 14:24:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-22T14:24:22Z.


Change

Translate RDNA2 32-bit scalar shifted addition instructions s_lshl1_add_u32, s_lshl2_add_u32, s_lshl3_add_u32, and s_lshl4_add_u32 in tools/pixel_aot.py as ((src0 << K) + src1) with carry-out SCC condition ((src0 >> (32 - K) != 0) || (dest < src1)).

This advances the offline shader AOT pipeline by completing the RDNA2 SOP2 scaled addition family, complementing the 32-bit scalar ALU scope in #257 (where s_lshl1_add_u32 was previously listed as an unsupported rejection placeholder). Refs #257.

  • Register opcodes 0x2e..0x31 in tools/disasm_rdna2.py and recognition in tools/scan_unsupported_shaders.py.
  • Add synthetic opcode table verification in tests/rdna2_tools_check.py.
  • Replace the s_lshl1_add_u32 rejection in tests/pixel_aot_check.py with s_lshl5_add_u32, add sop2_lshl_add_group() static translation checks, and enforce rejections on out-of-range shift amounts (0, 5), wrong arity, vector sources, and vector destination.
  • Assert coverage across gfx1013.tsv and rdna2.tsv in tests/form_coverage_check.py.
  • Add check_lshl_add_u32_draw wired into check_e64_render using R32G32B32A32_UINT lossless readback, verifying small arithmetic values, shift wrap, add wrap, and selective SCC carry conditions against negative mismatch controls.
  • Document scalar shifted addition semantics and draw verification in docs/experiments.md.

Verification

Commit under test: 97d2cec on shader/sop2-lshl-add, rebased on upstream/main (d4c7656).
Environment: Windows 11 (build 10.0.26200), VS 2022 (17.14), Windows SDK 10.0.26100.0, DXC 10.0.26100.0.
Adapter: Microsoft Basic Render Driver (WARP), vendor 1414, device 008c, driver 10.0.26100.9711, debug layer enabled.

# Pure-Python checks
.\out\pe-env\Scripts\python.exe -B tests/rdna2_tools_check.py
# Result: Ran 43 tests in 0.640s, OK (skipped=1)

.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py
# Result: form coverage checks passed

.\out\pe-env\Scripts\python.exe -B tests/pixel_aot_check.py
# Result: exit 0 (all lowerer controls and must_reject checks pass)

.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
# Result: Self-test passed. Checked 10 Markdown files and 119 links.

.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
# Result: Self-test passed. Checked 554 tracked source, script and build/CI files: no bidirectional controls.

# CTest D3D12 WARP draws
.\tools\dev.ps1
ctest --preset dev --no-tests=error -R '^pixel_aot_e64_warp$' -V
# Result: 1/1 Test #260: pixel_aot_e64_warp ............... Passed 3.58 sec (100% tests passed, 0 tests failed)

ctest --preset dev --no-tests=error -R '^pixel_aot_blend_scalar_warp$' -V
# Result: 1/1 Test #259: pixel_aot_blend_scalar_warp ...... Passed 6.38 sec (100% tests passed, 0 tests failed)

Evidence and follow-up

  • All fixtures use synthetic source-built RDNA2 assembly and constant buffers; no game files, dumps, or proprietary assets are included.
  • Negative controls:
    • Lowerer controls assert that s_lshl0_add_u32, s_lshl5_add_u32, s_lshl1_add_u32 s62, s44, s_lshl3_add_u32 s62, v12, s45, s_lshl4_add_u32 s62, s44, v13, and s_lshl1_add_u32 v12, s44, s45 are rejected.
    • Draw tests evaluate oracle failure cases: a corrupted arithmetic expectation word (53 -> 999) and an inverted SCC carry flag (0 -> 1) each report pixel_mismatch and fail the batch check.
  • Measures synthetic shader lowering, DXC compilation, and D3D12 WARP integer readback. Full title execution remains unverified.

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543510466 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/587). Originally posted by [stan495](https://github.com/stan495) on 2026-11-22T14:24:22Z. --- ## Change Translate RDNA2 32-bit scalar shifted addition instructions `s_lshl1_add_u32`, `s_lshl2_add_u32`, `s_lshl3_add_u32`, and `s_lshl4_add_u32` in `tools/pixel_aot.py` as `((src0 << K) + src1)` with carry-out SCC condition `((src0 >> (32 - K) != 0) || (dest < src1))`. This advances the offline shader AOT pipeline by completing the RDNA2 SOP2 scaled addition family, complementing the 32-bit scalar ALU scope in #257 (where `s_lshl1_add_u32` was previously listed as an unsupported rejection placeholder). Refs #257. - Register opcodes `0x2e`..`0x31` in `tools/disasm_rdna2.py` and recognition in `tools/scan_unsupported_shaders.py`. - Add synthetic opcode table verification in `tests/rdna2_tools_check.py`. - Replace the `s_lshl1_add_u32` rejection in `tests/pixel_aot_check.py` with `s_lshl5_add_u32`, add `sop2_lshl_add_group()` static translation checks, and enforce rejections on out-of-range shift amounts (`0`, `5`), wrong arity, vector sources, and vector destination. - Assert coverage across `gfx1013.tsv` and `rdna2.tsv` in `tests/form_coverage_check.py`. - Add `check_lshl_add_u32_draw` wired into `check_e64_render` using `R32G32B32A32_UINT` lossless readback, verifying small arithmetic values, shift wrap, add wrap, and selective SCC carry conditions against negative mismatch controls. - Document scalar shifted addition semantics and draw verification in `docs/experiments.md`. ## Verification Commit under test: `97d2cec` on `shader/sop2-lshl-add`, rebased on `upstream/main` (`d4c7656`). Environment: Windows 11 (build 10.0.26200), VS 2022 (17.14), Windows SDK 10.0.26100.0, DXC 10.0.26100.0. Adapter: Microsoft Basic Render Driver (WARP), vendor 1414, device 008c, driver 10.0.26100.9711, debug layer enabled. ```powershell # Pure-Python checks .\out\pe-env\Scripts\python.exe -B tests/rdna2_tools_check.py # Result: Ran 43 tests in 0.640s, OK (skipped=1) .\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py # Result: form coverage checks passed .\out\pe-env\Scripts\python.exe -B tests/pixel_aot_check.py # Result: exit 0 (all lowerer controls and must_reject checks pass) .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py # Result: Self-test passed. Checked 10 Markdown files and 119 links. .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py # Result: Self-test passed. Checked 554 tracked source, script and build/CI files: no bidirectional controls. # CTest D3D12 WARP draws .\tools\dev.ps1 ctest --preset dev --no-tests=error -R '^pixel_aot_e64_warp$' -V # Result: 1/1 Test #260: pixel_aot_e64_warp ............... Passed 3.58 sec (100% tests passed, 0 tests failed) ctest --preset dev --no-tests=error -R '^pixel_aot_blend_scalar_warp$' -V # Result: 1/1 Test #259: pixel_aot_blend_scalar_warp ...... Passed 6.38 sec (100% tests passed, 0 tests failed) ``` ## Evidence and follow-up - All fixtures use synthetic source-built RDNA2 assembly and constant buffers; no game files, dumps, or proprietary assets are included. - Negative controls: - Lowerer controls assert that `s_lshl0_add_u32`, `s_lshl5_add_u32`, `s_lshl1_add_u32 s62, s44`, `s_lshl3_add_u32 s62, v12, s45`, `s_lshl4_add_u32 s62, s44, v13`, and `s_lshl1_add_u32 v12, s44, s45` are rejected. - Draw tests evaluate oracle failure cases: a corrupted arithmetic expectation word (`53` -> `999`) and an inverted SCC carry flag (`0` -> `1`) each report `pixel_mismatch` and fail the batch check. - Measures synthetic shader lowering, DXC compilation, and D3D12 WARP integer readback. Full title execution remains unverified. ## 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.
upstream-sync closed this pull request 2026-11-24 06:43:49 +00:00
alexander-src commented 2026-11-24 06:48:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-22T15:11:53Z.


Independent Linux x64 + LLVM 23.1.4 check on 97d2cec:

  • Assembled and disassembled s_lshl1_add_u32, s_lshl2_add_u32, s_lshl3_add_u32, and s_lshl4_add_u32 (0x2e..0x31) against libLLVM.so (gfx1013); all four match disasm_rdna2 output bit-for-bit.
  • Checked the SCC overflow condition ({0} >> (32-k) != 0u) || ({r} < {1}) against RDNA 2's (S0.u64 << k) + S1.u64 >= 2^32 rule; both shift-out overflow and 32-bit add wrap are covered accurately.
  • Local checks passing on 97d2cec: pixel_aot_check.py binary (LLVM 23), rdna2_tools_check.py, pso_readiness_check.py, form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py.

Windows DXC/WARP and hardware draws were not run locally on Linux.

AI-assisted: yes

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7081118173 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/587#issuecomment-7081118173). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-22T15:11:53Z. --- Independent Linux x64 + LLVM 23.1.4 check on `97d2cec`: - Assembled and disassembled `s_lshl1_add_u32`, `s_lshl2_add_u32`, `s_lshl3_add_u32`, and `s_lshl4_add_u32` (`0x2e`..`0x31`) against `libLLVM.so` (`gfx1013`); all four match `disasm_rdna2` output bit-for-bit. - Checked the SCC overflow condition `({0} >> (32-k) != 0u) || ({r} < {1})` against RDNA 2's `(S0.u64 << k) + S1.u64 >= 2^32` rule; both shift-out overflow and 32-bit add wrap are covered accurately. - Local checks passing on `97d2cec`: `pixel_aot_check.py binary` (LLVM 23), `rdna2_tools_check.py`, `pso_readiness_check.py`, `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py`. Windows DXC/WARP and hardware draws were not run locally on Linux. AI-assisted: yes
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!581
No description provided.