shader: vote a quad-complete EXEC for WQM EXECZ branches in native pixel draws #2946

Merged
roansystemlabs merged 1 commit from upstream-pr/2946 into cpp-migration 2026-11-26 22:54:07 +00:00
roansystemlabs commented 2026-11-26 22:39:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-26T22:39:31Z.


Fixes #2907. Part of #870, refs #2125. Follows the maintainers' decision in https://github.com/R0Y00/Xbox2Windows/issues/2907#issuecomment-7203723133.

Change

An s_cbranch_execz after s_wqm exec, sM is skipped only when EXEC is zero in the whole guest wave. Until now the direct frontend refused that branch. For the bounded form below, PixelWqm::raster_vote in src/gfx1013_graphics_wqm.inl now lowers the condition as WaveActiveAnyTrue of the modelled EXEC bit, after OR-ing that bit with QuadReadAcrossX, QuadReadAcrossY and QuadReadAcrossDiagonal.

s_mov sE, exec ; s_wqm exec, exec
v_cmp_* vcc, ... ; s_andn2 sE, sE, vcc          one or more coverage filters
v_cmp_* vcc, ... ; s_andn2 sM, sE|exec, vcc     the mask, from the survivors or the whole-quad EXEC
v_cmp_* vcc, ... ; s_andn2 sM, sM, vcc          optional further terms
s_wqm exec, sM ; s_cbranch_execz J              the region writes only scalars
J: s_mov exec, sE                               then a terminal colour export
  • Helper lanes: quad reads see them, so a quad whose bits sit only on helpers or on covered pixels that did not survive still votes. Everything is SM 6.0; there is no [WaveOpsIncludeHelperLanes] and no 6.7 gate.

  • Where the vote is emitted: the quad reads and the vote come before the first conditional branch, where the whole quad still runs. A new IR test checks this, and checks that the declarations carry the attributes DXC gives the HLSL intrinsics (nounwind).

  • The branch: it becomes a uniform SCC branch on the vote. The varying-condition refusal is waived for that one branch only; its input dependencies still reach the merged values. Wave intrinsics return undefined values on helper lanes, so a helper may take the other path. That is harmless here because nothing after the branch reads another lane: the region is scalar-only and the tail after the restore is lane-local ALU and colour exports, which a helper never writes.

  • Still refused by name:

    • inside the region: a vector or DPP instruction, an EXEC or VCC read, a hardware register access (s_setreg/s_getreg), a branch, or an EXEC write other than the restore;
    • a restore that is not the branch target;
    • a second branch;
    • anything after the restore other than lane-local ALU and colour exports.

    raster_program(2.5, cross=True) keeps its existing refusal.

  • Contract: this is the packing contract of #2835 and #2854: a correct program cannot depend on which quads share a console wave. The fixture builds such a dependency on purpose (a scalar written in the region), so its reference uses the measured desktop layout. This shows the vote over the desktop wave, not console equivalence for an output that depends on another quad. The note in docs/experiments/native-graphics-wqm-cross-quad.md says so.

Fixture

tests/native_graphics_wqm_check.py. native_graphics_wqm_hardware stays where it was in CMakeLists.txt. native_graphics_wqm_warp and native_graphics_wqm_ir are new, in tests/cmake/native_graphics_wqm.cmake.

Measured layout. Two HLSL pixel stages, drawn with the same vertex stage and target as the guest program, give each covered pixel:

  • its wave (the smallest covered id in it);
  • the ids of its three quad peers;
  • whether each peer is a helper (IsHelperLane, SM 6.6).

Wave operations leave helpers out, so the helper flags come from quad reads. The fixture checks that every desktop quad is the aligned 2x2 block and that all covered lanes of a quad report the same quad. Quads are per primitive. On WARP the two middle quads of the 8x2 target are each shaded twice, once with each row covered and the other row as helpers, as if the full-screen triangle were drawn as two primitives. The reference follows the measured quads instead of assuming a 2x2 grid. The layout is measured in separate draws from the guest draw, so a different packing would make the test fail, not pass; it was identical in all four runs below.

Adapter Lanes Full-screen draw Diagonal draw (x + y < 5.5)
NVIDIA GeForce RTX 3070 (10de:2484), driver 32.0.16.2101 32 4 quads, 1 wave, no helpers 3 quads, 1 wave, 3 helpers
Microsoft Basic Render Driver, 10.0.26100.9818 4 6 quads, 6 waves, 8 helpers 5 quads, 5 waves, 11 helpers

