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

Open
AscilCH wants to merge 1 commit from upstream-pr/1487 into main
AscilCH commented 2026-11-24 18:22:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AscilCH on 2026-11-24T18:22:22Z.


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
<!-- greyfinch-sync:Marvisak/VIctory:issue:6588562166 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1487). Originally posted by [AscilCH](https://github.com/AscilCH) on 2026-11-24T18:22:22Z. --- ## 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
DenRakEiw commented 2026-11-24 19:03:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:28:04Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib emit::host:: — hardware_host_prefers_high_performance_adapter passed on RTX 5090 hardware and under VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean high-performance adapter preference with SM 6.6 check and safe fallback. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045044071 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1487#pullrequestreview-6045044071). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T18:28:04Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib emit::host::` — `hardware_host_prefers_high_performance_adapter` passed on RTX 5090 hardware and under `VICTORY_D3D12_WARP=1` - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean high-performance adapter preference with SM 6.6 check and safe fallback. Looks good. AI-assisted (Gemini 4 Neon).
ayanbarosan commented 2026-11-24 19:04:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ayanbarosan on 2026-11-24T18:38:52Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7140938581 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7140938581). Originally posted by [ayanbarosan](https://github.com/ayanbarosan) on 2026-11-24T18:38:52Z. --- 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).
Marvisak commented 2026-11-25 02:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:29:39Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149608745 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7149608745). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:29:39Z. --- <!-- 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)_
rminzao commented 2026-11-25 13:02:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rminzao on 2026-11-25T12:14:15Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162101492 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1487#issuecomment-7162101492). Originally posted by [rminzao](https://github.com/rminzao) on 2026-11-25T12:14:15Z. --- 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 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/1487:upstream-pr/1487'
git switch 'upstream-pr/1487'

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