Repository navigation
GPU: choose an adapter that can run the title, and name the ones that cannot - #967
zzm1234560621-prog wants to merge 1 commit into
Conversation
… cannot D3D12CreateDevice(None, …) takes the adapter DXGI calls the default, which is the one driving the primary output: the integrated GPU on a hybrid laptop, and on a machine with a remote-desktop or emulator display driver an adapter that cannot create a device at all. The title needs shader model 6.6 and, for the world, mesh shaders, so neither is a safe default, and when none of them worked the failure was a bare E_FAIL that named nothing. Enumerate and probe every adapter — a device, SHADER_MODEL, D3D12_OPTIONS7's mesh tier, the software flag — then choose: hardware, SM 6.6, mesh shaders first, then the most dedicated memory, then the lowest LUID so the choice does not depend on enumeration order. Software adapters are never chosen (Microsoft Basic Render Driver reports SM 6.6 and mesh shaders too), and WARP stays the explicit VICTORY_D3D12_WARP switch. When nothing qualifies, the error lists every adapter with what it offers. Measured on the machine this was written on (Core Ultra 9 185H, Intel Arc iGPU, plus a remote-desktop and an emulator display driver): four adapters, the same GPU listed three times — once per display path, so which is the default is not stable — and the Basic Render Driver passing a naive SM 6.6 + mesh test. cargo test -p victory-gpu: 57 passed, 0 failed, 1 ignored. cargo clippy --workspace --all-targets --all-features -- -D warnings: clean. cargo xtask policy: ok.
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 66d97ee on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 57 passed, and with --features diagnostics 60 passed, including the seven choose tests. cargo clippy -p victory-gpu --all-targets is clean. This machine has the RTX 5070, an AMD integrated GPU and two virtual display adapters, so it's a realistic multi-adapter host. The selection itself isn't exercised by a test against the real adapters, and the title wasn't run.
chooseas a pure function over probed facts (device creatable, SM 6.6, mesh tier, software flag, VRAM, LUID) is easy to reason about. Excluding software adapters keeps WARP an explicit switch, and the LUID tiebreak makes the result stable for a given machine.- Two suggestions:
- There's no user override. With "mesh, then most VRAM" a user can't force a specific GPU, for example to compare iGPU against dGPU behaviour, short of disabling the other in Device Manager. A
VICTORY_ADAPTER=<LUID or index>escape hatch, listed inreport()'s output, would cover that. - Probing creates a D3D12 device on every adapter at startup, including virtual display adapters (Parsec and Meta here) that have no device. That's harmless, but it's worth a
debug!per probe so a slow driver at startup is attributable.
- There's no user override. With "mesh, then most VRAM" a user can't force a specific GPU, for example to compare iGPU against dGPU behaviour, short of disabling the other in Device Manager. A
AI-assisted (Claude Code).
…he title, and name the ones that cannot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent DXGI/D3D12 probe on a hybrid Windows 11 laptop (build 26100). I created a feature-level 12.0 D3D12 device per enumerated adapter and made the same SM 6.6 and OPTIONS7 mesh-tier queries used in
Applying the PR's selection rules to the measured facts picks the RTX 5060. In this configuration, Standalone probe of the Windows APIs and the selection criteria. The PR binary and game were not run. AI-assisted with Codex. |
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
|
A suggestion from testing #967: skip software adapters in
The change, in // Software adapters are never chosen (`runs_the_title`), so no device is
// made on them: a WARP device in every process costs time and memory, and
// it is the very device (one per adapter and process) that code and tests
// asking for WARP on purpose get.
if facts.software {
return facts;
}The choice does not change: on Windows 11 with an RTX 5080, an AMD integrated GPU and the Basic Render Driver, #967 with this change picks the RTX 5080 ( AI use: found, written and tested with Claude Code (Claude Opus 5.5). |
GPU: choose an adapter that can run the title, and name the ones that cannot
What
victory_gpu::host::createnow picks the host adapter instead of takingD3D12CreateDevice(None, …). New modulecrates/victory-gpu/src/adapter.rs:enumerate()walksIDXGIFactory4::EnumAdapters1and probes each adapter:its description, whether a D3D12 device can be created on it,
SHADER_MODEL,D3D12_OPTIONS7::MeshShaderTier, and the software flag.choose()is a pure function over those facts and is where the policy lives.report()renders one line per adapter, for the error below.open()creates the device on the chosen adapter.create()keeps its WARP branch unchanged (VICTORY_D3D12_WARP, diagnosticsbuilds) and returns
anyhow::Resultinstead ofwindows::core::Result, so afailure can carry the adapter list rather than a bare
E_FAIL.Why
D3D12CreateDevice(None, …)means "whatever DXGI calls the default adapter",which is the adapter driving the primary output. That is the wrong adapter in
two common configurations:
integrated GPU. It may create a device and still not be what runs the
world; the old code would either use it or fail the SM 6.6 check with
the device supports SM 0x65 onlyand no hint that a capable GPU is inthe machine.
adapters that enumerate like any other and cannot create a D3D12 device.
When one of them ends up as the default, the failure was an
E_FAILwithno name attached.
The title needs shader model 6.6 (README) and, for the world, mesh shaders,
so "the default adapter" is not a safe default.
How the choice is made
Microsoft Basic Render Driverreports SM 6.6 and mesh shaders too (measured below), andsilently running the title on the CPU is worse than a failure that names
the reason. WARP stays the explicit
VICTORY_D3D12_WARPswitch.DedicatedVideoMemory.order the driver enumerates in.
When nothing qualifies, the error lists every adapter with its LUID, vendor,
dedicated memory, shader model, mesh support and whether it is software.
Measured
enumerate()+choose()on the machine this was written on (Windows 11,Core Ultra 9 185H, one Intel Arc iGPU, plus a remote-desktop display driver
and an emulator display driver installed):
Two things this shows that the old code could not:
the three is "the default" is not stable across runs; the LUID tie-break is.
reason for rule 1.
Not verified
what is drawn.
README ("mesh shaders for the world"), not something measured on a GPU
without mesh support.
touched by this PR; it is the same host the old code would have used
whenever the default adapter was the right one.
Tested
cargo test -p victory-gpu --locked: 50 passed, 1 ignored, 0 failed(8 of them new; they drive
chooseandreportover synthetic facts andneed neither a GPU nor a display).
CI's commands, on Windows 11 with MSVC 14.51 and Rust 1.98.1 (the pinned
toolchain):
cargo clippy --workspace --all-targets --locked -- -D warnings: cleancargo clippy --workspace --all-targets --all-features --locked -- -D warnings: cleancargo xtask policy: okcargo test --workspace --locked: see the run belowOne caveat for anyone re-running the suite:
victory-core's twopolicy::testsandvictory-gpu'sshader_cache/watchtests createdirectories under
%TEMP%. They pass on a normal machine; a run whose%TEMP%is not writable fails them withPermissionDenied, which is not acode failure.
Relation to open PRs
VICTORY_ADAPTERand adapter helpers for the shader testhost. This PR deliberately adds no environment variable: if that lands
first,
Factsandchooseare the shared implementation those helpersshould call, and the override becomes one more input to
choose.victory-shader, so Shaders: wave64 compute on 32-lane hosts, in halves and in the console flow #233 / Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439's stack is unaffected.