Shaders: ds_permute_b32 scatters through a scratch in LDS #511

Open
github-bot wants to merge 1 commit from github-bot/gh-511 into main AGit
Owner

@⁠pug205gti6 on GitHub · 2026-11-25 01:55 UTC · original
pug205gti6:pr/454-shaders-ds_permute → main · +95 −0 · 2 files · 1 commits · open

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)

**@⁠pug205gti6** on GitHub · 2026-11-25 01:55 UTC · [original](https://github.com/fxceless/victory-fork/pull/511) `pug205gti6:pr/454-shaders-ds_permute` → `main` · +95 −0 · 2 files · 1 commits · open 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)
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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:45:02 +00:00
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:36 UTC · original

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.

**@⁠Revens2** on GitHub · 2026-11-25 07:36 UTC · [original](https://github.com/fxceless/victory-fork/pull/511#issuecomment-7156043650) 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/511/head:github-bot/gh-511'
git switch 'github-bot/gh-511'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-511'
git switch 'github-bot/gh-511'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-511'
git switch 'github-bot/gh-511'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-511'
git switch 'main'
git merge --squash 'github-bot/gh-511'
git switch 'main'
git merge --ff-only 'github-bot/gh-511'
git switch 'main'
git merge 'github-bot/gh-511'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.