Shaders: track source lane in whole-wave Sym::Own to prevent miscompiled shuffles #1486
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!1486
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1486"
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?
@AscilCH on GitHub · 2026-11-24 18:22 UTC · original
AscilCH:fix/wave-own-tracks-source-lane→main· +106 −6 · 1 files · 1 commits · openBug
In
crates/victory-shader/src/emit/wave.rs, pre-section VGPR inputs were represented asSym::Own(Value)without recording which lane originally held the value.When a whole-wave section performed cross-lane operations on a pre-section VGPR:
v_readlane_b32(and subsequent broadcasts) copiedSym::Own(v)into scalar outputs;shapes()then matchedSym::Own(v)and returnedShape::Value(v)— silently lowering a broadcast of lanekas each lane's ownv[l]!row_mirror,quad_perm,row_ror,dpp8, etc.) andv_permlanex16_b32movedSym::Own(v)from lanesrcto lanedst;per_lane()then checkedlane.iter().all(|x| *x == Sym::Own(v))and collapsed the shuffled vector back toShape::Value(v)(identity)!v_cndmask_b32over a shuffled pre-section VGPR checked*a == Sym::Own(v)without checking the originating lane, silently collapsing toShape::Masked(v, mask, 0).Reproduction (Before Fix)
With a synthetic whole-wave section executing
v_readlane_b32 s5, v0, 7,v_mov_b32_dpp v2, v0 row_mirror,v_permlanex16_b32 v3, v0, 0, 0, andv_cndmask_b32over a shuffledv0:Fix
Sym::Own(Value, u8)(initialized withl as u8when reading an untracked VGPR in lanel).usize::from(from) == lwhen recognizing identity/masked outputs inv_cndmask_b32andper_lane().Sym::Own(..)toShape::Valuein scalarshapes()or inper_lane()'s uniform broadcast branch (since a broadcast of a single source lane's pre-section VGPR is not each lane's own value).emit::wave::tests::cross_lane_ops_on_pre_section_vgpr_do_not_collapse_to_identitycoveringv_readlane_b32,v_mov_b32_dpp(row_mirror),v_permlanex16_b32, andv_cndmask_b32over a shuffled VGPR, while asserting unshuffled identity/masked paths remain recognized.(Disjoint from #646, which addresses
constant()sign-extension andop: Noneinper_lane().)Verification
rustfmt --edition 2024 --check crates/victory-shader/src/emit/wave.rs: cleanVICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1: 121 passed, 0 failedcargo xtask policy: 154 files okcargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleanIn crates/victory-shader/src/emit/wave.rs, every per-lane VGPR entering a whole-wave section was represented as Sym::Own(Value) without recording which lane it belonged to. Because all lanes shared the same symbol: - v_readlane_b32 of a pre-section VGPR (and any broadcast of that scalar) collapsed via shapes()/per_lane() to Shape::Value(v), giving each lane its own v[lane] instead of the selected lane's value. - Cross-lane DPP permutations (e.g. row_mirror, quad_perm, row_ror, dpp8) and v_permlanex16_b32 on a pre-section VGPR produced [Sym::Own(v); wave] and silently collapsed to Shape::Value(v), turning shuffles into no-ops. - v_cndmask_b32 over a shuffled pre-section VGPR matched Sym::Own(v) and produced a wrong Shape::Masked / reduction over unshuffled lanes. Fix: - Carry the originating lane in Sym::Own(Value, u8). - Require usize::from(from) == l in v_cndmask_b32 and in per_lane()'s identity check; never map Sym::Own(..) to Shape::Value in shapes() (scalar outputs) or in per_lane()'s uniform branch. - Add unit test emit:👋:tests::cross_lane_ops_on_pre_section_vgpr_do_not_collapse_to_identity.@sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
ecdb146ontomainffe310e(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.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 121, 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).
@Marvisak on GitHub · 2026-11-25 01:29 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/wave.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.