Shader tests: prefer high-performance hardware adapter in emit::host::Host::new #1487

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

@⁠AscilCH on GitHub · 2026-11-24 18:22 UTC · original
AscilCH:fix/shader-host-high-perf-adapter → main · +143 −21 · 1 files · 1 commits · open

Problem

Addresses point 1 of #1132.

On hybrid/dual-GPU Windows machines (e.g. integrated Intel UHD Graphics at adapter index 0 + discrete NVIDIA GeForce RTX 3050 at adapter index 1), emit::host::Host::new(false) called D3D12CreateDevice(None, ...), which always picks DXGI adapter 0 (the integrated GPU) instead of the high-performance discrete GPU.

Before this fix, running cargo test -p victory-shader on a dual-GPU laptop silently executed hardware shader tests on Intel(R) UHD Graphics (32.0.101.6078) rather than NVIDIA GeForce RTX 3050 6GB Laptop GPU (32.0.16.1742), causing tests to hit iGPU driver quirks (such as 16-lane wave limits and Intel Xe med3 NaN behavior).

Fix

  • Extracted check_sm66 in crates/victory-shader/src/emit/host.rs.
  • In Host::new(false), enumerate hardware adapters via IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE), skipping DXGI_ADAPTER_FLAG_SOFTWARE, and select the first hardware adapter that creates a D3D12 device supporting SM 6.6.
  • Fall back to D3D12CreateDevice(None, ...) if IDXGIFactory6 is unavailable or no hardware adapter succeeds (preserving WARP-only CI environments).
  • Added emit::host::tests::hardware_host_prefers_high_performance_adapter verifying that Host::new(false) selects the first non-software SM 6.6 high-performance adapter (and passes cleanly under VICTORY_WARP=1 or on WARP-only hosts).

