From e26cf053f10b7326d78e874df2dafd8cb6b7cfbd Mon Sep 17 00:00:00 2001 From: sahajiscoding <135018977+sahajiscoding@users.noreply.github.com> Date: Wed, 25 Nov 2026 10:25:23 +0000 Subject: [PATCH] test(gpu): remove SM 6.6 bindless root flags from depth-bounds test and fix watch cleanup race Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- crates/victory-gpu/src/pipeline/host.rs | 45 ++++++++++++++++++++++++- crates/victory-gpu/src/watch.rs | 13 +++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/crates/victory-gpu/src/pipeline/host.rs b/crates/victory-gpu/src/pipeline/host.rs index accfa206fe..8bf0883914 100644 --- a/crates/victory-gpu/src/pipeline/host.rs +++ b/crates/victory-gpu/src/pipeline/host.rs @@ -1069,12 +1069,37 @@ mod tests { return float4(p * 2.0 - 1.0, 0.5, 1.0); }"; + #[test] + fn only_enabled_depth_bounds_change_the_pipeline_key() { + let mut g = GraphicsState::default(); + let key = |g: &GraphicsState| super::super::library::name("graphics", &[], &[], &g.describe()); + let plain_key = key(&g); + let legacy = Sub(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, g.depth); + let mut extended = Sub(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, g.depth1()); + + // SAFETY: each pointer is to a complete, matching stream subobject. + unsafe { g.read(21, (&raw const extended).cast()) }; + assert_eq!(key(&g), plain_key, "a disabled test must preserve the existing key"); + + extended.1.DepthBoundsTestEnable = true.into(); + // SAFETY: `extended` is still a complete subobject 21. + unsafe { g.read(21, (&raw const extended).cast()) }; + assert!(g.depth1().DepthBoundsTestEnable.as_bool()); + assert_ne!(key(&g), plain_key, "an enabled test needs a distinct key"); + + // SAFETY: `legacy` is a complete subobject 11. + unsafe { g.read(11, (&raw const legacy).cast()) }; + assert!(!g.depth1().DepthBoundsTestEnable.as_bool()); + assert_eq!(key(&g), plain_key, "legacy depth state clears the bounds flag"); + } + /// A graphics pipeline with `DepthBoundsTestEnable` loads back from the /// pipeline library and culls or passes fragments according to /// `OMSetDepthBounds` (including across a command-list cut). #[test] fn depth_bounds_pipeline_loads_and_filters_draws() { let Some(host) = host() else { + eprintln!("no host D3D12 device; skipped"); return; }; if !host.depth_bounds() { @@ -1088,7 +1113,25 @@ mod tests { let dir = tempfile::tempdir().unwrap(); let vs = compile(&dxc, dir.path(), VS, "vs_6_5"); let ps = compile(&dxc, dir.path(), PS, "ps_6_5"); - let (root, root_blob) = root_signature(&host.device, &[], &[], false).unwrap(); + // The fixture has no descriptors. Don't require SM 6.6 bindless + // root flags just to exercise depth bounds on inbox D3D12 runtimes. + let root_desc = D3D12_ROOT_SIGNATURE_DESC { + Flags: D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, + ..Default::default() + }; + let mut blob = None; + // SAFETY: the empty description has no arrays; bytes are copied + // before the serialized blob is released. + let root_blob = unsafe { + D3D12SerializeRootSignature(&root_desc, D3D_ROOT_SIGNATURE_VERSION_1, &mut blob, None) + .expect("serialize the test root signature"); + let blob = blob.expect("serialized test root signature"); + std::slice::from_raw_parts(blob.GetBufferPointer().cast::(), blob.GetBufferSize()) + .to_vec() + }; + // SAFETY: the bytes were returned by D3D12SerializeRootSignature. + let root: ID3D12RootSignature = unsafe { host.device.CreateRootSignature(0, &root_blob) } + .expect("create the test root signature"); let mut g = GraphicsState::default(); // Subobject 21 (`DEPTH_STENCIL1`) with `DepthBoundsTestEnable = true`, diff --git a/crates/victory-gpu/src/watch.rs b/crates/victory-gpu/src/watch.rs index 02d066f297..2385948064 100644 --- a/crates/victory-gpu/src/watch.rs +++ b/crates/victory-gpu/src/watch.rs @@ -1099,6 +1099,10 @@ mod tests { guard(view, view + 2 * BLOCK), Some((view / PAGE..view / PAGE + 1).collect()) ); + // Forgotten before the view goes: once it is unmapped, a test on + // another thread may map memory at the same address and find these + // blocks still noted guarded and clean. + title_memory_remapped(view, 2 * BLOCK); // SAFETY: our view. unsafe { UnmapViewOfFile( @@ -1107,7 +1111,6 @@ mod tests { }, ) }; - title_memory_remapped(view, 2 * BLOCK); } #[test] @@ -1248,6 +1251,9 @@ mod tests { let mut local = [0u8; 16]; let at = local.as_mut_ptr() as usize; assert!(!is_view(at, at + local.len())); + // Forgotten before the memory goes (see + // `kernel_reads_into_guarded_blocks_after_opening`). + title_memory_remapped(p, 3 * BLOCK); // SAFETY: our views and placeholder. unsafe { UnmapViewOfFile2(GetCurrentProcess(), first, MEM_PRESERVE_PLACEHOLDER); @@ -1257,7 +1263,6 @@ mod tests { } windows_sys::Win32::Foundation::CloseHandle(section); } - title_memory_remapped(p, 3 * BLOCK); } /// Blocks of a placeholder between views are reported once, then not @@ -1332,6 +1337,9 @@ mod tests { title_memory_remapped(p + BLOCK, BLOCK); assert_eq!(guard(p, p + 3 * BLOCK), Some(pages(1).collect())); assert_eq!(guard(p, p + 3 * BLOCK), Some(Vec::new())); + // Forgotten before the memory goes (see + // `kernel_reads_into_guarded_blocks_after_opening`). + title_memory_remapped(p, 3 * BLOCK); // SAFETY: our views and placeholder. unsafe { UnmapViewOfFile2(GetCurrentProcess(), first, MEM_PRESERVE_PLACEHOLDER); @@ -1341,7 +1349,6 @@ mod tests { } windows_sys::Win32::Foundation::CloseHandle(section); } - title_memory_remapped(p, 3 * BLOCK); } /// A pagefile section mapped twice: two views of the same physical