shader: open pixel_aot masked regions with s_mov_b64 exec save and VOPC e32 v_cmpx #950

Merged
MasterDomino merged 1 commit from upstream-pr/957 into main 2026-11-23 19:16:46 +00:00
MasterDomino commented 2026-11-23 18:45:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-23T18:45:59Z.


Change

The first stage scoped in #932: tools/pixel_aot.py now also opens the #651 masked region with s_mov_b64 s[a:b], exec immediately followed by a VOPC _e32 v_cmpx.

  • Forms. The 32 already-supported 32-bit comparison kinds: all 16 binary32 predicates and the 8 signed and 8 unsigned integer predicates. v_cmpx_class_f32 is left out of this stage by choice; it can follow on the same opener.
  • Mask. The save must hold the known entry mask: not a whole-quad mask, not overlapping a pending scalar load, and directly before the v_cmpx. EXEC becomes the entry mask intersected with the comparison, the same lane condition as v_cmp plus s_and_saveexec_b64, so the existing region body rules and restore-time per-lane selects apply unchanged.
  • Restores. s_mov_b64 exec, s[a:b] and the existing s_or_b64 exec, exec, s[a:b], both on the saved pair. They stay distinct for SCC: v_cmpx and s_mov_b64 leave SCC tracked, and s_or_b64 makes it unknown, so a later SCC reader rejects. v_cmpx does not write VCC; VCC keeps its tracked value. The s_and_saveexec_b64 region still closes only with s_or_b64.
  • Skip. An optional s_cbranch_execz must sit right after the v_cmpx and land exactly on the matching restore (either spelling).
  • Still rejected: _e64, SDWA, binary16, binary64, 16- and 64-bit integer and class forms, a VSRC1 that is not a VGPR, source modifiers, chained or nested v_cmpx, wave32 saves, partial entry masks and else/kill shapes.

The change refactors the restore merge into close_region(), shared by both restores; the generated HLSL for #651 regions is unchanged.

tools/scan_unsupported_shaders.py is unchanged. It already reports the #651 region instructions (s_and_saveexec_b64, the s_or_b64 restore, s_cbranch_execz) as unsupported line by line, because only lower() can check the region structure. I followed that precedent rather than marking context-dependent lines as supported.

One existing coverage assertion changed. tests/form_coverage_check.py listed v_cmpx_lt_i32 and v_cmpx_lt_f32 among the compare neighbours that must stay uncovered. This PR covers them, so they leave that set. The replacement checks are stricter:

  • the covered v_cmpx forms must equal exactly the 32 VOPC forms above, in both gfx1013.tsv and rdna2.tsv;
  • none of their _e64 spellings may be covered;
  • v_cmpx_lt_i16, v_cmpx_lt_f16, v_cmpx_class_f32, v_cmpx_lt_i64 and v_cmpx_lt_u64 are asserted uncovered.

Refs #932

Verification

Upstream main at 0f0c3eb, Fedora 45 x86_64, Python 3.15.2, LLVM 15.0.7, DXC 1.9.2609.5 (Linux release, for the compile dry run only).

python -B tests/pixel_aot_check.py                       # translation controls
python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM-15.so>
python -B tests/form_coverage_check.py

All exit 0, and so do the 26 platform-independent checks, tests/ffx_dispatch_aot_check.py with LLVM 15 and tests/rdna2_tools_check.py.

  • Translation controls (check_cmpx_controls):
    • Both restores, the skip and all eight predicate groups lower with the expected number of selects.
    • Each comparison kind lowers to the same expression as its v_cmp (f32 with an SGPR, i32 with VGPRs, u32 with a literal, nlg with -1.0).
    • After an s_mov_b64 close, VCC and SCC readers use the comparisons made before the region; after an s_or_b64 close an SCC reader rejects with Select condition is not a tracked scalar result.
    • Rejected, each checked for the intended message:
      • save problems: a missing or non-adjacent save, a wave32 or exec_lo save, a save under the whole-quad mask, and a save overlapping a pending load;
      • pair problems: a different save or restore pair, and an s_mov_b64 close of an s_and_saveexec_b64 region;
      • region body problems: an unclosed region, and inside the region an overwritten save pair, a nested save, a chained v_cmpx, a nested s_and_saveexec_b64, an else s_andn2_b64 exec, waits, loads, samples, exports and lane reads;
      • out-of-scope forms: the encodings, kinds and operands listed above;
      • bad skips: five wrong skip displacements, a skip placed mid-region, and a skip onto another pair's restore.
  • Binary. The ramp regions with both restores and the skip (with a real labelled branch), the VCC/SCC program and all eight predicate groups are assembled and disassembled with LLVM 15 for gfx1013, and each must lower identically to its source.
  • Draw dry run. Not a substitute for WARP. check_cmpx_draw ran with the real Linux DXC and only the D3D12 batch call replaced by a recorder: all 14 shaders compile, and 53 well-formed cases are written (48 pass, 5 mismatch).

