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

Open
github-bot wants to merge 1 commit from github-bot/gh-2367 into main AGit
Owner

@⁠PanS4ge on GitHub · 2026-11-25 11:59 UTC · original
PanS4ge:gpu-adapter-selection → main · +160 −1 · 2 files · 1 commits · open

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.
**@⁠PanS4ge** on GitHub · 2026-11-25 11:59 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367) `PanS4ge:gpu-adapter-selection` → `main` · +160 −1 · 2 files · 1 commits · open 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=<spec> 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:03:42 +00:00
Author
Owner

@⁠welisonzika14-jpg on GitHub · 2026-11-25 12:25 UTC · original

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.

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 12:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367#issuecomment-7162344014) 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.
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 12:43 UTC · original

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.

**@⁠KainanP** on GitHub · 2026-11-25 12:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367#issuecomment-7162772376) 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._
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 14:50 UTC · original · edited 2026-11-25 16:01 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 14:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367#issuecomment-7165909482) · edited 2026-11-25 16:01 UTC <!-- victory-triage v1 head=d8e3d9f1bebaecbc8892f97de2dfea8d4050a8fd verdict=needs-rebase at=2026-11-25T16:01:20Z --> 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](https://claude.ai/code)_
github-bot force-pushed github-bot/gh-2367 from d8e3d9f1be to e405bb2697 2026-11-26 11:33:37 +00:00 Compare
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 12:36 UTC · original · reviewed

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

**@⁠catminou4** on GitHub · 2026-11-25 12:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367#pullrequestreview-6057696504) · **reviewed** 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).
Author
Owner

@⁠PanS4ge on GitHub · 2026-11-26 11:21 UTC · original

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).
**@⁠PanS4ge** on GitHub · 2026-11-26 11:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2367#issuecomment-7190626068) 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).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2367/head:github-bot/gh-2367'
git switch 'github-bot/gh-2367'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2367'
git switch 'github-bot/gh-2367'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2367'
git switch 'github-bot/gh-2367'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2367'
git switch 'main'
git merge --squash 'github-bot/gh-2367'
git switch 'main'
git merge --ff-only 'github-bot/gh-2367'
git switch 'main'
git merge 'github-bot/gh-2367'
git push origin 'main'
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!2367
No description provided.