Shaders: a mask built up in a loop every lane runs the same way (stacked on #1407) #1419
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1420"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T17:54:44Z.
Stacked on #1407: the first two commits are that pull request's, the last one is this change.
A mask ORed together over a loop and read after it failed with "a lane-mask join of an untracked mask":
The join at the loop's head takes in the 0 written before the loop, which is no mask, so the lowering had no lane bit for that edge. When no branch in the loop depends on the lane (here an SCC test of a scalar counter), each lane goes round as often as the wave and enters the head over the wave's edge, so its own value there is the wave's.
structurenow records those joins, with the forward joins that #1407 checks edge by edge, asper_lane_joins, and only those take in a number by its lane bit. A loop that lanes leave after different passes (v_cmpx_lt_u32thens_cbranch_execnz) is still refused: there the wave's s20 keeps growing after a lane has left, so the lane's own copy is not the wave's.How I checked it
Three tests in
lane_mask_tests.rs, on synthetic wave32 programs of 32 lanes:0x7) and counted withs_bcnt1_i32_b32(3);On an RTX 5070 (driver 621.40), all eight tests of the file pass. Devices without 32-lane waves (WARP, the CI's adapter) are skipped, as in #1407.
cargo test --workspace --lockedpasses andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.Not checked: the title's shaders (I have no dump), wave64 on a GPU, and loops with a lane-dependent branch inside that does not leave the loop. Those are still refused, which is safe but stricter than needed.
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T18:09:53Z.
Independent verification of \
7b7d5fd\ 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.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:24:56Z.
Review: APPROVED
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.Same lane-mask work as #1407 plus the loop cases: a mask built up in a loop every lane runs the same way now reads as a number and counts its lanes (
accumulating_loopvariants). Newlane_mask_tests.rs(380 lines) — Windows-gated hardware cases, not run on macOS (96 green).Note: conflicts with #1407 (same new file, same helpers/tests); this one is the superset, so landing this one and closing #1407 would avoid a rebase.
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T19:56:18Z.
On the conflict with #1407: this branch is stacked on it, not a copy. It contains #1407's two commits unchanged, plus one commit for the loops, so the two do not conflict. Merging this one lands both. Merging #1407 first (as a merge, not a squash) leaves only the last commit here. If #1407 is squashed, I'll rebase this one.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:44:00Z.
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
7b7d5fdontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.5 programs move from "a lane mask holding lanes elsewhere read as data" to later failures.
Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 128, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T21:40:07Z.
Thanks for running the comparison on this one too. It gives the same 5 programs as #1407 alone, so the loop handling here doesn't move any program on top of it in this build. Their next refusal is what blocks them, not the masks.
If you still have both lists, the reason each of those 5 fails with now would settle where to look next. That one comparison covers both PRs, so there's no need to repeat it on #1407.
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T22:06:00Z.
Rebased onto
main70564ae, still stacked on #1407 (head9f57d9c: #1407's two commits, then the loop commit). The only conflict came frommain's new fields in the structure builder.On an RTX 5070, the two loop tests fail on plain
mainand pass here.cargo test -p victory-shader --locked: 214 passed, and 3 failures that plainmainhas on this card too (listed on #1407).Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:27:08Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-25T04:41:21Z.
Restacked on the new #1407 (head
f9fb9aa, onmain940d32f): #1407's single commit, then the loop commit. #1407 has dropped itsoutsidefallback, so the per-lane joins here no longer look at it either. A uniform loop's head joins and the forward joins checked edge by edge go intoper_lane_joins, and only those take in a number.On the CI failure: the
checkjob's failing tests aresynthetic_tests::gathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out, which this branch does not touch. On an RTX 5070, plainmain940d32ffailsgathers_at_a_level…and twostride_teststhe same way. Here,cargo test -p victory-shader --locked -- lane_maskgives 9 passed,cargo clippy -p victory-shader --all-targets --locked -- -D warningsis clean, and the full crate gives 252 passed with only those 3mainfailures.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.