fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts #295

Open
github-bot wants to merge 4 commits from github-bot/gh-295 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-26 01:43 UTC · original
mauroalvare:fix/victory-wave64-lds-limit → main · +150 −3 · 3 files · 4 commits · open

Vice-Tay

On a 32-lane host, Vice-Tay now reuses one group-shared dword for the thread-numbering prologue when the shader declares the full 32 KiB. The prologue finishes using it before the emulated shader's LDS accesses. If cross-half exchange needs more group-shared memory than D3D12 supports, lowering reports the limit explicitly.

The NVIDIA test exercised a split wave that reads across halves at the limit. A second regression covers a shader whose exchange storage exceeds the limit.

Earlier Neptune description

Change

In VIctory's RDNA2-to-DXIL translator (third_party/victory/crates/victory-shader/src/emit/lower.rs), the non-paired wave64-on-wave32 compute lowering (used on 32-lane hosts such as NVIDIA GPUs) could push thread-group shared memory (TGSM) past D3D12's hard 32 KiB (8,192 dwords) limit:

  1. halves (wave_base's LDS counter) unconditionally appended 1 dword (s.lds_dwords += 1), turning a 32 KiB console shader into 32,772 bytes (8,193 dwords), rejected by dxil.dll and D3D12 CreateComputePipelineState. The paired form already reuses slot 0 when s.lds_dwords == 8192 because wave_base() emits a post-counter group_sync whenever slot < cs.lds_bytes() / 4; the non-paired path now does the same.
  2. exchange unconditionally added 2 * group.div_ceil(64) dwords even when s.lds_dwords was already at or near 8,192 (and even when group <= 32 or LOCAL_WAVES, where exchange_halves never touches LDS). Because emit_forms still returned Ok((_, Some(32))) with invalid >32 KiB DXIL, emit_any never fell back to the paired form (which needs zero exchange dwords and fits in 32 KiB). Checking s.lds_dwords + exchange_dwords <= 8192 keeps wave = 64 when exchange does not fit, letting emit_any fall back to the valid paired form.

Linked issue: Refs #213

Verification

Base SHA: c4c93bdc413191a9dc909998d2d53080a3f0c880 (LooperSalty/AnyXboxX:main)
Hardware: Windows 11, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver 621.40), dxil.dll 10.0.26100.0, Rust 1.98.1 (MSVC).

Before the fix (both new tests failing on base c4c93bd):

cargo test --locked -p victory-shader wave64_full_32kib_lds -- --test-threads=1 --nocapture
-> FAILED: DXIL validation failed: "error: Total Thread Group Shared Memory storage is 32772, exceeded 32768."
-> FAILED: expected fallback to paired form when exchange overflows 32 KiB LDS (emitted 32,788-byte TGSM)

After the fix (from third_party/victory):

cargo test --locked -p victory-shader wave64_full_32kib_lds -- --test-threads=1 --nocapture
-> test result: ok. 2 passed; 0 failed; 0 ignored (both validated by dxil.dll and executed on RTX 5070 Ti)
cargo test --locked -p victory-shader -- --test-threads=1
-> test result: ok. 244 passed; 0 failed; 2 ignored
cargo check --locked -p victory
-> Finished `dev` profile (no new warnings)
cargo xtask policy
-> asset policy: 199 files ok

Oracle and test data

Both new regression tests in third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs synthesize minimal GFX10 wave64 compute shaders with 32 KiB (32,768 bytes) of LDS:

  • wave64_full_32kib_lds_without_exchange_fits_on_32_lane_host: 64 threads writing 3*t + 1 to LDS[4*t] (including LDS[0]) and reading mirror lane 63 - t across halves; validated with dxil.dll and checked dword-for-dword on RTX 5070 Ti.
  • wave64_full_32kib_lds_with_exchange_falls_back_to_paired_on_32_lane_host: 128 threads writing 5*t + 7 to LDS[4*t], reading t ^ 32, and computing s_bcnt1_i32_b64 + v_mbcnt_lo/hi; verifies fallback to paired form, dxil.dll validation, and all 512 output dwords on RTX 5070 Ti.

No game, console, or SDK files were used.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: unchanged (not applicable).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none (synthetic tests only).
  • Code taken from another project: none.

AI assistance: investigated, implemented, tested on RTX 5070 Ti, and drafted with Antigravity (Gemini).

