From be2b06c99b0f83773ecd3dc867c71a6cc9cf12bc Mon Sep 17 00:00:00 2001 From: us3r40456 <322771597+us3r40456@users.noreply.github.com> Date: Tue, 24 Nov 2026 02:38:45 +0100 Subject: [PATCH 1/3] Recompiler: keep a draw's descriptor heaps alive until the list has run For a draw with no textures or samplers, draw_indexed_on bound its CBV/SRV/UAV and sampler heaps through `bind_resources(...).map(|_| Vec::new())`, which drops the returned `Bound`, and the heaps with it, right after SetDescriptorHeaps. D3D12 command lists hold no reference to the heaps they bind, so the list was executed with released heaps. On D3DMetal (CrossOver 26.3, Apple M5 Pro) such a list never completes: the fence wait times out after 10 s, then GetDeviceRemovedReason blocks, so the seven graphics tests that draw without textures hang (gpu_graphics_vs_ps_draw, the three gpu_rect_list_* tests and the three gpu_wave64_{ps,vs}_* tests). bind_views handles the empty case the same way (two CBV/SRV/UAV slots, one sampler slot) and returns the heaps, so every draw now goes through it and keeps them until the fence wait. The compute paths already keep theirs. --- crates/xcl/src/gpu/recomp/runner.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index c7f9cc42f3..b29f716182 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -956,7 +956,8 @@ fn draw_indexed_on( list.ClearRenderTargetView(rtv, &clear, None); list.RSSetViewports(&[D3D12_VIEWPORT { TopLeftX: 0.0, TopLeftY: 0.0, Width: size as f32, Height: size as f32, MinDepth: 0.0, MaxDepth: 1.0 }]); list.RSSetScissorRects(&[windows::Win32::Foundation::RECT { left: 0, top: 0, right: size as i32, bottom: size as i32 }]); - let _bound = if textures.is_empty() && samplers.is_empty() { bind_resources(dev, &list, &[], &[]).map(|_| Vec::new())? } else { bind_views(dev, &list, textures, samplers)? }; + // Keep the descriptor heaps alive until the list has run: D3D12 command lists do not hold a reference to them. + let _bound = bind_views(dev, &list, textures, samplers)?; list.SetGraphicsRootSignature(rs); list.SetGraphicsRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress()); list.SetGraphicsRootUnorderedAccessView(1, res_buf.GetGPUVirtualAddress()); From ae105637ba4b42452edc6a059516ba33e74c1fed Mon Sep 17 00:00:00 2001 From: us3r40456 <322771597+us3r40456@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:03:58 +0100 Subject: [PATCH 2/3] Tests: a draw without textures keeps its descriptor heaps, on any adapter The seven draw tests skip on an adapter that runs neither 64- nor 32-lane waves, so on the CI runner's WARP no draw reached the released heaps. gpu_draw_keeps_its_descriptor_heaps draws a plain HLSL VS / PS triangle through runner::draw four times, gated only on an adapter and DXC. Without the heap fix it removes the device (0x887A0020) or faults on WARP (Kalmarv's runs on #553) and has no result after 60 s on D3DMetal (Apple M5 Pro, CrossOver 26.3); with it, it passes on both, 3 of 3 runs. Co-authored-by: Kalmarv <59708937+Kalmarv@users.noreply.github.com> --- crates/xcl/src/gpu/recomp/tests.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 596a74198c..00166c324d 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -7187,3 +7187,31 @@ fn fspx_containers_translate_and_compile() { println!("FSPX: {ok} / {n} translated and compiled"); assert_eq!(ok, n); } + +/// `runner::draw` without textures, on any adapter with DXC (plain HLSL VS/PS, no wave size +/// needed, so also the CI runner's WARP): a triangle over the whole target, every pixel its +/// colour. The draw's descriptor heaps have to live until the command list has run. They were +/// released right after `SetDescriptorHeaps`, which a hardware driver did not notice; WARP +/// removed the device (0x887A0020) or faulted in the test process. +#[test] +fn gpu_draw_keeps_its_descriptor_heaps() { + if runner::adapter().is_err() || super::dxc::location().is_err() { + return runner::skip_test(if runner::adapter().is_err() { "no GPU" } else { "no DXC" }); + } + use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32B32A32_FLOAT; + let vs_hlsl = "struct V { float4 pos : SV_Position; float4 color : COLOR0; };\nV main(float4 pos : POSITION, float4 color : COLOR0) { V o; o.pos = pos; o.color = color; return o; }\n"; + let ps_hlsl = "float4 main(float4 pos : SV_Position, float4 color : COLOR0) : SV_Target { return color; }\n"; + let vs = super::dxc::compile(vs_hlsl, "main", "vs_6_6", &[]).unwrap(); + let ps = super::dxc::compile(ps_hlsl, "main", "ps_6_6", &[]).unwrap(); + let layout = [ + runner::VertexElement { semantic: "POSITION", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 0 }, + runner::VertexElement { semantic: "COLOR", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 16 }, + ]; + let color = [0.25f32, 0.5, 0.75, 1.0]; + let v: Vec = [[-1.0f32, -1.0], [-1.0, 3.0], [3.0, -1.0]].iter().flat_map(|&[x, y]| [x, y, 0.0, 1.0, color[0], color[1], color[2], color[3]]).collect(); + // a few draws: each makes and binds its own heaps + for run in 0..4 { + let px = runner::draw(&vs, &ps, &layout, &v, 32, &[], &[], 8, [0.0; 4]).unwrap(); + assert!(px.len() == 64 && px.iter().all(|p| *p == color), "run {run}: {px:?}"); + } +} From bbbb8defa2d0d3be04a14a5ef032c0ae50ea61c9 Mon Sep 17 00:00:00 2001 From: us3r40456 <322771597+us3r40456@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:05:25 +0100 Subject: [PATCH 3/3] Tests: gpu_draw_keeps_its_descriptor_heaps next to the other draw tests At the end of tests.rs it conflicted with the tests main has added there since 508a0c7. --- crates/xcl/src/gpu/recomp/tests.rs | 56 +++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 00166c324d..1d90f3a5c6 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -1641,6 +1641,34 @@ fn gpu_graphics_vs_ps_draw() { } } +/// `runner::draw` without textures, on any adapter with DXC (plain HLSL VS/PS, no wave size +/// needed, so also the CI runner's WARP): a triangle over the whole target, every pixel its +/// colour. The draw's descriptor heaps have to live until the command list has run. They were +/// released right after `SetDescriptorHeaps`, which a hardware driver did not notice; WARP +/// removed the device (0x887A0020) or faulted in the test process. +#[test] +fn gpu_draw_keeps_its_descriptor_heaps() { + if runner::adapter().is_err() || super::dxc::location().is_err() { + return runner::skip_test(if runner::adapter().is_err() { "no GPU" } else { "no DXC" }); + } + use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32B32A32_FLOAT; + let vs_hlsl = "struct V { float4 pos : SV_Position; float4 color : COLOR0; };\nV main(float4 pos : POSITION, float4 color : COLOR0) { V o; o.pos = pos; o.color = color; return o; }\n"; + let ps_hlsl = "float4 main(float4 pos : SV_Position, float4 color : COLOR0) : SV_Target { return color; }\n"; + let vs = super::dxc::compile(vs_hlsl, "main", "vs_6_6", &[]).unwrap(); + let ps = super::dxc::compile(ps_hlsl, "main", "ps_6_6", &[]).unwrap(); + let layout = [ + runner::VertexElement { semantic: "POSITION", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 0 }, + runner::VertexElement { semantic: "COLOR", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 16 }, + ]; + let color = [0.25f32, 0.5, 0.75, 1.0]; + let v: Vec = [[-1.0f32, -1.0], [-1.0, 3.0], [3.0, -1.0]].iter().flat_map(|&[x, y]| [x, y, 0.0, 1.0, color[0], color[1], color[2], color[3]]).collect(); + // a few draws: each makes and binds its own heaps + for run in 0..4 { + let px = runner::draw(&vs, &ps, &layout, &v, 32, &[], &[], 8, [0.0; 4]).unwrap(); + assert!(px.len() == 64 && px.iter().all(|p| *p == color), "run {run}: {px:?}"); + } +} + /// `emit::rect_list_gs` declares the VS's output struct; the fourth vertex is v[0] with its /// float outputs continued from the other three, its integer (flat) ones left as v[0]'s. #[test] @@ -7187,31 +7215,3 @@ fn fspx_containers_translate_and_compile() { println!("FSPX: {ok} / {n} translated and compiled"); assert_eq!(ok, n); } - -/// `runner::draw` without textures, on any adapter with DXC (plain HLSL VS/PS, no wave size -/// needed, so also the CI runner's WARP): a triangle over the whole target, every pixel its -/// colour. The draw's descriptor heaps have to live until the command list has run. They were -/// released right after `SetDescriptorHeaps`, which a hardware driver did not notice; WARP -/// removed the device (0x887A0020) or faulted in the test process. -#[test] -fn gpu_draw_keeps_its_descriptor_heaps() { - if runner::adapter().is_err() || super::dxc::location().is_err() { - return runner::skip_test(if runner::adapter().is_err() { "no GPU" } else { "no DXC" }); - } - use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32B32A32_FLOAT; - let vs_hlsl = "struct V { float4 pos : SV_Position; float4 color : COLOR0; };\nV main(float4 pos : POSITION, float4 color : COLOR0) { V o; o.pos = pos; o.color = color; return o; }\n"; - let ps_hlsl = "float4 main(float4 pos : SV_Position, float4 color : COLOR0) : SV_Target { return color; }\n"; - let vs = super::dxc::compile(vs_hlsl, "main", "vs_6_6", &[]).unwrap(); - let ps = super::dxc::compile(ps_hlsl, "main", "ps_6_6", &[]).unwrap(); - let layout = [ - runner::VertexElement { semantic: "POSITION", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 0 }, - runner::VertexElement { semantic: "COLOR", index: 0, format: DXGI_FORMAT_R32G32B32A32_FLOAT, offset: 16 }, - ]; - let color = [0.25f32, 0.5, 0.75, 1.0]; - let v: Vec = [[-1.0f32, -1.0], [-1.0, 3.0], [3.0, -1.0]].iter().flat_map(|&[x, y]| [x, y, 0.0, 1.0, color[0], color[1], color[2], color[3]]).collect(); - // a few draws: each makes and binds its own heaps - for run in 0..4 { - let px = runner::draw(&vs, &ps, &layout, &v, 32, &[], &[], 8, [0.0; 4]).unwrap(); - assert!(px.len() == 64 && px.iter().all(|p| *p == color), "run {run}: {px:?}"); - } -}