Shaders: track source lane in whole-wave Sym::Own to prevent miscompiled shuffles #209
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/209"
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 fxceless/victory-fork. Originally posted by AscilCH on 2026-11-24T22:34:00Z.
Bug
In
crates/victory-shader/src/emit/wave.rs, pre-section VGPR inputs are represented asSym::Own(Value)without recording which lane originally held the value.When a whole-wave section executes cross-lane operations on a pre-section VGPR:
v_readlane_b32(and subsequent broadcasts) copiesSym::Own(v)into scalar outputs;shapes()matchesSym::Own(v)and returnsShape::Value(v)— silently lowering a broadcast of lanekas each lane's ownv[l].row_mirror,quad_perm,row_ror,dpp8, etc.) andv_permlanex16_b32moveSym::Own(v)from lanesrcto lanedst;per_lane()checkslanes.iter().all(|&s| s == first)and collapses the shuffled vector back toShape::Value(v)(identity).v_cndmask_b32over a shuffled pre-section VGPR checksSome(Sym::Own(x))without checking the originating lane, silently collapsing toShape::Masked(v, mask, 0).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 (a broadcast of one 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.Verification
rustfmt --edition 2024 --check crates/victory-shader/src/emit/wave.rs(changed hunks): cleancargo test -p victory-shader --locked wave -- --test-threads=1: 21 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit test only, no game data.)
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.