**@⁠mauroalvare** on GitHub · 2026-11-26 01:43 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/295) `mauroalvare:fix/victory-wave64-lds-limit` → `main` · +150 −3 · 3 files · 4 commits · open ## Vice-Tay On a 32-lane host, Vice-Tay now reuses one group-shared dword for the thread-numbering prologue when the shader declares the full 32 KiB. The prologue finishes using it before the emulated shader's LDS accesses. If cross-half exchange needs more group-shared memory than D3D12 supports, lowering reports the limit explicitly. The NVIDIA test exercised a split wave that reads across halves at the limit. A second regression covers a shader whose exchange storage exceeds the limit. <details> <summary>Earlier Neptune description</summary> ## Change In VIctory's RDNA2-to-DXIL translator (`third_party/victory/crates/victory-shader/src/emit/lower.rs`), the non-paired wave64-on-wave32 compute lowering (used on 32-lane hosts such as NVIDIA GPUs) could push thread-group shared memory (TGSM) past D3D12's hard 32 KiB (8,192 dwords) limit: 1. `halves` (`wave_base`'s LDS counter) unconditionally appended 1 dword (`s.lds_dwords += 1`), turning a 32 KiB console shader into 32,772 bytes (`8,193` dwords), rejected by `dxil.dll` and D3D12 `CreateComputePipelineState`. The paired form already reuses slot 0 when `s.lds_dwords == 8192` because `wave_base()` emits a post-counter `group_sync` whenever `slot < cs.lds_bytes() / 4`; the non-paired path now does the same. 2. `exchange` unconditionally added `2 * group.div_ceil(64)` dwords even when `s.lds_dwords` was already at or near 8,192 (and even when `group <= 32` or `LOCAL_WAVES`, where `exchange_halves` never touches LDS). Because `emit_forms` still returned `Ok((_, Some(32)))` with invalid >32 KiB DXIL, `emit_any` never fell back to the paired form (which needs zero exchange dwords and fits in 32 KiB). Checking `s.lds_dwords + exchange_dwords <= 8192` keeps `wave = 64` when `exchange` does not fit, letting `emit_any` fall back to the valid paired form. Linked issue: Refs #213 ## Verification Base SHA: `c4c93bdc413191a9dc909998d2d53080a3f0c880` (`LooperSalty/AnyXboxX:main`) Hardware: Windows 11, Ryzen 7 9700X, NVIDIA GeForce RTX 5070 Ti (driver `621.40`), `dxil.dll` `10.0.26100.0`, Rust `1.98.1` (MSVC). Before the fix (both new tests failing on base `c4c93bd`): ``` cargo test --locked -p victory-shader wave64_full_32kib_lds -- --test-threads=1 --nocapture -> FAILED: DXIL validation failed: "error: Total Thread Group Shared Memory storage is 32772, exceeded 32768." -> FAILED: expected fallback to paired form when exchange overflows 32 KiB LDS (emitted 32,788-byte TGSM) ``` After the fix (from `third_party/victory`): ``` cargo test --locked -p victory-shader wave64_full_32kib_lds -- --test-threads=1 --nocapture -> test result: ok. 2 passed; 0 failed; 0 ignored (both validated by dxil.dll and executed on RTX 5070 Ti) cargo test --locked -p victory-shader -- --test-threads=1 -> test result: ok. 244 passed; 0 failed; 2 ignored cargo check --locked -p victory -> Finished `dev` profile (no new warnings) cargo xtask policy -> asset policy: 199 files ok ``` ## Oracle and test data Both new regression tests in `third_party/victory/crates/victory-shader/src/emit/wave64_tests.rs` synthesize minimal GFX10 wave64 compute shaders with 32 KiB (32,768 bytes) of LDS: - `wave64_full_32kib_lds_without_exchange_fits_on_32_lane_host`: 64 threads writing `3*t + 1` to `LDS[4*t]` (including `LDS[0]`) and reading mirror lane `63 - t` across halves; validated with `dxil.dll` and checked dword-for-dword on RTX 5070 Ti. - `wave64_full_32kib_lds_with_exchange_falls_back_to_paired_on_32_lane_host`: 128 threads writing `5*t + 7` to `LDS[4*t]`, reading `t ^ 32`, and computing `s_bcnt1_i32_b64` + `v_mbcnt_lo/hi`; verifies fallback to paired form, `dxil.dll` validation, and all 512 output dwords on RTX 5070 Ti. No game, console, or SDK files were used. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: unchanged (not applicable). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none (synthetic tests only). - [x] Code taken from another project: none. *AI assistance: investigated, implemented, tested on RTX 5070 Ti, and drafted with Antigravity (Gemini).* </details>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:42:15 +00:00
github-bot force-pushed github-bot/gh-295 from 174f85c99a to 9134d56626 2026-11-26 20:25:03 +00:00 Compare
github-bot changed title from fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts to test(victory-shader): cover the full LDS budget on 32-lane hosts 2026-11-26 20:33:49 +00:00
github-bot changed title from test(victory-shader): cover the full LDS budget on 32-lane hosts to fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts 2026-11-27 00:37:17 +00:00
github-bot force-pushed github-bot/gh-295 from 9134d56626 to a45726872b 2026-11-27 00:37:18 +00:00 Compare
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/295/head:github-bot/gh-295'
git switch 'github-bot/gh-295'

Merge

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