From 42363ab6cd5265f0fb3b500ad265f2b84c6b5dbf Mon Sep 17 00:00:00 2001 From: Marvis Date: Wed, 25 Nov 2026 01:42:12 +0100 Subject: [PATCH] Tests: hardware-only shader checks skip on a machine without a GPU GitHub's Windows runner has no GPU, so the default adapter the shader tests call "hardware" was WARP. The gather test then ran its hardware-only rounding check on WARP, and the permute test (a wave of 32, which WARP refuses) ran on no device; both failed every CI run. The test host now refuses a software default adapter, and the permute test skips when only WARP is there (a refused pipeline on hardware is an error). Co-Authored-By: Claude Opus 5.5 --- crates/victory-shader/src/emit/host.rs | 21 ++++++++++++------- .../src/emit/synthetic_tests.rs | 4 +--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/victory-shader/src/emit/host.rs b/crates/victory-shader/src/emit/host.rs index e783baa..1147c78 100644 --- a/crates/victory-shader/src/emit/host.rs +++ b/crates/victory-shader/src/emit/host.rs @@ -64,19 +64,26 @@ fn err(e: windows::core::Error) -> String { 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 + /// refused, so hardware-only checks never run on WARP. pub fn new(warp: bool) -> Result { let warp = warp || std::env::var("VICTORY_WARP").is_ok_and(|v| v == "1"); // SAFETY: plain D3D12/DXGI calls with valid out pointers. unsafe { let mut device: Option = None; - if warp { - let factory: IDXGIFactory4 = - CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).map_err(err)?; - let adapter: IDXGIAdapter = factory.EnumWarpAdapter().map_err(err)?; - D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device).map_err(err)?; + let factory: IDXGIFactory4 = + CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).map_err(err)?; + let adapter: IDXGIAdapter1 = if warp { + factory.EnumWarpAdapter().map_err(err)? } else { - D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device).map_err(err)?; - } + 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 + }; + D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device).map_err(err)?; let device = device.ok_or("no device")?; let mut sm = D3D12_FEATURE_DATA_SHADER_MODEL { HighestShaderModel: D3D_SHADER_MODEL_6_6, diff --git a/crates/victory-shader/src/emit/synthetic_tests.rs b/crates/victory-shader/src/emit/synthetic_tests.rs index c2b2d34..48b92c4 100644 --- a/crates/victory-shader/src/emit/synthetic_tests.rs +++ b/crates/victory-shader/src/emit/synthetic_tests.rs @@ -329,7 +329,6 @@ fn permutes_read_the_lane_named_and_zero_from_lanes_left_out() { let _one = super::valu_tests::ONE_AT_A_TIME .lock() .unwrap_or_else(|e| e.into_inner()); - let mut ran = 0; for (label, warp) in [("hardware", false), ("warp", true)] { let Ok(host) = Host::new(warp) else { eprintln!("no SM 6.6 {label} device; skipped"); @@ -337,6 +336,7 @@ fn permutes_read_the_lane_named_and_zero_from_lanes_left_out() { }; // The program declares the console's wave of 32, which WARP refuses. let Ok((root, pso)) = host.compute_pipeline(&shader) else { + assert!(warp, "{label}: no pipeline for a wave of 32"); eprintln!("{label}: no pipeline for a wave of 32; skipped"); continue; }; @@ -354,9 +354,7 @@ fn permutes_read_the_lane_named_and_zero_from_lanes_left_out() { ) .unwrap_or_else(|e| panic!("{label}: dispatch failed: {e}")); assert_eq!(out[0], want, "{label}"); - ran += 1; } - assert!(ran > 0, "no device ran the permute"); } #[test]