Skip to content

Use the discrete GPU on laptops instead of the integrated one - #22

Open
spy0eye-beep wants to merge 1 commit into
PastiiJay:betafrom
spy0eye-beep:klbf-discrete-gpu
Open

spy0eye-beep wants to merge 1 commit into
PastiiJay:betafrom
spy0eye-beep:klbf-discrete-gpu

Conversation

@spy0eye-beep

Copy link
Copy Markdown

What

On a laptop with two GPUs, KLBF Lab made its D3D12 device on the default adapter, which Windows lists as the integrated GPU unless the user sets a per-app preference. So on a hybrid laptop the game, and every "hardware" shader test, run on the integrated GPU.

Found on an RTX 4060 Laptop GPU + Intel UHD Graphics (i7-13620H, Windows 11 24H2): adapter 0 is the Intel UHD, adapter 1 the RTX 4060.

Change

  • victory-gpu host: the first hardware adapter in DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE order that creates a D3D12 device is used, and its name is logged (host device adapter=...). If DXGI cannot order adapters it falls back to the default, as before. Software adapters (WARP, the Basic Render Driver) are never picked.
  • Shader test host (emit/host.rs): the same choice, so GPU tests run on the discrete GPU. VICTORY_TEST_ADAPTER=n takes the n-th hardware adapter in that order, to run the suite on each GPU of a machine. The adapter name is printed in test output only.
  • New test high_performance_adapter_is_hardware.

Note: this overrides a "power saving" choice made for victory.exe in Windows graphics settings, which is the usual behaviour for games.

Testing

cargo test --workspace --all-features on beta (c71c7d6), RTX 4060 Laptop + Intel UHD, Windows 11 24H2, Rust 1.98.1:

Build GPU the tests ran on Result
beta as published Intel UHD (default adapter) 580 passed, 9 failed
this PR RTX 4060 Laptop 587 passed, 2 failed
this PR, VICTORY_TEST_ADAPTER=1 Intel UHD 580 passed, the same 9 failed

7 of the 9 failures are Intel UHD driver behaviour (intersect_tests ×4, ds_min_max_f32..., v_permlane16..., whole_wave_f64...). The 2 left (emit::rect::tests::*) fail on beta too and are not touched here.

Also seen: in one run of beta as published on the Intel UHD, the victory-gpu test binary exited with STATUS_ACCESS_VIOLATION after watch::mapping_tests::reads_in_place_and_remappings_wait_for_each_other. It did not happen with this PR, but I did not look into it.

  • cargo check / cargo build --release -p victory: OK. cargo clippy -D warnings reports the same two errors with and without this PR (draw.rs sort_unstable_by_key, indirect.rs depth_written); none are new.
  • Not run with the title.

The same fix is open upstream as Marvisak/VIctory#1483.

AI-assisted (Claude).

🤖 Generated with Claude Code

The host device and the shader test host were made on the default adapter,
which on a laptop with two GPUs is the integrated one (adapter 0) unless the
user set a per-app preference in Windows. On an RTX 4060 Laptop + Intel UHD
machine the game and every "hardware" test ran on the Intel UHD.

Now the first hardware adapter in DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE order
that makes a D3D12 device is used, and its name is logged ("host device").
Falls back to the default adapter if DXGI cannot order them. Software
adapters (WARP, the Basic Render Driver) are never picked. For the tests,
VICTORY_TEST_ADAPTER=n takes the n-th hardware adapter in that order, so a
suite can be run on each GPU of a machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PastiiJay

Copy link
Copy Markdown
Owner

Thanks a lot @spy0eye-beep! Noted. It goes into tonight's RX 9070 XT test queue and I'll report the result here.

amirshaker000 pushed a commit to amirshaker000/PAG6Port that referenced this pull request Nov 25, 2026
The host device and the shader test host were made on the default adapter,
the integrated GPU on a laptop with two. Now the first hardware adapter in
DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE order that makes a D3D12 device is
used, its name logged; software adapters (WARP, the Basic Render Driver)
never. VICTORY_TEST_ADAPTER=n runs the tests on the n-th hardware adapter.
Same change as PastiiJay/klbf-lab#22 and Marvisak/VIctory#1483.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HandshakeHackin

Copy link
Copy Markdown
Contributor

On a Windows runner with no physical GPU, high_performance_adapter() at 6b4569b returned Microsoft Basic Render Driver as the preferred hardware adapter. Its DXGI descriptor was 1414:008c, flags 0x0. Explicit WARP had the same IDs, flags 0x2, and a different LUID. The PR’s shader host already recognizes both forms and correctly reports no hardware adapter. Original result

I tested a three-line change on top of this PR that gives the runtime selector the same PCI-ID check. It then returns None on this machine. The normal runtime still starts through its existing default fallback, and forcing WARP still selects the explicit software adapter. All three checks passed. The original laptop results remain the test of discrete-versus-integrated selection. Cherry-pick 7786134 · Windows verification

@PastiiJay

Copy link
Copy Markdown
Owner

Thanks for catching the Basic Render Driver case on GPU-less runners. We'll try it on a laptop before merging.

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.

4 participants