Shaders: support cross-half ds_bpermute_b32 and fix group <= 32 OOB lanes on 32-lane GPUs #615

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

@⁠orazal12 on GitHub · 2026-11-25 03:19 UTC · original
orazal12:fix/wave32-bpermute → main · +295 −6 · 2 files · 1 commits · open

Fixes and extends ds_bpermute_b32 lowering for console wave64 shaders running on 32-lane GPUs (NVIDIA / wave32):

  • Fix group <= 32 OOB lane reads: previously passed src in 0..=63 directly to dx.op.waveReadLaneAt.i32 on a 32-lane host wave (UB / wraps mod 32 instead of returning 0 for lanes 32..63). Now masks lane = src & 31 and selects 0 when src >= 32.
  • Support cross-half ds_bpermute_b32 (group > 32): allocates 64-dword-per-console-wave LDS scratch (checking D3D12's 32 KiB limit with 1 dword reserved for wave_base), exchanges all 64 lanes via store -> group_sync -> load -> group_sync, selects 0 for missing lanes in partial tail waves (!group.is_multiple_of(64)), and hooks into needs_every_lane / widen when called inside a per-lane branch.
  • Local-wave modes: matches v_readlane_b32 (masks src & 31 under local && local_any; refuses cleanly under local && !local_any).

Verification:

  • cargo test -p victory-shader --offline: 218 passed, 0 failed (4 new wave64_tests validated with dxil.dll and executed on hardware GPU covering [32,1,1], [64,1,1], [128,1,1], [96,1,1], per-lane branch widening, and 32 KiB LDS overflow refusal)
  • cargo test -p xtask --offline: 4 passed (asset policy check ok)
  • cargo clippy -p victory-shader --all-targets --offline -- -D warnings: 0 warnings
**@⁠orazal12** on GitHub · 2026-11-25 03:19 UTC · [original](https://github.com/fxceless/victory-fork/pull/615) `orazal12:fix/wave32-bpermute` → `main` · +295 −6 · 2 files · 1 commits · open Fixes and extends `ds_bpermute_b32` lowering for console wave64 shaders running on 32-lane GPUs (NVIDIA / wave32): - **Fix `group <= 32` OOB lane reads**: previously passed `src` in `0..=63` directly to `dx.op.waveReadLaneAt.i32` on a 32-lane host wave (UB / wraps mod 32 instead of returning `0` for lanes `32..63`). Now masks `lane = src & 31` and selects `0` when `src >= 32`. - **Support cross-half `ds_bpermute_b32` (`group > 32`)**: allocates 64-dword-per-console-wave LDS scratch (checking D3D12's 32 KiB limit with 1 dword reserved for `wave_base`), exchanges all 64 lanes via `store -> group_sync -> load -> group_sync`, selects `0` for missing lanes in partial tail waves (`!group.is_multiple_of(64)`), and hooks into `needs_every_lane` / `widen` when called inside a per-lane branch. - **Local-wave modes**: matches `v_readlane_b32` (masks `src & 31` under `local && local_any`; refuses cleanly under `local && !local_any`). **Verification:** - `cargo test -p victory-shader --offline`: 218 passed, 0 failed (4 new `wave64_tests` validated with `dxil.dll` and executed on hardware GPU covering `[32,1,1]`, `[64,1,1]`, `[128,1,1]`, `[96,1,1]`, per-lane branch widening, and 32 KiB LDS overflow refusal) - `cargo test -p xtask --offline`: 4 passed (asset policy check ok) - `cargo clippy -p victory-shader --all-targets --offline -- -D warnings`: 0 warnings
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:47:28 +00:00
Author
Owner

@⁠HAL9000RELOADED on GitHub · 2026-11-25 19:29 UTC · original

RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: all 4 new tests pass on the card with this PR, and all 4 fail with the tests alone on the base. No other test changed. Run table: #129 (#129).

**@⁠HAL9000RELOADED** on GitHub · 2026-11-25 19:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/615#issuecomment-7172374228) RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main `d510ee4`: all 4 new tests pass on the card with this PR, and all 4 fail with the tests alone on the base. No other test changed. Run table: #129 (https://git.gtahub.st/github/fxceless--victory-fork/pulls/129).
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/wave64_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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