GPU: Pre-check wave lane constraints for compute pipelines (fixes #817) #2194

Open
github-bot wants to merge 3 commits from github-bot/gh-2194 into main AGit
Owner

@⁠Xvania7 on GitHub · 2026-11-25 07:21 UTC · original
Xvania7:feat/issue-817-wave-lane-check → main · +218 −5 · 5 files · 3 commits · open

Fixes #817 (supersedes tracking issue #893; related to #468).

Summary

  • Device capability query (crates/victory-gpu/src/device.rs, host.rs): Queries D3D12_FEATURE_DATA_D3D12_OPTIONS1 (WaveLaneCountMin, WaveLaneCountMax).
  • DXIL wave constraint check (crates/victory-shader/src/emit/mod.rs): Reads declared WaveSize from PSV0 via HostShader::required_wave_size().
  • Pre-check (crates/victory-gpu/src/pipeline/host.rs): Checks !(min..=max).contains(&req) via unsupported_compute_wave before CreateComputePipelineState and distinguishes root-signature vs PSO refusal stages in offline ranslate --pipelines (incorporating follow-up commits from @⁠fuzeofficlal and @⁠MichaelSmithAI).

Note: Opened as a PR per maintainer triage (#893); happy to coordinate with #1922 / #2157 if maintainers prefer one consolidated PR.

**@⁠Xvania7** on GitHub · 2026-11-25 07:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194) `Xvania7:feat/issue-817-wave-lane-check` → `main` · +218 −5 · 5 files · 3 commits · open Fixes #817 (supersedes tracking issue #893; related to #468). ### Summary - **Device capability query (crates/victory-gpu/src/device.rs, host.rs):** Queries D3D12_FEATURE_DATA_D3D12_OPTIONS1 (WaveLaneCountMin, WaveLaneCountMax). - **DXIL wave constraint check (crates/victory-shader/src/emit/mod.rs):** Reads declared WaveSize from PSV0 via HostShader::required_wave_size(). - **Pre-check (crates/victory-gpu/src/pipeline/host.rs):** Checks !(min..=max).contains(&req) via unsupported_compute_wave before CreateComputePipelineState and distinguishes root-signature vs PSO refusal stages in offline ranslate --pipelines (incorporating follow-up commits from @⁠fuzeofficlal and @⁠MichaelSmithAI). Note: Opened as a PR per maintainer triage (#893); happy to coordinate with #1922 / #2157 if maintainers prefer one consolidated PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:03 +00:00
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 07:47 UTC · original · edited 2026-11-25 07:52 UTC

For the consolidation question: I combined #1922 (24a7bc2, runtime) and #2157 (9771cae, offline CLI) on Windows. The merge includes main 940d32f and needs no manual resolution (tree 884f866b). Seven targeted tests passed: three GPU runtime checks, two shader diagnostic checks, and two CLI checks, including the WARP pipeline test that distinguishes root-signature errors from wave-size refusals.

One behavior worth preserving when deciding between implementations: #1922 explicitly tests the unsized console-wave64 fallback on a host with fewer than 64 lanes. Testing the fixed wave size alone would miss that distinction.

Update for 754fe02: the rebase resolved the four conflicts against main@940d32f. I compared both parsers and pre-check functions using the same synthetic PSV0 metadata (guest Wave64 compute, simulated 32-lane-only host). Both rejected fixed 64 and allowed fixed 32. The current PSV0 writer emits either a fixed size or the unrestricted pair (0, UINT32_MAX). For the unrestricted pair with a Wave64 guest on this host, #1922 rejected early and #2194 deferred to pipeline creation. A separate synthetic 64–128 interval also distinguished the parsers, but that interval does not come from this writer. These are pre-check results; driver behavior was not measured.

AI-assisted; synthetic tests only.

**@⁠Dathinel** on GitHub · 2026-11-25 07:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7156254331) · edited 2026-11-25 07:52 UTC For the consolidation question: I combined #1922 (`24a7bc2`, runtime) and #2157 (`9771cae`, offline CLI) on Windows. The merge includes main `940d32f` and needs no manual resolution (tree `884f866b`). Seven targeted tests passed: three GPU runtime checks, two shader diagnostic checks, and two CLI checks, including the WARP pipeline test that distinguishes root-signature errors from wave-size refusals. One behavior worth preserving when deciding between implementations: #1922 explicitly tests the unsized console-wave64 fallback on a host with fewer than 64 lanes. Testing the fixed wave size alone would miss that distinction. Update for `754fe02`: the rebase resolved the four conflicts against `main@940d32f`. I compared both parsers and pre-check functions using the same synthetic PSV0 metadata (guest Wave64 compute, simulated 32-lane-only host). Both rejected fixed 64 and allowed fixed 32. The current PSV0 writer emits either a fixed size or the unrestricted pair (0, UINT32_MAX). For the unrestricted pair with a Wave64 guest on this host, #1922 rejected early and #2194 deferred to pipeline creation. A separate synthetic 64–128 interval also distinguished the parsers, but that interval does not come from this writer. These are pre-check results; driver behavior was not measured. AI-assisted; synthetic tests only.
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 07:56 UTC · original

