Skip to content

GPU: select host DXGI adapter via VICTORY_ADAPTER and log GPU - #2367

Open
PanS4ge wants to merge 1 commit into
Marvisak:mainfrom
PanS4ge:gpu-adapter-selection
Open

PanS4ge wants to merge 1 commit into
Marvisak:mainfrom
PanS4ge:gpu-adapter-selection

Conversation

@PanS4ge

@PanS4ge PanS4ge commented Nov 25, 2026

Copy link
Copy Markdown

Relates to #1736 (reported difficulty choosing between iGPU and dGPU on dual-GPU laptops).

  • Default host D3D12 device creation to DXGI's high-performance hardware adapter (DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE), instead of passing None (DXGI adapter ).
  • Add VICTORY_ADAPTER= to select a specific GPU: dgpu / high-performance, igpu / minimum-power, numeric DXGI adapter index, or case-insensitive adapter name substring (skipping software adapters).
  • Log the resolved adapter name, vendor ID, and dedicated VRAM (host GPU ...) at startup.
  • Document VICTORY_ADAPTER in README.md.

Verification

  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings - passed.
  • cargo test -p xtask --locked - 6 passed (including
    epository_passes_policy).
  • cargo test -p victory-gpu --lib --locked adapter - 3 passed (�dapter_spec_parses_presets_indices_and_names, �dapter_name_trims_trailing_nulls, warp_adapter_accepts_only_software).
  • VICTORY_ADAPTER=igpu cargo test -p victory-gpu --lib --locked - 145 passed, 0 failed, 2 ignored on AMD Radeon 780M Graphics.

@welisonzika14-jpg

Copy link
Copy Markdown

First run on NVIDIA hardware here, as far as I can see. RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head d8e3d9f merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

The PR's new test(s) pass on this card: host::tests::adapter_spec_parses_presets_indices_and_names, host::tests::adapter_name_trims_trailing_nulls. The rest is the same as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-shader), nothing new.

One run, unit tests only, title not run.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

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

VICTORY_ADAPTER selects host GPU (dgpu/igpu/index/name substring). 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. Cluster warning: this is the third adapter-selection PR — #2371 (high-performance FL12 preference) and the conflicted #1889 overlap the same host.rs create() device selection lines. #2367 and #2371 both rewrite the same D3D12CreateDevice call path; whichever merges second conflicts. Suggest converging on one (this one is the most configurable).

@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

Tested head d8e3d9f (identical to a merge onto main 940d32f) on a dual-GPU laptop. DXGI adapter 0 is an RTX 4060 Laptop (driver 610.47 / 32.0.16.1047), 1 is Intel UHD 8086:a78b (31.0.101.5445), 2 is Microsoft Basic Render Driver. Windows 11 26200, Rust 1.98.1 MSVC, no game data.

cargo test installs no tracing subscriber, so the new host GPU line is not printed there. To see it, I temporarily added a local test (not pushed) that sets a print-everything subscriber and calls host(). It also checks the device's GetAdapterLuid against EnumAdapters1. Both always agreed.

VICTORY_ADAPTER logged
unset / 0 / DGPU / nvidia host GPU name=NVIDIA GeForce RTX 4060 Laptop GPU vendor=0x10de dedicated_mib=7956
igpu / 1 / Intel / intel(r) uhd host GPU name=Intel(R) UHD Graphics vendor=0x8086 dedicated_mib=128
2 host GPU name=Microsoft Basic Render Driver vendor=0x1414 dedicated_mib=0
7 WARN VICTORY_ADAPTER index matched no GPU; using default index=7, then RTX 4060
Radeon / Microsoft Basic WARN VICTORY_ADAPTER matched no GPU; using default, then RTX 4060
diagnostics build, VICTORY_D3D12_WARP=1 (± VICTORY_ADAPTER=Intel) host device on the software adapter (WARP), host GPU name=Microsoft Basic Render Driver

cargo test -p victory-gpu --lib --locked --no-fail-fast (probe skipped):

  • unset: 143 passed / 2 failed / 2 ignored. These are the 2 NVIDIA view-heap failures (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views).
  • Intel, igpu, 1: 142 / 3 / 2 each. That matches main 940d32f on this iGPU (140 / 3, from an earlier local hook) plus this PR's 2 tests. The third failure is a_texture_written_in_one_format_reads_in_another_through_a_placed_view.
  • Radeon (no match): 143 / 2 / 2, i.e. back on NVIDIA.

The switch works. All four spellings reach the iGPU, matching is case-insensitive, and the log line names the adapter actually used. Notes:

  1. An invalid value falls back without a hard error. It warns, and in the title the WARN plus the host GPU line make that visible. Under cargo test it is invisible: a typo gives NVIDIA results and nothing says so.
  2. The fallback is not the documented default. A failed index, name or preference returns None, which reaches D3D12CreateDevice(None, …), i.e. DXGI adapter 0. Unset uses the high-performance preference. On laptops where adapter 0 is the iGPU, a typo would land on the iGPU while the README says dgpu is the default. Both are the RTX here, so this is from reading the code. Falling back to by_pref(HIGH_PERFORMANCE) would make them agree.
  3. A numeric index does not skip software adapters, while names and presets do. =2 puts the title's host on WARP in a non-diagnostics build, which VICTORY_D3D12_WARP otherwise gates behind that feature. With VICTORY_D3D12_WARP=1, WARP wins and VICTORY_ADAPTER is silently ignored. That is fine, but worth a word in the README.

Relation to #1889. No conflict: git merge-tree is clean for each PR onto main and for the two together. They are complementary, not duplicates: #1889 picks the adapter for victory-shader's test Host::new, this PR picks it for victory-gpu's title host. But both read VICTORY_ADAPTER with different grammars. #1889 accepts only an index, and any other value is an error there, including for WARP. With both merged, VICTORY_ADAPTER=igpu (as documented here) makes cargo test -p victory-shader fail 75 tests (measured on #1889's head with =Intel). Indices mean the same in both (EnumAdapters1 order). Sharing one parser would fix it, since victory-gpu already depends on victory-shader with host; otherwise, one PR could adopt the other's spellings.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in README.md, crates/victory-gpu/src/host.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (needs-work) was for an older state of main.


Generated by Claude Code

@PanS4ge
PanS4ge force-pushed the gpu-adapter-selection branch from d8e3d9f to e405bb2 Compare November 26, 2026 11:21
@PanS4ge

PanS4ge commented Nov 26, 2026

Copy link
Copy Markdown
Author

Rebased onto current main (63bcca4) to resolve conflicts in README.md and crates/victory-gpu/src/host.rs, and addressed review feedback from @KainanP and @catminou4:

  1. Consistent high-performance fallback: when a VICTORY_ADAPTER preference, index, or substring fails to match a hardware GPU, selected_adapter() now falls back to �y_pref(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) instead of returning None (which fell back to DXGI adapter �).
  2. Exclude software adapters for numeric indices: AdapterSpec::Index now also filters out DXGI_ADAPTER_FLAG_SOFTWARE, keeping VICTORY_D3D12_WARP=1 (diagnostics) as the single gate for WARP.
  3. Docs: clarified in README.md that VICTORY_ADAPTER selects a hardware GPU and is ignored when VICTORY_D3D12_WARP=1 is active.

Verification on e405bb2

  • cargo clippy --workspace --all-targets --locked -- -D warnings - passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - passed.
  • cargo test -p xtask --locked - 6 passed, 0 failed.
  • VICTORY_ADAPTER=igpu cargo test -p victory-gpu --lib --locked - 233 passed, 0 failed, 1 ignored (on AMD Radeon 780M Graphics).

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.

5 participants