Repository navigation
Shaders: a lane-mask join of masks and numbers, read as a number - #1407
marquezinii wants to merge 1 commit into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
Tested head 82ad8ac (fast-forward on main ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):
cargo test -p victory-shader emit::lower: 11 passed, 0 failedcargo clippy -p victory-shader --all-targets: 0 warningscargo xtask policy: ok (156 files ok)
Clean handling of lane masks and mask joins read as numbers. Approving.
AI-assisted (Gemini 4 Neon).
|
Independent verification of \�855757\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200, native wave32 + wave64) / Rust 1.98.1 MSVC:
AI-assisted; synthetic tests only, no game files. |
…umbers Port of upstream Marvisak#1407 (marquezinii, a855757). A mask set in every lane outside EXEC where it is written (s_not of a compare in a branch, saved EXEC without the current one) is the ballot of the lanes there plus every lane not there (~WaveActiveBallot(true)); a join of masks and constants read as a number takes the constant where the join was checked per lane. 39 compute programs refused this way in the user's gameplay log. Adapted to JMAN730#439: the structure's `numbers` are JMAN730#439's `others`; the console flow keeps its own exchange. Co-authored-by: CitizenCInema <fredericlaura.fl@pm.me> Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
catminou4
left a comment
There was a problem hiding this comment.
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96. GPU/valu execution tests are Windows-gated and were not run here.
Lane masks that hold lanes from elsewhere (negated compares, masks surviving branch joins) now read as numbers: the structure tracks which lanes a mask covers across CFG joins and lower.rs ballots/composes them instead of erroring. New lane_mask_tests.rs (315 lines) with five hardware cases — Windows-gated, so not run here; macOS suite stays green (96).
Note: #1420 adds the same file with the same helpers and the same five tests plus three loop cases — the two PRs conflict textually; whichever lands second needs a rebase (and #1420 looks like the superset).
Offline measurement on a retail dump, and the shader tests on AdaResult: no count change against Offline. I merged head a855757 onto 5 programs move from "a lane mask holding lanes elsewhere read as data" to later failures. Tests: with the same merge, No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
|
Thanks for running it on the dump. So these patterns are not what stops those programs: 5 programs only get past this refusal and then fail on something else. Could you post which reasons those 5 now fail with? That tells me where to look next. #1420 (the loop case, stacked on this one) would be worth the same comparison, if you have the time. |
|
Three open PRs lift the same lane-mask refusals; a note for whoever reviews them. #1407 (this one), #1423 and #1270 all target the refusals that FIND-6 in #1633 lists ("a lane mask holding lanes elsewhere read as data", "a select on an untracked mask"):
On an RTX 5070 (Blackwell, driver 621.24, Windows 11), each head's
So #1407 and #1423 overlap in code as well as in purpose, and all three need a rebase. #1270 and #1423 combine cleanly. I did not run the combinations or count refusals on a shader archive. No game files used. AI-assisted (Claude Code). |
a855757 to
e193474
Compare
|
Rebased onto Since
So in the rebase,
@sinan-cmyk's dump run found no count change on the old base; with |
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
A join of masks read by a VALU instruction (a compare written in a branch, read after EXEC is restored) is tracked as a mask and read as one, before the first loop, when every lane's own incoming mask is the wave's: the wave leaves a join from its last predecessor in program order, so a lane must find there the mask of every later edge. A constant joined in (s20 = 0 before the branch) is taken by its lane bit in such joins only. Masks holding lanes elsewhere are left to mask_number, which replays the scalar operation that writes them. The lane-mask tests run only where 32-lane waves run.
e193474 to
ad8e76a
Compare
|
Following the triage: I took the first option and dropped the On an RTX 5070 (driver 621.40):
The overlap with #1423 now comes down to |
|
Tested
A/B with Crate: Two extra cases I tried on the lowering only (no GPU), both behave as expected:
Nit: AI-assisted. |
Update (2026-11-25, head
ad8e76a):main'smask_numbernow covers masks holding lanes elsewhere, so the first part below (the~WaveActiveBallot(true)fallback) has been dropped. This PR now adds only the second part, the per-lane-checked join of masks and numbers. Details are in the latest comment.Two lane-mask reads that were refused now lower in compute programs.
A mask set in every lane outside EXEC where it is written.
s_not_b32of a compare inside a branch, or the saved EXEC without the current one (s_andn2_b32 s20, s6, exec_lo), holds lanes that do not run the writing block, so the ballot there missed them ("a lane mask holding lanes elsewhere read as data"). When the analysis proves that every lane with EXEC clear at the write has its bit set, the mask is now the ballot of the lanes that run there, plus every lane that does not (~WaveActiveBallot(true)). Compute only, where host lane n is console lane n (reading a mask as a number already fixes the wave size).A join of masks read by a VALU instruction.
s20 = 0; if (lane < 10) s20 = (lane < 5); v1 = s20failed with "a lane mask read as data": only scalar instructions andv_cndmaskresolved mask joins, so av_mov_b32 v1, s20after the branch saw an untracked value. VALU reads of a join now resolve it too. Reading it as a number takes each lane's own incoming mask, sostructureonly allows that before the first loop (where a block'sreachis exactly the lanes that get there) and when every lane's own mask is the wave's: the wave leaves a join from its last predecessor in program order, so a lane arriving over an edge must find the mask of every later edge there.s20 = 0before the branch passes (the compare is clear in the lanes that skip it);s20 = -1before it, or a mask both arms of an if/else write, is still refused, and a test checks each. A constant joined in is taken by its lane bit only in joins that passed this check.How I checked it
lane_mask_tests.rshas five tests on synthetic wave32 programs (32 lanes,v0is the lane):s_notof a compare in a branch counted withs_bcnt1(27), the lanes that skipped a branch read as a number (0xFFFFFC00), and a compare from a branch read after the join (0x1F);On an RTX 5070 (driver 621.40), all five pass. The GPU tests skip a device that does not run 32-lane waves (they ask
D3D12_OPTIONS1for the wave lane range): WARP and the CI's adapter, where creating the pipeline failed in the first CI run. Without the per-lane check, both refusal tests fail (the programs lower).cargo test --workspace --lockedpasses andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.rustfmt --checkpasses on the new file. The diffs it reports instructure.rsandlower.rsare lines already on main.Not checked: wave64 programs on a GPU (NVIDIA runs no 64-lane waves), and the change against the title's shaders, since I have no dump. Masks accumulated in a loop are still refused ("a lane-mask join of an untracked mask").
The AnyXboxX notes on the world's black image (
docs/running-gta6.md) name "a lane mask holding lanes elsewhere read as data" among the refusals of the compute passes that produce the meshExecuteIndirectarguments, which start at zero. That is why I picked these patterns.