Skip to content

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

Open
mauroalvare wants to merge 4 commits into
LooperSalty:mainfrom
mauroalvare:fix/victory-wave64-lds-limit
Open

mauroalvare wants to merge 4 commits into
LooperSalty:mainfrom
mauroalvare:fix/victory-wave64-lds-limit

Conversation

@mauroalvare

@mauroalvare mauroalvare commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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
mauroalvare force-pushed the fix/victory-wave64-lds-limit branch from 174f85c to 9134d56 Compare November 26, 2026 20:23
@mauroalvare mauroalvare changed the title fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts test(victory-shader): cover the full LDS budget on 32-lane hosts Nov 26, 2026
@mauroalvare
mauroalvare force-pushed the fix/victory-wave64-lds-limit branch from 9134d56 to f1d5787 Compare November 26, 2026 22:47
@mauroalvare mauroalvare changed the title test(victory-shader): cover the full LDS budget on 32-lane hosts fix(victory-shader): keep wave64-on-wave32 TGSM within 32 KiB on 32-lane hosts Nov 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant