gpu: prefer high-performance DXGI adapter on multi-GPU systems #245

Open
rudy-07 wants to merge 2 commits from upstream-pr/245 into main
rudy-07 commented 2026-11-30 16:55:24 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by rudy-07 on 2026-11-30T16:55:24Z.


On dual-GPU laptops (tested on AMD Radeon Graphics iGPU + AMD Radeon RX 5600M dGPU), D3D12CreateDevice(None, ...) picks the integrated GPU by default. Because the iGPU lacks SM 6.6 dynamic resource support, victory-shader hardware tests skipped and depth_bounds_pipeline_loads_and_filters_draws failed at CreateRootSignature with E_INVALIDARG (0x80070057).

Changes:

  • crates/victory-gpu/src/host.rs: enumerate hardware adapters with IDXGIFactory6::EnumAdapterByGpuPreference(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE) (skipping software adapters, falling back to None), and extract Host::shader_model_6_6() reused by Host::mesh_shaders().
  • crates/victory-shader/src/emit/host.rs: apply the same high-performance adapter preference in Host::new(false).
  • crates/victory-gpu/src/pipeline/host.rs: make direct-heap root signature flags conditional in root_signature(...) and pass false in depth_bounds_pipeline_loads_and_filters_draws, which does not use dynamic heap indexing.

Tested on Windows 11 x64, AMD Radeon RX 5600M (driver 32.0.21043.19003):

  • cargo clippy --workspace --all-targets --locked -- -D warnings: pass
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: pass
  • victory-gpu: 219 passed, 0 failed, 4 ignored
  • victory-shader: 115 passed, 0 failed
  • xtask: 4 passed, 0 failed
<!-- greyfinch-sync:DexNom/VIctory:issue:5569785265 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/245). Originally posted by [rudy-07](https://github.com/rudy-07) on 2026-11-30T16:55:24Z. --- On dual-GPU laptops (tested on AMD Radeon Graphics iGPU + AMD Radeon RX 5600M dGPU), `D3D12CreateDevice(None, ...)` picks the integrated GPU by default. Because the iGPU lacks SM 6.6 dynamic resource support, `victory-shader` hardware tests skipped and `depth_bounds_pipeline_loads_and_filters_draws` failed at `CreateRootSignature` with `E_INVALIDARG (0x80070057)`. Changes: - `crates/victory-gpu/src/host.rs`: enumerate hardware adapters with `IDXGIFactory6::EnumAdapterByGpuPreference(DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)` (skipping software adapters, falling back to `None`), and extract `Host::shader_model_6_6()` reused by `Host::mesh_shaders()`. - `crates/victory-shader/src/emit/host.rs`: apply the same high-performance adapter preference in `Host::new(false)`. - `crates/victory-gpu/src/pipeline/host.rs`: make direct-heap root signature flags conditional in `root_signature(...)` and pass `false` in `depth_bounds_pipeline_loads_and_filters_draws`, which does not use dynamic heap indexing. Tested on Windows 11 x64, AMD Radeon RX 5600M (driver 32.0.21043.19003): - `cargo clippy --workspace --all-targets --locked -- -D warnings`: pass - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: pass - `victory-gpu`: 219 passed, 0 failed, 4 ignored - `victory-shader`: 115 passed, 0 failed - `xtask`: 4 passed, 0 failed
Zippp69 commented 2026-11-30 17:38:35 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by Zippp69 on 2026-11-30T17:38:35Z.


Check SM 6.6 before ending adapter enumeration. On 9df1f9c, the shader test host stops at the first adapter that creates a feature-level 12.0 device. The SM 6.6 check runs after selection, so Host::new(false) can fail and hardware shader tests can skip even when a later adapter supports SM 6.6. Shader test host

I moved the existing shader-model query into require_shader_model_6_6(&ID3D12Device) and reused it for WARP and the default fallback. In the preferred hardware loop, after checking the adapter description and excluding software, the local patch selects a candidate only when both checks pass:

let mut candidate = None;
if D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut candidate).is_ok()
    && let Some(candidate) = candidate
    && require_shader_model_6_6(&candidate).is_ok()
{
    return Ok(Host { device: candidate });
}