Thanks for the comparison data, @⁠Dathinel.

Two quick updates on the branch state:

  1. Rebase conflicts resolved: The conflicts you saw at 9d4b8d7 were before the rebase onto main (940d32f). Current head 754fe02 is cleanly rebased onto 940d32f with mergeable_state = clean and green CI, and @MichaelSmithAI also verified 754fe02 on an RTX 4090 under Wine (wave32 pipeline created, wave64 returned the expected host-width diagnostic).
  2. Unsized vs fixed wave size: In HostShader::required_wave_size(), we only extract a fixed constraint (min != 0 && min == max from PSV0), so an unsized shader returns None and is allowed through unsupported_compute_wave(None, ...). Agreed that #1922's explicit test for the unsized console-wave64 fallback on hosts with < 64 lanes is a useful distinction to preserve regardless of which PR pair lands.
**@⁠Xvania7** on GitHub · 2026-11-25 07:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7156419958) Thanks for the comparison data, @⁠Dathinel. Two quick updates on the branch state: 1. **Rebase conflicts resolved:** The conflicts you saw at `9d4b8d7` were before the rebase onto `main` (`940d32f`). Current head `754fe02` is cleanly rebased onto `940d32f` with `mergeable_state = clean` and green CI, and `@MichaelSmithAI` also verified `754fe02` on an RTX 4090 under Wine (wave32 pipeline created, wave64 returned the expected host-width diagnostic). 2. **Unsized vs fixed wave size:** In `HostShader::required_wave_size()`, we only extract a fixed constraint (`min != 0 && min == max` from `PSV0`), so an unsized shader returns `None` and is allowed through `unsupported_compute_wave(None, ...)`. Agreed that `#1922`'s explicit test for the unsized console-wave64 fallback on hosts with `< 64` lanes is a useful distinction to preserve regardless of which PR pair lands.
Author
Owner

@⁠giacbiologicbomb on GitHub · 2026-11-25 11:03 UTC · original

Test data from an RTX 5070 (12 GB, NVIDIA, WaveLaneCountMax = 32), Windows, 16 GB RAM, on the vitutu1/victory-perf fork at 97c3aa2 (based on fxceless/victory-fork). Profile: --console series-s, VICTORY_RENDER_SCALE=0.5, VICTORY_OWN_UPSCALER=1, VICTORY_AMBIENT_STUB=1, VICTORY_SHADOWMASK_STUB=1, VICTORY_RELAY=2, VICTORY_LATE_WAIT=3, VICTORY_WIDE_BACK=1, VICTORY_REBAR=0, VICTORY_CARD_BUFFERS_MB=2048.

Four compute pipelines are refused in-game with E_INVALIDARG (0x80070057):

02384a60fda6f2d0  369cbe906ea72764  2cc4c197ee29e291  2da4beb386509b77

Analysed offline, without running the game: the translated DXIL for all four still carries WaveSize = 64 (dxc -dumpbin), which is incompatible with the reported maximum wave size; this is the leading explanation for the refusal. The split / local-wave retries all fall back to wave 64. The main reason given is LDS in a group over 32, with an LDS read and write inside one lane-branch region; three of the four also use v_mbcnt / v_readlane / a lane mask read as data.

