GPU: prefer high-performance D3D12 adapter and support VICTORY_ADAPTER #94

Closed
github-bot wants to merge 4 commits from gh-pr/94/head into gh-pr/94/base
Owner

@⁠lordon1a on GitHub · 2026-11-24 00:26 UTC · original
feat/high-performance-adapter → main · +216 −33 · 3 files · 4 commits · closed without merging

Summary

On dual-GPU Windows systems (such as Optimus / hybrid laptops with an integrated GPU at DXGI adapter 0 and a discrete GPU at adapter 1), D3D12CreateDevice(None, ...) defaults to adapter 0 (the integrated GPU, which may have limited VRAM or lack Mesh Shaders).

This change updates both victory-gpu (crates/victory-gpu/src/host.rs) and victory-shader (crates/victory-shader/src/emit/host.rs) to:

  1. Enumerate adapters via IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) (falling back to IDXGIFactory1::EnumAdapters1 / D3D12CreateDevice(None, ...)), skipping software adapters by default so discrete GPUs are chosen automatically.
  2. Support VICTORY_ADAPTER=<substring> (case-insensitive match against DXGI_ADAPTER_DESC1::Description) so multi-GPU users and testers can explicitly target a specific adapter (failing cleanly with DXGI_ERROR_NOT_FOUND rather than silently falling back when no adapter matches).
  3. Log the selected adapter's name, PCI vendor/device IDs, and dedicated VRAM in victory-gpu startup logs (tracing::info!) to aid GPU bug reports.

Verification

Tested on Windows 11 dual-GPU laptop (DXGI Adapter 0: Intel Iris Xe 8086:46a6 128 MB, DXGI Adapter 1: NVIDIA GeForce RTX 3070 Ti Laptop GPU 10de:24e0 8017 MB; rustc 1.100.0, x86_64-pc-windows-gnullvm):

  • cargo xtask policy: 150 files ok (zero game data)
  • cargo clippy -p victory-gpu -p victory-shader --all-targets: 0 warnings in modified files
  • cargo test -p victory-gpu -p victory-shader:
    • Default (HIGH_PERFORMANCE -> RTX 3070 Ti): 43 passed (victory-gpu, +4 new unit tests) + 57 passed (victory-shader)
    • VICTORY_ADAPTER=Intel: 43 passed + 57 passed
    • VICTORY_ADAPTER="RTX 3070": 43 passed + 57 passed
    • unknown_adapter_filter_fails_instead_of_falling_back: returns DXGI_ERROR_NOT_FOUND

AI-assisted.

**@⁠lordon1a** on GitHub · 2026-11-24 00:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/94) `feat/high-performance-adapter` → `main` · +216 −33 · 3 files · 4 commits · closed without merging ## Summary On dual-GPU Windows systems (such as Optimus / hybrid laptops with an integrated GPU at DXGI adapter 0 and a discrete GPU at adapter 1), `D3D12CreateDevice(None, ...)` defaults to adapter 0 (the integrated GPU, which may have limited VRAM or lack Mesh Shaders). This change updates both `victory-gpu` (`crates/victory-gpu/src/host.rs`) and `victory-shader` (`crates/victory-shader/src/emit/host.rs`) to: 1. Enumerate adapters via `IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)` (falling back to `IDXGIFactory1::EnumAdapters1` / `D3D12CreateDevice(None, ...)`), skipping software adapters by default so discrete GPUs are chosen automatically. 2. Support `VICTORY_ADAPTER=<substring>` (case-insensitive match against `DXGI_ADAPTER_DESC1::Description`) so multi-GPU users and testers can explicitly target a specific adapter (failing cleanly with `DXGI_ERROR_NOT_FOUND` rather than silently falling back when no adapter matches). 3. Log the selected adapter's name, PCI vendor/device IDs, and dedicated VRAM in `victory-gpu` startup logs (`tracing::info!`) to aid GPU bug reports. ## Verification Tested on Windows 11 dual-GPU laptop (`DXGI Adapter 0`: Intel Iris Xe `8086:46a6` 128 MB, `DXGI Adapter 1`: NVIDIA GeForce RTX 3070 Ti Laptop GPU `10de:24e0` 8017 MB; `rustc 1.100.0`, `x86_64-pc-windows-gnullvm`): - `cargo xtask policy`: **150 files ok** (zero game data) - `cargo clippy -p victory-gpu -p victory-shader --all-targets`: **0 warnings in modified files** - `cargo test -p victory-gpu -p victory-shader`: - Default (`HIGH_PERFORMANCE` -> RTX 3070 Ti): **43 passed (`victory-gpu`, +4 new unit tests) + 57 passed (`victory-shader`)** - `VICTORY_ADAPTER=Intel`: **43 passed + 57 passed** - `VICTORY_ADAPTER="RTX 3070"`: **43 passed + 57 passed** - `unknown_adapter_filter_fails_instead_of_falling_back`: returns `DXGI_ERROR_NOT_FOUND` AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:03 +00:00
github-bot closed this pull request 2026-11-26 03:50:03 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:52 UTC · original

