From ed98461e39cfdad21843bfc2b0d462932c7af362 Mon Sep 17 00:00:00 2001 From: bmjask <> Date: Thu, 26 Nov 2026 01:13:08 -0800 Subject: [PATCH] D3D12.X: run ready split pipelines through ExecuteIndirect A split compute pipeline previously always used its expensive whole form for ExecuteIndirect. For the measured one-Dispatch, one-command shape, generate bounded piece commands on the GPU once that whole fallback is already available. The slicer emits either every piece slab or only the whole dispatch, so it cannot lose work. Generated commands remain owned by the recording until its allocator resets, including when ABI binding fails. The first use and all other command shapes retain the existing whole-form path. Assisted-by: Codex (GPT-5.6-sol) --- crates/xcl/src/gpu/recomp/pso.rs | 152 +++++++++++++++++- crates/xcl/src/hle/d3d12x/bind.rs | 45 ++++++ crates/xcl/src/hle/d3d12x/device_x.rs | 4 + .../xcl/src/hle/d3d12x/real/dispatch_chain.rs | 106 +++++++++++- 4 files changed, 304 insertions(+), 3 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index 4311795260..21fc09a4eb 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -1496,6 +1496,145 @@ pub(crate) unsafe fn record_dispatch_chain<'a>( } } +/// Bytes of one indirect chain command: eight slab constants followed by Dispatch arguments. +pub(crate) const CHAIN_COMMAND_BYTES: u32 = 44; + +pub(crate) fn chain_command_signature(dev: &ID3D12Device, rs: &ID3D12RootSignature) -> Result { + let args = [ + D3D12_INDIRECT_ARGUMENT_DESC { Type: D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT, Anonymous: D3D12_INDIRECT_ARGUMENT_DESC_0 { + Constant: D3D12_INDIRECT_ARGUMENT_DESC_0_1 { RootParameterIndex: 7, DestOffsetIn32BitValues: 0, Num32BitValuesToSet: 8 } } }, + D3D12_INDIRECT_ARGUMENT_DESC { Type: D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH, ..Default::default() }, + ]; + let desc = D3D12_COMMAND_SIGNATURE_DESC { ByteStride: CHAIN_COMMAND_BYTES, NumArgumentDescs: 2, pArgumentDescs: args.as_ptr(), NodeMask: 0 }; + let mut sig = None; + unsafe { dev.CreateCommandSignature(&desc, rs, &mut sig) }.map_err(|e| format!("CreateCommandSignature: {e}"))?; + sig.ok_or_else(|| "CreateCommandSignature".into()) +} + +pub(crate) fn dispatch_command_signature(dev: &ID3D12Device) -> Result { + static MADE: Mutex> = Mutex::new(None); + let mut made = MADE.lock().unwrap(); + if let Some((_, sig)) = made.as_ref().filter(|m| m.0 == windows::core::Interface::as_raw(dev) as usize) { + return Ok(sig.clone()); + } + let arg = D3D12_INDIRECT_ARGUMENT_DESC { Type: D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH, ..Default::default() }; + let desc = D3D12_COMMAND_SIGNATURE_DESC { ByteStride: 12, NumArgumentDescs: 1, pArgumentDescs: &arg, NodeMask: 0 }; + let mut sig = None; + unsafe { dev.CreateCommandSignature(&desc, None, &mut sig) }.map_err(|e| format!("CreateCommandSignature: {e}"))?; + let sig: ID3D12CommandSignature = sig.ok_or("CreateCommandSignature")?; + *made = Some((windows::core::Interface::as_raw(dev) as usize, sig.clone())); + Ok(sig) +} + +const INDIRECT_SLICER: &str = r#" +#define RS "RootConstants(num32BitConstants=3, b0), SRV(t0), UAV(u0)" +cbuffer C : register(b0) { uint rounds; uint most; uint pieces; }; +ByteAddressBuffer args : register(t0); +RWByteAddressBuffer cmds : register(u0); +void put(uint r, uint3 n, uint3 o) { + for (uint i = 0; i < pieces; i++) { + uint at = (r * pieces + i) * 44; + cmds.Store4(at, uint4(n, i)); + cmds.Store4(at + 16, uint4(o, 0)); + cmds.Store3(at + 32, n); + } +} +[RootSignature(RS)] +[numthreads(1, 1, 1)] +void main() { + uint3 g = min(args.Load3(0), 65535); + uint3 s; + s.x = min(g.x, max(most, 1)); + s.y = s.x == g.x ? min(g.y, max(most / max(g.x, 1), 1)) : 1; + s.z = s.x == g.x && s.y == g.y ? min(g.z, max(most / max(g.x, 1) / max(g.y, 1), 1)) : 1; + uint3 c = (g + s - 1) / s; + bool partial = any(g == 0) ? false : c.x > rounds || c.y > rounds / max(c.x, 1) || c.z > rounds / max(c.x * c.y, 1); + uint r = 0; + if (!partial && all(g != 0)) + for (uint oz = 0; oz < g.z; oz += s.z) + for (uint oy = 0; oy < g.y; oy += s.y) + for (uint ox = 0; ox < g.x; ox += s.x) { + uint3 o = uint3(ox, oy, oz); + put(r++, min(s, g - o), o); + } + for (; r < rounds; r++) put(r, 0, 0); + uint at = (rounds * pieces * 44 + 7) & ~7u; + cmds.Store3(at, partial ? g : 0); +} +"#; + +pub(crate) fn chain_tail_offset(rounds: u32, pieces: u32) -> u64 { + (u64::from(rounds) * u64::from(pieces) * u64::from(CHAIN_COMMAND_BYTES)).next_multiple_of(8) +} + +fn indirect_slicer(dev: &ID3D12Device) -> Result<(ID3D12RootSignature, ID3D12PipelineState), String> { + static MADE: Mutex> = Mutex::new(None); + let mut made = MADE.lock().unwrap(); + if let Some((_, rs, pso)) = made.as_ref().filter(|m| m.0 == windows::core::Interface::as_raw(dev) as usize) { + return Ok((rs.clone(), pso.clone())); + } + let dxil = super::dxc::compile(INDIRECT_SLICER, "main", "cs_6_0", &[])?; + unsafe { + let rs: ID3D12RootSignature = dev.CreateRootSignature(0, &dxil).map_err(|e| format!("indirect slicer root signature: {e}"))?; + let desc = D3D12_COMPUTE_PIPELINE_STATE_DESC { pRootSignature: std::mem::transmute_copy(&rs), + CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr().cast(), BytecodeLength: dxil.len() }, ..Default::default() }; + let pso: ID3D12PipelineState = dev.CreateComputePipelineState(&desc).map_err(|e| format!("indirect slicer pipeline: {e}"))?; + *made = Some((windows::core::Interface::as_raw(dev) as usize, rs.clone(), pso.clone())); + Ok((rs, pso)) + } +} + +pub(crate) unsafe fn chain_commands_buffer(dev: &ID3D12Device, rounds: u32, pieces: u32) -> Option { + let desc = D3D12_RESOURCE_DESC { + Dimension: D3D12_RESOURCE_DIMENSION_BUFFER, Width: chain_tail_offset(rounds, pieces) + 12, Height: 1, DepthOrArraySize: 1, MipLevels: 1, + SampleDesc: windows::Win32::Graphics::Dxgi::Common::DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, + Layout: D3D12_TEXTURE_LAYOUT_ROW_MAJOR, Flags: D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS, ..Default::default() + }; + let mut resource = None; + dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_DEFAULT, CreationNodeMask: 1, VisibleNodeMask: 1, ..Default::default() }, + D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, None, &mut resource).ok()?; + resource +} + +pub(crate) unsafe fn record_indirect_slicer( + list: &ID3D12GraphicsCommandList, args: u64, rounds: u32, most: u64, pieces: u32, out: &ID3D12Resource, +) -> Result<(), String> { + let mut dev = None; + list.GetDevice(&mut dev).map_err(|e| e.to_string())?; + let (rs, pso) = indirect_slicer(&dev.ok_or("device")?)?; + let constants = [rounds, most.min(u64::from(u32::MAX)) as u32, pieces]; + list.SetComputeRootSignature(&rs); + list.SetPipelineState(&pso); + list.SetComputeRoot32BitConstants(0, 3, constants.as_ptr().cast(), 0); + list.SetComputeRootShaderResourceView(1, args); + list.SetComputeRootUnorderedAccessView(2, out.GetGPUVirtualAddress()); + list.ResourceBarrier(&[D3D12_RESOURCE_BARRIER { Type: D3D12_RESOURCE_BARRIER_TYPE_UAV, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, + Anonymous: D3D12_RESOURCE_BARRIER_0 { UAV: std::mem::ManuallyDrop::new(D3D12_RESOURCE_UAV_BARRIER { pResource: std::mem::ManuallyDrop::new(None) }) } }]); + list.Dispatch(1, 1, 1); + list.ResourceBarrier(&[D3D12_RESOURCE_BARRIER { Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, + Anonymous: D3D12_RESOURCE_BARRIER_0 { Transition: std::mem::ManuallyDrop::new(D3D12_RESOURCE_TRANSITION_BARRIER { + pResource: std::mem::transmute_copy(out), Subresource: D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, + StateBefore: D3D12_RESOURCE_STATE_UNORDERED_ACCESS, StateAfter: D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT }) } }]); + Ok(()) +} + +pub(crate) unsafe fn record_dispatch_chain_indirect<'a>( + list: &ID3D12GraphicsCommandList, sig: &ID3D12CommandSignature, commands: &ID3D12Resource, rounds: u32, + scratch: &ID3D12Resource, pieces: impl IntoIterator + Clone, +) { + let n = pieces.clone().into_iter().count() as u32; + list.SetComputeRootUnorderedAccessView(6, scratch.GetGPUVirtualAddress()); + for r in 0..rounds { + for (i, piece) in pieces.clone().into_iter().enumerate() { + list.ResourceBarrier(&[D3D12_RESOURCE_BARRIER { Type: D3D12_RESOURCE_BARRIER_TYPE_UAV, Flags: D3D12_RESOURCE_BARRIER_FLAG_NONE, + Anonymous: D3D12_RESOURCE_BARRIER_0 { UAV: std::mem::ManuallyDrop::new(D3D12_RESOURCE_UAV_BARRIER { pResource: std::mem::ManuallyDrop::new(None) }) } }]); + list.SetPipelineState(piece); + let offset = (u64::from(r) * u64::from(n) + i as u64) * u64::from(CHAIN_COMMAND_BYTES); + list.ExecuteIndirect(sig, 1, commands, offset, None::<&ID3D12Resource>, 0); + } + } +} + pub(crate) fn dispatch_chain_root_signature(dev: &ID3D12Device, samplers: &[StaticSampler]) -> Result { abi_signature(dev, false, samplers, Some(ChainSlabBinding::RootConstants)) } @@ -1575,7 +1714,7 @@ fn abi_signature( #[cfg(test)] mod slab_tests { - use super::{chain_slab_parameter, dispatch_slabs, ChainSlabBinding}; + use super::{chain_slab_parameter, chain_tail_offset, dispatch_slabs, ChainSlabBinding, CHAIN_COMMAND_BYTES}; use windows::Win32::Graphics::Direct3D12::{ D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE, D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS, D3D12_ROOT_PARAMETER_TYPE_CBV, @@ -1597,6 +1736,17 @@ mod slab_tests { } } + #[test] + fn indirect_whole_arguments_follow_aligned_piece_commands() { + for (rounds, pieces) in [(1, 2), (16, 9), (1024, 64)] { + let commands = u64::from(rounds * pieces * CHAIN_COMMAND_BYTES); + let tail = chain_tail_offset(rounds, pieces); + assert!(tail >= commands); + assert_eq!(tail % 8, 0); + assert!(tail - commands < 8); + } + } + #[test] fn slabs_cover_a_dispatch_once_within_their_size() { for grid in [[1, 1, 1], [2, 3, 2], [240, 135, 1], [65_535, 2, 1], [5, 1, 7]] { diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs index 3414e2e27b..9f3818d3a5 100644 --- a/crates/xcl/src/hle/d3d12x/bind.rs +++ b/crates/xcl/src/hle/d3d12x/bind.rs @@ -287,6 +287,18 @@ fn signature_dispatches(sig: usize) -> bool { DISPATCH_SIGNATURES.lock().unwrap().as_ref().is_some_and(|s| s.contains(&sig)) } +/// Command signatures made of one Dispatch argument, keyed to their stride. +static DISPATCH_ONLY: Mutex>> = Mutex::new(None); + +pub(super) fn note_dispatch_only_signature(sig: usize, stride: Option) { + let mut signatures = DISPATCH_ONLY.lock().unwrap(); + let signatures = signatures.get_or_insert_with(Default::default); + match stride { + Some(stride) => { signatures.insert(sig, stride); } + None => { signatures.remove(&sig); } + } +} + /// #59 ExecuteIndirect(signature, max count, arguments, offset, count buffer, offset): with a /// translated pipeline, on XCL's ABI with the kept root arguments (signatures that change root /// arguments themselves cannot be – skipped, logged) @@ -300,6 +312,7 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us } let (pso, bound_unbuilt) = super::pso_async::resolve_wait_bound(raw_pso); let (gfx, compute) = (super::real::is_translated_graphics(pso), super::real::is_translated_compute(pso)); + let args_off_title = args_off; let (args_off, count_off) = (args_off + super::real::buffer_delta(args), count_off + super::real::buffer_delta(count_buf)); if !gfx && !compute { // A pipeline still being built (or whose build failed): its stand-in draws nothing, and @@ -359,6 +372,27 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us return; } let Some(list) = ID3D12GraphicsCommandList::from_raw_borrowed(&this) else { return }; + if compute && max == 1 && count_buf == 0 && DISPATCH_ONLY.lock().unwrap().as_ref().is_some_and(|m| m.contains_key(&sig)) { + let chained = indirect_address(args, args_off_title, args_off).map_or(Ok(false), |address| { + super::real::dispatch_chain::execute_indirect(list, pso, with(this, |s| s.allocator), address, + || bind_abi(this, list, pso, false)) + }); + match chained { + Ok(true) => { + count(DISPATCHES); + return; + } + Ok(false) => {} + Err(e) => { + count(DISPATCHES_SKIPPED); + static N: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + if N.fetch_add(1, Ordering::Relaxed) < 4 { + crate::xlog_warn!("D3D12.X: split ExecuteIndirect skipped: {e}"); + } + return; + } + } + } match bind_abi(this, list, pso, gfx) { Ok(()) => { if compute { @@ -401,6 +435,17 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us } } +unsafe fn indirect_address(resource: usize, title_offset: u64, pc_offset: u64) -> Option { + match super::real::console_buffer(resource) { + Some((base, size)) if title_offset.checked_add(12).is_some_and(|end| end <= size as u64) => { + super::real::uma_va_of(base + title_offset as usize) + } + Some(_) => None, + None => Some(ID3D12Resource::from_raw_borrowed(&(resource as *mut c_void))?.GetGPUVirtualAddress()) + .filter(|&address| address != 0).and_then(|address| address.checked_add(pc_offset)), + } +} + /// XCL's own buffer for `fresh_indirect_arguments` (device, buffer): COMMON between its uses static ARGUMENT_ORDER: Mutex> = Mutex::new(None); diff --git a/crates/xcl/src/hle/d3d12x/device_x.rs b/crates/xcl/src/hle/d3d12x/device_x.rs index 139b6100cd..7bd0829645 100644 --- a/crates/xcl/src/hle/d3d12x/device_x.rs +++ b/crates/xcl/src/hle/d3d12x/device_x.rs @@ -1321,6 +1321,10 @@ pub(super) unsafe extern "system" fn create_command_signature_x(this: *mut c_voi } if hr >= 0 && !ppv.is_null() && !(*ppv).is_null() { super::bind::note_signature_dispatches(*ppv as usize, list.iter().any(|a| a[0] == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH.0 as u32)); + let stride = u32::from_le_bytes(pc[..4].try_into().unwrap()); + let dispatch_only = list.len() == 1 && list[0][0] == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH.0 as u32 + && stride >= 12 && stride % 4 == 0; + super::bind::note_dispatch_only_signature(*ppv as usize, dispatch_only.then_some(stride)); } hr } diff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs index 6708d3203a..c146cfa335 100644 --- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs +++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs @@ -83,6 +83,10 @@ impl WholeBuild { } } } + + fn ready(&self) -> Option> { + self.result.get().cloned() + } } /// A transient whole-form OOM is retried after memory has had time to drain. @@ -94,6 +98,7 @@ struct Chain { words: u32, whole_code: Vec, whole: WholeBuild, + indirect_signature: OnceLock, } impl Chain { @@ -148,7 +153,7 @@ pub(super) unsafe fn build(this: *mut c_void, create: PsoFn, desc: &D3D12_COMPUT let mut pieces = built.into_iter().collect::>>()?.into_iter(); let first = pieces.next()?; let chain = Arc::new(Chain { builder, tail: pieces.collect(), words: plan.dwords_per_group, - whole_code: whole.to_vec(), whole: WholeBuild::new() }); + whole_code: whole.to_vec(), whole: WholeBuild::new(), indirect_signature: OnceLock::new() }); PROGRAMS.fetch_add(1, Ordering::Relaxed); PIECES.fetch_add(plan.pieces.len() as u64, Ordering::Relaxed); *result = first.into_raw(); @@ -181,6 +186,7 @@ struct Recording { scratch: Arc, first: ID3D12PipelineState, chain: Arc, + _indirect_commands: Option, } static RECORDINGS: LazyLock>>>> = LazyLock::new(Default::default); @@ -310,7 +316,7 @@ pub(in crate::hle::d3d12x) unsafe fn dispatch(list: &ID3D12GraphicsCommandList, return Ok(()); }; let first = ID3D12PipelineState::from_raw_borrowed(&(pso as *mut c_void)).ok_or("first compute piece")?.clone(); - let held = Arc::new(Recording { scratch, first, chain }); + let held = Arc::new(Recording { scratch, first, chain, _indirect_commands: None }); RECORDINGS.lock().unwrap().entry(allocator).or_default().push(held.clone()); DISPATCHES.fetch_add(1, Ordering::Relaxed); SLABS.fetch_add(slabs.len() as u64, Ordering::Relaxed); @@ -318,6 +324,62 @@ pub(in crate::hle::d3d12x) unsafe fn dispatch(list: &ID3D12GraphicsCommandList, Ok(()) } +fn indirect_rounds() -> u32 { + static ROUNDS: OnceLock = OnceLock::new(); + *ROUNDS.get_or_init(|| std::env::var("XCL_SPLIT_INDIRECT_ROUNDS").ok().and_then(|v| v.trim().parse().ok()) + .filter(|&n| n > 0).unwrap_or(16u32).min(1024)) +} + +/// Run one Dispatch-only indirect command through an existing split chain. Until the whole form +/// is already built, return false so the caller preserves the existing synchronous fallback. The +/// slicer writes either bounded piece commands or the whole-form command, never a partial chain. +pub(in crate::hle::d3d12x) unsafe fn execute_indirect( + list: &ID3D12GraphicsCommandList, pso: usize, allocator: usize, args: u64, + bind: impl FnOnce() -> Result<(), String>, +) -> Result { + let Some(chain) = CHAINS.lock().unwrap().get(&pso).cloned() else { return Ok(false) }; + let whole = match chain.whole.ready() { + None => return Ok(false), + Some(Ok(pso)) => pso, + Some(Err(hr)) => return Err(format!("whole compute pipeline ({hr:#x})")), + }; + let allocator = if super::super::alloc_pool::enabled() { + super::super::alloc_pool::recording_backing(list.as_raw() as usize).unwrap_or(0) + } else { allocator }; + if allocator == 0 || list.GetType() == D3D12_COMMAND_LIST_TYPE_BUNDLE { return Ok(false); } + let group = u64::from(chain.words) * 4; + let Some((scratch, _)) = scratch_for(&chain.builder.device, list.as_raw() as usize, allocator, scratch_budget(), group) else { + return Ok(false); + }; + let signature = match chain.indirect_signature.get() { + Some(sig) => sig.clone(), + None => { + let sig = pso::chain_command_signature(&chain.builder.device, &chain.builder.signature)?; + chain.indirect_signature.get_or_init(|| sig).clone() + } + }; + let whole_signature = pso::dispatch_command_signature(&chain.builder.device)?; + let rounds = indirect_rounds(); + let pieces = chain.tail.len() as u32 + 1; + let commands = pso::chain_commands_buffer(&chain.builder.device, rounds, pieces) + .ok_or("no command buffer for split ExecuteIndirect")?; + let first = ID3D12PipelineState::from_raw_borrowed(&(pso as *mut c_void)).ok_or("first compute piece")?.clone(); + pso::record_indirect_slicer(list, args, rounds, (scratch.bytes / group).max(1), pieces, &commands)?; + let bound = bind(); + if bound.is_ok() { + list.SetPipelineState(&whole); + list.ExecuteIndirect(&whole_signature, 1, &commands, + pso::chain_tail_offset(rounds, pieces), None::<&ID3D12Resource>, 0); + pso::record_dispatch_chain_indirect(list, &signature, &commands, rounds, &scratch.buffer, + std::iter::once(&first).chain(&chain.tail)); + } + RECORDINGS.lock().unwrap().entry(allocator).or_default().push(Arc::new(Recording { + scratch, first, chain, _indirect_commands: Some(commands), + })); + bound?; + Ok(true) +} + #[cfg(test)] mod tests { use super::*; @@ -427,6 +489,46 @@ mod tests { assert_eq!(calls, 2, "the successful retry is retained"); } + #[test] + fn failed_binding_keeps_indirect_commands_until_allocator_reset() { + use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0; + unsafe extern "system" fn never(_: *mut c_void, _: *const c_void, _: *const GUID, _: *mut *mut c_void) -> HRESULT { E_INVALIDARG } + unsafe { + let mut dev = None; + if D3D12CreateDevice(None, D3D_FEATURE_LEVEL_11_0, &mut dev).is_err() { + return crate::gpu::recomp::runner::skip_test("no GPU"); + } + let dev = dev.unwrap(); + let Ok(dxil) = crate::gpu::recomp::dxc::compile("[numthreads(1,1,1)] void main() {}", "main", "cs_6_0", &[]) else { + return crate::gpu::recomp::runner::skip_test("no DXC"); + }; + let rs = pso::dispatch_chain_root_signature(&dev, &[]).unwrap(); + let desc = D3D12_COMPUTE_PIPELINE_STATE_DESC { pRootSignature: std::mem::transmute_copy(&rs), + CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr().cast(), BytecodeLength: dxil.len() }, ..Default::default() }; + let first: ID3D12PipelineState = dev.CreateComputePipelineState(&desc).unwrap(); + let whole = WholeBuild::new(); + whole.get_or_build(std::time::Instant::now(), || Ok(first.clone())).unwrap(); + let builder = Arc::new(PipelineBuilder { device: dev.clone(), create: never, signature: rs, samplers: Vec::new(), + flags: D3D12_PIPELINE_STATE_FLAG_NONE, node: 0, record: 0 }); + let key = first.as_raw() as usize; + CHAINS.lock().unwrap().insert(key, Arc::new(Chain { builder, tail: vec![first.clone()], words: 4, + whole_code: Vec::new(), whole, indirect_signature: OnceLock::new() })); + let ty = D3D12_COMMAND_LIST_TYPE_COMPUTE; + let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(ty).unwrap(); + let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, ty, &alloc, None).unwrap(); + let (raw_list, allocator) = (list.as_raw() as usize, alloc.as_raw() as usize); + super::super::super::alloc_pool::created_on(raw_list, allocator, ty.0); + let args = pso::chain_commands_buffer(&dev, 1, 1).unwrap(); + assert_eq!(execute_indirect(&list, key, allocator, args.GetGPUVirtualAddress(), || Err("bind failed".into())), Err("bind failed".into())); + assert!(RECORDINGS.lock().unwrap().get(&allocator).is_some_and(|r| r.iter().any(|r| r._indirect_commands.is_some()))); + list.Close().unwrap(); + allocator_reset(allocator); + list_reset(raw_list); + forget(key); + super::super::super::alloc_pool::forget_list(raw_list); + } + } + #[test] fn remap_compile_oom_retries_but_deterministic_failure_is_final() { let at = std::time::Instant::now();