Shaders: track source lane in whole-wave Sym::Own to prevent miscompiled shuffles #209
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!209
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@AscilCH on GitHub · 2026-11-24 22:34 UTC · original
AscilCH:fix/wave-own-tracks-source-lane→main· +60 −6 · 1 files · 1 commits · openBug
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.)
In `crates/victory-shader/src/emit/wave.rs`, pre-section VGPR inputs were represented as `Sym::Own(Value)` without recording their originating lane. When a whole-wave section applied `v_readlane_b32`, DPP shuffles (`row_mirror`, `quad_perm`, `dpp8`, etc.), or `v_permlanex16_b32` to a pre-section VGPR, `shapes()` and `per_lane()` collapsed the broadcast or shuffled result back to `Shape::Value(v)` (identity), and `v_cndmask_b32` over a shuffled VGPR collapsed to `Shape::Masked(v, mask, 0)`. Store the originating lane in `Sym::Own(Value, u8)`, require `usize::from(from) == l` in `v_cndmask_b32` and `per_lane()`, and never treat `Sym::Own(..)` as a uniform broadcast in `shapes()` or `per_lane()`. Add `emit:👋:tests::cross_lane_ops_on_pre_section_vgpr_do_not_collapse_to_identity`.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.