Skip to content

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

Open
AscilCH wants to merge 1 commit into
Marvisak:mainfrom
AscilCH:fix/shader-host-high-perf-adapter
Open

AscilCH wants to merge 1 commit into
Marvisak:mainfrom
AscilCH:fix/shader-host-high-perf-adapter

Conversation

@AscilCH

@AscilCH AscilCH commented Nov 24, 2026

Copy link
Copy Markdown

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

…:Host::new

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 Marvisak#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.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

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:

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

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

Copy link
Copy Markdown
Owner

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

@rminzao

rminzao commented Nov 25, 2026

Copy link
Copy Markdown

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants