[Ready to merge] Pre-check wave lane constraints for compute pipelines #893

Open
opened 2026-11-26 04:14:07 +00:00 by github-bot · 4 comments
Owner

@⁠Xvania7 on GitHub · 2026-11-24 13:37 UTC · original

GPU: Pre-check wave lane constraints for compute pipelines

Fixes #817 (related to #468 / PRs #233, #189, #578).

Problem

Titles emitting 64-lane compute shaders cause pipeline creation to fail on host GPUs that only support up to 32 lanes (e.g. NVIDIA or Intel hardware reporting WaveLaneCountMax = 32). While logging the error inside CreateComputePipelineState failure paths (as explored in diagnostic branches) surfaces the issue, passing an incompatible bytecode directly to the D3D12 runtime triggers driver error queue noise and debug layer breaks.

Solution

Instead of failing late inside the driver, this PR adds an upfront capability check:

  1. Device Capability Query (crates/victory-gpu/src/device.rs, host.rs):

    • Queries D3D12_FEATURE_DATA_D3D12_OPTIONS1 at device creation via CheckFeatureSupport.
    • Stores host wave_lanes: Option<(u32, u32)> (WaveLaneCountMin, WaveLaneCountMax).
  2. Wave Size Extraction from DXIL (crates/victory-shader/src/emit/mod.rs):

    • Implements HostShader::required_wave_size(&self) -> Option<u32>.
    • Inspects the DXIL container's PSV0 runtime info part (bytes 20..28) to read the declared wave size constraint (WaveSize).
  3. Compute Pipeline Pre-check (crates/victory-gpu/src/pipeline/host.rs):

    • In HostPipeline::create(), if the compute shader specifies required_wave > max_wave_lanes, we emit an informative tracing::warn! and skip host pipeline creation cleanly (return None) without invoking CreateComputePipelineState.

Verification

  • Unit test required_wave_size_reads_the_emitted_constraint covering unconstrained, Wave32, and Wave64 shaders in victory-shader.
  • Unit test query_wave_lane_limits_reports_capabilities in victory-gpu.
  • cargo test -p victory-gpu (51 passed, 0 failed).
  • cargo clippy --all-targets -- -D warnings and cargo xtask policy pass cleanly.

Branch: feat/issue-817-wave-lane-check (commit 1318357).

