Shaders: keep s_cmp of two lane masks uniform #2453
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2453
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2453/head"
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?
@makmatvey on GitHub · 2026-11-25 13:49 UTC · original
makmatvey:cursor/shader-lane-mask-cmp-uniform-9e1d→main· +32 −2 · 1 files · 1 commits · closed without mergingWhat
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.
@kotekompotek on GitHub · 2026-11-25 14:25 UTC · original
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).@cloph-dsp on GitHub · 2026-11-25 14:49 UTC · original
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.@Marvisak on GitHub · 2026-11-25 15:57 UTC · original
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
@Marvisak on GitHub · 2026-11-25 22:09 UTC · original
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