From 8ab8acb63d3f1f1c630fcebeb23570d054d7e504 Mon Sep 17 00:00:00 2001 From: XCL Agent Date: Sat, 28 Nov 2026 22:42:43 +0100 Subject: [PATCH] Recompiler: add mesh_poison to test compressed depth/colour after a mesh pass A completed two-pass mesh dispatch can leave depth/colour compression metadata (HiZ/ZCull/DCC) that a later operation trips over ~20-25 s later (0x887A0005, no DRED page fault). The in-tree path mesh_draw cannot exercise this: it binds no depth buffer and uses R32G32B32A32_FLOAT, which gets no delta colour compression. mesh_poison binds the game's target shape - the rt_formats colour targets plus a dsv_format depth buffer - primes depth compression by writing it in a first pass, then runs what a normal frame does after it: a depth-reading pass, a colour resolve/copy, and a readback, each a separately fenced submission, so the PoisonReport names the first phase to hang or remove the device (the 10 s fence wait turns a hang into an error). gpu_mesh_poison drives it with a game-shaped pass (128 threads, 128v/128p) into three R8G8B8A8_UNORM targets + a D32_FLOAT_S8X24 depth buffer at 1024 square for 9 frames, matching the 3-RT + depth draws the removal clusters on. Co-Authored-By: Claude Opus 4.8 --- crates/xcl/src/gpu/recomp/runner.rs | 287 ++++++++++++++++++++++++++++ crates/xcl/src/gpu/recomp/tests.rs | 75 ++++++++ 2 files changed, 362 insertions(+) diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index f3006d87d7..7356c4270a 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -1444,6 +1444,293 @@ pub fn mesh_draw_split( } } +/// One mesh pipeline-state stream with a depth-stencil target (`MeshStream` plus the DSV +/// format subobject, which the output-merger needs for depth test/write). +#[repr(C)] +struct MeshDepthStream { + rs: Sub<*mut std::ffi::c_void>, + ms: Sub, + ps: Sub, + blend: Sub, + mask: Sub, + rast: Sub, + depth: Sub, + dsv: Sub, + rtv: Sub, + samples: Sub, +} + +/// What `mesh_poison` found: the phases that completed, in order, and the first one that +/// failed (its name and the device-removed reason / timeout / error), or `None` if the whole +/// sequence ran. A removal poisons the shared device, so the run stops at the first failure. +pub struct PoisonReport { + pub completed: Vec, + pub failed: Option<(String, String)>, +} + +impl PoisonReport { + /// The whole sequence completed with no device removal. + pub fn ok(&self) -> bool { + self.failed.is_none() + } +} + +/// A mesh pass into the game's target shape, then the operations a normal frame does after it +/// (depth read, colour resolve/copy, readback), each a separately fenced submission so a hang +/// or device removal is pinned to the phase it first happens in. Unlike `mesh_draw`, this +/// binds a real depth buffer (`dsv_format`) and the `rt_formats` colour targets, and primes depth +/// compression by writing it in a first pass before reading it in a second – the state a +/// minimal single-dispatch repro never reaches. `cs` writes one record per group (u1) as in +/// `mesh_draw`; `ms`/`ps` are its pass-through and pixel shader. `frames` extra clear→write→ +/// read→copy frames follow the first, to catch a delayed effect under sustained load. +#[allow(clippy::too_many_arguments)] +pub fn mesh_poison( + cs: &[u8], + ms: &[u8], + ps: &[u8], + groups: u32, + split: u32, + record_dwords: usize, + sgprs: &[u32], + mem: &[u32], + rt_formats: &[DXGI_FORMAT], + dsv_format: DXGI_FORMAT, + size: u32, + frames: u32, +) -> Result { + let mut g = GPU.lock().unwrap(); + let gpu = g.get_or_insert_with(init).as_mut().map_err(|x| x.clone())?; + let dev = gpu.dev.clone(); + let queue = gpu.queue.clone(); + let fence = gpu.fence.clone(); + let rs = gpu.rs.clone(); + let mut value = gpu.value; + let has_stencil = matches!(dsv_format, DXGI_FORMAT_D24_UNORM_S8_UINT | DXGI_FORMAT_D32_FLOAT_S8X24_UINT); + unsafe { + let bytecode = |b: &[u8]| D3D12_SHADER_BYTECODE { pShaderBytecode: b.as_ptr() as _, BytecodeLength: b.len() }; + let cpso: ID3D12PipelineState = dev + .CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC { + pRootSignature: transmute_copy(&rs), + CS: bytecode(cs), + ..Default::default() + }) + .map_err(|x| format!("CreateComputePipelineState: {x}"))?; + // the two graphics PSOs differ only in the depth-stencil state: the first writes depth + // (compressing it), the second reads it with depth-write off (what a later pass does) + let make_pso = |ds: D3D12_DEPTH_STENCIL_DESC| -> Result { + let mut blend = D3D12_BLEND_DESC::default(); + blend.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL.0 as u8; + let rast = D3D12_RASTERIZER_DESC { FillMode: D3D12_FILL_MODE_SOLID, CullMode: D3D12_CULL_MODE_NONE, DepthClipEnable: true.into(), ..Default::default() }; + let mut rtv_formats = D3D12_RT_FORMAT_ARRAY { NumRenderTargets: rt_formats.len() as u32, ..Default::default() }; + for (i, &f) in rt_formats.iter().enumerate() { + rtv_formats.RTFormats[i] = f; + } + let mut stream = MeshDepthStream { + rs: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE, v: rs.as_raw() }, + ms: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS, v: bytecode(ms) }, + ps: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS, v: bytecode(ps) }, + blend: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, v: blend }, + mask: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, v: u32::MAX }, + rast: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, v: rast }, + depth: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, v: ds }, + dsv: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT, v: dsv_format }, + rtv: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS, v: rtv_formats }, + samples: Sub { ty: D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, v: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 } }, + }; + let dev2: ID3D12Device2 = dev.cast().map_err(e)?; + dev2.CreatePipelineState(&D3D12_PIPELINE_STATE_STREAM_DESC { + SizeInBytes: std::mem::size_of::(), + pPipelineStateSubobjectStream: &mut stream as *mut MeshDepthStream as *mut std::ffi::c_void, + }) + .map_err(|x| format!("CreatePipelineState (mesh): {x}")) + }; + let pso_write = make_pso(D3D12_DEPTH_STENCIL_DESC { + DepthEnable: true.into(), + DepthWriteMask: D3D12_DEPTH_WRITE_MASK_ALL, + DepthFunc: D3D12_COMPARISON_FUNC_LESS, + ..Default::default() + })?; + let pso_read = make_pso(D3D12_DEPTH_STENCIL_DESC { + DepthEnable: true.into(), + DepthWriteMask: D3D12_DEPTH_WRITE_MASK_ZERO, + DepthFunc: D3D12_COMPARISON_FUNC_LESS_EQUAL, + ..Default::default() + })?; + + // the depth buffer in its cleared/compressed first-use state, plus a copy target to force + // decompression on resolve + let committed = |desc: &D3D12_RESOURCE_DESC, state: D3D12_RESOURCE_STATES, clear: Option<&D3D12_CLEAR_VALUE>| -> Result { + let mut r: Option = None; + dev.CreateCommittedResource(&D3D12_HEAP_PROPERTIES { Type: D3D12_HEAP_TYPE_DEFAULT, ..Default::default() }, D3D12_HEAP_FLAG_NONE, desc, state, clear.map(|c| c as *const _), &mut r).map_err(e)?; + r.ok_or_else(|| "resource".into()) + }; + let tex_desc = |f: DXGI_FORMAT, flags: D3D12_RESOURCE_FLAGS| D3D12_RESOURCE_DESC { + Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D, + Width: size as u64, + Height: size, + DepthOrArraySize: 1, + MipLevels: 1, + Format: f, + SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, + Flags: flags, + ..Default::default() + }; + let cv_depth = D3D12_CLEAR_VALUE { Format: dsv_format, Anonymous: D3D12_CLEAR_VALUE_0 { DepthStencil: D3D12_DEPTH_STENCIL_VALUE { Depth: 1.0, Stencil: 0 } } }; + // all `rt_formats` colour targets (the game's hang clusters on multi-RT + depth), each + // with its optimised clear; only RT0 is resolved and read back afterwards + let rts: Vec = rt_formats + .iter() + .map(|&f| committed(&tex_desc(f, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET), D3D12_RESOURCE_STATE_RENDER_TARGET, Some(&D3D12_CLEAR_VALUE { Format: f, Anonymous: D3D12_CLEAR_VALUE_0 { Color: [0.0, 0.0, 0.0, 1.0] } }))) + .collect::>()?; + let copy_rt = committed(&tex_desc(rt_formats[0], D3D12_RESOURCE_FLAG_NONE), D3D12_RESOURCE_STATE_COPY_DEST, None)?; + let depth_desc = D3D12_RESOURCE_DESC { + Dimension: D3D12_RESOURCE_DIMENSION_TEXTURE2D, + Width: size as u64, + Height: size, + DepthOrArraySize: 1, + MipLevels: 1, + Format: dsv_format, + SampleDesc: DXGI_SAMPLE_DESC { Count: 1, Quality: 0 }, + Flags: D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL, + ..Default::default() + }; + let depth = committed(&depth_desc, D3D12_RESOURCE_STATE_DEPTH_WRITE, Some(&cv_depth))?; + + let rtv_heap: ID3D12DescriptorHeap = dev.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC { Type: D3D12_DESCRIPTOR_HEAP_TYPE_RTV, NumDescriptors: rts.len() as u32, ..Default::default() }).map_err(e)?; + let rtv_inc = dev.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV) as usize; + let rtv = rtv_heap.GetCPUDescriptorHandleForHeapStart(); + for (i, r) in rts.iter().enumerate() { + dev.CreateRenderTargetView(r, None, D3D12_CPU_DESCRIPTOR_HANDLE { ptr: rtv.ptr + i * rtv_inc }); + } + let dsv_heap: ID3D12DescriptorHeap = dev.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC { Type: D3D12_DESCRIPTOR_HEAP_TYPE_DSV, NumDescriptors: 1, ..Default::default() }).map_err(e)?; + let dsv = dsv_heap.GetCPUDescriptorHandleForHeapStart(); + dev.CreateDepthStencilView(&depth, None, dsv); + + // records (u1) written by the compute pass; io (u0) / mem (u2) as in `mesh_draw` + let mut io = sgprs.to_vec(); + io.resize(KERNEL_SGPRS, 0); + let io_bytes = (io.len() * 4) as u64; + let mem_len = mem.len().max(64); + let mem_bytes = (mem_len * 4) as u64; + let res_bytes = (record_dwords * groups as usize * 4) as u64; + let upload = buffer(&dev, io_bytes + mem_bytes, D3D12_HEAP_TYPE_UPLOAD, D3D12_RESOURCE_STATE_GENERIC_READ, false)?; + let mut p = std::ptr::null_mut(); + upload.Map(0, None, Some(&mut p)).map_err(e)?; + std::ptr::copy_nonoverlapping(io.as_ptr(), p as *mut u32, io.len()); + let mut m = mem.to_vec(); + m.resize(mem_len, 0); + std::ptr::copy_nonoverlapping(m.as_ptr(), (p as *mut u32).add(io.len()), m.len()); + upload.Unmap(0, None); + let io_buf = buffer(&dev, io_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?; + let mem_buf = buffer(&dev, mem_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?; + let res_buf = buffer(&dev, res_bytes, D3D12_HEAP_TYPE_DEFAULT, D3D12_RESOURCE_STATE_COMMON, true)?; + let mut fp = D3D12_PLACED_SUBRESOURCE_FOOTPRINT::default(); + let mut total = 0u64; + dev.GetCopyableFootprints(&tex_desc(rt_formats[0], D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET), 0, 1, 0, Some(&mut fp), None, None, Some(&mut total)); + let readback = buffer(&dev, total, D3D12_HEAP_TYPE_READBACK, D3D12_RESOURCE_STATE_COPY_DEST, false)?; + + let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(e)?; + let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, &cpso).map_err(e)?; + let list6: ID3D12GraphicsCommandList6 = list.cast().map_err(e)?; + let viewport = D3D12_VIEWPORT { TopLeftX: 0.0, TopLeftY: 0.0, Width: size as f32, Height: size as f32, MinDepth: 0.0, MaxDepth: 1.0 }; + let scissor = windows::Win32::Foundation::RECT { left: 0, top: 0, right: size as i32, bottom: size as i32 }; + let clear_flags = if has_stencil { D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL } else { D3D12_CLEAR_FLAG_DEPTH }; + + // close, execute and fence-wait the current list; the wait turns a device removal into + // an error carrying `GetDeviceRemovedReason`, and a hang into a 10 s timeout error + let flush = |list: &ID3D12GraphicsCommandList, value: &mut u64, name: &str| -> Result<(), String> { + list.Close().map_err(e)?; + queue.ExecuteCommandLists(&[Some(list.cast().map_err(e)?)]); + *value += 1; + wait_for_submission(&dev, &queue, &fence, *value, name) + }; + + let mut completed: Vec = Vec::new(); + let mut failed: Option<(String, String)> = None; + // heaps bound per list (the directly-indexed root signature) must outlive their submit + let mut _bounds: Vec = Vec::new(); + 'run: { + // --- compute: write the records --- + list.CopyBufferRegion(&io_buf, 0, &upload, 0, io_bytes); + list.CopyBufferRegion(&mem_buf, 0, &upload, io_bytes, mem_bytes); + list.ResourceBarrier(&[ + transition(&io_buf, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS), + transition(&mem_buf, D3D12_RESOURCE_STATE_COPY_DEST, D3D12_RESOURCE_STATE_UNORDERED_ACCESS), + transition(&res_buf, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_UNORDERED_ACCESS), + ]); + _bounds.push(bind_resources(&dev, &list, &[], &[])?); + list.SetComputeRootSignature(&rs); + list.SetComputeRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress()); + list.SetComputeRootUnorderedAccessView(1, res_buf.GetGPUVirtualAddress()); + list.SetComputeRootUnorderedAccessView(2, mem_buf.GetGPUVirtualAddress()); + list.Dispatch(groups, 1, 1); + list.ResourceBarrier(&[uav_barrier(&res_buf)]); + if let Err(err) = flush(&list, &mut value, "compute") { + failed = Some(("compute".into(), err)); + break 'run; + } + completed.push("compute".into()); + + // --- one normal frame, then `frames` more: clear, mesh write (compress depth + + // colour), mesh read (sample the compressed depth), resolve/copy, readback --- + for fi in 0..=frames { + if let Err(x) = alloc.Reset() { + failed = Some((format!("frame {fi} reset"), e(x))); + break 'run; + } + if let Err(x) = list.Reset(&alloc, &pso_write) { + failed = Some((format!("frame {fi} reset"), e(x))); + break 'run; + } + _bounds.push(bind_resources(&dev, &list, &[], &[])?); + // write pass + list.SetPipelineState(&pso_write); + list.SetGraphicsRootSignature(&rs); + list.SetGraphicsRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress()); + list.SetGraphicsRootUnorderedAccessView(1, res_buf.GetGPUVirtualAddress()); + list.SetGraphicsRootUnorderedAccessView(2, mem_buf.GetGPUVirtualAddress()); + list.OMSetRenderTargets(rts.len() as u32, Some(&rtv), true, Some(&dsv)); + for i in 0..rts.len() { + list.ClearRenderTargetView(D3D12_CPU_DESCRIPTOR_HANDLE { ptr: rtv.ptr + i * rtv_inc }, &[0.0, 0.0, 0.0, 1.0], None); + } + list.ClearDepthStencilView(dsv, clear_flags, 1.0, 0, None); + list.RSSetViewports(&[viewport]); + list.RSSetScissorRects(&[scissor]); + list6.DispatchMesh(groups * split, 1, 1); + // read pass: the output-merger orders it after the write on the same targets + list.SetPipelineState(&pso_read); + list6.DispatchMesh(groups * split, 1, 1); + // resolve/copy the colour target (decompresses DCC) + a texture readback + list.ResourceBarrier(&[transition(&rts[0], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE)]); + list.CopyResource(©_rt, &rts[0]); + let dst = D3D12_TEXTURE_COPY_LOCATION { pResource: transmute_copy(&readback), Type: D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { PlacedFootprint: fp } }; + let src = D3D12_TEXTURE_COPY_LOCATION { pResource: transmute_copy(&rts[0]), Type: D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, Anonymous: D3D12_TEXTURE_COPY_LOCATION_0 { SubresourceIndex: 0 } }; + list.CopyTextureRegion(&dst, 0, 0, 0, &src, None); + list.ResourceBarrier(&[transition(&rts[0], D3D12_RESOURCE_STATE_COPY_SOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET)]); + let name = format!("frame {fi}"); + if let Err(err) = flush(&list, &mut value, &name) { + failed = Some((name, err)); + break 'run; + } + completed.push(name); + } + + // map the readback (the CPU-visible result of the last frame): a removal would + // already have surfaced in the frame's fence wait, this only touches the data + let mut q = std::ptr::null_mut(); + if let Err(x) = readback.Map(0, None, Some(&mut q)) { + failed = Some(("readback map".into(), e(x))); + break 'run; + } + std::ptr::read_volatile(q as *const u8); + readback.Unmap(0, None); + completed.push("readback".into()); + } + gpu.value = value; + Ok(PoisonReport { completed, failed }) + } +} + /// Process memory regions for `run_in_region` (see `gpu::uma`): the memory windows. struct Arena { pub windows: Vec<(*mut u8, usize)>, diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 3443a603fb..a9cdc72ad9 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -3771,6 +3771,81 @@ fn gpu_mesh_mode_two_passes() { assert!(px16 == px, "split pass-through draws the same pixels"); } +/// Poison test: one game-shaped mesh pass into the title's target shape – three `R8G8B8A8_UNORM` +/// colour targets (delta-colour-compressed, unlike `mesh_draw`'s `R32G32B32A32_FLOAT`) and a +/// `D32_FLOAT_S8X24_UINT` depth buffer primed into its compressed first-use state – then the +/// operations a normal frame runs afterwards (a depth-reading pass, a colour resolve/copy, a +/// readback), each separately fenced (`runner::mesh_poison`). A completed dispatch that leaves +/// depth/colour compression metadata corrupted shows up as a later phase (not the mesh pass) +/// being the first to hang or remove the device; the report names that phase. If every phase +/// completes, the mesh pass leaves nothing behind that these frame operations trip over. +#[test] +fn gpu_mesh_poison() { + if !gpu_ready() || !mesh_ready() { + return; + } + use super::emit::{mesh_passthrough, passthrough_elements, passthrough_split}; + use super::{MsInterface, MESH_HEADER}; + use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_D32_FLOAT_S8X24_UINT, DXGI_FORMAT_R8G8B8A8_UNORM}; + let sig = |name: &str, sv: u32, reg: u32, index: u32| crate::gpu::dxbc::SigElement { + name: name.into(), + index, + system_value: sv, + component_type: 3, + register: reg, + mask: 0xF, + rw_mask: 0xF, + stream: 0, + }; + // a game-shaped pass: 128 threads, 128 vertices / 128 primitives, 4 output rows + let params = 4u32; + let mut outputs = vec![sig("SV_Position", 1, 0, 0)]; + for k in 0..params { + outputs.push(sig("TEXCOORD", 0, k + 1, k)); + } + let ms = MsInterface { outputs, threads: 128, max_vertices: 128, max_primitives: 128 }; + let split = passthrough_split(&ms, passthrough_elements(&ms, None)); + let (vd, vdq, rd) = (ms.vert_dwords(), ms.vert_dwords() / 4, ms.record_dwords()); + let tri_base = MESH_HEADER + ms.max_vertices as usize * vd; + let (mv, mp) = (ms.max_vertices, ms.max_primitives); + let cs_src = format!( + "RWByteAddressBuffer res : register(u1); +[numthreads(1, 1, 1)] +void main(uint3 gid : SV_GroupID) {{ + uint rec = gid.x * {rd}u; + res.Store(rec * 4u, {mv}u); + res.Store(rec * 4u + 4u, {mp}u); + for (uint i = 0u; i < {mv}u; i++) {{ + uint b = (rec + {MESH_HEADER}u + i * {vd}u) * 4u; + float fi = (float)i; + float x = -1.0 + 2.0 * frac(fi * 0.123 + 0.05); + float y = -1.0 + 2.0 * frac(fi * 0.371 + 0.05); + res.Store4(b, asuint(float4(x, y, 0.0, 1.0))); + for (uint p = 1u; p < {vdq}u; p++) res.Store4(b + p * 16u, uint4(0u, 0u, 0u, 0u)); + }} + for (uint j = 0u; j < {mp}u; j++) {{ + uint a = j % {mv}u; + uint bb = (j + 1u) % {mv}u; + uint cc = (j + 2u) % {mv}u; + res.Store((rec + {tri_base}u + j) * 4u, a | (bb << 10u) | (cc << 20u)); + }} +}} +" + ); + let cs = super::dxc::compile(&cs_src, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("cs: {e}")); + let pass = mesh_passthrough(&ms); + let msb = super::dxc::compile(&pass, "main", "ms_6_6", &[]).unwrap_or_else(|e| panic!("ms: {e}\n{pass}")); + let fields: String = (0..params).map(|k| format!(" float4 p{k} : TEXCOORD{k};")).collect(); + let ps_src = format!("struct V {{ float4 pos : SV_Position;{fields} }};\nstruct O {{ float4 t0 : SV_Target0; float4 t1 : SV_Target1; float4 t2 : SV_Target2; }};\nO main(V v) {{ O o; o.t0 = float4(1, 1, 1, 1); o.t1 = o.t0; o.t2 = o.t0; return o; }}\n"); + let ps = super::dxc::compile(&ps_src, "main", "ps_6_6", &[]).unwrap_or_else(|e| panic!("ps: {e}")); + + // three R8G8B8A8_UNORM targets + depth at 1024x1024, matching the game's hanging draws + // ([state: 3 RT, console DSV 20]); the target is large enough that HiZ/ZCull/DCC compression + // metadata is actually allocated, and 8 extra frames catch a delayed effect under load + let report = runner::mesh_poison(&cs, &msb, &ps, 1, split, rd, &[], &[], &[DXGI_FORMAT_R8G8B8A8_UNORM; 3], DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 1024, 8).unwrap(); + assert!(report.ok(), "mesh pass poisoned a later operation: failed at {:?}; completed {:?}", report.failed, report.completed); +} + #[test] fn mesh_passthrough_strips_rdna2_edge_flag_bits() { use super::{mesh_passthrough, MsInterface};