Cases. Each is drawn against the measured-layout reference:

  1. survivors with x <= 1: one quad's survivors keep the wave from skipping;
  2. survivors with x <= 4.5;
  3. x <= -1: the empty wave, where every vote agrees;
  4. the whole-quad EXEC with x >= 4.5 and survivors x <= 3.5: bits only on covered pixels that did not survive (WQM before the filter);
  5. survivors with x >= 4.5: no bits;
  6. the bit only on the diagonal helper of the one covered pixel (4,0) of a quad in the diagonal draw;
  7. the bit only on its horizontal helper;
  8. the bit only on its vertical helper.

Pixels outside exact coverage keep the clear value -1.0 (sentinels).

Controls. The same program is redrawn against a quad-local vote, a wave vote without the quad OR, and a vote over survivors only. Each must make --startup-pixel-words report differing pixels.

RTX 3070 WARP
controls that differ quad-local 6, no-OR 3, survivors-only 4 no-OR 3, survivors-only 3
pixels per control quad-local 10, 4 and 8 on cases 1, 2 and 4, and 8 on each helper case; no-OR and survivors-only 9 on each helper case; survivors-only 8 on case 4 1 (pixel (4,0)) on each helper case

Skips. On WARP no wave holds two quads, so the quad-local control cannot differ. native_graphics_wqm_warp still runs every other case and control, prints SKIPPED cross-quad quad-local control: no desktop wave holds two quads (4 lanes) and passes. On a physical adapter that has no wave with two quads, native_graphics_wqm_hardware runs the same checks and then exits 77, because it has not exercised the cross-quad decision. That path was not exercised here: our physical adapter always had a wave with more than one quad. If you would rather have the WARP entry exit 77 as well, or the quad-local control as its own test, I can split it.

Fail-first

Translator unchanged (e97c5c7c), new fixture: all three tests fail with native compute +0x10: unbound numeric SGPR s12. That is not the "complete guest vote" refusal: numeric_guards took the shape for a numeric EXEC region and then could not evaluate the raster mask. raster_vote now claims the shape before numeric_guards.

Mutants, each built in a scratch copy and run against the fixture (on the previous revision of this commit, which differs only by the 77 exit, the hardware-register refusal and comments):

Mutant hardware warp ir
quad-local vote (no WaveActiveAnyTrue) red, 10 px green (one quad per wave: same as the wave vote) red
no quad OR red, 9 px (helper case) red, 1 px red
survivor-only vote red, 8 px (case 4) red, 1 px green
vote always true / always false red, 14 / 14 px red, 10 / 4 px red
exact restore removed red, 2 px (sentinels) red, 2 px green
QuadReadAcrossX removed red, 9 px (case 7) red, 1 px red
QuadReadAcrossY removed red, 9 px (case 8) red, 1 px red
QuadReadAcrossDiagonal removed red, 9 px (case 6) red, 1 px red
region scalar-only guard removed red (DPP-in-region refusal gone) red green

Reproduction

Windows 11 25H2 build 26200.9974, MSVC 19.44 (toolset 14.44), DXC 1.9.2602.17 (SDK 10.0.26100.0), Python 3.12. D3D12 debug layer enabled on both adapters; every draw reported debug_errors=0 debug_warnings=0. Head eee7f839 on cpp-migration e97c5c7c.

cmake --build --preset dev --target compile_dxil offscreen_check native_store_replay native_pixel_ir_dump
ctest --preset dev --no-tests=error -R '^native_graphics_wqm_hardware$' -V
ctest --preset dev --no-tests=error -j 1 -V -R '^native_graphics_wqm_(hardware|warp|ir)$'
  • The issue's command: passed.
  • dev and release (/O2), each run twice in series: 3/3 passed every time, with the same counts.
  • ctest --preset dev --no-tests=error -j 1 -R '^native_', with every native target built: 34 tests, 33 passed and 1 skipped. The skip is native_comparison_pso_warp, "compute requires wave32: WaveOps=1 range=4..4", a capability skip that this change does not touch.