I ported this PR's check onto that fork (local commit only). It builds in release mode and the targeted tests pass. The four pipelines are now refused before creation with that reason named, instead of the opaque 0x80070057. They still don't run: that needs split-wave lowering for LDS shared across more than 32 lanes.

The same class of refusals was observed on fxceless a26859f and skornuta/victory-fork 9292987. VICTORY_SHADER_LOOP_LIMIT=32 didn't change that.

Analysis done with Claude Opus 5.5 (claude-opus-5-5) agents; the in-game logs come from real runs.

**@⁠giacbiologicbomb** on GitHub · 2026-11-25 11:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7160524573) Test data from an RTX 5070 (12 GB, NVIDIA, `WaveLaneCountMax = 32`), Windows, 16 GB RAM, on the [vitutu1/victory-perf](https://github.com/vitutu1/victory-perf) fork at `97c3aa2` (based on fxceless/victory-fork). Profile: `--console series-s`, `VICTORY_RENDER_SCALE=0.5`, `VICTORY_OWN_UPSCALER=1`, `VICTORY_AMBIENT_STUB=1`, `VICTORY_SHADOWMASK_STUB=1`, `VICTORY_RELAY=2`, `VICTORY_LATE_WAIT=3`, `VICTORY_WIDE_BACK=1`, `VICTORY_REBAR=0`, `VICTORY_CARD_BUFFERS_MB=2048`. Four compute pipelines are refused in-game with `E_INVALIDARG (0x80070057)`: ``` 02384a60fda6f2d0 369cbe906ea72764 2cc4c197ee29e291 2da4beb386509b77 ``` Analysed offline, without running the game: the translated DXIL for all four still carries `WaveSize = 64` (`dxc -dumpbin`), which is incompatible with the reported maximum wave size; this is the leading explanation for the refusal. The split / local-wave retries all fall back to wave 64. The main reason given is *LDS in a group over 32, with an LDS read and write inside one lane-branch region*; three of the four also use `v_mbcnt` / `v_readlane` / a lane mask read as data. I ported this PR's check onto that fork (local commit only). It builds in release mode and the targeted tests pass. The four pipelines are now refused before creation with that reason named, instead of the opaque `0x80070057`. They still don't run: that needs split-wave lowering for LDS shared across more than 32 lanes. The same class of refusals was observed on fxceless `a26859f` and skornuta/victory-fork `9292987`. `VICTORY_SHADER_LOOP_LIMIT=32` didn't change that. Analysis done with Claude Opus 5.5 (claude-opus-5-5) agents; the in-game logs come from real runs.
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 11:40 UTC · original

Thanks for the detailed test data and hardware verification on RTX 5070 @⁠giacbiologic! This confirms the exact intent of #2194: catching the wave size mismatch cleanly before pipeline creation so we don't nuke the D3D12 device with an opaque 0x80070057, while diagnosing precisely why the fallback to wave 64 occurred (LDS across >32 lanes with branch regions / lane mask ops). Those 4 pipelines (␀2384a60fda6f2d0, 369cbe906ea72764, 2cc4c197ee29e291, 2da4beb386509b77) are great concrete test targets for subsequent split-wave LDS lowering work.

**@⁠Xvania7** on GitHub · 2026-11-25 11:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7161360635) Thanks for the detailed test data and hardware verification on RTX 5070 @⁠giacbiologic! This confirms the exact intent of #2194: catching the wave size mismatch cleanly before pipeline creation so we don't nuke the D3D12 device with an opaque `0x80070057`, while diagnosing precisely why the fallback to wave 64 occurred (LDS across >32 lanes with branch regions / lane mask ops). Those 4 pipelines (␀2384a60fda6f2d0, 369cbe906ea72764, 2cc4c197ee29e291, 2da4beb386509b77) are great concrete test targets for subsequent split-wave LDS lowering work.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:41 UTC · original · edited 2026-11-25 22:20 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-gpu/src/host.rs and crates/victory-shader/src/emit/host.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7162725682) · edited 2026-11-25 22:20 UTC <!-- victory-triage v1 head=754fe024f40a83dc8f224bc197bd0954f1603b66 verdict=needs-rebase at=2026-11-25T22:23:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-gpu/src/host.rs` and `crates/victory-shader/src/emit/host.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 13:34 UTC · original

Following up on the unsized-shader point in the triage summary, I ran a standalone native D3D12 probe on an RTX 4070 Ti with driver 621.01 and Windows build 26300.9974. D3D12 reported a wave lane range of 32–32.

I compiled the same lane-independent cs_6_6 shader with no WaveSize attribute, with WaveSize(32), and with WaveSize(64). With the same root signature, the unsized and fixed-wave32 variants both created a compute pipeline. Fixed wave64 returned E_INVALIDARG, and GetDeviceRemovedReason() returned S_OK afterward. Both runs produced the same results.

This supports letting unsized shaders reach pipeline creation. The probe used synthetic DXC shaders and covered pipeline creation only.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 13:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7163969047) Following up on the unsized-shader point in the triage summary, I ran a standalone native D3D12 probe on an RTX 4070 Ti with driver 621.01 and Windows build 26300.9974. D3D12 reported a wave lane range of 32–32. I compiled the same lane-independent `cs_6_6` shader with no `WaveSize` attribute, with `WaveSize(32)`, and with `WaveSize(64)`. With the same root signature, the unsized and fixed-wave32 variants both created a compute pipeline. Fixed wave64 returned `E_INVALIDARG`, and `GetDeviceRemovedReason()` returned `S_OK` afterward. Both runs produced the same results. This supports letting unsized shaders reach pipeline creation. The probe used synthetic DXC shaders and covered pipeline creation only. *AI-assisted with Codex.*
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-25 13:43 UTC · original

@⁠DrDarkDK Thanks for the native D3D12 probe on the RTX 4070 Ti (32-32 wave range).

That confirms the driver behavior: unsized shaders cleanly default to the native wave lane width (32) and succeed, whereas fixed wave64 fails with E_INVALIDARG without taking down the device. This aligns with keeping unsized shaders eligible for pipeline creation while refusing explicit 64-lane constraints on 32-lane hardware.

**@⁠Xvania7** on GitHub · 2026-11-25 13:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7164184986) @⁠DrDarkDK Thanks for the native D3D12 probe on the RTX 4070 Ti (32-32 wave range). That confirms the driver behavior: unsized shaders cleanly default to the native wave lane width (32) and succeed, whereas fixed wave64 fails with `E_INVALIDARG` without taking down the device. This aligns with keeping unsized shaders eligible for pipeline creation while refusing explicit 64-lane constraints on 32-lane hardware.
github-bot force-pushed github-bot/gh-2194 from 754fe024f4 to f8277a6cbe 2026-11-26 17:37:25 +00:00 Compare
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 08:10 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

145 passed / 0 failed / 2 ignored. Wave lane constraints pre-checked for compute pipelines (+1 test) — pre-validation of lane constraints; mixed gpu+shader.

