shader: accept gfx10 scheduling hints in pixel_aot #362

Manually merged
github merged 3 commits from gh-pr/362/head into gh-pr/362/base 2026-11-26 21:45:59 +00:00
Owner

@⁠denn0x on GitHub · 2026-11-21 23:21 UTC · original
denn0x:shader/sopp-hints → main · +53 −3 · 4 files · 3 commits · merged 2026-11-21 23:56 UTC

Change

Advances an independent problem: pixel_aot rejecting compiler-emitted gfx10 code that only carries scheduling hints. It touches the top of the instruction loop in tools/pixel_aot.py, next to the existing s_nop/s_inst_prefetch case. No open PR claims these hints, and no prerequisite PR is needed.

gfx10 compilers emit s_clause before memory clauses, and may emit s_setprio and s_sleep. None of these affects results, but pixel_aot rejected all three as unsupported instructions.

  • s_clause, s_setprio, s_sleep: accepted wherever s_nop is, and lowered exactly like it. Each operand must fit its RDNA 2 field, so a larger value is rejected:
    • s_clause: 6 bits, the clause length minus one;
    • s_setprio: 2 bits, the wave priority;
    • s_sleep: 7 bits.
  • s_code_end: still rejected. native_program ends the code at s_endpgm, so padding after it never reaches the translator. As before, nothing may follow s_endpgm and no hint may sit between the color export and s_endpgm.

Tests

  • check_scheduling_hints(), which runs in both test modes:
    • The fixture with all three hints must translate identically to the same program with each hint replaced by s_nop 0. Generated names carry the instruction index, so s_nop at the same position is the exact reference.
    • Each hint at its maximum operand, in decimal and hex, matches s_nop 0.
    • Maximum + 1 is rejected.
    • s_code_end is rejected before and after s_endpgm, any instruction after s_endpgm is rejected, and a hint after the export is rejected.
  • Round trip: scheduling_hints() is in check_binary, so LLVM assembles and disassembles the hinted program, and the extracted native bytes must equal the .text bytes.
  • Coverage control: tests/form_coverage_check.py now expects s_nop, s_clause, s_setprio and s_sleep to be recorded from the real controls, and keeps s_branch (fed only to must_reject) and s_code_end as the rejected-form control.

Verification

Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, D3D12 debug layer enabled. Hardware: AMD Radeon RX 9070 XT (vendor 1002, device 7550), driver 32.0.32015.7029. WARP: Microsoft Basic Render Driver 10.0.26100.9818.

ctest --preset dev --no-tests=error
129/146 Test #129: pixel_aot_hardware .................   Passed    9.89 sec
132/146 Test #132: pixel_aot_warp .....................   Passed    4.14 sec
100% tests passed, 0 tests failed out of 146

bvh_wave64_warp and wave_shuffle_warp reported capability skips.

Mutation checks (local, reverted): widening every hint limit to 0xffff makes check_scheduling_hints fail with translate accepted invalid input. Re-adding the s_code_end skip after s_endpgm fails the same way.

After 2b93466, in the same environment:

tests/pixel_aot_check.py draw ... hardware: pixels=4096 channels=16384 max_absolute_error=0, debug_errors=0 debug_warnings=0
tests/pixel_aot_check.py draw ... warp:     pixels=4096 channels=16384 max_absolute_error=0, debug_errors=0 debug_warnings=0
tests/form_coverage_check.py: form coverage checks passed

Not run locally: tests/pixel_aot_check.py binary, because this machine has no LLVM with gfx1013. Ubuntu CI covers the round trip, including the LLVM 15 spelling of these hints.

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 (Claude Code).

**@⁠denn0x** on GitHub · 2026-11-21 23:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/362) `denn0x:shader/sopp-hints` → `main` · +53 −3 · 4 files · 3 commits · merged 2026-11-21 23:56 UTC ## Change Advances an independent problem: `pixel_aot` rejecting compiler-emitted gfx10 code that only carries scheduling hints. It touches the top of the instruction loop in `tools/pixel_aot.py`, next to the existing `s_nop`/`s_inst_prefetch` case. No open PR claims these hints, and no prerequisite PR is needed. gfx10 compilers emit `s_clause` before memory clauses, and may emit `s_setprio` and `s_sleep`. None of these affects results, but `pixel_aot` rejected all three as unsupported instructions. - **`s_clause`, `s_setprio`, `s_sleep`:** accepted wherever `s_nop` is, and lowered exactly like it. Each operand must fit its RDNA 2 field, so a larger value is rejected: - `s_clause`: 6 bits, the clause length minus one; - `s_setprio`: 2 bits, the wave priority; - `s_sleep`: 7 bits. - **`s_code_end`:** still rejected. `native_program` ends the code at `s_endpgm`, so padding after it never reaches the translator. As before, nothing may follow `s_endpgm` and no hint may sit between the color export and `s_endpgm`. ## Tests - **`check_scheduling_hints()`**, which runs in both test modes: - The fixture with all three hints must translate identically to the same program with each hint replaced by `s_nop 0`. Generated names carry the instruction index, so `s_nop` at the same position is the exact reference. - Each hint at its maximum operand, in decimal and hex, matches `s_nop 0`. - Maximum + 1 is rejected. - `s_code_end` is rejected before and after `s_endpgm`, any instruction after `s_endpgm` is rejected, and a hint after the export is rejected. - **Round trip:** `scheduling_hints()` is in `check_binary`, so LLVM assembles and disassembles the hinted program, and the extracted native bytes must equal the `.text` bytes. - **Coverage control:** `tests/form_coverage_check.py` now expects `s_nop`, `s_clause`, `s_setprio` and `s_sleep` to be recorded from the real controls, and keeps `s_branch` (fed only to `must_reject`) and `s_code_end` as the rejected-form control. ## Verification Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, D3D12 debug layer enabled. Hardware: AMD Radeon RX 9070 XT (vendor 1002, device 7550), driver 32.0.32015.7029. WARP: Microsoft Basic Render Driver 10.0.26100.9818. ```powershell ctest --preset dev --no-tests=error ``` ```text 129/146 Test #129: pixel_aot_hardware ................. Passed 9.89 sec 132/146 Test #132: pixel_aot_warp ..................... Passed 4.14 sec 100% tests passed, 0 tests failed out of 146 ``` `bvh_wave64_warp` and `wave_shuffle_warp` reported capability skips. **Mutation checks (local, reverted):** widening every hint limit to 0xffff makes `check_scheduling_hints` fail with `translate accepted invalid input`. Re-adding the `s_code_end` skip after `s_endpgm` fails the same way. After `2b93466`, in the same environment: ```text tests/pixel_aot_check.py draw ... hardware: pixels=4096 channels=16384 max_absolute_error=0, debug_errors=0 debug_warnings=0 tests/pixel_aot_check.py draw ... warp: pixels=4096 channels=16384 max_absolute_error=0, debug_errors=0 debug_warnings=0 tests/form_coverage_check.py: form coverage checks passed ``` Not run locally: `tests/pixel_aot_check.py binary`, because this machine has no LLVM with gfx1013. Ubuntu CI covers the round trip, including the LLVM 15 spelling of these hints. ## 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 (Claude Code)._
Lower s_clause, s_setprio and s_sleep like s_nop, with each operand held
to its RDNA 2 field width, and accept s_code_end only as padding after
s_endpgm. The hinted program joins the LLVM round trip.

AI-assisted (Claude Code).
native_program ends the code at s_endpgm, so the LLVM .text of the hint
fixture was 8 bytes longer than the extracted program (two trailing
s_code_end words) and the byte comparison failed. Padding after s_endpgm
never reaches the translator, so s_code_end is no longer accepted and the
fixture carries no padding; the byte comparison is unchanged.

form_coverage_check expected s_nop never to be accepted, but the hint
fixtures translate it next to s_clause, s_setprio and s_sleep. The real
controls now assert those forms are recorded, and s_branch, which reaches
only must_reject, plus s_code_end serve as the rejected-form control.