Not run

  • 64-lane adapter: the RX 9070 XT run that @MasterDomino offered is blocked by #2915.
  • Other hardware: AMD and Intel; the console.
  • Inputs: real programs or captures. Only the bounded form above is accepted.
  • CI: the Linux jobs do not run these Windows GPU tests, and the pr preset does not select native_graphics_wqm_*.

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/native-graphics-wqm-cross-quad.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5518107998 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2946). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-26T22:39:31Z. --- Fixes #2907. Part of #870, refs #2125. Follows the maintainers' decision in https://github.com/R0Y00/Xbox2Windows/issues/2907#issuecomment-7203723133. ## Change An `s_cbranch_execz` after `s_wqm exec, sM` is skipped only when EXEC is zero in the whole guest wave. Until now the direct frontend refused that branch. For the bounded form below, `PixelWqm::raster_vote` in `src/gfx1013_graphics_wqm.inl` now lowers the condition as `WaveActiveAnyTrue` of the modelled EXEC bit, after OR-ing that bit with `QuadReadAcrossX`, `QuadReadAcrossY` and `QuadReadAcrossDiagonal`. ``` s_mov sE, exec ; s_wqm exec, exec v_cmp_* vcc, ... ; s_andn2 sE, sE, vcc one or more coverage filters v_cmp_* vcc, ... ; s_andn2 sM, sE|exec, vcc the mask, from the survivors or the whole-quad EXEC v_cmp_* vcc, ... ; s_andn2 sM, sM, vcc optional further terms s_wqm exec, sM ; s_cbranch_execz J the region writes only scalars J: s_mov exec, sE then a terminal colour export ``` - **Helper lanes:** quad reads see them, so a quad whose bits sit only on helpers or on covered pixels that did not survive still votes. Everything is SM 6.0; there is no `[WaveOpsIncludeHelperLanes]` and no 6.7 gate. - **Where the vote is emitted:** the quad reads and the vote come before the first conditional branch, where the whole quad still runs. A new IR test checks this, and checks that the declarations carry the attributes DXC gives the HLSL intrinsics (`nounwind`). - **The branch:** it becomes a uniform SCC branch on the vote. The varying-condition refusal is waived for that one branch only; its input dependencies still reach the merged values. Wave intrinsics return undefined values on helper lanes, so a helper may take the other path. That is harmless here because nothing after the branch reads another lane: the region is scalar-only and the tail after the restore is lane-local ALU and colour exports, which a helper never writes. - **Still refused by name:** - inside the region: a vector or DPP instruction, an EXEC or VCC read, a hardware register access (`s_setreg`/`s_getreg`), a branch, or an EXEC write other than the restore; - a restore that is not the branch target; - a second branch; - anything after the restore other than lane-local ALU and colour exports. `raster_program(2.5, cross=True)` keeps its existing refusal. - **Contract:** this is the packing contract of #2835 and #2854: a correct program cannot depend on which quads share a console wave. The fixture builds such a dependency on purpose (a scalar written in the region), so its reference uses the measured desktop layout. **This shows the vote over the desktop wave, not console equivalence for an output that depends on another quad.** The note in `docs/experiments/native-graphics-wqm-cross-quad.md` says so. ## Fixture `tests/native_graphics_wqm_check.py`. `native_graphics_wqm_hardware` stays where it was in `CMakeLists.txt`. `native_graphics_wqm_warp` and `native_graphics_wqm_ir` are new, in `tests/cmake/native_graphics_wqm.cmake`. **Measured layout.** Two HLSL pixel stages, drawn with the same vertex stage and target as the guest program, give each covered pixel: - its wave (the smallest covered id in it); - the ids of its three quad peers; - whether each peer is a helper (`IsHelperLane`, SM 6.6). Wave operations leave helpers out, so the helper flags come from quad reads. The fixture checks that every desktop quad is the aligned 2x2 block and that all covered lanes of a quad report the same quad. Quads are per primitive. On WARP the two middle quads of the 8x2 target are each shaded twice, once with each row covered and the other row as helpers, as if the full-screen triangle were drawn as two primitives. The reference follows the measured quads instead of assuming a 2x2 grid. The layout is measured in separate draws from the guest draw, so a different packing would make the test fail, not pass; it was identical in all four runs below. | Adapter | Lanes | Full-screen draw | Diagonal draw (x + y < 5.5) | |---|---|---|---| | NVIDIA GeForce RTX 3070 (`10de:2484`), driver 32.0.16.2101 | 32 | 4 quads, 1 wave, no helpers | 3 quads, 1 wave, 3 helpers | | Microsoft Basic Render Driver, 10.0.26100.9818 | 4 | 6 quads, 6 waves, 8 helpers | 5 quads, 5 waves, 11 helpers | **Cases.** Each is drawn against the measured-layout reference: 1. survivors with x <= 1: one quad's survivors keep the wave from skipping; 2. survivors with x <= 4.5; 3. x <= -1: the empty wave, where every vote agrees; 4. the whole-quad EXEC with x >= 4.5 and survivors x <= 3.5: bits only on covered pixels that did not survive (WQM before the filter); 5. survivors with x >= 4.5: no bits; 6. the bit only on the diagonal helper of the one covered pixel (4,0) of a quad in the diagonal draw; 7. the bit only on its horizontal helper; 8. the bit only on its vertical helper. Pixels outside exact coverage keep the clear value -1.0 (sentinels). **Controls.** The same program is redrawn against a quad-local vote, a wave vote without the quad OR, and a vote over survivors only. Each must make `--startup-pixel-words` report differing pixels. | | RTX 3070 | WARP | |---|---|---| | controls that differ | quad-local 6, no-OR 3, survivors-only 4 | no-OR 3, survivors-only 3 | | pixels per control | quad-local 10, 4 and 8 on cases 1, 2 and 4, and 8 on each helper case; no-OR and survivors-only 9 on each helper case; survivors-only 8 on case 4 | 1 (pixel (4,0)) on each helper case | **Skips.** On WARP no wave holds two quads, so the quad-local control cannot differ. `native_graphics_wqm_warp` still runs every other case and control, prints `SKIPPED cross-quad quad-local control: no desktop wave holds two quads (4 lanes)` and passes. On a physical adapter that has no wave with two quads, `native_graphics_wqm_hardware` runs the same checks and then exits 77, because it has not exercised the cross-quad decision. That path was not exercised here: our physical adapter always had a wave with more than one quad. If you would rather have the WARP entry exit 77 as well, or the quad-local control as its own test, I can split it. ## Fail-first Translator unchanged (`e97c5c7c`), new fixture: all three tests fail with `native compute +0x10: unbound numeric SGPR s12`. That is not the "complete guest vote" refusal: `numeric_guards` took the shape for a numeric EXEC region and then could not evaluate the raster mask. `raster_vote` now claims the shape before `numeric_guards`. Mutants, each built in a scratch copy and run against the fixture (on the previous revision of this commit, which differs only by the 77 exit, the hardware-register refusal and comments): | Mutant | hardware | warp | ir | |---|---|---|---| | quad-local vote (no `WaveActiveAnyTrue`) | red, 10 px | green (one quad per wave: same as the wave vote) | red | | no quad OR | red, 9 px (helper case) | red, 1 px | red | | survivor-only vote | red, 8 px (case 4) | red, 1 px | green | | vote always true / always false | red, 14 / 14 px | red, 10 / 4 px | red | | exact restore removed | red, 2 px (sentinels) | red, 2 px | green | | `QuadReadAcrossX` removed | red, 9 px (case 7) | red, 1 px | red | | `QuadReadAcrossY` removed | red, 9 px (case 8) | red, 1 px | red | | `QuadReadAcrossDiagonal` removed | red, 9 px (case 6) | red, 1 px | red | | region scalar-only guard removed | red (DPP-in-region refusal gone) | red | green | ## Reproduction Windows 11 25H2 build 26200.9974, MSVC 19.44 (toolset 14.44), DXC 1.9.2602.17 (SDK 10.0.26100.0), Python 3.12. D3D12 debug layer enabled on both adapters; every draw reported `debug_errors=0 debug_warnings=0`. Head `eee7f839` on `cpp-migration` `e97c5c7c`. ```powershell cmake --build --preset dev --target compile_dxil offscreen_check native_store_replay native_pixel_ir_dump ctest --preset dev --no-tests=error -R '^native_graphics_wqm_hardware$' -V ctest --preset dev --no-tests=error -j 1 -V -R '^native_graphics_wqm_(hardware|warp|ir)$' ``` - The issue's command: passed. - dev and release (`/O2`), each run twice in series: 3/3 passed every time, with the same counts. - `ctest --preset dev --no-tests=error -j 1 -R '^native_'`, with every native target built: 34 tests, 33 passed and 1 skipped. The skip is `native_comparison_pso_warp`, "compute requires wave32: WaveOps=1 range=4..4", a capability skip that this change does not touch. ## Not run - **64-lane adapter:** the RX 9070 XT run that @MasterDomino offered is blocked by #2915. - **Other hardware:** AMD and Intel; the console. - **Inputs:** real programs or captures. Only the bounded form above is accepted. - **CI:** the Linux jobs do not run these Windows GPU tests, and the `pr` preset does not select `native_graphics_wqm_*`. ## 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/native-graphics-wqm-cross-quad.md`). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
MasterDomino commented 2026-11-26 22:54:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T22:54:05Z.

Review: APPROVED


Review of head eee7f839, tested merged onto cpp-migration c2f6d3de. It merges cleanly. Approving and merging. This is the RX 9070 XT run I offered on #2907, possible now that #2932 fixed #2915.

Code: raster_vote claims only the documented shape:

  • a save, then s_wqm, then filters on sE;
  • one survivor or whole-quad mask write, optionally narrowed;
  • s_wqm exec, sM with a forward s_cbranch_execz;
  • a scalar-only region that does not touch sE;
  • a jump to the exact s_mov exec, sE, then a lane-local colour-export tail, with no other branch.

Everything else in a claimed program is refused by name. The vote is waveAnyTrue of the modelled EXEC bit OR-ed with quadOp 0, 1 and 2, as decided on #2907, and the branch becomes s_cbranch_scc0 on it.

Run on a 64-lane adapter: Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release, D3D12 debug layer enabled.

ctest --preset release --no-tests=error -j 1 -V -R '^native_graphics_wqm_(hardware|warp|ir)$'

3/3 passed. All 42 draws report debug_errors=0 debug_warnings=0.

  • Measured layout: a new topology for this fixture.
    • Full draw: 64 lanes, 4 quads in 1 waves, 1 waves with more than one quad, 0 helper lanes.
    • Diagonal draw: 64 lanes, 3 quads in 1 waves, 1 waves with more than one quad, 3 helper lanes.
  • Controls:
    • quad-local: 10, 4 and 8 of 16 pixels on cases 1, 2 and 4, and 8 on each helper case;
    • no-OR ("plain") and survivors-only: 9 of 16 on each helper case;
    • survivors-only: 8 of 16 on case 4.
  • WARP: passes with SKIPPED cross-quad quad-local control: no desktop wave holds two quads (4 lanes), as described.