**@⁠catminou4** on GitHub · 2026-11-25 08:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#pullrequestreview-6053923321) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored. Wave lane constraints pre-checked for compute pipelines (+1 test) — pre-validation of lane constraints; mixed gpu+shader.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 09:23 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib wave — 4 passed, 0 failed on RTX 5090 (including query_wave_lane_limits_reports_capabilities and wave_size_precheck_rejects_both_outside_bounds)
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean wave-lane capability query and compute pipeline wave-size pre-check (fixing #817). Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 09:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#pullrequestreview-6054874406) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib wave` — **4 passed, 0 failed** on RTX 5090 (including `query_wave_lane_limits_reports_capabilities` and `wave_size_precheck_rejects_both_outside_bounds`) - `cargo clippy -p victory-gpu -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean wave-lane capability query and compute pipeline wave-size pre-check (fixing #817). Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-26 17:35 UTC · original

Rebased cleanly onto origin/main (63bcca4) resolving the conflicts in crates/victory-gpu/src/host.rs and crates/victory-shader/src/emit/host.rs:

  • Integrated wave_lanes_from_device queries with the shared WARP device singleton and multi-threaded test harness (#181), preserving depth_bounds_supported and thread serialization.
  • Preserved both existing WARP draw tests and offline wave pre-check classification tests.
  • Verified targeted unit tests in victory-gpu and victory-shader (query_wave_lane_limits_reports_capabilities, wave_size_precheck_rejects_both_outside_bounds, wave_size_precheck_accepts_boundaries_or_unknown_constraints, required_wave_size_reads_the_emitted_constraint all ok).
  • Verified strict Clippy (cargo clippy -p victory-shader -p victory-gpu -- -D warnings) with 0 warnings.
  • cargo xtask policy clean (191 files ok).
**@⁠Xvania7** on GitHub · 2026-11-26 17:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7199273280) Rebased cleanly onto `origin/main` (`63bcca4`) resolving the conflicts in `crates/victory-gpu/src/host.rs` and `crates/victory-shader/src/emit/host.rs`: - Integrated `wave_lanes_from_device` queries with the shared WARP device singleton and multi-threaded test harness (`#181`), preserving `depth_bounds_supported` and thread serialization. - Preserved both existing WARP draw tests and offline wave pre-check classification tests. - Verified targeted unit tests in `victory-gpu` and `victory-shader` (`query_wave_lane_limits_reports_capabilities`, `wave_size_precheck_rejects_both_outside_bounds`, `wave_size_precheck_accepts_boundaries_or_unknown_constraints`, `required_wave_size_reads_the_emitted_constraint` all ok). - Verified strict Clippy (`cargo clippy -p victory-shader -p victory-gpu -- -D warnings`) with 0 warnings. - `cargo xtask policy` clean (191 files ok).
Author
Owner

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

I checked f8277a6 after the offline refusal-stage change. The live GPU pipeline precheck uses the advertised minimum and maximum, while the offline Host::compute_pipeline precheck checks only the maximum.

I exercised the offline entry point on verified app-local Agility 1.620.2/WARP 1.0.22. The real device reported 4–128 and created both fixed Wave32 and Wave64 PSOs. With a simulated advertised range of 64–64 on the same WARP device, the old maximum-only gate still creates Wave32. Follow-up b72e1a3 reports the wave constraint before PSO creation. Reciprocal Wave32-only controls and an unsized shader pass. The probe passed three fresh runs, both existing GPU precheck tests passed, and strict GPU/shader Clippy and policy passed. The single-width device ranges in this test are injected.

@⁠Xvania7 the patch is directly on your head if you want to take it. Please retain its Git author on cherry-pick, 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:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2194#issuecomment-7200205802) I checked `f8277a6` after the offline refusal-stage change. The live GPU pipeline precheck uses the advertised minimum and maximum, while the offline `Host::compute_pipeline` precheck checks only the maximum. I exercised the offline entry point on verified app-local Agility 1.620.2/WARP 1.0.22. The real device reported 4–128 and created both fixed Wave32 and Wave64 PSOs. With a simulated advertised range of 64–64 on the same WARP device, the old maximum-only gate still creates Wave32. [Follow-up `b72e1a3`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/b72e1a39ab6392dbac698fff66f5474fe1874ec7) reports the wave constraint before PSO creation. Reciprocal Wave32-only controls and an unsized shader pass. The probe passed three fresh runs, both existing GPU precheck tests passed, and strict GPU/shader Clippy and policy passed. The single-width device ranges in this test are injected. @⁠Xvania7 the patch is directly on your head if you want to take it. Please retain its Git author on cherry-pick, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding it into another commit. AI-assisted with Codex.
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/2194/head:github-bot/gh-2194'
git switch 'github-bot/gh-2194'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2194'
git switch 'github-bot/gh-2194'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2194'
git switch 'github-bot/gh-2194'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2194'
git switch 'main'
git merge --squash 'github-bot/gh-2194'
git switch 'main'
git merge --ff-only 'github-bot/gh-2194'
git switch 'main'
git merge 'github-bot/gh-2194'
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!2194
No description provided.