From 0b76b291cd0847f8675f916ea1c5cd7467514d50 Mon Sep 17 00:00:00 2001 From: T-Crypt Date: Mon, 23 Nov 2026 15:27:23 -0700 Subject: [PATCH] tests: skip hardware-only GPU tests on a software adapter The Windows runner has no GPU: DXGI offers the Microsoft Basic Render Driver, which DXGI does not flag as software and which reports D3D12 with mesh shader tier 1. Four tests that need a real device failed on it: two aperture tests (4 GiB reserved resources: E_OUTOFMEMORY from CreateReservedResource) and two two-pass pipeline tests (the driver rejects the translated rect-list GS and mesh pipelines with E_INVALIDARG). Recognize the Basic Render Driver by its vendor and device id (0x1414 / 0x008C) and by the DXGI software flag, and skip those tests with the existing SKIPPED : no GPU note, which scripts/test.ps1 counts and XCL_REQUIRE_GPU still turns into a failure. --- crates/xcl/src/gpu/adapter.rs | 14 ++++++++++++++ crates/xcl/src/gpu/adapter_tests.rs | 14 ++++++++++++++ crates/xcl/src/gpu/recomp/aperture_tests.rs | 5 +++++ crates/xcl/src/gpu/recomp/runner.rs | 17 +++++++++++++---- crates/xcl/src/hle/d3d12x/real.rs | 11 +++++++++++ crates/xcl/src/hle/d3d12x/two_pass_tests.rs | 6 ++++++ 6 files changed, 63 insertions(+), 4 deletions(-) diff --git a/crates/xcl/src/gpu/adapter.rs b/crates/xcl/src/gpu/adapter.rs index cd0b61f..6600ea4 100644 --- a/crates/xcl/src/gpu/adapter.rs +++ b/crates/xcl/src/gpu/adapter.rs @@ -115,6 +115,20 @@ pub(crate) fn select_indices>(names: &[S], sel: &Selector) -> Vec< Vec::new() } +/// Microsoft's Basic Render Driver (vendor 0x1414, device 0x008C): the adapter Windows +/// provides when no GPU driver is installed. It has a D3D12 device, but no GPU behind it. +pub fn basic_render_driver(desc: &DXGI_ADAPTER_DESC1) -> bool { + desc.VendorId == 0x1414 && desc.DeviceId == 0x008c +} + +/// Whether the adapter is a software renderer: WARP (which DXGI flags as software) or the +/// Basic Render Driver (not flagged, so recognized by vendor and device id). A software +/// device runs kernels, but it does not have the hardware features the GPU tests check +/// (sparse reservations, mesh pipelines, a 4 GiB aperture). +pub fn software(desc: &DXGI_ADAPTER_DESC1) -> bool { + desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0 || basic_render_driver(desc) +} + /// The adapter's name from its description. pub fn name(desc: &DXGI_ADAPTER_DESC1) -> String { let n = desc.Description.iter().position(|&c| c == 0).unwrap_or(desc.Description.len()); diff --git a/crates/xcl/src/gpu/adapter_tests.rs b/crates/xcl/src/gpu/adapter_tests.rs index 70fc209..b4c6ce4 100644 --- a/crates/xcl/src/gpu/adapter_tests.rs +++ b/crates/xcl/src/gpu/adapter_tests.rs @@ -1,4 +1,18 @@ use super::{select_indices, Selector}; +use windows::Win32::Graphics::Dxgi::*; + +#[test] +fn software_adapters_are_recognized() { + // the Basic Render Driver is not flagged software by DXGI, so its ids identify it + let basic = DXGI_ADAPTER_DESC1 { VendorId: 0x1414, DeviceId: 0x008c, ..Default::default() }; + assert!(super::basic_render_driver(&basic)); + assert!(super::software(&basic)); + let warp = DXGI_ADAPTER_DESC1 { Flags: DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32, ..Default::default() }; + assert!(super::software(&warp)); + let gpu = DXGI_ADAPTER_DESC1 { VendorId: 0x10de, DeviceId: 0x2684, ..Default::default() }; + assert!(!super::basic_render_driver(&gpu)); + assert!(!super::software(&gpu)); +} #[test] fn selector_parsing() { diff --git a/crates/xcl/src/gpu/recomp/aperture_tests.rs b/crates/xcl/src/gpu/recomp/aperture_tests.rs index 7a433e7..b2a6756 100644 --- a/crates/xcl/src/gpu/recomp/aperture_tests.rs +++ b/crates/xcl/src/gpu/recomp/aperture_tests.rs @@ -133,6 +133,11 @@ fn device() -> Option<(ID3D12Device, String)> { return None; } let (a, desc) = crate::gpu::adapter::candidates(&factory, &sel).into_iter().next()?; + if crate::gpu::adapter::software(&desc) { + // a software device cannot reserve sparse resources or map a 4 GiB aperture + super::runner::skip_test("no GPU"); + return None; + } let dev = crate::gpu::agility::create_device(&a, D3D_FEATURE_LEVEL_12_0).ok()?; Some((dev, crate::gpu::adapter::name(&desc))) } diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index 7ebe475..9699f3f 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -60,6 +60,9 @@ struct Gpu { fence: ID3D12Fence, value: u64, adapter: String, + /// a software renderer (WARP or the Basic Render Driver): kernels run, but the tests + /// that need sparse reservations or a real mesh pipeline skip + software: bool, wave64: bool, /// 32-lane waves (`[WaveSize(32)]`: the split wave64 form; WARP has neither 32 nor 64) wave32: bool, @@ -122,14 +125,14 @@ fn init() -> Result { let factory: IDXGIFactory6 = CreateDXGIFactory2(DXGI_CREATE_FACTORY_FLAGS(0)).map_err(werr)?; // `XCL_ADAPTER` picks the adapter (default: the first in high-performance order) let sel = crate::gpu::adapter::Selector::from_env_or("auto"); - let (adapter, name): (IDXGIAdapter1, String) = if sel == crate::gpu::adapter::Selector::Warp { - (factory.EnumWarpAdapter().map_err(werr)?, "WARP (software renderer)".into()) + let (adapter, name, software): (IDXGIAdapter1, String, bool) = if sel == crate::gpu::adapter::Selector::Warp { + (factory.EnumWarpAdapter().map_err(werr)?, "WARP (software renderer)".into(), true) } else { let (a, desc) = crate::gpu::adapter::candidates(&factory, &sel) .into_iter() .next() .ok_or_else(|| crate::gpu::adapter::no_match(&factory, &sel))?; - (a, crate::gpu::adapter::name(&desc)) + (a, crate::gpu::adapter::name(&desc), crate::gpu::adapter::software(&desc)) }; let dev = crate::gpu::agility::create_device(&adapter, D3D_FEATURE_LEVEL_12_0).map_err(werr)?; let mut sm = D3D12_FEATURE_DATA_SHADER_MODEL { HighestShaderModel: D3D_SHADER_MODEL_6_6 }; @@ -152,7 +155,7 @@ fn init() -> Result { dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC { Type: D3D12_COMMAND_LIST_TYPE_DIRECT, ..Default::default() }).map_err(werr)?; let rs = root_signature(&dev, false)?; let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).map_err(werr)?; - Ok(Gpu { dev, queue, rs, fence, value: 0, adapter: name, wave64, wave32, mesh }) + Ok(Gpu { dev, queue, rs, fence, value: 0, adapter: name, software, wave64, wave32, mesh }) } } @@ -395,6 +398,12 @@ pub fn adapter() -> Result { with_gpu(|g| Ok(g.adapter.clone())) } +/// Whether a hardware GPU backs the device: false on WARP and on the Basic Render Driver, +/// which run kernels but have no sparse reservations, real mesh pipeline or 4 GiB aperture. +pub fn hardware_gpu() -> bool { + with_gpu(|g| Ok(!g.software)).unwrap_or(false) +} + pub fn wave64_supported() -> Result { with_gpu(|g| Ok(g.wave64)) } diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 7d20879..9e33bb0 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -411,10 +411,19 @@ pub fn stats() -> D3d12Stats { static DEVICE: AtomicUsize = AtomicUsize::new(0); +/// The backend device runs on a software adapter (WARP or the Basic Render Driver). +static SOFTWARE_ADAPTER: AtomicBool = AtomicBool::new(false); + pub fn device_raw() -> *mut c_void { DEVICE.load(Ordering::Acquire) as *mut c_void } +/// Whether the backend device is a software renderer: it draws, but it has no sparse +/// reservations, real mesh pipeline or 4 GiB aperture, so tests that check those skip. +pub fn software_adapter() -> bool { + SOFTWARE_ADAPTER.load(Ordering::Relaxed) +} + /// The process's video memory on the device's adapter: (local, non-local) bytes in use. pub fn video_memory() -> Option<(u64, u64)> { use windows::Win32::Graphics::Dxgi::*; @@ -517,6 +526,7 @@ pub fn init() -> Result { if let Ok(dev) = crate::gpu::agility::create_device(&adapter, D3D_FEATURE_LEVEL_12_0) { device = Some(dev); name = format!("{} ({} MiB VRAM)", crate::gpu::adapter::name(&desc), desc.DedicatedVideoMemory >> 20); + SOFTWARE_ADAPTER.store(crate::gpu::adapter::software(&desc), Ordering::Relaxed); break; } } @@ -528,6 +538,7 @@ pub fn init() -> Result { let d = crate::gpu::agility::create_device(&warp, D3D_FEATURE_LEVEL_11_0) .map_err(|e| format!("D3D12 device (WARP): {e}"))?; name = "WARP (software renderer)".into(); + SOFTWARE_ADAPTER.store(true, Ordering::Relaxed); d } }; diff --git a/crates/xcl/src/hle/d3d12x/two_pass_tests.rs b/crates/xcl/src/hle/d3d12x/two_pass_tests.rs index 941f21a..aa9fd15 100644 --- a/crates/xcl/src/hle/d3d12x/two_pass_tests.rs +++ b/crates/xcl/src/hle/d3d12x/two_pass_tests.rs @@ -39,6 +39,12 @@ fn ready() -> Option { println!("no real D3D12 device – skipping"); return None; } + if real::software_adapter() { + // WARP / the Basic Render Driver report mesh shaders but reject the translated pipelines + println!("software adapter (no GPU) – skipping"); + crate::gpu::recomp::runner::skip_test("no GPU"); + return None; + } if real::uma_window_vas().is_empty() { println!("unified memory is not open on the GPU – skipping"); return None;