Skip to content

GPU: select high-performance D3D12 adapter and probe host caps - #208

Closed
wbkepler wants to merge 1 commit into
Marvisak:mainfrom
wbkepler:gpu/high-perf-adapter
Closed

wbkepler wants to merge 1 commit into
Marvisak:mainfrom
wbkepler:gpu/high-perf-adapter

Conversation

@wbkepler

@wbkepler wbkepler commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

  • Replaces implicit D3D12CreateDevice(None, ...) with explicit DXGI adapter selection via IDXGIFactory6::EnumAdapterByGpuPreference(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) (falling back to IDXGIFactory1::EnumAdapters1 when IDXGIFactory6 is unavailable).
  • Skips software adapters (DXGI_ADAPTER_FLAG_SOFTWARE) by default while preserving VICTORY_D3D12_WARP software validation under diagnostics.
  • Adds optional VICTORY_D3D12_ADAPTER override (0-based hardware adapter index or case-insensitive description substring match). Note: a non-matching VICTORY_D3D12_ADAPTER value returns a hard device-creation error (listing available adapters in the error/log) rather than silently falling back to the default adapter.
  • Probes and caches host D3D12 capabilities in HostCaps (adapter metadata, Options 0/1/5/7/9/11, downward SHADER_MODEL probe), logs a concise startup summary, and exposes capability getters on Host (caps, mesh_shaders, supports_wave64, wave_lane_count_max, supports_atomic_int64_typed, resource_binding_tier).
  • Adds 7 unit tests including live WARP device and capability probing.

Verification

  • cargo clippy --workspace --all-targets — passed
  • cargo clippy -p victory --features diagnostics --all-targets — passed
  • cargo test --workspace — passed (50 passed, 1 ignored in victory-gpu)
  • cargo xtask policy — passed (151 files ok)

Replace implicit D3D12CreateDevice(None, ...) with explicit DXGI adapter
selection via IDXGIFactory6::EnumAdapterByGpuPreference(HIGH_PERFORMANCE)
(with IDXGIFactory1::EnumAdapters1 fallback), skipping software adapters
by default while preserving diagnostics VICTORY_D3D12_WARP software
validation.

Add optional VICTORY_D3D12_ADAPTER override supporting either a 0-based
hardware adapter index or a case-insensitive description substring match.

Probe and store host D3D12 capabilities on Host in HostCaps (adapter
description, vendor/device IDs, dedicated VRAM, Options 0/1/5/7/9/11,
and highest supported shader model), log a single concise startup summary,
expose capability getters on Host (including supports_wave64,
wave_lane_count_max, supports_atomic_int64_typed, and
resource_binding_tier), and add unit tests covering adapter filter
parsing/matching, capability helpers, and WARP device capability probing.
@SkippySteve

SkippySteve commented Nov 24, 2026 •

Copy link
Copy Markdown

I ran this PR under Proton on Linux. I used only synthetic victory-gpu tests: no game files and no title run.

Host: Arch Linux (kernel 7.2), single GPU: RTX 2060 SUPER, NVIDIA 615.78.08. Runtime: UMU-Proton 11.0-2e (files/bin/wine) with a fresh dedicated prefix that proton run created, so the prefix has Proton's vkd3d-proton and DXVK DLLs. I ran with WINEDLLOVERRIDES="d3d12=n;d3d12core=n;dxgi=n;d3d11=n", so DXGI is DXVK's and D3D12 is vkd3d-proton's. Build: cargo xwin test --target x86_64-pc-windows-msvc -p victory-gpu --no-run (Rust 1.98.1), and I ran the test exe under wine --test-threads=1.

Test suite

main @ d2a4bae #208 @ eb72359
victory-gpu, all tests 40 pass / 3 fail / 1 ignored 47 pass / 3 fail / 1 ignored
host::tests (7 new tests) n/a 7/7 pass
victory-gpu --features diagnostics n/a 49 pass / 3 fail / 1 ignored

The PR results were the same in 4 runs (3 with one test thread, 1 with parallel threads). The 3 failures are the ones main already has here: argument_clamp_builds, a_rejected_blob_gives_an_empty_library and buffer_data_reaches_the_host_texture. They have nothing to do with this PR. Every test that creates a real Host (and so runs the new create_device()) still passes.

Adapter selection under vkd3d-proton

The tests don't log the startup summary, so I added a temporary #[ignore] test locally. It is not pushed. It prints what DXGI enumerates and what create_device() + probe_caps() pick:

IDXGIFactory6 available: yes (EnumAdapterByGpuPreference path taken)
EnumAdapters1[0] NVIDIA GeForce RTX 2060 SUPER vendor=0x10de flags=0x0 vram=8160MB
hardware candidates: [0] NVIDIA GeForce RTX 2060 SUPER
selected: NVIDIA GeForce RTX 2060 SUPER (vendor=0x10de device=0x1f06) | VRAM=8160 MB | SM=6.8 | Wave=32..32 (ops=true) | BindingTier=3 | TiledTier=4 | Mesh=1.0 | RT=1.1 | AtomicI64(typed=true, shared=true, heap=true)