Not run here: pixel_aot_cmpx_regions_warp. It needs Windows; this PR's CI run will be the first WARP result. Its checks, all compared bit for bit (tests/pixel_aot_render.cpp compares the expected and actual words, with a tolerance only when one is set):

  • the 8x8 ramp region with the s_mov_b64 restore, the s_or_b64 restore and the skip, each on mixed (0.5), full (10) and empty (-1) masks;
  • the VCC/SCC program on the same three masks;
  • every predicate against the existing less/equal/greater/unordered truth tables, with the two restores alternating;
  • controls that must mismatch: a reversed predicate and a mask-free body on the mixed mask, references that take VCC from the v_cmpx comparison or invert SCC, and the signed shader against the unsigned truth table.

No _hardware run is reported.

Evidence and follow-up

All fixtures are source-built in tests/pixel_aot_check.py.

The EXEC_old & cond definition comes from the RDNA 2 ISA guide (§6.2.2, §12.9) and from LLVM's gfx10.3 rewrite of v_cmp plus s_and_saveexec into this pattern. WARP establishes the translated behaviour of the source-built fixtures, not gfx1013 execution.

Impact on one local input (the 12,101 PS records from #932; aggregates only, decoded with tools/disasm_rdna2.py). This re-measures the "4,379 structural candidates" from #932 with this PR's actual rules:

Measurement Count
Records with a save + f32/i32/u32 _e32 v_cmpx + restore of the same pair 3,719
Regions whose body also passes REGION_ALU and whose skip, if any, targets the restore 152, in 112 records (0.9%)
Skips in these shapes that target exactly their restore 6,462 of 6,462

Most regions are blocked by the existing #651 body rule. The first blocking body instruction is most often s_load_dwordx4, s_nop, v_cvt_f32_ubyte2_e32, s_mov_b32 or v_rcp_f32_e32. A record also needs everything outside its regions to translate, so this doesn't count translatable shaders.

Follow-ups, separately validated as you suggested:

  • widening the region body (e.g. s_nop, more VALU ops);
  • v_cmpx_class_f32;
  • _e64;
  • else via s_andn2_b64 exec, saved, exec;
  • chained v_cmpx, wave32 saves, partial entry masks and kill.

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. (docs/experiments.md, "Exec-masked pixel regions".)
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B48PpcRN2Er51keRf2DsS5

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6566396480 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/957). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-23T18:45:59Z. --- ## Change The first stage scoped in #932: `tools/pixel_aot.py` now also opens the #651 masked region with `s_mov_b64 s[a:b], exec` immediately followed by a VOPC `_e32` `v_cmpx`. - **Forms.** The 32 already-supported 32-bit comparison kinds: all 16 binary32 predicates and the 8 signed and 8 unsigned integer predicates. `v_cmpx_class_f32` is left out of this stage by choice; it can follow on the same opener. - **Mask.** The save must hold the known entry mask: not a whole-quad mask, not overlapping a pending scalar load, and directly before the `v_cmpx`. EXEC becomes the entry mask intersected with the comparison, the same lane condition as `v_cmp` plus `s_and_saveexec_b64`, so the existing region body rules and restore-time per-lane selects apply unchanged. - **Restores.** `s_mov_b64 exec, s[a:b]` and the existing `s_or_b64 exec, exec, s[a:b]`, both on the saved pair. They stay distinct for SCC: `v_cmpx` and `s_mov_b64` leave SCC tracked, and `s_or_b64` makes it unknown, so a later SCC reader rejects. `v_cmpx` does not write VCC; VCC keeps its tracked value. The `s_and_saveexec_b64` region still closes only with `s_or_b64`. - **Skip.** An optional `s_cbranch_execz` must sit right after the `v_cmpx` and land exactly on the matching restore (either spelling). - **Still rejected:** `_e64`, SDWA, binary16, binary64, 16- and 64-bit integer and class forms, a VSRC1 that is not a VGPR, source modifiers, chained or nested `v_cmpx`, wave32 saves, partial entry masks and else/kill shapes. The change refactors the restore merge into `close_region()`, shared by both restores; the generated HLSL for #651 regions is unchanged. `tools/scan_unsupported_shaders.py` is unchanged. It already reports the #651 region instructions (`s_and_saveexec_b64`, the `s_or_b64` restore, `s_cbranch_execz`) as unsupported line by line, because only `lower()` can check the region structure. I followed that precedent rather than marking context-dependent lines as supported. **One existing coverage assertion changed.** `tests/form_coverage_check.py` listed `v_cmpx_lt_i32` and `v_cmpx_lt_f32` among the compare neighbours that must stay uncovered. This PR covers them, so they leave that set. The replacement checks are stricter: - the covered `v_cmpx` forms must equal exactly the 32 VOPC forms above, in both `gfx1013.tsv` and `rdna2.tsv`; - none of their `_e64` spellings may be covered; - `v_cmpx_lt_i16`, `v_cmpx_lt_f16`, `v_cmpx_class_f32`, `v_cmpx_lt_i64` and `v_cmpx_lt_u64` are asserted uncovered. Refs #932 ## Verification Upstream `main` at `0f0c3eb`, Fedora 45 x86_64, Python 3.15.2, LLVM 15.0.7, DXC 1.9.2609.5 (Linux release, for the compile dry run only). ```sh python -B tests/pixel_aot_check.py # translation controls python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <libLLVM-15.so> python -B tests/form_coverage_check.py ``` All exit 0, and so do the 26 platform-independent checks, `tests/ffx_dispatch_aot_check.py` with LLVM 15 and `tests/rdna2_tools_check.py`. - **Translation controls** (`check_cmpx_controls`): - Both restores, the skip and all eight predicate groups lower with the expected number of selects. - Each comparison kind lowers to the same expression as its `v_cmp` (f32 with an SGPR, i32 with VGPRs, u32 with a literal, `nlg` with `-1.0`). - After an `s_mov_b64` close, VCC and SCC readers use the comparisons made before the region; after an `s_or_b64` close an SCC reader rejects with `Select condition is not a tracked scalar result`. - Rejected, each checked for the intended message: - **save problems:** a missing or non-adjacent save, a wave32 or `exec_lo` save, a save under the whole-quad mask, and a save overlapping a pending load; - **pair problems:** a different save or restore pair, and an `s_mov_b64` close of an `s_and_saveexec_b64` region; - **region body problems:** an unclosed region, and inside the region an overwritten save pair, a nested save, a chained `v_cmpx`, a nested `s_and_saveexec_b64`, an else `s_andn2_b64 exec`, waits, loads, samples, exports and lane reads; - **out-of-scope forms:** the encodings, kinds and operands listed above; - **bad skips:** five wrong skip displacements, a skip placed mid-region, and a skip onto another pair's restore. - **Binary.** The ramp regions with both restores and the skip (with a real labelled branch), the VCC/SCC program and all eight predicate groups are assembled and disassembled with LLVM 15 for gfx1013, and each must lower identically to its source. - **Draw dry run.** Not a substitute for WARP. `check_cmpx_draw` ran with the real Linux DXC and only the D3D12 batch call replaced by a recorder: all 14 shaders compile, and 53 well-formed cases are written (48 `pass`, 5 `mismatch`). **Not run here: `pixel_aot_cmpx_regions_warp`.** It needs Windows; this PR's CI run will be the first WARP result. Its checks, all compared bit for bit (`tests/pixel_aot_render.cpp` compares the expected and actual words, with a tolerance only when one is set): - the 8x8 ramp region with the `s_mov_b64` restore, the `s_or_b64` restore and the skip, each on mixed (0.5), full (10) and empty (-1) masks; - the VCC/SCC program on the same three masks; - every predicate against the existing less/equal/greater/unordered truth tables, with the two restores alternating; - controls that must mismatch: a reversed predicate and a mask-free body on the mixed mask, references that take VCC from the `v_cmpx` comparison or invert SCC, and the signed shader against the unsigned truth table. No `_hardware` run is reported. ## Evidence and follow-up All fixtures are source-built in `tests/pixel_aot_check.py`. The `EXEC_old & cond` definition comes from the RDNA 2 ISA guide (§6.2.2, §12.9) and from LLVM's gfx10.3 rewrite of `v_cmp` plus `s_and_saveexec` into this pattern. WARP establishes the translated behaviour of the source-built fixtures, not gfx1013 execution. **Impact on one local input** (the 12,101 PS records from #932; aggregates only, decoded with `tools/disasm_rdna2.py`). This re-measures the "4,379 structural candidates" from #932 with this PR's actual rules: | Measurement | Count | |---|---| | Records with a save + f32/i32/u32 `_e32` `v_cmpx` + restore of the same pair | 3,719 | | Regions whose body also passes `REGION_ALU` and whose skip, if any, targets the restore | 152, in **112 records (0.9%)** | | Skips in these shapes that target exactly their restore | 6,462 of 6,462 | Most regions are blocked by the existing #651 body rule. The first blocking body instruction is most often `s_load_dwordx4`, `s_nop`, `v_cvt_f32_ubyte2_e32`, `s_mov_b32` or `v_rcp_f32_e32`. A record also needs everything outside its regions to translate, so this doesn't count translatable shaders. **Follow-ups, separately validated as you suggested:** - widening the region body (e.g. `s_nop`, more VALU ops); - `v_cmpx_class_f32`; - `_e64`; - else via `s_andn2_b64 exec, saved, exec`; - chained `v_cmpx`, wave32 saves, partial entry masks and kill. ## 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. (`docs/experiments.md`, "Exec-masked pixel regions".) - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01B48PpcRN2Er51keRf2DsS5
upstream-sync closed this pull request 2026-11-24 06:45:35 +00:00
lantiumBot commented 2026-11-24 06:49:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lantiumBot on 2026-11-23T20:07:18Z.


