Skip to content

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

Closed
lordon1a wants to merge 4 commits into
Marvisak:mainfrom
lordon1a:feat/high-performance-adapter
Closed

lordon1a wants to merge 4 commits into
Marvisak:mainfrom
lordon1a:feat/high-performance-adapter

Conversation

@lordon1a

Copy link
Copy Markdown
Contributor

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.

Copilot AI balanced review requested due to automatic review settings November 24, 2026 00:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@DaviTostes

Copy link
Copy Markdown

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, Wine/vkd3d: deferred uploads are skipped because VirtualQuery() reports mapped memory as MEM_FREE #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).

…-adapter

# Conflicts:
#	crates/victory-gpu/src/host.rs
@Lyrnc

Lyrnc commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 Shaders: ds_swizzle_b32 offsets from 0xC000 are the rotate and FFT modes #606.

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

@Ilokaxt

Ilokaxt commented Nov 24, 2026

Copy link
Copy Markdown

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.

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