fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts #295
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/295"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-26T01:43:40Z.
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: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,193dwords), rejected bydxil.dlland D3D12CreateComputePipelineState. The paired form already reuses slot 0 whens.lds_dwords == 8192becausewave_base()emits a post-countergroup_syncwheneverslot < cs.lds_bytes() / 4; the non-paired path now does the same.exchangeunconditionally added2 * group.div_ceil(64)dwords even whens.lds_dwordswas already at or near 8,192 (and even whengroup <= 32orLOCAL_WAVES, whereexchange_halvesnever touches LDS). Becauseemit_formsstill returnedOk((_, Some(32)))with invalid >32 KiB DXIL,emit_anynever fell back to the paired form (which needs zero exchange dwords and fits in 32 KiB). Checkings.lds_dwords + exchange_dwords <= 8192keepswave = 64whenexchangedoes not fit, lettingemit_anyfall 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.dll10.0.26100.0, Rust1.98.1(MSVC).Before the fix (both new tests failing on base
c4c93bd):After the fix (from
third_party/victory):Oracle and test data
Both new regression tests in
third_party/victory/crates/victory-shader/src/emit/wave64_tests.rssynthesize 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 writing3*t + 1toLDS[4*t](includingLDS[0]) and reading mirror lane63 - tacross halves; validated withdxil.dlland checked dword-for-dword on RTX 5070 Ti.wave64_full_32kib_lds_with_exchange_falls_back_to_paired_on_32_lane_host: 128 threads writing5*t + 7toLDS[4*t], readingt ^ 32, and computings_bcnt1_i32_b64+v_mbcnt_lo/hi; verifies fallback to paired form,dxil.dllvalidation, and all 512 output dwords on RTX 5070 Ti.No game, console, or SDK files were used.
Checklist
E_NOTIMPL), never a fake success.AI assistance: investigated, implemented, tested on RTX 5070 Ti, and drafted with Antigravity (Gemini).
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T13:03:12Z.
Rebase on current main (
fa6b209e) is needed: recent merges into main now conflict with this PR. Please rebase and push so the PR can be reviewed again.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:01:58Z.
Updated this PR to
a4453083. The LDS-limit tests now coexist with #317's first-lane coverage. The targeted shader suite passed, including the 32 KiB case and the explicit overflow error.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T17:31:08Z.
One question: does this change the translation of any wave64 shader that translated before (rather than only turning an earlier failure into a fitting layout or an explicit error)? If so,
TRANSLATOR_VERSION(victory-shader/src/lib.rs) needs a bump so older caches are not reused; #456 uses 3, #485 4, #306 asks for 5.Imported from LooperSalty/AnyXboxX. Originally posted by mauroalvare on 2026-11-27T17:57:25Z.
Good catch — checked
shader_cache.rs, andcache.get_or_convertcaches the output ofvictory_shader::translate()before D3D12 PSO creation. For shaders withlds_dwords < 8192the emitted DXIL is unchanged, but a wave64 compute shader right at the 32 KiB LDS limit previously returnedOk(dxil)with an invalid> 32 KiBTGSM allocation and got written to disk cache, whereas with this PR it now either borrowsLDS[0]to fit in 32 KiB or returnsErr(ShaderError::Unsupported).Bumped
TRANSLATOR_VERSIONto8in717f7fb(leaving3for #456,4for #485,5for #306,6for #321,7for #327; happy to re-bump on rebase if another lands first). Re-verifiedwave64_thread_ticket_fits_at_the_d3d12_lds_limit,wave64_exchange_reports_an_lds_overflow, andcargo xtask policy(286 files ok).