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

Closed
github-bot wants to merge 1 commit from gh-pr/208/head into gh-pr/208/base
Owner

@⁠wbkepler on GitHub · 2026-11-24 01:25 UTC · original
wbkepler:gpu/high-perf-adapter → main · +642 −45 · 1 files · 1 commits · closed without merging

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)
**@⁠wbkepler** on GitHub · 2026-11-24 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/208) `wbkepler:gpu/high-perf-adapter` → `main` · +642 −45 · 1 files · 1 commits · closed without merging ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:54:46 +00:00
github-bot closed this pull request 2026-11-26 03:54:46 +00:00
Author
Owner

@⁠SkippySteve on GitHub · 2026-11-24 01:33 UTC · original

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.

**@⁠SkippySteve** on GitHub · 2026-11-24 01:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/208#issuecomment-7119223467) 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.
Author
Owner

@⁠wbkepler on GitHub · 2026-11-24 01:38 UTC · original

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.

**@⁠wbkepler** on GitHub · 2026-11-24 01:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/208#issuecomment-7119310314) 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.
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-24 16:37 UTC · original

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.

**@⁠AgneyaK** on GitHub · 2026-11-24 16:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/208#issuecomment-7137944124) 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.
Author
Owner

@⁠ayanbarosan on GitHub · 2026-11-24 16:53 UTC · original

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. #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).

**@⁠ayanbarosan** on GitHub · 2026-11-24 16:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/208#issuecomment-7138356751) 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. #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).
Author
Owner

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

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** on GitHub · 2026-11-25 00:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/208#issuecomment-7148035023) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!208
No description provided.