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")?;