(Orthogonal to #1138, which addresses victory-gpu runtime adapter selection rather than the victory-shader test host.)

Verification

Tested on Windows 11 with Intel UHD Graphics (Adapter 0) + NVIDIA GeForce RTX 3050 6GB Laptop GPU (Adapter 1):

  • Verified Host::new(false) now selects NVIDIA GeForce RTX 3050 6GB Laptop GPU instead of Intel(R) UHD Graphics.
  • rustfmt --edition 2024 --check crates/victory-shader/src/emit/host.rs: clean
  • cargo test -p victory-shader --locked -- --test-threads=1 (RTX 3050 + WARP + dxil.dll): 121 passed, 0 failed
  • VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1: 121 passed, 0 failed
  • cargo xtask policy: 154 files ok
  • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
**@⁠AscilCH** on GitHub · 2026-11-24 18:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/1487) `AscilCH:fix/shader-host-high-perf-adapter` → `main` · +143 −21 · 1 files · 1 commits · open ## Problem Addresses point 1 of #1132. On hybrid/dual-GPU Windows machines (e.g. integrated Intel UHD Graphics at adapter index 0 + discrete NVIDIA GeForce RTX 3050 at adapter index 1), `emit::host::Host::new(false)` called `D3D12CreateDevice(None, ...)`, which always picks DXGI adapter 0 (the integrated GPU) instead of the high-performance discrete GPU. Before this fix, running `cargo test -p victory-shader` on a dual-GPU laptop silently executed hardware shader tests on `Intel(R) UHD Graphics` (`32.0.101.6078`) rather than `NVIDIA GeForce RTX 3050 6GB Laptop GPU` (`32.0.16.1742`), causing tests to hit iGPU driver quirks (such as 16-lane wave limits and Intel Xe `med3` NaN behavior). ## Fix - Extracted `check_sm66` in `crates/victory-shader/src/emit/host.rs`. - In `Host::new(false)`, enumerate hardware adapters via `IDXGIFactory6::EnumAdapterByGpuPreference(..., DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE)`, skipping `DXGI_ADAPTER_FLAG_SOFTWARE`, and select the first hardware adapter that creates a D3D12 device supporting SM 6.6. - Fall back to `D3D12CreateDevice(None, ...)` if `IDXGIFactory6` is unavailable or no hardware adapter succeeds (preserving WARP-only CI environments). - Added `emit::host::tests::hardware_host_prefers_high_performance_adapter` verifying that `Host::new(false)` selects the first non-software SM 6.6 high-performance adapter (and passes cleanly under `VICTORY_WARP=1` or on WARP-only hosts). *(Orthogonal to #1138, which addresses `victory-gpu` runtime adapter selection rather than the `victory-shader` test host.)* ## Verification Tested on Windows 11 with Intel UHD Graphics (Adapter 0) + NVIDIA GeForce RTX 3050 6GB Laptop GPU (Adapter 1): - Verified `Host::new(false)` now selects `NVIDIA GeForce RTX 3050 6GB Laptop GPU` instead of `Intel(R) UHD Graphics`. - `rustfmt --edition 2024 --check crates/victory-shader/src/emit/host.rs`: clean - `cargo test -p victory-shader --locked -- --test-threads=1` (RTX 3050 + WARP + `dxil.dll`): 121 passed, 0 failed - `VICTORY_WARP=1 cargo test -p victory-shader --locked -- --test-threads=1`: 121 passed, 0 failed - `cargo xtask policy`: 154 files ok - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean
On hybrid / dual-GPU laptops, Host::new(false) called
D3D12CreateDevice(None, ...), which selects DXGI adapter 0 (typically
the integrated GPU) instead of the discrete GPU (reported in #1132).

Fix:
- In crates/victory-shader/src/emit/host.rs, enumerate hardware
  adapters via IDXGIFactory6::EnumAdapterByGpuPreference(...,
  DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE), skipping software adapters
  and selecting the first adapter that creates a D3D12 device with
  Shader Model 6.6 support.
- Fall back to D3D12CreateDevice(None, ...) when IDXGIFactory6 is
  unavailable or no non-software adapter is present (preserving WARP-only
  CI behavior).
- Add test emit::host::tests::hardware_host_prefers_high_performance_adapter.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:33:42 +00:00
Author
Owner

@⁠ayanbarosan on GitHub · 2026-11-24 18:38 UTC · original

Tested on a hybrid laptop like the one in the description: i5-11400H with Intel UHD Graphics (driver 31.0.101.5333) at DXGI adapter 0 and an RTX 3050 Laptop GPU (driver 610.91), Windows 11 build 26300. I cherry-picked 1455884 onto #1138's branch (main at ffe310e plus #1138). It applies cleanly.

cargo test -p victory-shader --locked --lib -- --test-threads=1 result
main + #1138 119 passed, 1 failed, 1 ignored. The failure is #726: hardware (Intel(R) UHD Graphics): v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1
main + #1138 + #1487 121 passed, 0 failed, 1 ignored
the same, with VICTORY_WARP=1 121 passed, 0 failed, 1 ignored

A local probe (not pushed) printed Host::new(false).adapter() as NVIDIA GeForce RTX 3050 Laptop GPU and Host::new(true).adapter() as Microsoft Basic Render Driver. On the combination, clippy on victory-shader (--all-targets, also with --all-features) is clean, and host.rs passes rustfmt.

On the note about #1138: it doesn't touch victory-gpu. It changes this same test host. Host::adapter() reads the device's adapter back, and the VALU and waterfall test labels include it, as in the first row. So the two fit together: #1487 picks the GPU, and #1138 names the GPU in each failure. With #1487, a laptop's default run no longer uses the iGPU, so the #726 failure stops showing there. Machines whose only GPU is an Intel one still hit it, and #110 and the branch on #745 both fix it.

Overlap: three other open PRs change adapter selection in this host.rs:

  • #94 adds the high-performance order plus a VICTORY_ADAPTER name filter. It no longer merges with main.
  • #439 adds a VICTORY_ADAPTER name filter and a hardware() check. That check treats the Microsoft Basic Render Driver as software when a CI runner lists it without the flag.
  • #1483 adds the high-performance order plus VICTORY_TEST_ADAPTER=n.

#1487 conflicts with #439 and with #1483 there. Whichever lands second could keep #1487's default together with a name or index override, which would also let a laptop run the suite on its iGPU.

No game data used. AI-assisted (Claude Code).

**@⁠ayanbarosan** on GitHub · 2026-11-24 18:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7140938581) Tested on a hybrid laptop like the one in the description: i5-11400H with Intel UHD Graphics (driver 31.0.101.5333) at DXGI adapter 0 and an RTX 3050 Laptop GPU (driver 610.91), Windows 11 build 26300. I cherry-picked 1455884 onto #1138's branch (`main` at ffe310e plus #1138). It applies cleanly. | `cargo test -p victory-shader --locked --lib -- --test-threads=1` | result | |---|---| | `main` + #1138 | 119 passed, 1 failed, 1 ignored. The failure is #726: `hardware (Intel(R) UHD Graphics): v_med3_f32(1.0, 2.0, NaN) = 2 (0x40000000), want 1` | | `main` + #1138 + #1487 | 121 passed, 0 failed, 1 ignored | | the same, with `VICTORY_WARP=1` | 121 passed, 0 failed, 1 ignored | A local probe (not pushed) printed `Host::new(false).adapter()` as `NVIDIA GeForce RTX 3050 Laptop GPU` and `Host::new(true).adapter()` as `Microsoft Basic Render Driver`. On the combination, clippy on `victory-shader` (`--all-targets`, also with `--all-features`) is clean, and `host.rs` passes rustfmt. On the note about #1138: it doesn't touch `victory-gpu`. It changes this same test host. `Host::adapter()` reads the device's adapter back, and the VALU and waterfall test labels include it, as in the first row. So the two fit together: #1487 picks the GPU, and #1138 names the GPU in each failure. With #1487, a laptop's default run no longer uses the iGPU, so the #726 failure stops showing there. Machines whose only GPU is an Intel one still hit it, and #110 and the branch on #745 both fix it. Overlap: three other open PRs change adapter selection in this `host.rs`: - #94 adds the high-performance order plus a `VICTORY_ADAPTER` name filter. It no longer merges with `main`. - #439 adds a `VICTORY_ADAPTER` name filter and a `hardware()` check. That check treats the Microsoft Basic Render Driver as software when a CI runner lists it without the flag. - #1483 adds the high-performance order plus `VICTORY_TEST_ADAPTER=n`. #1487 conflicts with #439 and with #1483 there. Whichever lands second could keep #1487's default together with a name or index override, which would also let a laptop run the suite on its iGPU. No game data used. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:29 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/host.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7149608745) <!-- victory-triage v1 head=1455884a28d734159ccf8ff20c3d405a6e2de7e0 verdict=needs-rebase at=2026-11-25T01:29:38Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/host.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠rminzao on GitHub · 2026-11-25 12:14 UTC · original

