Shaders: keep s_cmp of two lane masks uniform #2451
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2453"
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 makmatvey on 2026-11-25T13:49:25Z.
What
s_cmp_eq/s_cmp_lgof two tracked lane masks sets a wave-wide SCC on the console (all bits equal / any bit differs). Structuring lowered that to a per-lane XNOR/XOR intoscc_lane, sos_cbranch_scc0/1diverged when only some lanes agreed locally.Tracked as VIC-BT-006 in #1242. Focused re-land of stalled #1412 (
triage: needs rebase); does not include that PR's GPU valu harness changes.Change
In
crates/victory-shader/src/structure.rs, skip the per-lanescc_laneinsert when both operands are tracked masks. SCC stays a uniform atom; lowering already compares the ballots as scalar values.Tests
cargo test -p victory-shader --locked --lib structure::tests::branches_comparing_two_lane_masks_are_uniform— pass (fails onmainwithout the skip:LanevsUniform)cargo test -p victory-shader --locked --lib structure::— 12 passed, 1 ignoredcargo clippy -p victory-shader --locked -- -D warnings— cleancargo xtask policy— okNo game data used.
Fixes VIC-BT-006 in #1242.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T13:54:30Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:s_cmpof two lane masks uniform instructure.rsis clean and passes all structure tests.cargo test -p victory-shader structure::tests: 12/12 passed on RTX 5090, 12/12 passed on WARP (includingbranches_comparing_two_lane_masks_are_uniform).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:06Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — s_cmp of two lane masks kept uniform.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:25:16Z.
Correct semantics:
s_cmp_eq_u32 vcc, execcompares two ballot values as scalars — the result is a single uniform SCC, not a per-lane relation, so feeding it through the per-lane XOR path would haves_cbranch_scc*report divergent (a wrong branch structure, not just a missed optimization). The!(a_mask && c_mask)gate keeps the per-lane path for the mask-vs-scalar case where it belongs. The test pins the uniform support for both wave widths and both senses (eq/lg).Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T14:49:24Z.
Independent local validation (Windows, Rust 1.100.0/MSVC, head
11ce139, no game data):cargo test --locked -p victory-shader --lib-> 248 passed, 0 failed, 3 ignored, exit 0;git diff --check HEAD~1 HEADclean. The lib test count matches upstream main, so this is a compile/regression check only; I did not independently replay the synthetic s_cmp lane-mask scenario. AI-assisted (Hy4 flash). GPU/driver: N/A for the CPU test run. No game data, assets or extracted content used.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:57:52Z.
Automated triage for the maintainers.
Merge candidate. In
crates/victory-shader/src/structure.rsLanes::step,s_cmp_eq/lg_u32/u64of two tracked lane masks no longer gets a per-lane XNOR/XOR inscc_lane, sobranchfalls back to the uniform SCC atom; that matches the ISA (the scalar compare sets one SCC for the wave), whereas the per-lane form let lanes that agree locally take a branch the wave does not. I checked the test's encodings (v_cmp_eq_u32,s_cmp_eq/lg_u32/u64 vcc, exec,s_cbranch_scc1). One observation for later, outside this PR: a mask compared with a constant (e.g.s_cmp_eq_u64 vcc, 0) still takes the per-lane path. CI: passing.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:09:59Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because it reverses a documented design rule without a case where the rule gives a wrong result, and it breaks mesh programs.
structure.rsturns a branch on a wave-wide mask test into a branch on the lane's own bit on purpose. With this change the uniform SCC has to be computed from a mask read as a number, which mesh programs cannot do: a small mesh program (v_cmp_eq_u32 vcc, 0, v2; s_cmp_eq_u32 vcc_lo, exec_lo; s_cbranch_scc1) emits onmainand is refused with "a lane mask read as data" with this PR.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed