shader: lower gfx1013 SOP1 s_abs_i32, s_cmov_b32 and s_bitset ops in pixel_aot #574

Manually merged
github merged 2 commits from gh-pr/574/head into gh-pr/574/base 2026-11-26 22:02:59 +00:00
Owner

@⁠Neoplayer on GitHub · 2026-11-22 13:17 UTC · original
Neoplayer:shader/sop1-scalar-ops → main · +127 −2 · 3 files · 2 commits · merged 2026-11-22 14:30 UTC

Change

Lower four 32-bit scalar SOP1 instructions (s_abs_i32, s_cmov_b32, s_bitset0_b32, s_bitset1_b32) in tools/pixel_aot.py, keep tools/scan_unsupported_shaders.py synchronized, and add coverage and controls in tests/pixel_aot_check.py.

  • Add abs_i32 to SCALAR ((asint({0}) < 0 ? (0u - {0}) : {0}), setting scc = (result != 0u) so INT_MIN wraps to 0x80000000 with scc = 1), and validate sgpr_name(dst) in the SCALAR handler so out-of-range SGPRs (s106+) are rejected cleanly.
  • Lower s_cmov_b32 (scc ? src0 : dst, requiring tracked scc, validating dst and src0 via scalar_u32(), preserving scc).
  • Lower s_bitset0_b32 and s_bitset1_b32 (masking bit index & 31u, performing read-modify-write on dst via scalar_u32(), preserving scc).
  • Add all four opcodes to _check_two_exits() in tools/pixel_aot.py and sync SUPPORTED_INSTRUCTIONS_REGEX and KNOWN_RDNA2_BASE_OPCODES in tools/scan_unsupported_shaders.py.
  • Update tests/pixel_aot_check.py:
    • Replace the prior must_reject placeholder s_abs_i32 s62, s44 with genuinely unsupported s_quadmask_b32 s62, s44 and s_bitset0_b64 s[62:63], s44.
    • Add sop1_scalar_ops(), sop1_scalar_ops_reference(), and check_sop1_scalar_ops_draw() (integer_rt=True, wired into check_binary() and check_blend_and_scalar_draws()), exercising 0, negative, positive, and INT_MIN inputs for s_abs_i32, register and literal sources for s_cmov_b32, scc preservation across s_cmov_b32/s_bitset*, 5-bit shift masking (35 & 31 == 3), and two draw mutation controls.

Verification

Ran on macOS arm64 against Homebrew LLVM 15 (llvm@15 15.0.7):

  • FORM_COVERAGE_RECORD=/tmp/x2w-cov-sop1.txt ./out/pe-env/bin/python -B tests/pixel_aot_check.py binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/bin/llvm-objcopy /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib && grep -E '^s_(abs_i32|cmov_b32|bitset[01]_b32)$' /tmp/x2w-cov-sop1.txt | sort -u
    • Result: exit 0; all 4 forms (s_abs_i32, s_bitset0_b32, s_bitset1_b32, s_cmov_b32) recorded.
  • LLVM_LIB=/opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib LLVM_MC=/opt/homebrew/opt/llvm@15/bin/llvm-mc LLVM_OBJCOPY=/opt/homebrew/opt/llvm@15/bin/llvm-objcopy ./out/pe-env/bin/python -B tests/rdna2_tools_check.py
    • Result: Ran 41 tests in 0.424s — OK.
  • ./out/pe-env/bin/python -B tests/bidi_controls_check.py
    • Result: Checked 551 tracked source, script and build/CI files: no bidirectional controls.
  • git diff --check
    • Result: exit 0.

Could not run locally on macOS: DXC compilation and D3D12/WARP readback (pixel_aot_blend_scalar_warp, check_sop1_scalar_ops_draw) require Windows/MSVC/DXC/D3D12; they will run in Windows CI.

Evidence and follow-up

  • All fixtures are source-built from synthetic RDNA2 (gfx1013) assembly lists assembled via LLVM 15 llvm-mc.
  • Negative and mutation controls: missing or clobbered scc (s_and_b64 exec, s_wqm_b64 exec), uninitialized destination SGPRs, pending lgkmcnt reads/writes, unsupported VGPR/64-bit/s106/vcc_lo operands, and two draw mutations (s_abs_i32 -> s_not_b32 and s_bitset0_b32 -> s_bitset1_b32).

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. (Not applicable — no capability or build requirement change.)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

