Skip to content

GPU: refuse wave64 mesh and compute programs on hosts without 64-lane waves (rebase of #578) - #1922

Open
slatefield wants to merge 5 commits into
Marvisak:mainfrom
slatefield:up-578-rebase
Open

slatefield wants to merge 5 commits into
Marvisak:mainfrom
slatefield:up-578-rebase

Conversation

@slatefield

Copy link
Copy Markdown
Contributor

Rebase of #578 onto current main (4118f33). The original work is wbkepler's, all five commits are kept with their author and message unchanged; only conflict resolution sits inside them, so the history is the same change, brought up to date. If #578 updates first, take that one instead.

Why it is worth merging now: on hosts whose waves are narrower than 64 (every NVIDIA D3D12 GPU reports WaveLaneCountMin = Max = 32), console wave64 mesh and unsized wave64 compute programs currently reach a pipeline and hang the GPU, which ends the run with DXGI_ERROR_DEVICE_HUNG. This checks the emitted DXIL PSV0 wave range against the host's D3D12_OPTIONS1 range in HostPipeline::new and refuses the programs that cannot run, so their draws and dispatches are dropped with a named reason instead of taking the device down. It also allows wave64 compute that was deliberately lowered to WaveSize(32) (the #233 class) to run on a 32-lane host.

What was done for the rebase: nothing of the PR is in main yet (wave_lanes, WaveLaneCount, the PSV0 bounds: none of them appear), so the whole 300 added lines were ported. Seven conflict hunks over three files, all because main grew around the PR: host.rs keeps heap_atomics64() and takes the wave-lane query beside it; pipeline.rs builds the wave64 cache inside main's newer Shader::new/translated shape; pipeline/host.rs merges main's own test module with the PR's three tests into one module. The one line not carried verbatim is a test-module use that use super::*; makes redundant.

Checked here: Windows-target clippy --all-targets with and without --all-features, clean for victory-gpu and for victory with diagnostics; native tests for the crates that build on Linux all pass (shader 144, formats 38, game 15, core 13, pipeline 7); cargo xtask policy 182 files ok. The PR's three tests need victory-gpu on Windows; I also ran their bodies against the real victory-shader parser through an off-tree harness and they pass.

Not checked, needs a Windows GPU: the three tests executing, the refusal wording on a 32-lane host, zero driver E_INVALIDARG wave-lane errors, and a world run that survives where main loses the device. The PR's tester notes (in #578) say reference runs from 393 s to 17.5 minutes with one 5060 Ti counter-example removed by an unrelated wave32 submission.

Companion changes: #233 (the other worker on this team) is being rebased in parallel; the PSV0 rule here is what lets its lowered WaveSize(32) compute run. #32 (queue Wait is a no-op on main today) is worth landing near this one, since async submissions assume cross-queue ordering that the synchronous wait currently hides.

wbkepler and others added 5 commits November 25, 2026 00:51
… waves

A console mesh or compute program written for 64-lane waves reads lanes
and wave-wide masks as the 64-lane wave has them. Run as 32-lane waves
(NVIDIA's D3D12 range is 32..32) such programs hang the GPU in the world:
the device is removed as hung after a 2 s timeout, at a dispatch of one
of them, every run. Their pipelines are now refused there, so their draws
and dispatches are dropped instead of hanging the host.

Vertex and pixel programs run per lane and are kept; hosts with 64-lane
waves are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Console wave64 compute programs whose emitted DXIL declares no PSV0
wave-lane range (or an upper bound wider than the host) can still rely
on 64-lane wave semantics and hang 32-lane hosts.

On hosts with max wave lanes < 64, refuse console wave64 compute
programs unless the emitted DXIL PSV0 explicitly bounds the wave size
within the host's supported range (max_lanes <= host_max), preserving
Wave32-split compute translations (PSV0 WaveSize(32)) and 64-lane hosts
while refusing unconstrained wave64 compute like wave64 mesh.

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

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Refuse wave64 mesh/compute programs on hosts that can't: capability refusal instead of miscompile — good hardening.

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown

A Windows GPU run, as the description asks. Ran on Windows 11 with an RTX 3070 (Ampere, 32-lane waves, driver 616.56), debug build, at 24a7bc2, cargo test -p victory-gpu --locked: 142 passed, 2 failed, 2 ignored. The PR's three tests pass on this 32-lane host: emitted_wave_size_checked_against_host_range, wave_lanes_refusal_reports_emitted_and_host_ranges and dxil_wave_lanes_reads_psv0_bounds. The 2 failures are #1744's heap-cap failures on main. Same as main on this hardware. Not checked: the driver's E_INVALIDARG count in a title run.

AI-assisted (Claude Code).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Proposed close.

Reason: this PR re-packages another contributor's open PR. It is #578 (wbkepler, still open, labelled triage: needs rebase) rebased: the same five commits by the same author, conflicts resolved. Two open PRs for one change split the review. The rebase belongs on #578: its author can take it over, or a maintainer can choose this branch as #578's replacement.

Thanks for doing the rebase work. For whoever picks it up, there's one point on the substance that #578 should settle. On main, Lower (emit/lower.rs, the compute wave_size choice) already declares WaveSize(64) for wave64 compute whose results depend on console lanes, or that is a single wave using LDS. Every other wave64 compute program is deliberately emitted per lane with no wave size. wave_lanes_unsupported refuses all of those unsized wave64 compute programs whenever the host's max is below 64, which on NVIDIA means every one of them. That drops their dispatches wholesale on the most common host. The evidence for it is TDR reports, not a program identified as needing 64 lanes. Narrowing it to the programs that actually hang, or fixing the translation, would be the stronger change.

CI: no check runs on this head.

The PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.


Generated by Claude Code

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 26, 2026
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.

5 participants