The probed caps make sense for Turing on vkd3d-proton. The shader model probe steps down past 6.9 and lands on 6.8, which is what vkd3d-proton reports. Wave lanes are 32..32, so supports_wave64() is false on NVIDIA, as it should be.

VICTORY_D3D12_ADAPTER override:

value result
unset / "" RTX 2060 SUPER
0, nvidia, RTX RTX 2060 SUPER
1, amd, zzz create_device fails with 0x887A0002 (DXGI_ERROR_NOT_FOUND)

So the index and the case-insensitive substring match both work. An override that matches nothing is a hard failure, not a fallback to the default adapter. That looks intentional given the warn! that lists the available adapters. Still, someone with a stale value in their environment will get no device at all, so it may be worth saying so in the PR description or docs.

WARP under Proton

DXVK's EnumWarpAdapter logs WARP not supported, returning first hardware adapter and returns the RTX (flags 0x0). warp_adapter_accepts_only_software checks that warp_adapter() refuses it, and it passes. warp_device_creation_and_caps_probe returns early here, so on Proton it passes without testing anything. Its WARP assertions only run on real Windows. In a diagnostics build with VICTORY_D3D12_WARP=1, device creation fails with E_FAIL, which is the same as main. The software adapter filter in the normal path never comes into play here because DXVK lists no software adapter.

Not covered

This machine has only one GPU, so I couldn't check high-performance ordering across iGPU and dGPU, or a hybrid laptop setup. I also didn't do a title run.

@wbkepler

Copy link
Copy Markdown
Author

Thanks @SkippySteve for testing on Proton/vkd3d-proton! Updated the PR description to clarify that a non-matching `VICTORY_D3D12_ADAPTER` value returns a hard device-creation error (listing available adapters) rather than falling back to the default adapter.

@AgneyaK

AgneyaK commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Test report on eb72359, merged onto main d2a4bae (clean merge). Laptop: Intel Iris Xe is DXGI
adapter 0, NVIDIA RTX 3050 is adapter 1.

Tested

  • A local probe reads the game host's adapter back from the device's LUID:
    • main: Intel(R) Iris(R) Xe Graphics;
    • this PR: NVIDIA GeForce RTX 3050 6GB Laptop GPU.
  • cargo test -p victory-gpu --lib: 50 passed, 0 failed, 1 ignored.

Note: victory-shader's test host (emit/host.rs) still uses D3D12CreateDevice(None), so the
shader tests keep running on the iGPU here. #94 changes both hosts.

Not tested: AMD, Wine, a desktop with one GPU, the title.

Details: #1232.

AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title on my machine and drafted this note; results are from the runs described.

@ayanbarosan

Copy link
Copy Markdown

A second hybrid laptop, adding to the report above. The default choice is the same, and this run also covers the VICTORY_D3D12_ADAPTER override, WARP on real Windows and the startup summaries. I used synthetic victory-gpu tests only: no game files and no title run.

Host: Windows 11 build 26300, i5-11400H laptop with Intel UHD Graphics (Tiger Lake, driver 31.0.101.5333) and an NVIDIA GeForce RTX 3050 Laptop GPU (driver 610.91). Build: eb72359 cherry-picked onto main at ffe310e (applies cleanly).

  • cargo test -p victory-gpu --locked: 57 passed, 0 failed, 1 ignored (the benchmark). The three tests that fail under Proton pass here.
  • With --features diagnostics, host::tests: 11 passed. warp_device_creation_and_caps_probe gets a real WARP device here, so its assertions run.
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, also with --all-features: clean.

Adapter selection

I checked this with a temporary local test that calls create_device() and probe_caps(). It is not pushed. DXGI's own order here is Intel UHD (LUID 0:e012), RTX 3050, a second Intel UHD entry (0:17ac3), then the Microsoft Basic Render Driver (flags 0x2). So main runs on the Intel. The PR's high-performance list is RTX 3050, UHD 0:e012, UHD 0:17ac3.

VICTORY_D3D12_ADAPTER device
unset, blank RTX 3050 Laptop
nvidia, RTX 3050, 0 RTX 3050 Laptop
intel, UHD, 1 Intel UHD (0:e012)
2 Intel UHD (0:17ac3)
3, 99, amd, Basic Render DXGI_ERROR_NOT_FOUND, after the warning that lists the three adapters above

In a diagnostics build, VICTORY_D3D12_WARP=1 gets the Basic Render Driver, even with VICTORY_D3D12_ADAPTER=nvidia set.

Startup summaries (caps.summary()):