Read against the head (1455884) and current main (940d32f):

  • It conflicts with main's hardware_adapter() (ccfb029), which made Host::new(false) refuse machines without a GPU: !SOFTWARE && DedicatedVideoMemory > 0, because GitHub's runner lists Microsoft Basic Render Driver without the software flag and its device refuses wave32.
    • crates/victory-shader/src/emit/host.rs:117 filters on the flag only.
    • The fallback at :135 (D3D12CreateDevice(None)) accepts the software default adapter again. On a GPU-less runner that brings back the failure main just fixed. After a rebase, the fallback should be hardware_adapter() (or an error), not None.
  • The SM 6.6 probe per adapter (:120-128) is better than #1483's unprobed nth. Adding D3D12_OPTIONS1 (WaveOps, WaveLaneCountMax >= 32) to check_sm66 would also skip a 16-lane iGPU (Intel UHD reports 8..16 lanes) when it is first.
  • The test at :1445 repeats the selection logic it checks, so it mainly guards against the two copies drifting apart. That's fine, but it creates a device on every adapter.
  • #1483, #1889 (VICTORY_ADAPTER=n) and #439 change the same function, and #1138 labels test failures with the adapter. A single shape (high-performance order + probe + index/name override) would be easier to land.

Static review (AI-assisted), read against the PR head 1455884a28; nothing was run on a GPU.

**@⁠rminzao** on GitHub · 2026-11-25 12:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7162101492) Read against the head (`1455884`) and current `main` (`940d32f`): - It conflicts with `main`'s `hardware_adapter()` (ccfb029), which made `Host::new(false)` refuse machines without a GPU: `!SOFTWARE && DedicatedVideoMemory > 0`, because GitHub's runner lists `Microsoft Basic Render Driver` without the software flag and its device refuses wave32. - `crates/victory-shader/src/emit/host.rs:117` filters on the flag only. - The fallback at `:135` (`D3D12CreateDevice(None)`) accepts the software default adapter again. On a GPU-less runner that brings back the failure `main` just fixed. After a rebase, the fallback should be `hardware_adapter()` (or an error), not `None`. - The SM 6.6 probe per adapter (`:120-128`) is better than #1483's unprobed `nth`. Adding `D3D12_OPTIONS1` (`WaveOps`, `WaveLaneCountMax >= 32`) to `check_sm66` would also skip a 16-lane iGPU (Intel UHD reports 8..16 lanes) when it is first. - The test at `:1445` repeats the selection logic it checks, so it mainly guards against the two copies drifting apart. That's fine, but it creates a device on every adapter. - #1483, #1889 (`VICTORY_ADAPTER=n`) and #439 change the same function, and #1138 labels test failures with the adapter. A single shape (high-performance order + probe + index/name override) would be easier to land. _Static review (AI-assisted), read against the PR head 1455884a28d734159ccf8ff20c3d405a6e2de7e0; nothing was run on a GPU._
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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