gfx2hlsl: prove lane-local compute readfirstlane waterfall bodies #2686

Merged
RavenCurseBurg merged 4 commits from upstream-pr/2694 into main 2026-11-26 02:46:02 +00:00
RavenCurseBurg commented 2026-11-26 02:18:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T02:18:27Z.


Change

This implements the numeric and fixed raw-buffer part of #2644 T1. A compute loop can use a lane-varying v_readfirstlane_b32 key when the next compare selects that key's lanes, the saved remaining mask is intact, and s_andn2_wrexec_b32 plus s_cbranch_scc1 closes the loop. The fixture covers groups of up to 32 threads for the low-word mask.

Each active lane receives its own key on its one participating visit. The proof reuses the compute scalar effect sets, exit liveness and branch targets. It checks the mask copy, entry edges, loop-carried scalars, the straight-line body and the registers that can escape. The output SGPR is marked varying. Per-key byte offsets are supported in a fixed bound raw buffer. Per-key resource selection still requires T3's bound heap range. AMD describes the waterfall and the two WREXEC widths in RDNA 2 ISA §12.3, opcodes 58 and 71.

Verification

Both complete synthetic programs stop at v_readfirstlane_b32 requires a proven uniform source on the parent f06646ba. The host and LLVM 15.0.7 reassembly modes pass on the candidate. They cover a store, a read of the actual active-mask rank, a changed saved mask, a different compare source, a second entry edge, an escaping scalar on one or all paths, loop-carried SGPR/SCC, a per-key descriptor and a group with 33 threads. Overwriting the escaping scalar on every path is a positive control.

python -B tests/startup_compute_readfirstlane_check.py
python -B tests/startup_compute_readfirstlane_check.py --llvm-mc llvm-mc-15
python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer warp
python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer hardware

The independent host reference covers 1,215 input and active-mask combinations. An active-mask-rank body produced 495 counterexamples to singleton execution and has a named refusal here. The synthetic fixtures use no captured input.

The registered dispatch fixture passed on WARP, GeForce RTX 4060 and Intel UHD 770 at 4fe7a4a5. Each run checked active counts from zero to four, an arithmetic overflow case, fixed-buffer reads, and two deliberately wrong references. The affected fixture also retains its original uniform-source and mutation checks.

I separately compiled both programs with an input-configurable mask. For each adapter, five key tuples crossed with all 16 four-lane masks gave 80 arithmetic and 80 fixed-buffer readbacks. All 480 outputs matched the independent reference over all 320 words. A separately compiled mutant used the same lane's key for everyone. On each adapter, its first mismatch was word 1 in both programs (arithmetic expected 0x30, got 0x50; fixed buffer expected 0x91, got 0x119). All 97 selected host-side translator and documentation checks passed. Two neighboring graphics fixtures also passed in their actual WARP draw modes.

The branch includes #2693, which lets the existing fixture accept the renderer's adapter-selection notice when testing a secondary GPU. Review the four waterfall files against that prerequisite.

The first Linux CI run failed only the scalar-table arity mutation count (37 of 40). I reproduced the same result on unmodified main at e76f8acd. The three templates with dedicated refusals are s_bfm_b32, s_mul_hi_i32 and s_mul_hi_u32. Windows and LLVM CI passed on that head. The upstream fix landed in #2659 at ad1ad194. I merged main through 8ad488af: the resulting head 27de79c9 passes both the scalar-table mutation suite and the host readfirstlane tests, including LLVM reassembly.

Refs #2644 and #2274. AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6618066379 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2694). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T02:18:27Z. --- ## Change This implements the numeric and fixed raw-buffer part of [#2644 T1](https://github.com/R0Y00/Xbox2Windows/issues/2644#issuecomment-7179869860). A compute loop can use a lane-varying `v_readfirstlane_b32` key when the next compare selects that key's lanes, the saved remaining mask is intact, and `s_andn2_wrexec_b32` plus `s_cbranch_scc1` closes the loop. The fixture covers groups of up to 32 threads for the low-word mask. Each active lane receives its own key on its one participating visit. The proof reuses the compute scalar effect sets, exit liveness and branch targets. It checks the mask copy, entry edges, loop-carried scalars, the straight-line body and the registers that can escape. The output SGPR is marked varying. Per-key byte offsets are supported in a fixed bound raw buffer. Per-key resource selection still requires T3's bound heap range. AMD describes the waterfall and the two WREXEC widths in [RDNA 2 ISA §12.3, opcodes 58 and 71](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf). ## Verification Both complete synthetic programs stop at `v_readfirstlane_b32 requires a proven uniform source` on the parent `f06646ba`. The host and LLVM 15.0.7 reassembly modes pass on the candidate. They cover a store, a read of the actual active-mask rank, a changed saved mask, a different compare source, a second entry edge, an escaping scalar on one or all paths, loop-carried SGPR/SCC, a per-key descriptor and a group with 33 threads. Overwriting the escaping scalar on every path is a positive control. ```powershell python -B tests/startup_compute_readfirstlane_check.py python -B tests/startup_compute_readfirstlane_check.py --llvm-mc llvm-mc-15 python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer warp python -B tests/startup_compute_readfirstlane_check.py --dispatch $dxc $renderer hardware ``` The [independent host reference](https://github.com/R0Y00/Xbox2Windows/issues/2644#issuecomment-7179923728) covers 1,215 input and active-mask combinations. An active-mask-rank body produced 495 counterexamples to singleton execution and has a named refusal here. The synthetic fixtures use no captured input. The registered dispatch fixture passed on WARP, GeForce RTX 4060 and Intel UHD 770 at `4fe7a4a5`. Each run checked active counts from zero to four, an arithmetic overflow case, fixed-buffer reads, and two deliberately wrong references. The affected fixture also retains its original uniform-source and mutation checks. I separately compiled both programs with an input-configurable mask. For each adapter, five key tuples crossed with all 16 four-lane masks gave 80 arithmetic and 80 fixed-buffer readbacks. All 480 outputs matched the independent reference over all 320 words. A separately compiled mutant used the same lane's key for everyone. On each adapter, its first mismatch was word 1 in both programs (arithmetic expected `0x30`, got `0x50`; fixed buffer expected `0x91`, got `0x119`). All 97 selected host-side translator and documentation checks passed. Two neighboring graphics fixtures also passed in their actual WARP draw modes. The branch includes [#2693](https://github.com/R0Y00/Xbox2Windows/pull/2693), which lets the existing fixture accept the renderer's adapter-selection notice when testing a secondary GPU. [Review the four waterfall files against that prerequisite](https://github.com/RavenCurseBurg/Xbox2Windows/compare/fa691dd6...4fe7a4a5). The [first Linux CI run](https://github.com/R0Y00/Xbox2Windows/actions/runs/45741536532/job/139647474285) failed only the scalar-table arity mutation count (37 of 40). I reproduced the same result on unmodified main at `e76f8acd`. The three templates with dedicated refusals are `s_bfm_b32`, `s_mul_hi_i32` and `s_mul_hi_u32`. Windows and LLVM CI passed on that head. The upstream fix landed in [#2659](https://github.com/R0Y00/Xbox2Windows/pull/2659) at `ad1ad194`. I merged main through `8ad488af`: the resulting head `27de79c9` passes both the scalar-table mutation suite and the host readfirstlane tests, including LLVM reassembly. Refs #2644 and #2274. AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).
upstream-sync closed this pull request 2026-11-26 03:03:14 +00:00
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!2686
No description provided.