NVIDIA GeForce RTX 3050 Laptop GPU (vendor=0x10de device=0x25a5) | VRAM=3962 MB | SM=6.8 | Wave=32..32 (ops=true) | BindingTier=3 | TiledTier=4 | Mesh=1.0 | RT=unknown | AtomicI64(typed=true, shared=true, heap=true)
Intel(R) UHD Graphics (vendor=0x8086 device=0x9a68) | VRAM=128 MB | SM=6.7 | Wave=16..16 (ops=true) | BindingTier=3 | TiledTier=3 | Mesh=none | RT=none | AtomicI64(typed=false, shared=false, heap=false)
Microsoft Basic Render Driver (vendor=0x1414 device=0x008c, WARP) | VRAM=0 MB | SM=6.8 | Wave=4..4 (ops=true) | BindingTier=3 | TiledTier=3 | Mesh=1.0 | RT=1.1 | AtomicI64(typed=true, shared=true, heap=true)

Notes

  1. RT=unknown on the RTX: the driver reports RaytracingTier 12 (DXR 1.2). raytracing_tier_label has no arm for it, and windows 0.62 has no constant for it. Printing an unknown tier's number, such as RT=unknown(12), would keep it in the log.
  2. Index order: the index counts the high-performance list, so 0 is the RTX here, while DXGI's adapter 0 is the Intel. The README's variable table doesn't list VICTORY_D3D12_ADAPTER yet, and a row there could say this.
  3. Machines without a GPU: the Basic Render Driver carries DXGI_ADAPTER_FLAG_SOFTWARE here, so the PR skips it. Where it is the only adapter and carries the flag, create_device fails with DXGI_ERROR_NOT_FOUND and host() is None, while main gets a WARP device. The victory-gpu tests that return early without a host would then pass without testing anything. Shaders: one console wave sharing LDS runs in the console flow on 32-lane hosts #439's emit/host.rs notes that a CI runner can list this adapter without the flag. There the PR keeps it, so nothing changes. A WARP fallback when no hardware adapter is found and no override is set would keep main's behavior there.

No game data used. AI-assisted (Claude Code).

sahajiscoding added a commit to sahajiscoding/VIctory that referenced this pull request Nov 24, 2026
… & shader ops

- Prefer high-performance discrete GPU via IDXGIFactory6::EnumAdapterByGpuPreference
  and VICTORY_ADAPTER (index or name substring) in victory-gpu and victory-shader (Marvisak#208/Marvisak#1132)
- Cap shader-visible sampler heaps at D3D12's 2,048 architectural limit instead of
  failing heap creation (Marvisak#100/Marvisak#86)
- Fall back to the in-memory translated shader if shader-cache disk write fails (Marvisak#358)
- Add F11 / Alt+Enter borderless fullscreen toggle and clean WM_CLOSE handling to
  both title windows (lifecycle.rs) and VIctory's fallback window (host.rs); clamp
  fit_into() dimensions to >= 1 (Marvisak#451)
- Enhance PC keyboard+mouse fallback gamepad with Space/LShift/R/LCtrl aliases,
  LMB/RMB/MMB triggers, and RMB/F9 mouse camera look; support null-device
  cross-device previous/next reading walk (Marvisak#361)
- Fall back to a no-op display deferral when PowerSetRequest returns ERROR_NOT_SUPPORTED
- Clamp short virtual-drive '..' paths at the virtual drive root (Marvisak#182)
- Wake and cancel sleeping delayed callbacks immediately on XTaskQueueTerminate (Marvisak#132)
- Cache XMA IMDCT rotation sin/cos tables across subframes (Marvisak#172)
- Lower additional RDNA2 VALU instructions (v_mul_hi_{u,i}32_{u,i}24, v_mad_{u,i}32_{u,i}16,
  v_lerp_u8, v_sad_u{8,16,32}, v_cvt_pk_{u,i}16_{u,i}32, v_dot{2,4}_{i,u}32_{i,u}{16,8})
  with DXIL validation and conditional INT64 feature flagging (Marvisak#157)
- Add portable victory.toml lookup next to victory.exe, interactive [S] Setup wizard
  and [K] Controls guide in victory.exe, and scripts/build-windows.ps1 release packager

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
MamaLeVrai added a commit to MamaLeVrai/VIctory that referenced this pull request Nov 24, 2026
…erlaps with the GPU bundles

Marvisak#189 (wave64 on 32-lane hosts) and the GPU bundles Marvisak#1426 and Marvisak#1439 overlap
in three places:

- host.rs, where the host is built: Marvisak#208 (Marvisak#1426) logs the capabilities
  summary, Marvisak#189 chooses the Wave64 mode. Both lines are kept.
- host.rs, after the device helpers: Marvisak#208's adapter and capability probe and
  Marvisak#189's recommended_wave64_mode are two new functions at the same spot.
  Both are kept.
- shader_cache.rs: Marvisak#189 prefixes the translation input with a mode byte
  (input[33..]), Marvisak#358 (Marvisak#1439) records that a translation ran
  (self.translated). Both are kept; the two tests of Marvisak#358 that call
  cached() pass Wave64Mode::Native, as Marvisak#189's own tests do.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(725 passed, 11 ignored, two runs).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #967. Same goal as #967 (choose a hardware adapter instead of the default) in 642 lines inside host.rs with a block of unused capability accessors.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

@Marvisak Marvisak closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants