Skip to content

GPU: prefer high-performance DXGI adapter supporting FL 12.0 (fixes #1226) - #2371

Open
antikohza wants to merge 1 commit into
Marvisak:mainfrom
antikohza:feat/dxgi-high-perf-adapter
Open

antikohza wants to merge 1 commit into
Marvisak:mainfrom
antikohza:feat/dxgi-high-perf-adapter

Conversation

@antikohza

Copy link
Copy Markdown

Split out of #2146 per maintainer triage feedback.

What this changes

  • Replaces the blind D3D12CreateDevice(None, ...) call in crates/victory-gpu/src/host.rs with best_adapter():
    • Uses IDXGIFactory6::EnumAdapterByGpuPreference(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) first so Windows per-app GPU preferences and discrete/eGPU devices take priority on hybrid laptops instead of falling onto an integrated GPU.
    • Verifies D3D_FEATURE_LEVEL_12_0 support with a null out-pointer (supports_fl12()) before selecting an adapter.
    • Falls back to the non-software adapter with the largest DedicatedVideoMemory, then to D3D12CreateDevice(None, ...) if needed.
  • Adds adapter_memory(&device) (LUID-matched via DXGI) to log host device memory on startup.

Closes #1226.

@Xvania7 Xvania7 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 bbac5c0 on Windows 10 + NVIDIA GeForce RTX 5060:

  • Clean isolation of best_adapter() and supports_fl12() via EnumAdapterByGpuPreference(HIGH_PERFORMANCE)
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings
  • cargo xtask policy: 182 files ok
  • GitHub Actions Windows CI passed.

Approving.

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

Prefer high-performance DXGI adapter supporting FL 12.0, falling back to default device. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. See cluster note on #2367 — these two collide.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Re-reviewed after the rebase. The branch now merges cleanly, and the content is the same as the version reviewed earlier.

In create (crates/victory-gpu/src/host.rs), best_adapter() replaces D3D12CreateDevice(None, ...). It picks the first non-software adapter from EnumAdapterByGpuPreference(HIGH_PERFORMANCE) that supports FL 12.0, checked with a null-device probe. If that fails, it takes the one with the most dedicated memory. If creating the device on it fails, it falls back to the default adapter. The startup probes (fuses_fmad) use from_device, so they follow the chosen adapter.

One minor point, not blocking: adapter_memory repeats the LUID lookup that video_memory already does with EnumAdapterByLuid. futurepro62's full-suite run on an RTX 5070 Ti passed.

Verdict: merge candidate (a recommendation to look, not an approval). CI: passing.


Generated by Claude Code

@futurepro62

Copy link
Copy Markdown

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 3ffa2d5 (on its base 67e8ae1).

Tested

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

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

Reviewed crates/victory-gpu/src/host.rs at 4028dc19 merged onto origin/main (63bcca43) and verified live on a dual-GPU host (Ryzen 9 9950X AMD Radeon iGPU + NVIDIA GeForce RTX 5090 dGPU) as well as WARP (VICTORY_D3D12_WARP=1) with VICTORY_D3D12_DEBUG=1.

Adapter selection & fallback audit

  • create() (host.rs:193) preserves the VICTORY_D3D12_WARP software branch untouched; for hardware creation it calls best_adapter() (host.rs:426), which queries IDXGIFactory6::EnumAdapterByGpuPreference(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE), filters out DXGI_ADAPTER_FLAG_SOFTWARE, and checks FL 12.0 via a null out-pointer (supports_fl12 at host.rs:409), falling back to max non-software DedicatedVideoMemory and finally D3D12CreateDevice(None, ...) if needed.
  • Non-blocking maintainer notes: adapter_memory (host.rs:391) could optionally use EnumAdapterByLuid like video_memory; open #3073 addresses the same multi-GPU adapter preference (and #2053 adds GPU logging/warnings).

Verification

  • cargo run -p xtask -- policy: 191 files ok.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default and --all-features): clean.
  • Live dual-GPU selection probe on a host enumerating [0] NVIDIA GeForce RTX 5090 (0x10de, 33,750,515,712 B), [1] AMD Radeon(TM) Graphics (0x1002, 2,119,970,816 B), and [2] Microsoft Basic Render Driver (0x1414, flags=0x2):
    • Default mode selected NVIDIA GeForce RTX 5090 (sw=false, adapter_memory = 33,750,515,712).
    • VICTORY_D3D12_WARP=1 (--features diagnostics) still selected Microsoft Basic Render Driver (0x1414:0x008c, sw=true).
  • host:: with VICTORY_D3D12_DEBUG=1: 35/35 passed on RTX 5090 (skipping dynamic_slots_are_held_until_released) and 36/36 passed on WARP (--features diagnostics, skipping the pre-existing main compositor_failure_presents_primary_in_the_same_frame Debug Layer mismatch).

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.

GPU: a failed host texture allocation removes the device instead of dropping detail (8 GB NVIDIA laptop, world load)

6 participants