Tested 163752c under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc: pass, no regression.

  • victory_gpu: 44 passed, 3 failed, 1 ignored; the PR adds 5 tests. The 3 failures are the environment-only ones from main (argument_clamp_builds, a_rejected_blob_gives_an_empty_library, #128's VirtualQuery upload skip).
  • The adapter selection is exercised here (single RADV adapter through DXGI): default_adapter_is_hardware_when_present, warp_adapter_accepts_only_software, unknown_adapter_filter_fails_instead_of_falling_back, adapter_filter_matches_case_insensitively and adapter_name_stops_at_nul all pass.
  • texture_checks_per_submission stays ignored (benchmark).

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/94#issuecomment-7118516955) Tested `163752c` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc`: **pass, no regression**. - `victory_gpu`: **44 passed, 3 failed, 1 ignored**; the PR adds 5 tests. The 3 failures are the environment-only ones from `main` (`argument_clamp_builds`, `a_rejected_blob_gives_an_empty_library`, #128's `VirtualQuery` upload skip). - The adapter selection is exercised here (single RADV adapter through DXGI): `default_adapter_is_hardware_when_present`, `warp_adapter_accepts_only_software`, `unknown_adapter_filter_fails_instead_of_falling_back`, `adapter_filter_matches_case_insensitively` and `adapter_name_stops_at_nul` all pass. - `texture_checks_per_submission` stays ignored (benchmark). No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-24 06:18 UTC · original

Tested on native Windows with two hardware adapters, the case this PR is for: each selection picks the right adapter.

Machine. RTX 5080 (driver 610.88) and the AMD Radeon iGPU of a Ryzen 7 9800X3D (driver 32.0.21042.62), plus WARP. Windows 11 Pro 26200, Rust 1.98.1, debug. Head 513eb91 merged with main d2a4bae (clean). A local test (not pushed) prints what pick_hardware_adapter returns for a few filters.

VICTORY_ADAPTER Picked
unset NVIDIA GeForce RTX 5080 (the high-performance GPU)
amd AMD Radeon(TM) Graphics
radeon AMD Radeon(TM) Graphics
NVIDIA NVIDIA GeForce RTX 5080
geforce rtx 5080 NVIDIA GeForce RTX 5080
Microsoft Basic Render Microsoft Basic Render Driver (WARP, by name)
no such gpu error 0x887A0002, no fallback
  • victory_gpu adapter tests: all five pass (adapter_filter_matches_case_insensitively, adapter_name_stops_at_nul, default_adapter_is_hardware_when_present, unknown_adapter_filter_fails_instead_of_falling_back, warp_adapter_accepts_only_software).
  • The victory-shader test host follows the variable too: with VICTORY_ADAPTER=amd its device is the Radeon, otherwise the RTX 5080. I used that to run GPU checks on the iGPU's 64-lane waves for #606.

AI use: Claude Code (Claude Opus 5.5) wrote the local print test, ran it and drafted this comment.

**@⁠Lyrnc** on GitHub · 2026-11-24 06:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/94#issuecomment-7123796994) Tested on native Windows with two hardware adapters, the case this PR is for: **each selection picks the right adapter.** **Machine.** RTX 5080 (driver 610.88) and the AMD Radeon iGPU of a Ryzen 7 9800X3D (driver 32.0.21042.62), plus WARP. Windows 11 Pro 26200, Rust 1.98.1, debug. Head `513eb91` merged with `main` `d2a4bae` (clean). A local test (not pushed) prints what `pick_hardware_adapter` returns for a few filters. | `VICTORY_ADAPTER` | Picked | |---|---| | unset | NVIDIA GeForce RTX 5080 (the high-performance GPU) | | `amd` | AMD Radeon(TM) Graphics | | `radeon` | AMD Radeon(TM) Graphics | | `NVIDIA` | NVIDIA GeForce RTX 5080 | | `geforce rtx 5080` | NVIDIA GeForce RTX 5080 | | `Microsoft Basic Render` | Microsoft Basic Render Driver (WARP, by name) | | `no such gpu` | error `0x887A0002`, no fallback | - `victory_gpu` adapter tests: all five pass (`adapter_filter_matches_case_insensitively`, `adapter_name_stops_at_nul`, `default_adapter_is_hardware_when_present`, `unknown_adapter_filter_fails_instead_of_falling_back`, `warp_adapter_accepts_only_software`). - The `victory-shader` test host follows the variable too: with `VICTORY_ADAPTER=amd` its device is the Radeon, otherwise the RTX 5080. I used that to run GPU checks on the iGPU's 64-lane waves for #606. AI use: Claude Code (Claude Opus 5.5) wrote the local print test, ran it and drafted this comment.
Author
Owner

@⁠Ilokaxt on GitHub · 2026-11-24 12:07 UTC · original

Tested on a hybrid laptop: Intel Iris Xe + RTX 3070 Ti Laptop (NVIDIA driver 610.88), Windows 11 build 26300.

  • On main the device is created on the default adapter, which on this laptop is the Iris Xe (adapter 0; checked with a D3D12CreateDevice(None) probe).
  • With this PR as it is (513eb91) the log reads host D3D12 device ready adapter=NVIDIA GeForce RTX 3070 Ti Laptop GPU vendor=0x10de device=0x24a0 vram_mb=8017, and the menus run at 30 fps.

Note: the branch no longer merges cleanly into main at ffe310e: there is a conflict in crates/victory-gpu/src/host.rs.

**@⁠Ilokaxt** on GitHub · 2026-11-24 12:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/94#issuecomment-7130992950) Tested on a hybrid laptop: Intel Iris Xe + **RTX 3070 Ti Laptop** (NVIDIA driver 610.88), Windows 11 build 26300. - On `main` the device is created on the default adapter, which on this laptop is the **Iris Xe** (adapter 0; checked with a `D3D12CreateDevice(None)` probe). - With this PR as it is (`513eb91`) the log reads `host D3D12 device ready adapter=NVIDIA GeForce RTX 3070 Ti Laptop GPU vendor=0x10de device=0x24a0 vram_mb=8017`, and the menus run at 30 fps. Note: the branch no longer merges cleanly into `main` at `ffe310e`: there is a conflict in `crates/victory-gpu/src/host.rs`.

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!94
No description provided.