AI-assisted (Claude Code).
AI-assisted (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:45:57 +00:00
github manually merged commit 04f4814670 into gh-pr/362/base 2026-11-26 21:45:59 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-21 23:26 UTC · original

Two independent checks fail at 2fc9ee4. tests/form_coverage_check.py:199 still asserts that s_nop is absent from pixel.ACCEPTED. Please update the coverage expectation for the newly accepted hint and retain a rejected-form control. The LLVM 15 round-trip also fails the byte comparison native == binary.read_bytes() in tests/pixel_aot_check.py:1333. Please identify the first differing instruction and reconcile its encoding with LLVM 15 while keeping the byte comparison. CI logs

**@⁠R0Y00** on GitHub · 2026-11-21 23:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/362#issuecomment-7070875323) Two independent checks fail at `2fc9ee4`. `tests/form_coverage_check.py:199` still asserts that `s_nop` is absent from `pixel.ACCEPTED`. Please update the coverage expectation for the newly accepted hint and retain a rejected-form control. The LLVM 15 round-trip also fails the byte comparison `native == binary.read_bytes()` in `tests/pixel_aot_check.py:1333`. Please identify the first differing instruction and reconcile its encoding with LLVM 15 while keeping the byte comparison. [CI logs](https://github.com/R0Y00/Xbox2Windows/actions/runs/44961387438)
Author
Owner

@⁠denn0x on GitHub · 2026-11-21 23:33 UTC · original

Thanks. Both are fixed in 2b93466.

  • LLVM 15 byte comparison: the first difference was not an instruction encoding. native_program ends the code at s_endpgm, but the fixture appended two s_code_end words, so the .text was 8 bytes longer than the extracted program, starting right after s_endpgm. Padding after s_endpgm therefore never reaches the translator, so I dropped s_code_end acceptance instead of loosening the comparison. The fixture now ends at s_endpgm, the byte comparison is unchanged, and s_code_end is rejected before and after s_endpgm.
  • Coverage expectation: the hint fixtures translate s_nop 0 as the reference, so s_nop is now legitimately recorded. check_shader_records now asserts that s_nop, s_clause, s_setprio and s_sleep are in ACCEPTED, and keeps a rejected-form control: s_branch reaches only must_reject (it is a gfx1013 SOPP form, asserted to be in the reference) and must stay out, as must s_code_end. The synthetic s_nop leak control above it is unchanged.

Local reruns on the RX 9070 XT and WARP give max_absolute_error=0 in both modes, and form_coverage_check.py passes. Re-adding the s_code_end skip makes check_scheduling_hints fail. The LLVM mode is still CI-only here.

**@⁠denn0x** on GitHub · 2026-11-21 23:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/362#issuecomment-7070955332) Thanks. Both are fixed in `2b93466`. - **LLVM 15 byte comparison:** the first difference was not an instruction encoding. `native_program` ends the code at `s_endpgm`, but the fixture appended two `s_code_end` words, so the `.text` was 8 bytes longer than the extracted program, starting right after `s_endpgm`. Padding after `s_endpgm` therefore never reaches the translator, so I dropped `s_code_end` acceptance instead of loosening the comparison. The fixture now ends at `s_endpgm`, the byte comparison is unchanged, and `s_code_end` is rejected before and after `s_endpgm`. - **Coverage expectation:** the hint fixtures translate `s_nop 0` as the reference, so `s_nop` is now legitimately recorded. `check_shader_records` now asserts that `s_nop`, `s_clause`, `s_setprio` and `s_sleep` are in `ACCEPTED`, and keeps a rejected-form control: `s_branch` reaches only `must_reject` (it is a gfx1013 SOPP form, asserted to be in the reference) and must stay out, as must `s_code_end`. The synthetic `s_nop` leak control above it is unchanged. Local reruns on the RX 9070 XT and WARP give `max_absolute_error=0` in both modes, and `form_coverage_check.py` passes. Re-adding the `s_code_end` skip makes `check_scheduling_hints` fail. The LLVM mode is still CI-only here.
This discussion has been locked. Commenting is limited to contributors.
No description provided.