Shaders: ds_permute_b32 scatters through a scratch in LDS #511

Open
pug205gti6 wants to merge 1 commit from upstream-pr/511 into main
pug205gti6 commented 2026-11-25 01:55:30 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pug205gti6 on 2026-11-25T01:55:30Z.


ds_permute_b32 was 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).

Two tests: a straight-line scatter lowers, and a scatter in a branch refuses. Written with DeepSeek V4 Pro (OpenCode).

Assisted-by: DeepSeek V4 Pro (OpenCode)

<!-- greyfinch-sync:fxceless/victory-fork:issue:6595349449 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/511). Originally posted by [pug205gti6](https://github.com/pug205gti6) on 2026-11-25T01:55:30Z. --- ds_permute_b32 was 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). Two tests: a straight-line scatter lowers, and a scatter in a branch refuses. Written with DeepSeek V4 Pro (OpenCode). Assisted-by: DeepSeek V4 Pro (OpenCode)
Revens2 commented 2026-11-25 08:09:00 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:36:05Z.


Duplicate of #454: @Melow-code opened this patch 53 minutes earlier, and gh pr diff returns the same bytes for both (+95/-0 on 2 file(s), same title).

Please continue in #454 so the review history and any test data stay in one place.
Thanks.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7156043650 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/511#issuecomment-7156043650). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:36:05Z. --- Duplicate of #454: @Melow-code opened this patch 53 minutes earlier, and `gh pr diff` returns the same bytes for both (+95/-0 on 2 file(s), same title). Please continue in #454 so the review history and any test data stay in one place. Thanks.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/511:upstream-pr/511'
git switch 'upstream-pr/511'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/511'
git switch 'upstream-pr/511'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/511'
git switch 'upstream-pr/511'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/511'
git switch 'main'
git merge --squash 'upstream-pr/511'
git switch 'main'
git merge --ff-only 'upstream-pr/511'
git switch 'main'
git merge 'upstream-pr/511'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!511
No description provided.