Mutation here: dropping QuadReadAcrossDiagonal from the vote (op<3 → op<2) and rebuilding makes native_graphics_wqm_hardware fail. After restoring, all of ctest --preset release -R '^native_' passes: 37/37, including the WARP capability skip.

That gives the fixture three adapters with three layouts: WARP (4 lanes), RTX 3070 (32 lanes, yours) and RX 9070 XT (64 lanes, here). I will close #2907 by hand after the merge.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6081276157 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2946#pullrequestreview-6081276157). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T22:54:05Z. **Review:** APPROVED --- Review of head `eee7f839`, tested merged onto `cpp-migration` `c2f6d3de`. It merges cleanly. Approving and merging. This is the RX 9070 XT run I offered on #2907, possible now that #2932 fixed #2915. **Code:** `raster_vote` claims only the documented shape: - a save, then `s_wqm`, then filters on `sE`; - one survivor or whole-quad mask write, optionally narrowed; - `s_wqm exec, sM` with a forward `s_cbranch_execz`; - a scalar-only region that does not touch `sE`; - a jump to the exact `s_mov exec, sE`, then a lane-local colour-export tail, with no other branch. Everything else in a claimed program is refused by name. The vote is `waveAnyTrue` of the modelled EXEC bit OR-ed with `quadOp` 0, 1 and 2, as decided on #2907, and the branch becomes `s_cbranch_scc0` on it. **Run on a 64-lane adapter:** Windows 11 26300.9974, AMD Radeon RX 9070 XT (driver 32.0.32029.2010), release, **D3D12 debug layer enabled**. ```powershell ctest --preset release --no-tests=error -j 1 -V -R '^native_graphics_wqm_(hardware|warp|ir)$' ``` 3/3 passed. All 42 draws report `debug_errors=0 debug_warnings=0`. - **Measured layout:** a new topology for this fixture. - Full draw: `64 lanes, 4 quads in 1 waves, 1 waves with more than one quad, 0 helper lanes`. - Diagonal draw: `64 lanes, 3 quads in 1 waves, 1 waves with more than one quad, 3 helper lanes`. - **Controls:** - quad-local: 10, 4 and 8 of 16 pixels on cases 1, 2 and 4, and 8 on each helper case; - no-OR ("plain") and survivors-only: 9 of 16 on each helper case; - survivors-only: 8 of 16 on case 4. - **WARP:** passes with `SKIPPED cross-quad quad-local control: no desktop wave holds two quads (4 lanes)`, as described. **Mutation here:** dropping `QuadReadAcrossDiagonal` from the vote (`op<3` → `op<2`) and rebuilding makes `native_graphics_wqm_hardware` **fail**. After restoring, all of `ctest --preset release -R '^native_'` passes: 37/37, including the WARP capability skip. That gives the fixture three adapters with three layouts: WARP (4 lanes), RTX 3070 (32 lanes, yours) and RX 9070 XT (64 lanes, here). I will close #2907 by hand after the merge. AI-assisted; the commands above were run locally.
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!2946
No description provided.