Skip to content

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

Open
Xvania7 wants to merge 3 commits into
Marvisak:mainfrom
Xvania7:feat/issue-817-wave-lane-check
Open

Xvania7 wants to merge 3 commits into
Marvisak:mainfrom
Xvania7:feat/issue-817-wave-lane-check

Conversation

@Xvania7

@Xvania7 Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown

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.

@Dathinel

Dathinel commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

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.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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.

RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
…2194)

From Marvisak/VIctory#2194 (GPL-3.0-or-later, Xvania7). Most of that PR is
already in our tree from our own wave work (#2157: psv_wave_range,
wave_lane_mismatch, the CLI's root-signature/wave-lane buckets), so only the
pipeline pre-check is new:

- Host::wave_lanes now reports both bounds (min, max); unknown is (0, 0).
- HostPipeline::new refuses a compute shader whose declared fixed wave range
  does not overlap the host's, with the counts in the reason, instead of
  letting CreateComputePipelineState fail with a bare E_INVALIDARG. An
  unread host range refuses nothing.
- refuse() takes the dynamic reason and dedupes owned strings.

Not taken: the PR's shader-side max_wave_lanes check (ours checks the PSV0
range in check_wave_lanes already) and its ignored two-fixture test.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@giacbiologicbomb

Copy link
Copy Markdown

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.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

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.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

@DrDarkDK

Copy link
Copy Markdown

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.

@Xvania7

Xvania7 commented Nov 25, 2026

Copy link
Copy Markdown
Author

@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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NVIDIA (32-lane): 103 compute pipelines refused at CreateComputeShader, reason only visible with VICTORY_D3D12_DEBUG=1

8 participants