From 3f031b8a71cd85722624ff0a5f984cea4f8d2850 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 25 Nov 2026 02:04:19 +0100 Subject: [PATCH] Tests: a machine with no GPU has no hardware adapter to check shaders on `main` at 42363ab is red in CI, on the same two tests, and its own fix did not cover it: emit::synthetic_tests::gathers_at_a_level_match_the_hardware ... FAILED hardware: lane 4 against its gather left [66, 67, 35, 34] right [65, 66, 34, 33] emit::synthetic_tests::permutes_read_the_lane_named_and_zero_from_lanes_left_out ... FAILED hardware: no pipeline for a wave of 32 Both are hardware-only: the first asks the hardware for its rounding, the second needs a wave of 32, which WARP refuses. 42363ab refuses a default adapter flagged DXGI_ADAPTER_FLAG_SOFTWARE, but on the runner the default adapter is not flagged software and its device still refuses a wave of 32, so `Host::new(false)` succeeded and the "hardware" runs were not hardware. The test host now asks for an adapter that is a GPU by two signs: not flagged software, and with dedicated video memory of its own (WARP and the basic render driver report none). It walks the adapters to the first one that is, and fails with "no hardware adapter" when there is none, which is the skip these tests already know how to take. On this machine (RTX 4090 and an integrated AMD, both with dedicated memory) nothing changes: `cargo test -p victory-shader --locked --lib` 246 passed, 3 ignored, and the two tests run and pass as before. --- crates/victory-shader/src/emit/host.rs | 36 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/victory-shader/src/emit/host.rs b/crates/victory-shader/src/emit/host.rs index 1147c78613..417f1c2182 100644 --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -62,6 +62,35 @@ fn err(e: windows::core::Error) -> String { e.message().to_string() } +/// The first adapter that is a GPU: not flagged software, and with video +/// memory of its own. A machine without one (GitHub's Windows runner has only +/// `Microsoft Basic Render Driver`) has nothing to run the hardware-only +/// checks on, and CI proved that the flag of adapter 0 alone is not enough: +/// the runner's default adapter is not flagged software and its device still +/// refuses a wave of 32 +/// (`permutes_read_the_lane_named_and_zero_from_lanes_left_out`). WARP and the +/// basic render driver report no dedicated video memory, which is what this +/// asks for as well. +fn hardware_adapter(factory: &IDXGIFactory4) -> windows::core::Result { + // SAFETY: plain DXGI adapter enumeration. + unsafe { + for index in 0.. { + let Ok(adapter) = factory.EnumAdapters1(index) else { + break; + }; + let desc = adapter.GetDesc1()?; + let software = desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0; + if !software && desc.DedicatedVideoMemory > 0 { + return Ok(adapter); + } + } + } + Err(windows::core::Error::new( + windows::Win32::Foundation::E_FAIL, + "no hardware adapter", + )) +} + impl Host { /// The default adapter, or WARP with `warp` (or `VICTORY_WARP=1`). /// A software default adapter (a machine without a GPU, as CI) is @@ -76,12 +105,7 @@ impl Host { let adapter: IDXGIAdapter1 = if warp { factory.EnumWarpAdapter().map_err(err)? } else { - let adapter = factory.EnumAdapters1(0).map_err(err)?; - if adapter.GetDesc1().map_err(err)?.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0 - { - return Err("no hardware adapter".into()); - } - adapter + hardware_adapter(&factory).map_err(err)? }; D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device).map_err(err)?; let device = device.ok_or("no device")?;