shader: support 32-lane host wave execution for console wave64 comput… #3301

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

@⁠AdvaitPalve11 on GitHub · 2026-11-26 16:25 UTC · original
AdvaitPalve11:feat/shader-wave32-compatibility → main · +5 −5 · 4 files · 1 commits · open

…e shaders

Xbox Series X|S consoles (AMD RDNA 2) frequently run compute shaders in Wave64 mode (wave64: true). In the host DXIL container emission:

  • container::psv set MinimumWaveLaneCount and MaximumWaveLaneCount strictly to (64, 64).
  • Shader::finish emitted DXIL entry-point tag 11 (kDxilWaveSizeTag) with 64.

On PC hardware with 32-lane execution units (NVIDIA GeForce RTX 20/30/40/50 series and Intel Arc), D3D12 CreateComputePipelineState unconditionally rejects pipelines requiring WaveSize(64) with 0x80070057 (E_INVALIDARG) because WaveLaneCountMax is 32.

Fix this by:

  1. Setting PSV0 runtime info MinimumWaveLaneCount to 32.min(wave_size) and MaximumWaveLaneCount to wave_size, exposing the [32, 64] range to D3D12 runtime validators.
  2. Clamping tag 11 entry-point wave size metadata to 32.min(n) so 32-lane hardware adapters accept compute PSOs while preserving valid lane sizing.
  3. Clamping wave stride to 32.min(wave_size) when reconstructing flat thread IDs in lower::thread_id, ensuring consecutive 32-lane host warps (e.g. lanes 32..63 in warp 1) receive non-overlapping, contiguous thread IDs (base & !31) + lane.
  4. Updating synthetic test annotations for WaveSize(64) execution on hardware devices.
**@⁠AdvaitPalve11** on GitHub · 2026-11-26 16:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3301) `AdvaitPalve11:feat/shader-wave32-compatibility` → `main` · +5 −5 · 4 files · 1 commits · open …e shaders Xbox Series X|S consoles (AMD RDNA 2) frequently run compute shaders in Wave64 mode (wave64: true). In the host DXIL container emission: - container::psv set MinimumWaveLaneCount and MaximumWaveLaneCount strictly to (64, 64). - Shader::finish emitted DXIL entry-point tag 11 (kDxilWaveSizeTag) with 64. On PC hardware with 32-lane execution units (NVIDIA GeForce RTX 20/30/40/50 series and Intel Arc), D3D12 CreateComputePipelineState unconditionally rejects pipelines requiring WaveSize(64) with 0x80070057 (E_INVALIDARG) because WaveLaneCountMax is 32. Fix this by: 1. Setting PSV0 runtime info MinimumWaveLaneCount to 32.min(wave_size) and MaximumWaveLaneCount to wave_size, exposing the [32, 64] range to D3D12 runtime validators. 2. Clamping tag 11 entry-point wave size metadata to 32.min(n) so 32-lane hardware adapters accept compute PSOs while preserving valid lane sizing. 3. Clamping wave stride to 32.min(wave_size) when reconstructing flat thread IDs in lower::thread_id, ensuring consecutive 32-lane host warps (e.g. lanes 32..63 in warp 1) receive non-overlapping, contiguous thread IDs (base & !31) + lane. 4. Updating synthetic test annotations for WaveSize(64) execution on hardware devices.
Xbox Series X|S consoles (AMD RDNA 2) frequently run compute shaders in
Wave64 mode (wave64: true). In the host DXIL container emission:
- container::psv set MinimumWaveLaneCount and MaximumWaveLaneCount
  strictly to (64, 64).
- Shader::finish emitted DXIL entry-point tag 11 (kDxilWaveSizeTag)
  with 64.

On PC hardware with 32-lane execution units (NVIDIA GeForce RTX 20/30/40/50
series and Intel Arc), D3D12 CreateComputePipelineState unconditionally
rejects pipelines requiring WaveSize(64) with 0x80070057 (E_INVALIDARG)
because WaveLaneCountMax is 32.

Fix this by:
1. Setting PSV0 runtime info MinimumWaveLaneCount to 32.min(wave_size)
   and MaximumWaveLaneCount to wave_size, exposing the [32, 64] range
   to D3D12 runtime validators.
2. Clamping tag 11 entry-point wave size metadata to 32.min(n) so 32-lane
   hardware adapters accept compute PSOs while preserving valid lane sizing.
3. Clamping wave stride to 32.min(wave_size) when reconstructing flat
   thread IDs in lower::thread_id, ensuring consecutive 32-lane host
   warps (e.g. lanes 32..63 in warp 1) receive non-overlapping, contiguous
   thread IDs (base & !31) + lane.
4. Updating synthetic test annotations for WaveSize(64) execution on
   hardware devices.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 16:27:51 +00:00
Author
Owner

@⁠AurumCarlos on GitHub · 2026-11-26 16:57 UTC · original · reviewed

This makes the pipelines get created, but I don't think the shaders stay correct.

  • The lowering still assumes 64 host lanes per console wave. Programs with wave_size = 64 are lowered with console-lane semantics (console_lanes: 64-lane EXEC/VCC masks, ballots and cross-lane reads, and thread_id built from waveReadLaneFirst + lane index). Declaring WaveSize(32) lets the driver split each console wave into two independent host waves, so every cross-lane op sees only half the wave, silently. That's why 64-lane programs are refused on 32-lane hosts today, and why the wave64-on-32 work (#3179, #189/#192, issue #2688) pairs or widens waves instead. Clamping thread_id's stride hides the symptom in one place but not in the masks.
  • It also changes AMD. Tag 11 is now 32 for every wave64 program, so RDNA hosts that ran them natively at 64 lanes would run them split too.
  • PSV and the entry tag disagree: PSV says [32, 64] while tag 11 says exactly 32. The test only got a comment change, so nothing checks a wave64 program's results on a 32-lane adapter.
**@⁠AurumCarlos** on GitHub · 2026-11-26 16:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/3301#pullrequestreview-6077934024) · **reviewed** This makes the pipelines get created, but I don't think the shaders stay correct. - **The lowering still assumes 64 host lanes per console wave.** Programs with `wave_size = 64` are lowered with console-lane semantics (`console_lanes`: 64-lane EXEC/VCC masks, ballots and cross-lane reads, and `thread_id` built from `waveReadLaneFirst` + lane index). Declaring `WaveSize(32)` lets the driver split each console wave into two independent host waves, so every cross-lane op sees only half the wave, silently. That's why 64-lane programs are refused on 32-lane hosts today, and why the wave64-on-32 work (#3179, #189/#192, issue #2688) pairs or widens waves instead. Clamping `thread_id`'s stride hides the symptom in one place but not in the masks. - **It also changes AMD.** Tag 11 is now 32 for every wave64 program, so RDNA hosts that ran them natively at 64 lanes would run them split too. - **PSV and the entry tag disagree**: PSV says `[32, 64]` while tag 11 says exactly 32. The test only got a comment change, so nothing checks a wave64 program's results on a 32-lane adapter.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 17:30 UTC · original · reviewed

Ran local verification on Windows 11 x64 (RTX 5090 + dxil.dll validator):

  • cargo test -p victory-shader --lib emit::synthetic_tests:: -- --test-threads=1 --skip gathers_at_a_level_match_the_hardware: 8 passed, 2 failed — both Wave64 permute tests fail DXIL validation:
    • emit::synthetic_tests::wave64_permutes_check_exec_within_each_half
    • emit::synthetic_tests::wave64_permutes_stay_within_each_32_lane_half
    • Exact error: DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part (WaveSize=32) and DXIL module (MinimumExpectedWaveLaneCount: 32, MaximumExpectedWaveLaneCount: 64) — container.rs writes (min=32, max=64) into PSV0 while shader.rs writes single-value WaveSize(32) into DXIL metadata (note: wave-size ranges [WaveSize(min, max)] require SM 6.8 dx.entryPoints tag 23, not SM 6.6 tag 11).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 17:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3301#pullrequestreview-6078395538) · **reviewed** Ran local verification on Windows 11 x64 (RTX 5090 + `dxil.dll` validator): - `cargo test -p victory-shader --lib emit::synthetic_tests:: -- --test-threads=1 --skip gathers_at_a_level_match_the_hardware`: **8 passed, 2 failed** — both Wave64 permute tests fail DXIL validation: - `emit::synthetic_tests::wave64_permutes_check_exec_within_each_half` - `emit::synthetic_tests::wave64_permutes_stay_within_each_32_lane_half` - Exact error: `DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part (WaveSize=32) and DXIL module (MinimumExpectedWaveLaneCount: 32, MaximumExpectedWaveLaneCount: 64)` — `container.rs` writes `(min=32, max=64)` into `PSV0` while `shader.rs` writes single-value `WaveSize(32)` into DXIL metadata (note: wave-size ranges `[WaveSize(min, max)]` require SM 6.8 `dx.entryPoints` tag 23, not SM 6.6 tag 11). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 18:00 UTC · original

I tested exact fbbca42 and 63bcca43 with a synthetic console Wave64 shader that broadcasts the thread ID from lane 8 and lane 40. Each dispatch stores a result for all 64 threads. Verified app-local Agility 1.620.2/WARP 1.0.22 and dxil.dll 1.9.2609.5, three fresh runs per revision.

  • 63bcca43: 64/64 correct for each lane in all three runs.
  • Exact PR head: the validator rejects the container before pipeline creation. The single-value wave-size tag requests 32 while the PSV range is 32–64. It reports a PSVRuntimeInfo mismatch in all three runs. Microsoft SM 6.6 wave-size metadata
  • Diagnostic control only, with both PSV limits set to the same 32 as the tag: validation and execution succeed, but each case returns only 32/64 correct. The guest lane-8 read is the direct control: the first half broadcasts 8 and the second half broadcasts 40. Lane 8 is a valid index in both physical waves.

The opt-in regression 96c7b78 is the test alone on this PR. The metadata-only control is local. To preserve guest Wave64 behavior on a Wave32 device, the lowering needs to share values across the two halves or decline the shaders that require that exchange. #1890 contains a related split-wave path and independent Wave32 hardware evidence. Strict shader Clippy and policy passed for the regression code.

Please retain the test's Git author if you reuse it, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding it into another commit. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 18:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/3301#issuecomment-7199953250) I tested exact `fbbca42` and `63bcca43` with a synthetic console Wave64 shader that broadcasts the thread ID from lane 8 and lane 40. Each dispatch stores a result for all 64 threads. Verified app-local Agility 1.620.2/WARP 1.0.22 and `dxil.dll` 1.9.2609.5, three fresh runs per revision. - `63bcca43`: 64/64 correct for each lane in all three runs. - Exact PR head: the validator rejects the container before pipeline creation. The single-value wave-size tag requests 32 while the PSV range is 32–64. It reports a `PSVRuntimeInfo` mismatch in all three runs. [Microsoft SM 6.6 wave-size metadata](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_WaveSize.html#dxil-metadata) - Diagnostic control only, with both PSV limits set to the same 32 as the tag: validation and execution succeed, but each case returns only 32/64 correct. The guest lane-8 read is the direct control: the first half broadcasts 8 and the second half broadcasts 40. Lane 8 is a valid index in both physical waves. The [opt-in regression `96c7b78`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/96c7b7887165d71526490d2716530212dc9c363a) is the test alone on this PR. The metadata-only control is local. To preserve guest Wave64 behavior on a Wave32 device, the lowering needs to share values across the two halves or decline the shaders that require that exchange. #1890 contains a related split-wave path and independent Wave32 hardware evidence. Strict shader Clippy and policy passed for the regression code. Please retain the test's Git author if you reuse it, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
Author
Owner

@⁠zed6000 on GitHub · 2026-11-26 19:35 UTC · original

The same mismatch shows up on the title's own shaders. Census of the whole shaders.rpf (victory translate --validate --list, the Windows SDK 10.0.26100 dxil.dll), this PR merged onto main 63bcca4, compared program by program:

  • 383 compute programs that validate on main fail on this PR, all with DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part. No program goes the other way.
  • These are the programs lower.rs gives a WaveSize because they depend on the console's lane layout (console_lanes), or because they are one wave with LDS. So a 32-lane host wave would also change their results, as the 32-of-64 control above shows.

AMD RDNA hosts run 64-lane waves, so there the clamp only removes programs that main already handles.

The repository's own tests on an RX 7900 XTX (driver 32.0.32029.2010): cargo test -p victory-shader --lib on this PR merged onto main gives 299 passed, 3 failed. The failures are ds_bpermute_wave64_preserves_32_lane_half, wave64_permutes_check_exec_within_each_half and wave64_permutes_stay_within_each_32_lane_half, each with the same PSVRuntimeInfo mismatch (WaveSize=32 against an expected lane count of 32 to 64). On main (with only #2936 merged, which does not touch this code) all 302 pass.

**@⁠zed6000** on GitHub · 2026-11-26 19:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/3301#issuecomment-7201754959) The same mismatch shows up on the title's own shaders. Census of the whole `shaders.rpf` (`victory translate --validate --list`, the Windows SDK 10.0.26100 `dxil.dll`), this PR merged onto `main` `63bcca4`, compared program by program: - 383 compute programs that validate on `main` fail on this PR, all with `DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part`. No program goes the other way. - These are the programs `lower.rs` gives a `WaveSize` because they depend on the console's lane layout (`console_lanes`), or because they are one wave with LDS. So a 32-lane host wave would also change their results, as the 32-of-64 control above shows. AMD RDNA hosts run 64-lane waves, so there the clamp only removes programs that `main` already handles. The repository's own tests on an RX 7900 XTX (driver 32.0.32029.2010): `cargo test -p victory-shader --lib` on this PR merged onto `main` gives 299 passed, 3 failed. The failures are `ds_bpermute_wave64_preserves_32_lane_half`, `wave64_permutes_check_exec_within_each_half` and `wave64_permutes_stay_within_each_32_lane_half`, each with the same `PSVRuntimeInfo` mismatch (`WaveSize=32` against an expected lane count of 32 to 64). On `main` (with only #2936 merged, which does not touch this code) all 302 pass.
This pull request can be merged automatically.
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/3301/head:github-bot/gh-3301'
git switch 'github-bot/gh-3301'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3301'
git switch 'github-bot/gh-3301'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3301'
git switch 'github-bot/gh-3301'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3301'
git switch 'main'
git merge --squash 'github-bot/gh-3301'
git switch 'main'
git merge --ff-only 'github-bot/gh-3301'
git switch 'main'
git merge 'github-bot/gh-3301'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3301
No description provided.