**@⁠Xvania7** on GitHub · 2026-11-24 13:37 UTC · [original](https://github.com/Marvisak/VIctory/issues/893) ### GPU: Pre-check wave lane constraints for compute pipelines Fixes #817 (related to #468 / PRs #233, #189, #578). #### Problem Titles emitting 64-lane compute shaders cause pipeline creation to fail on host GPUs that only support up to 32 lanes (e.g. NVIDIA or Intel hardware reporting `WaveLaneCountMax = 32`). While logging the error inside `CreateComputePipelineState` failure paths (as explored in diagnostic branches) surfaces the issue, passing an incompatible bytecode directly to the D3D12 runtime triggers driver error queue noise and debug layer breaks. #### Solution Instead of failing late inside the driver, this PR adds an upfront capability check: 1. **Device Capability Query (`crates/victory-gpu/src/device.rs`, `host.rs`)**: - Queries `D3D12_FEATURE_DATA_D3D12_OPTIONS1` at device creation via `CheckFeatureSupport`. - Stores host `wave_lanes: Option<(u32, u32)>` (`WaveLaneCountMin`, `WaveLaneCountMax`). 2. **Wave Size Extraction from DXIL (`crates/victory-shader/src/emit/mod.rs`)**: - Implements `HostShader::required_wave_size(&self) -> Option<u32>`. - Inspects the DXIL container's `PSV0` runtime info part (bytes 20..28) to read the declared wave size constraint (`WaveSize`). 3. **Compute Pipeline Pre-check (`crates/victory-gpu/src/pipeline/host.rs`)**: - In `HostPipeline::create()`, if the compute shader specifies `required_wave > max_wave_lanes`, we emit an informative `tracing::warn!` and skip host pipeline creation cleanly (`return None`) without invoking `CreateComputePipelineState`. #### Verification - Unit test `required_wave_size_reads_the_emitted_constraint` covering unconstrained, Wave32, and Wave64 shaders in `victory-shader`. - Unit test `query_wave_lane_limits_reports_capabilities` in `victory-gpu`. - `cargo test -p victory-gpu` (51 passed, 0 failed). - `cargo clippy --all-targets -- -D warnings` and `cargo xtask policy` pass cleanly. Branch: [`feat/issue-817-wave-lane-check`](https://github.com/Xvania7/VIctory/tree/feat/issue-817-wave-lane-check) (commit `1318357`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:07 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 13:43 UTC · original

On the RTX 4090 under Wine/vkd3d-proton 3.2, the runtime reported a wave range of 32..32. Through the ordinary runtime host pipeline constructor on 1318357, a DXC shader declaring Wave32 created a pipeline and the otherwise identical Wave64 shader was declined. An instrumented run confirmed the Wave64 return after root-signature creation and before the compute PSO call. The result repeated with the original production code. This was a pipeline-creation check.

The offline CLI uses a different host helper. We submitted a follow-up on your branch for that path, with the same width-specific outcome and separate stage labels for root-signature and PSO failures. The two synthetic widths passed their offline checks; individual #885 corpus failures have yet to be classified.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 13:43 UTC · [original](https://github.com/Marvisak/VIctory/issues/893#issuecomment-7133233102) On the RTX 4090 under Wine/vkd3d-proton 3.2, the runtime reported a wave range of 32..32. Through the ordinary runtime host pipeline constructor on 1318357, a DXC shader declaring Wave32 created a pipeline and the otherwise identical Wave64 shader was declined. An instrumented run confirmed the Wave64 return after root-signature creation and before the compute PSO call. The result repeated with the original production code. This was a pipeline-creation check. The offline CLI uses a different host helper. We submitted a [follow-up on your branch](https://github.com/Xvania7/VIctory/pull/1) for that path, with the same width-specific outcome and separate stage labels for root-signature and PSO failures. The two synthetic widths passed their offline checks; individual #885 corpus failures have yet to be classified.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 13:53 UTC · original

The upper-bound test above covers Wave64 on a 32..=32 device. I checked the other end on 1318357 with a CPU-only capability fixture. For [WaveSize(32)] and a reported range of 64..=64, the existing max-only check still proceeds toward PSO creation. D3D12 validates a fixed wave size against the full reported range. Shader Model 6.6 runtime validation

Follow-up commit checks the inclusive range and reports both limits in the existing warning. The tests cover both out-of-range directions, accepted boundaries, and the path for an absent constraint or unavailable caps.

victory-gpu --lib passed 53 tests with one benchmark ignored. Clippy and the staged asset check passed.

**@⁠fuzeofficlal** on GitHub · 2026-11-24 13:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/893#issuecomment-7133490741) The upper-bound test above covers Wave64 on a `32..=32` device. I checked the other end on `1318357` with a CPU-only capability fixture. For `[WaveSize(32)]` and a reported range of `64..=64`, the existing max-only check still proceeds toward PSO creation. D3D12 validates a fixed wave size against the full reported range. [Shader Model 6.6 runtime validation](https://microsoft.github.io/DirectX-Specs/d3d/HLSL_SM_6_6_WaveSize.html#runtime-validation) [Follow-up commit](https://github.com/fuzeofficlal/VIctory/commit/1ca1b018e110d7fbec9069c71634bb680fafd036) checks the inclusive range and reports both limits in the existing warning. The tests cover both out-of-range directions, accepted boundaries, and the path for an absent constraint or unavailable caps. `victory-gpu --lib` passed 53 tests with one benchmark ignored. Clippy and the staged asset check passed.
Author
Owner

@⁠Xvania7 on GitHub · 2026-11-24 14:49 UTC · original

Thanks @⁠fuzeofficlal and @⁠MichaelSmithAI!

I have updated feat/issue-817-wave-lane-check:

  1. Integrated @⁠fuzeofficlal's inclusive wave size range check (!(min..=max).contains(&req)) via unsupported_compute_wave with unit tests covering lower and upper bounds.
  2. Merged PR #1 from @⁠MichaelSmithAI distinguishing offline refusal stages (root signature creation vs compute PSO compilation).
  3. All tests (cargo test -p victory-gpu and victory-shader), Clippy, and cargo xtask policy pass cleanly.
**@⁠Xvania7** on GitHub · 2026-11-24 14:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/893#issuecomment-7134998844) Thanks @⁠fuzeofficlal and @⁠MichaelSmithAI! I have updated [`feat/issue-817-wave-lane-check`](https://github.com/Xvania7/VIctory/tree/feat/issue-817-wave-lane-check): 1. Integrated @⁠fuzeofficlal's inclusive wave size range check (`!(min..=max).contains(&req)`) via `unsupported_compute_wave` with unit tests covering lower and upper bounds. 2. Merged PR #1 from @⁠MichaelSmithAI distinguishing offline refusal stages (root signature creation vs compute PSO compilation). 3. All tests (`cargo test -p victory-gpu` and `victory-shader`), Clippy, and `cargo xtask policy` pass cleanly.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:53 UTC · original

Automated triage for the maintainers.

main does not check a compute program's declared wave size against the host's wave range before CreateComputePipelineState; a 32-lane host refuses a WaveSize(64) pipeline with 0x80070057 (discussed in #71). Pull requests are open to everyone again, so please open one from feat/issue-817-wave-lane-check. Overlapping open pull requests: #1922 (rebase of #578, refuses wave64 mesh and compute programs on hosts without 64-lane waves) does the same check, and #2157 distinguishes root-signature and wave-lane failures in translate --pipelines; comparing with those first would avoid a duplicate. Note that a refusal only quiets the error; the programs still need a wave64-on-32 lowering (#233/#1929, #1890) to run.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:53 UTC · [original](https://github.com/Marvisak/VIctory/issues/893#issuecomment-7155266092) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-24T14:49:09Z at=2026-11-25T06:53:29Z --> Automated triage for the maintainers. `main` does not check a compute program's declared wave size against the host's wave range before `CreateComputePipelineState`; a 32-lane host refuses a `WaveSize(64)` pipeline with `0x80070057` (discussed in #71). Pull requests are open to everyone again, so please open one from `feat/issue-817-wave-lane-check`. Overlapping open pull requests: #1922 (rebase of #578, refuses wave64 mesh and compute programs on hosts without 64-lane waves) does the same check, and #2157 distinguishes root-signature and wave-lane failures in `translate --pipelines`; comparing with those first would avoid a duplicate. Note that a refusal only quiets the error; the programs still need a wave64-on-32 lowering (#233/#1929, #1890) to run. --- _Generated by [Claude Code](https://claude.ai/code)_
This discussion has been locked. Commenting is limited to contributors.
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#893
No description provided.