The emit::valu_tests:: filter on Windows reported 22 passed, 0 failed, and 1 ignored. One passing test logged that its WARP pipeline was skipped. I did not verify the specific adapter ordering on a multi-GPU machine.

<!-- greyfinch-sync:DexNom/VIctory:comment:7286626907 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/245#issuecomment-7286626907). Originally posted by [Zippp69](https://github.com/Zippp69) on 2026-11-30T17:38:35Z. --- **Check SM 6.6 before ending adapter enumeration.** On `9df1f9c`, the shader test host stops at the first adapter that creates a feature-level 12.0 device. The SM 6.6 check runs after selection, so `Host::new(false)` can fail and hardware shader tests can skip even when a later adapter supports SM 6.6. [Shader test host](https://github.com/DexNom/VIctory/blob/9df1f9c987316a61e61d0a68d6b686899e57f386/crates/victory-shader/src/emit/host.rs#L105-L157) I moved the existing shader-model query into `require_shader_model_6_6(&ID3D12Device)` and reused it for WARP and the default fallback. In the preferred hardware loop, after checking the adapter description and excluding software, the local patch selects a candidate only when both checks pass: ```rust let mut candidate = None; if D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut candidate).is_ok() && let Some(candidate) = candidate && require_shader_model_6_6(&candidate).is_ok() { return Ok(Host { device: candidate }); } ``` The `emit::valu_tests::` filter on Windows reported 22 passed, 0 failed, and 1 ignored. One passing test logged that its WARP pipeline was skipped. I did not verify the specific adapter ordering on a multi-GPU machine.
rudy-07 commented 2026-11-30 17:54:41 +00:00 (Migrated from github.com)

Imported from DexNom/VIctory. Originally posted by rudy-07 on 2026-11-30T17:54:41Z.


Good catch, updated the branch:

  • crates/victory-shader/src/emit/host.rs: extracted require_shader_model_6_6 and reused it inside the high-performance adapter loop (so it keeps iterating if an earlier adapter lacks SM 6.6) as well as WARP and the default fallback.
  • crates/victory-gpu/src/host.rs: extracted device_supports_sm66 (reused by Host::shader_model_6_6) and updated create_high_performance_device to prefer an SM 6.6 hardware adapter while falling back to the first hardware adapter if none supports SM 6.6.

Re-verified victory-gpu (219 passed, 4 ignored), clippy (default & --all-features), and cargo xtask policy --staged.

<!-- greyfinch-sync:DexNom/VIctory:comment:7287030984 --> Imported from [DexNom/VIctory](https://github.com/DexNom/VIctory/pull/245#issuecomment-7287030984). Originally posted by [rudy-07](https://github.com/rudy-07) on 2026-11-30T17:54:41Z. --- Good catch, updated the branch: - `crates/victory-shader/src/emit/host.rs`: extracted `require_shader_model_6_6` and reused it inside the high-performance adapter loop (so it keeps iterating if an earlier adapter lacks SM 6.6) as well as WARP and the default fallback. - `crates/victory-gpu/src/host.rs`: extracted `device_supports_sm66` (reused by `Host::shader_model_6_6`) and updated `create_high_performance_device` to prefer an SM 6.6 hardware adapter while falling back to the first hardware adapter if none supports SM 6.6. Re-verified `victory-gpu` (219 passed, 4 ignored), `clippy` (default & `--all-features`), and `cargo xtask policy --staged`.
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/245:upstream-pr/245'
git switch 'upstream-pr/245'

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/245'
git switch 'upstream-pr/245'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/245'
git switch 'upstream-pr/245'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/245'
git switch 'main'
git merge --squash 'upstream-pr/245'
git switch 'main'
git merge --ff-only 'upstream-pr/245'
git switch 'main'
git merge 'upstream-pr/245'
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
DexNom/VIctory!245
No description provided.