First _hardware result for this draw, on RDNA 4. Data only.

pixel_aot_cmpx_regions_hardware passed on an AMD Radeon RX 9060 XT at merged main, in the full hardware run below.

ctest --preset dev --no-tests=error -R '_hardware$'
  • Commit: f8e80e5663097c3ccc6fd35adbe4fba65e0fbf2e, clean tree, dev preset (Debug)
  • Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010
  • Windows build: 26300.10075, D3D12 debug layer unavailable
  • DXC 1.9.2602.17 (21d28f727) from Windows SDK 10.0.26100.0

One run, CTest verdict only. The run covered 137 tests: 133 passed, 1 capability skip (bc7_mode6_multiblock_hardware), 3 failed. The three failures are the rows already recorded for RDNA 4 (dxr_opacity_hardware, gpu_alias_lookup_writes_hardware, pixel_aot_comparisons_hardware, #958).

AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7112591467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/957#issuecomment-7112591467). Originally posted by [lantiumBot](https://github.com/lantiumBot) on 2026-11-23T20:07:18Z. --- First `_hardware` result for this draw, on RDNA 4. Data only. `pixel_aot_cmpx_regions_hardware` passed on an AMD Radeon RX 9060 XT at merged `main`, in the full hardware run below. ```powershell ctest --preset dev --no-tests=error -R '_hardware$' ``` - Commit: `f8e80e5663097c3ccc6fd35adbe4fba65e0fbf2e`, clean tree, `dev` preset (Debug) - Adapter: AMD Radeon RX 9060 XT (vendor=1002 device=7590), driver 32.0.32029.2010 - Windows build: 26300.10075, D3D12 debug layer unavailable - DXC 1.9.2602.17 (21d28f727) from Windows SDK 10.0.26100.0 One run, CTest verdict only. The run covered 137 tests: 133 passed, 1 capability skip (`bc7_mode6_multiblock_hardware`), 3 failed. The three failures are the rows already recorded for RDNA 4 (`dxr_opacity_hardware`, `gpu_alias_lookup_writes_hardware`, `pixel_aot_comparisons_hardware`, #958). AI-assisted (Claude Code - Fable 5.2); runs executed locally on the adapter above.
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!950
No description provided.