From 13b04185e67d1a9b3d65f32aa9562b9a9bb5f340 Mon Sep 17 00:00:00 2001 From: fiestorra Date: Tue, 1 Dec 2026 04:00:47 +0100 Subject: [PATCH 1/2] gpu: a software adapter does not support the depth bounds test, whatever it answers D3D12_OPTIONS2.DepthBoundsTestSupported is true on WARP, and OMSetDepthBounds is then accepted with every fragment passing: the same frame reads back 255 where a card culls and reads 0. The feature query is right about the API surface and wrong about the driver. So depth_bounds() answers no for an adapter with DXGI_ADAPTER_FLAG_SOFTWARE. The test that guards on it then skips on a CI runner with no card, instead of failing there and passing on a GPU, and still runs where there is one. --- d3d12/crates/leonida-gpu/src/host.rs | 10 ++++++++++ d3d12/crates/leonida-gpu/src/indirect.rs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/d3d12/crates/leonida-gpu/src/host.rs b/d3d12/crates/leonida-gpu/src/host.rs index c5e110d4f0..a208ca7c40 100644 --- a/d3d12/crates/leonida-gpu/src/host.rs +++ b/d3d12/crates/leonida-gpu/src/host.rs @@ -6088,6 +6088,16 @@ impl Host { /// Whether the host GPU supports the depth bounds test; logged once. pub(crate) fn depth_bounds(&self) -> bool { static BOUNDS: OnceLock = OnceLock::new(); + // A software adapter answers that it supports the test and then does not gate the draw: + // `OMSetDepthBounds` is accepted and every fragment passes (measured on WARP, which is + // what a CI runner without a card gets, and the same frame reads back 255 instead of 0). + // The query is right about the API surface and wrong about the driver, so the answer is + // no for a software adapter. + if crate::indirect::adapter_of(&self.device) + .is_some_and(|d| d.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0) + { + return false; + } *BOUNDS.get_or_init(|| { let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS2::default(); // SAFETY: writes `options` of the given size. diff --git a/d3d12/crates/leonida-gpu/src/indirect.rs b/d3d12/crates/leonida-gpu/src/indirect.rs index 2ba5eda57e..a5634f039a 100644 --- a/d3d12/crates/leonida-gpu/src/indirect.rs +++ b/d3d12/crates/leonida-gpu/src/indirect.rs @@ -326,7 +326,7 @@ fn widest(device: &ID3D12Device) -> u32 { const WIDE: u32 = 1 << 20; /// The description of `device`'s adapter. -fn adapter_of(device: &ID3D12Device) -> Option { +pub(crate) fn adapter_of(device: &ID3D12Device) -> Option { use windows::Win32::Graphics::Dxgi::{CreateDXGIFactory2, DXGI_CREATE_FACTORY_FLAGS, IDXGIAdapter1, IDXGIFactory4}; // SAFETY: plain queries. unsafe { From b60a7294a9a94847ac721746a68d89edbba9fa94 Mon Sep 17 00:00:00 2001 From: MoonEyes <14891700+MoonEyes@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:26:07 +0100 Subject: [PATCH 2/2] leonida-gpu: ask the adapter for the depth bounds once Co-Authored-By: Claude Opus 5.5 --- d3d12/crates/leonida-gpu/src/host.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/d3d12/crates/leonida-gpu/src/host.rs b/d3d12/crates/leonida-gpu/src/host.rs index a208ca7c40..462c954739 100644 --- a/d3d12/crates/leonida-gpu/src/host.rs +++ b/d3d12/crates/leonida-gpu/src/host.rs @@ -6093,12 +6093,14 @@ impl Host { // what a CI runner without a card gets, and the same frame reads back 255 instead of 0). // The query is right about the API surface and wrong about the driver, so the answer is // no for a software adapter. - if crate::indirect::adapter_of(&self.device) - .is_some_and(|d| d.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0) - { - return false; - } + // Asked once: every `OMSetDepthBounds` and every replayed list comes here. *BOUNDS.get_or_init(|| { + if crate::indirect::adapter_of(&self.device) + .is_some_and(|d| d.Flags & DXGI_ADAPTER_FLAG_SOFTWARE.0 as u32 != 0) + { + tracing::info!(supported = false, "host depth bounds support (a software adapter)"); + return false; + } let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS2::default(); // SAFETY: writes `options` of the given size. let ok = unsafe {