**@⁠Neoplayer** on GitHub · 2026-11-22 13:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/574) `Neoplayer:shader/sop1-scalar-ops` → `main` · +127 −2 · 3 files · 2 commits · merged 2026-11-22 14:30 UTC ## Change Lower four 32-bit scalar `SOP1` instructions (`s_abs_i32`, `s_cmov_b32`, `s_bitset0_b32`, `s_bitset1_b32`) in [`tools/pixel_aot.py`](tools/pixel_aot.py), keep [`tools/scan_unsupported_shaders.py`](tools/scan_unsupported_shaders.py) synchronized, and add coverage and controls in [`tests/pixel_aot_check.py`](tests/pixel_aot_check.py). - Add `abs_i32` to `SCALAR` (`(asint({0}) < 0 ? (0u - {0}) : {0})`, setting `scc = (result != 0u)` so `INT_MIN` wraps to `0x80000000` with `scc = 1`), and validate `sgpr_name(dst)` in the `SCALAR` handler so out-of-range SGPRs (`s106+`) are rejected cleanly. - Lower `s_cmov_b32` (`scc ? src0 : dst`, requiring tracked `scc`, validating `dst` and `src0` via `scalar_u32()`, preserving `scc`). - Lower `s_bitset0_b32` and `s_bitset1_b32` (masking bit index `& 31u`, performing read-modify-write on `dst` via `scalar_u32()`, preserving `scc`). - Add all four opcodes to `_check_two_exits()` in [`tools/pixel_aot.py`](tools/pixel_aot.py) and sync `SUPPORTED_INSTRUCTIONS_REGEX` and `KNOWN_RDNA2_BASE_OPCODES` in [`tools/scan_unsupported_shaders.py`](tools/scan_unsupported_shaders.py). - Update [`tests/pixel_aot_check.py`](tests/pixel_aot_check.py): - Replace the prior `must_reject` placeholder `s_abs_i32 s62, s44` with genuinely unsupported `s_quadmask_b32 s62, s44` and `s_bitset0_b64 s[62:63], s44`. - Add `sop1_scalar_ops()`, `sop1_scalar_ops_reference()`, and `check_sop1_scalar_ops_draw()` (`integer_rt=True`, wired into `check_binary()` and `check_blend_and_scalar_draws()`), exercising `0`, negative, positive, and `INT_MIN` inputs for `s_abs_i32`, register and literal sources for `s_cmov_b32`, `scc` preservation across `s_cmov_b32`/`s_bitset*`, 5-bit shift masking (`35 & 31 == 3`), and two draw mutation controls. ## Verification Ran on macOS arm64 against Homebrew LLVM 15 (`llvm@15` 15.0.7): - `FORM_COVERAGE_RECORD=/tmp/x2w-cov-sop1.txt ./out/pe-env/bin/python -B tests/pixel_aot_check.py binary /opt/homebrew/opt/llvm@15/bin/llvm-mc /opt/homebrew/opt/llvm@15/bin/llvm-objcopy /opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib && grep -E '^s_(abs_i32|cmov_b32|bitset[01]_b32)$' /tmp/x2w-cov-sop1.txt | sort -u` - Result: exit 0; all 4 forms (`s_abs_i32`, `s_bitset0_b32`, `s_bitset1_b32`, `s_cmov_b32`) recorded. - `LLVM_LIB=/opt/homebrew/opt/llvm@15/lib/libLLVM-15.dylib LLVM_MC=/opt/homebrew/opt/llvm@15/bin/llvm-mc LLVM_OBJCOPY=/opt/homebrew/opt/llvm@15/bin/llvm-objcopy ./out/pe-env/bin/python -B tests/rdna2_tools_check.py` - Result: `Ran 41 tests in 0.424s — OK`. - `./out/pe-env/bin/python -B tests/bidi_controls_check.py` - Result: `Checked 551 tracked source, script and build/CI files: no bidirectional controls.` - `git diff --check` - Result: exit 0. Could not run locally on macOS: DXC compilation and D3D12/WARP readback (`pixel_aot_blend_scalar_warp`, `check_sop1_scalar_ops_draw`) require Windows/MSVC/DXC/D3D12; they will run in Windows CI. ## Evidence and follow-up - All fixtures are source-built from synthetic RDNA2 (`gfx1013`) assembly lists assembled via LLVM 15 `llvm-mc`. - Negative and mutation controls: missing or clobbered `scc` (`s_and_b64 exec`, `s_wqm_b64 exec`), uninitialized destination SGPRs, pending `lgkmcnt` reads/writes, unsupported VGPR/64-bit/`s106`/`vcc_lo` operands, and two draw mutations (`s_abs_i32` -> `s_not_b32` and `s_bitset0_b32` -> `s_bitset1_b32`). ## 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. - [ ] I updated README/docs when a capability or build requirement changed. *(Not applicable — no capability or build requirement change.)* - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:02:58 +00:00
github manually merged commit af0b2e2e8e into gh-pr/574/base 2026-11-26 22:02:59 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.