Shaders: wrap lane selectors at the guest wave width #298

Open
avt0m4t48 wants to merge 1 commit from upstream-pr/298 into main
avt0m4t48 commented 2026-11-24 23:25:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by avt0m4t48 on 2026-11-24T23:25:21Z.


RDNA 2 v_readlane_b32 and v_writelane_b32 select a lane modulo the guest wave width. Normalize the guest selector before the native lane operations or the split-wave LDS exchange. In wave32, selectors 3 and 35 also identify the same spill slot and the same descriptor origin. AMD RDNA 2 ISA, section 12.12

The related upstream proposal is VIctory #1312. This patch applies the width rule to this fork's split-wave execution and scalar spill lowering. The EXEC participation problem is tracked separately in #111.

Verification

  • Three source-built regressions failed on 2119b0e and pass here. They cover native and split-wave lowering, a wrapped spill overwriting the same slot, and a wrapped descriptor read finding the latest store.
  • Forcing the emitter to use a 32-lane mask made the split-wave upper-half regression fail.
  • cargo test --locked -p victory-shader --lib on Linux reported 173 passed, two ignored. cargo check --locked --target x86_64-pc-windows-msvc -p victory-shader --tests passed.
  • Microsoft DXIL validation passed for ten synthetic variants. Disassembly showed the expected dynamic selector masks for wave32 on wave32, wave64 on wave64, and wave64 split across wave32.

Native GPU readback and application behavior were outside this run.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6593470940 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/298). Originally posted by [avt0m4t48](https://github.com/avt0m4t48) on 2026-11-24T23:25:21Z. --- RDNA 2 `v_readlane_b32` and `v_writelane_b32` select a lane modulo the guest wave width. Normalize the guest selector before the native lane operations or the split-wave LDS exchange. In wave32, selectors 3 and 35 also identify the same spill slot and the same descriptor origin. [AMD RDNA 2 ISA, section 12.12](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf) The related upstream proposal is [VIctory #1312](https://github.com/Marvisak/VIctory/pull/1312). This patch applies the width rule to this fork's split-wave execution and scalar spill lowering. The EXEC participation problem is tracked separately in #111. ## Verification - Three source-built regressions failed on `2119b0e` and pass here. They cover native and split-wave lowering, a wrapped spill overwriting the same slot, and a wrapped descriptor read finding the latest store. - Forcing the emitter to use a 32-lane mask made the split-wave upper-half regression fail. - `cargo test --locked -p victory-shader --lib` on Linux reported 173 passed, two ignored. `cargo check --locked --target x86_64-pc-windows-msvc -p victory-shader --tests` passed. - Microsoft DXIL validation passed for ten synthetic variants. Disassembly showed the expected dynamic selector masks for wave32 on wave32, wave64 on wave64, and wave64 split across wave32. Native GPU readback and application behavior were outside this run.
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/298:upstream-pr/298'
git switch 'upstream-pr/298'

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/298'
git switch 'upstream-pr/298'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/298'
git switch 'upstream-pr/298'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/298'
git switch 'main'
git merge --squash 'upstream-pr/298'
git switch 'main'
git merge --ff-only 'upstream-pr/298'
git switch 'main'
git merge 'upstream-pr/298'
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!298
No description provided.