GPU: make the device on the high-performance adapter, not the default #27

Open
iNaxxs wants to merge 1 commit from upstream-pr/27 into main
iNaxxs commented 2026-11-25 04:11:28 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by iNaxxs on 2026-11-25T03:54:12Z.


The problem

create() in crates/victory-gpu/src/host.rs makes the host device with

D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device)?;

None means the system's default adapter. On a laptop with switchable
graphics DXGI reports the integrated GPU first, so the device is made on
that one. On this machine (Ryzen 5 8645HS, Radeon 760M + RTX 4050 Laptop
GPU, Windows 11) DXGI reports:

adapter 0: AMD Radeon(TM) Graphics (vendor 0x1002, 418 MiB dedicated, flags 0x0)
adapter 1: NVIDIA GeForce RTX 4050 Laptop GPU (vendor 0x10de, 5920 MiB dedicated, flags 0x0)
adapter 2: Microsoft Basic Render Driver (vendor 0x1414, 0 MiB dedicated, flags 0x2)

(adapter 0 is the integrated Radeon 760M, which DXGI names "AMD Radeon(TM) Graphics".)

Every submission went to the Radeon, whose wave width is not the one the
translator is tuned for (set_host_max_wave right below takes whatever the
device reports). Nothing in the log said which card had been taken, and none
of the VICTORY_* switches picks one.

The change

  • discrete_adapter() asks DXGI for the high-performance adapter
    (IDXGIFactory6::EnumAdapterByGpuPreference), refuses a software one, and
    returns None when DXGI is too old to be asked or has nothing to offer.
    create() then falls back to the old None behaviour, so a desktop with
    one card is unaffected.
  • The adapter the device landed on is named in the log at info level
    (host adapter), with its vendor and dedicated memory.
  • adapters_on_this_machine (ignored, on demand) reports what the machine
    has and which card was taken.
  • the_high_performance_adapter_is_never_software runs everywhere and
    returns early when DXGI has nothing to prefer.

The VICTORY_D3D12_WARP path is untouched.

Checks on this machine

cargo build --release -p victory ok
cargo clippy --all-targets -- -D warnings no warnings
cargo xtask policy 170 files ok
cargo test 497 passed, 0 failed, 8 ignored
adapters_on_this_machine after the change the host device is on NVIDIA GeForce RTX 4050 Laptop GPU

Before the change the same suite passed with 496 tests, every GPU test among
them running on the Radeon.

cargo fmt --check fails on main without this change, on 56 files across
every crate, mostly lines over 100 columns that rustfmt wants to wrap. This
change adds one such line, in adapter_name, in the style of the code around
it. Happy to split it, or to leave formatting to a decision of yours.

Not covered

No game files here, so this is the platform side only: the device is made on
the right card and the suite passes. Whether the frame rate or the known
shadow and exposure problems change on an RTX 4050 is untested.


🤖 Generated with Claude Code

https://claude.ai/code/session_013pnbLtdoTFoEWJQyG7rozM

<!-- greyfinch-sync:Zettrox/ztrx:issue:6596836363 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/27). Originally posted by [iNaxxs](https://github.com/iNaxxs) on 2026-11-25T03:54:12Z. --- ## The problem `create()` in `crates/victory-gpu/src/host.rs` makes the host device with ```rust D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device)?; ``` `None` means the system's default adapter. On a laptop with switchable graphics DXGI reports the integrated GPU first, so the device is made on that one. On this machine (Ryzen 5 8645HS, Radeon 760M + RTX 4050 Laptop GPU, Windows 11) DXGI reports: ``` adapter 0: AMD Radeon(TM) Graphics (vendor 0x1002, 418 MiB dedicated, flags 0x0) adapter 1: NVIDIA GeForce RTX 4050 Laptop GPU (vendor 0x10de, 5920 MiB dedicated, flags 0x0) adapter 2: Microsoft Basic Render Driver (vendor 0x1414, 0 MiB dedicated, flags 0x2) ``` (adapter 0 is the integrated Radeon 760M, which DXGI names "AMD Radeon(TM) Graphics".) Every submission went to the Radeon, whose wave width is not the one the translator is tuned for (`set_host_max_wave` right below takes whatever the device reports). Nothing in the log said which card had been taken, and none of the `VICTORY_*` switches picks one. ## The change - `discrete_adapter()` asks DXGI for the high-performance adapter (`IDXGIFactory6::EnumAdapterByGpuPreference`), refuses a software one, and returns `None` when DXGI is too old to be asked or has nothing to offer. `create()` then falls back to the old `None` behaviour, so a desktop with one card is unaffected. - The adapter the device landed on is named in the log at info level (`host adapter`), with its vendor and dedicated memory. - `adapters_on_this_machine` (ignored, on demand) reports what the machine has and which card was taken. - `the_high_performance_adapter_is_never_software` runs everywhere and returns early when DXGI has nothing to prefer. The `VICTORY_D3D12_WARP` path is untouched. ## Checks on this machine | | | |---|---| | `cargo build --release -p victory` | ok | | `cargo clippy --all-targets -- -D warnings` | no warnings | | `cargo xtask policy` | 170 files ok | | `cargo test` | 497 passed, 0 failed, 8 ignored | | `adapters_on_this_machine` after the change | the host device is on NVIDIA GeForce RTX 4050 Laptop GPU | Before the change the same suite passed with 496 tests, every GPU test among them running on the Radeon. `cargo fmt --check` fails on `main` without this change, on 56 files across every crate, mostly lines over 100 columns that rustfmt wants to wrap. This change adds one such line, in `adapter_name`, in the style of the code around it. Happy to split it, or to leave formatting to a decision of yours. ## Not covered No game files here, so this is the platform side only: the device is made on the right card and the suite passes. Whether the frame rate or the known shadow and exposure problems change on an RTX 4050 is untested. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_013pnbLtdoTFoEWJQyG7rozM
futurepro62 commented 2026-11-25 07:06:30 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by futurepro62 on 2026-11-25T06:38:29Z.


Full-suite run on Windows, since this PR has no test report yet. Tested exact head a4da48b (on its base 90b529f).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (rust-toolchain.toml), DXC + dxil.dll 1.9.2602.17, debug.
  • cargo test --workspace --locked: 497 passed, 0 failed, 8 ignored (main 90b529f on this machine: 496 passed, 0 failed, 7 ignored).
  • cargo clippy --workspace --all-targets --locked -- -D warnings (the CI lint step): passed.
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (the CI lint step): passed.
  • The new tests ran and passed: the_high_performance_adapter_is_never_software.
  • The new #[ignore] test adapters_on_this_machine, run on its own with --ignored --nocapture (this machine has a discrete NVIDIA card and an AMD iGPU), passed:
    adapter 0: NVIDIA GeForce RTX 5070 Ti (vendor 0x10de, 15995 MiB dedicated, flags 0x0)
    adapter 1: AMD Radeon(TM) Graphics (vendor 0x1002, 485 MiB dedicated, flags 0x0)
    adapter 2: Microsoft Basic Render Driver (vendor 0x1414, 0 MiB dedicated, flags 0x2)
    the host device is on NVIDIA GeForce RTX 5070 Ti
    

Not tested

  • AMD (ztrx targets NVIDIA), a release build, the game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Zettrox/ztrx:comment:7155004089 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/27#issuecomment-7155004089). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-25T06:38:29Z. --- Full-suite run on Windows, since this PR has no test report yet. Tested exact head `a4da48b` (on its base `90b529f`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (`rust-toolchain.toml`), DXC + dxil.dll 1.9.2602.17, debug. - `cargo test --workspace --locked`: **497 passed, 0 failed, 8 ignored** (main `90b529f` on this machine: 496 passed, 0 failed, 7 ignored). - `cargo clippy --workspace --all-targets --locked -- -D warnings` (the CI lint step): passed. - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (the CI lint step): passed. - The new tests ran and passed: `the_high_performance_adapter_is_never_software`. - The new `#[ignore]` test `adapters_on_this_machine`, run on its own with `--ignored --nocapture` (this machine has a discrete NVIDIA card and an AMD iGPU), passed: ``` adapter 0: NVIDIA GeForce RTX 5070 Ti (vendor 0x10de, 15995 MiB dedicated, flags 0x0) adapter 1: AMD Radeon(TM) Graphics (vendor 0x1002, 485 MiB dedicated, flags 0x0) adapter 2: Microsoft Basic Render Driver (vendor 0x1414, 0 MiB dedicated, flags 0x2) the host device is on NVIDIA GeForce RTX 5070 Ti ``` **Not tested** - AMD (ztrx targets NVIDIA), a release build, the game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27:upstream-pr/27'
git switch 'upstream-pr/27'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/27'
git switch 'upstream-pr/27'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27'
git switch 'upstream-pr/27'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27'
git switch 'main'
git merge --squash 'upstream-pr/27'
git switch 'main'
git merge --ff-only 'upstream-pr/27'
git switch 'main'
git merge 'upstream-pr/27'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Zettrox/ztrx!27
No description provided.