shader: accept gfx10 scheduling hints in pixel_aot #356

Merged
denn0x merged 3 commits from upstream-pr/362 into main 2026-11-21 23:56:17 +00:00
denn0x commented 2026-11-21 23:21:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T23:21:19Z.


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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535720280 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/362). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-21T23:21:19Z. --- ## 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)._
upstream-sync closed this pull request 2026-11-24 06:42:38 +00:00
R0Y00 commented 2026-11-24 06:48:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T23:26:28Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070875323 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/362#issuecomment-7070875323). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T23:26:28Z. --- 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)
denn0x commented 2026-11-24 06:48:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T23:33:48Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070955332 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/362#issuecomment-7070955332). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-21T23:33:48Z. --- 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.
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!356
No description provided.