Shaders: ds_permute_b32 scatters through a scratch in LDS #454
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!454
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/454/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?
@Melow-code on GitHub · 2026-11-25 01:02 UTC · original
fix/scatter-ds-permute-b32→main· +95 −0 · 2 files · 1 commits · closed without mergingds_permute_b32was not lowered: it fell to the generic LDS path, which is not what the instruction does.Each active lane gives its data register to the lane its address plus the offset names in dwords, within the 32-lane half of the calling lane (the ISA confines the permute there in wave64). The console writes a scratch that starts at zero and each active destination lane reads a slot of its own, so a destination nobody targets reads zero.
The lowering zeroes the slot of the calling lane, runs a group barrier, has every lane write the slot its address names, runs another barrier, and reads the slot of the calling lane. The scratch holds a dword per lane of every console wave in the group, past the LDS of the program, addressed by the console thread, so the two host waves of a split console wave never hit the same slot. A barrier needs every lane: in a block some lanes leave, this refuses (a wave-wide structuring of the block would open it).
Verification
cargo test --locked -p victory-shader --libon Linux: 173 passed, two ignored.a_scatter_permute_writes_the_lane_its_address_names), and a scatter in a branch refuses (a_scatter_permute_in_a_branch_is_refused).The GPU readback of the scatter needs a Windows host, outside this run.
Assisted-by: DeepSeek V4 Pro (OpenCode)
System Initand presents 100% black frames with 3 draws/frame #950System Initand presents 100% black frames with 3 draws/frame #950Pull request closed