diff --git a/crates/xcl/src/gpu/recomp/emit.rs b/crates/xcl/src/gpu/recomp/emit.rs index 96966005b6..4a7f9784b3 100644 --- a/crates/xcl/src/gpu/recomp/emit.rs +++ b/crates/xcl/src/gpu/recomp/emit.rs @@ -4704,7 +4704,12 @@ impl Em { } if windows > 1 { let coherent = if matches!(self.opt.mode, Mode::Compute(_)) { "globallycoherent " } else { "" }; - h = windowed(&h, windows, self.opt.heap_windows.then_some(coherent)); + let heap = self.opt.heap_windows.then_some(coherent); + // compute passes (CS, and the MS / GS compute passes) only: the driver times were + // measured on compute pipelines, and VS / PS keep their HLSL and cache keys. The heap + // form has no switch to drop. + let flat = heap.is_none() && !matches!(self.opt.mode, Mode::Vertex(_) | Mode::Pixel(_)) && h.len() >= FLAT_WINDOW_LOADS_FROM; + h = windowed(&h, windows, heap, flat); } h } @@ -5084,18 +5089,24 @@ fn float_minmax_mem(min: bool, x2: bool, a: &str, v: &str, old: &str, t: &str) - } /// Placeholder where the memory window accessors go (after the `mem` declarations). -const MEM_ACCESSORS_HERE: &str = "//XCL_MEM_ACCESSORS\n"; +pub(super) const MEM_ACCESSORS_HERE: &str = "//XCL_MEM_ACCESSORS\n"; /// Four dwords at four addresses (scalar buffer loads with their bounds checks); with several /// windows `mem_accessors` defines it, with one switch for all four. const LOADX4_ONE_WINDOW: &str = "uint4 xcl_loadx4(uint4 a) { return uint4(mem.Load(a.x), mem.Load(a.y), mem.Load(a.z), mem.Load(a.w)); }\n"; +/// Compute HLSL from this size on reads from its windows without a switch (`mem_accessors`' +/// `flat`). A retail game's ~1 MB-DXIL compute programs (13 000 - 21 000 instructions, ~1 150 +/// window switches each) took the NVIDIA driver 30 - 340 s to compile, 3 - 4 times less without +/// the switches. Smaller programs keep the switch, and with it their HLSL and every cache key. +pub(super) const FLAT_WINDOW_LOADS_FROM: usize = 1 << 20; + /// Several memory windows: every `mem.Method(` of the program (and of the preludes) becomes /// an accessor `xcl_mMethod(` that switches on `xcl_w` between `mem` and `mem1`.., whose -/// definitions replace the placeholder. +/// definitions replace the placeholder (`flat`: loads without the switch). /// `heap`: Some(storage class) – the accessors take window k from the descriptor heap /// (`Options::heap_windows`) instead of switching over the root UAVs. -fn windowed(h: &str, windows: u32, heap: Option<&str>) -> String { +pub(super) fn windowed(h: &str, windows: u32, heap: Option<&str>, flat: bool) -> String { let mut out = String::with_capacity(h.len() + 8192); let mut rest = h; while let Some(i) = rest.find("mem.") { @@ -5113,16 +5124,23 @@ fn windowed(h: &str, windows: u32, heap: Option<&str>) -> String { } } out.push_str(rest); - out.replacen(MEM_ACCESSORS_HERE, &mem_accessors(windows, heap), 1) + out.replacen(MEM_ACCESSORS_HERE, &mem_accessors(windows, heap, flat), 1) } /// The accessor functions: one per `mem` method (and overload) the translator emits. /// Only explicit windows `0..windows` touch GPU buffers; any out-of-range `xcl_w` hits /// `default` (reads return 0, stores/atomics are dropped and zero their `out` parameter) so /// out-of-UMA pointers can never wrap onto live memory windows. +/// `flat`: loads read every window – the selected one at the address, the others at offset 0 +/// (always inside the window's buffer; a sparse window's unmapped tile reads 0) – and select +/// by `xcl_w`, no branch: a switch per load makes the NVIDIA driver's compile of a big program +/// several times slower. Same values, including 0 for an out-of-range `xcl_w`. Stores and +/// atomics always switch (one window). This needs every window bound to its buffer, which +/// `real::open_uma` gives whenever the GPU has unified memory at all. /// `heap`: Some(storage class) – window k is taken from the descriptor heap -/// (`Options::heap_windows`) and the same rule is one comparison before the access. -fn mem_accessors(windows: u32, heap: Option<&str>) -> String { +/// (`Options::heap_windows`) and the same rule is one comparison before the access (`flat` +/// does not apply: there is no switch). +pub(super) fn mem_accessors(windows: u32, heap: Option<&str>, flat: bool) -> String { let mut sigs: Vec<(&str, String, &str, &str, &str)> = vec![ ("uint", "Load".into(), "uint a", "a", "return 0u;"), ("uint2", "Load2".into(), "uint a", "a", "return uint2(0u, 0u);"), @@ -5160,13 +5178,35 @@ fn mem_accessors(windows: u32, heap: Option<&str>) -> String { } return s; } - let _ = write!(s, "uint4 xcl_loadx4(uint4 a) {{ [branch] switch (xcl_w) {{ "); - let _ = write!(s, "case 0u: return uint4(mem.Load(a.x), mem.Load(a.y), mem.Load(a.z), mem.Load(a.w)); "); - for k in 1..windows { - let _ = write!(s, "case {k}u: return uint4(mem{k}.Load(a.x), mem{k}.Load(a.y), mem{k}.Load(a.z), mem{k}.Load(a.w)); "); + let buf = |k: u32| if k == 0 { "mem".to_string() } else { format!("mem{k}") }; + // the selected window's value, else the next one's .., else `zero` (out-of-range `xcl_w`) + let pick = |zero: &str| (0..windows).rev().fold(zero.to_string(), |rest, k| format!("select(xcl_w == {k}u, r{k}, {rest})")); + if flat { + let _ = write!(s, "uint4 xcl_loadx4(uint4 a) {{ "); + for k in 0..windows { + let m = buf(k); + let _ = write!(s, "uint4 b{k} = select(xcl_w == {k}u, a, 0u); uint4 r{k} = uint4({m}.Load(b{k}.x), {m}.Load(b{k}.y), {m}.Load(b{k}.z), {m}.Load(b{k}.w)); "); + } + let _ = writeln!(s, "return {}; }}", pick("uint4(0u, 0u, 0u, 0u)")); + } else { + let _ = write!(s, "uint4 xcl_loadx4(uint4 a) {{ [branch] switch (xcl_w) {{ "); + let _ = write!(s, "case 0u: return uint4(mem.Load(a.x), mem.Load(a.y), mem.Load(a.z), mem.Load(a.w)); "); + for k in 1..windows { + let _ = write!(s, "case {k}u: return uint4(mem{k}.Load(a.x), mem{k}.Load(a.y), mem{k}.Load(a.z), mem{k}.Load(a.w)); "); + } + let _ = writeln!(s, "default: return uint4(0u, 0u, 0u, 0u); }} }}"); } - let _ = writeln!(s, "default: return uint4(0u, 0u, 0u, 0u); }} }}"); for (ret, name, params, args, def) in sigs { + if flat && ret != "void" { + // loads only (`a` is their one argument) + let _ = write!(s, "{ret} xcl_m{name}({params}) {{ "); + for k in 0..windows { + let _ = write!(s, "{ret} r{k} = {}.{name}(select(xcl_w == {k}u, a, 0u)); ", buf(k)); + } + let zero = def.trim_start_matches("return ").trim_end_matches(';'); + let _ = writeln!(s, "return {}; }}", pick(zero)); + continue; + } let _ = write!(s, "{ret} xcl_m{name}({params}) {{ [branch] switch (xcl_w) {{ "); if ret == "void" { let _ = write!(s, "case 0u: mem.{name}({args}); break; "); diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 55ef19082f..0bf48f651c 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -3391,7 +3391,14 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap(); assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap); let hlsl_dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(); - let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil); + // the window switch (or the heap form) of programs below `emit::FLAT_WINDOW_LOADS_FROM` – + // the direct translator's with `XCL_DIRECT_DXIL=1` – then the flat loads of bigger ones: the + // same values, and the stores / atomics still switch + let mut dxils: Vec<(&str, Vec)> = vec![(if heap { "heap" } else { "switch" }, direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil))]; + if !heap { + let flat = flat_window_loads(&t.hlsl, 2); + dxils.push(("flat", super::dxc::compile(&flat, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{flat}")).unwrap())); + } let mut st = KernelState::default(); st.sgpr[2..4].copy_from_slice(&[0x1000, base_hi + 4]); // s[2:3]: out-of-UMA hi = base_hi + 4 @@ -3420,23 +3427,87 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { r[18] = 0x7777_7777; } - let r = runner::run_in_arena(&dxil, &st, &arena).unwrap(); - assert_eq!(r.sgpr[30], 0, "out-of-UMA s_load must return 0"); - assert_eq!(r.sgpr[31], 0xABCD_0123, "hi == 0 s_load must still read window 0 (32-bit descriptor tables)"); - assert_eq!(r.vgpr[0][2], 0, "out-of-UMA buffer_load must return 0"); - assert_eq!(r.vgpr[0][3], 0x5566_7788, "valid strided V# buffer_load must mask stride out of d1"); - assert_eq!(r.vgpr[0][10], 0, "out-of-UMA global_atomic_add GLC must return 0"); - assert_eq!(r.vgpr[0][11], 0, "out-of-UMA global_atomic_inc CAS loop must return 0 and terminate"); - assert_eq!(r.vgpr[0][14], 0, "out-of-UMA buffer_atomic_add GLC must return 0"); - assert_eq!(r.vgpr[0][17], 0x99AA_BBCC, "64-bit carry global_load must cross from w0 into w1"); - assert_eq!(r.vgpr[0][18], 0, "64-bit signed borrow below window 0 must be rejected and read 0"); - - assert_eq!(*word(w0 + 0x1000), CANARY0, "out-of-UMA global_store must not clobber w0"); - assert_eq!(*word(w1 + 0x1000), CANARY1, "out-of-UMA buffer_store must not clobber w1"); - assert_eq!(*word(w0 + 0x2000), CANARY0, "hi == 0 global_store must not clobber w0"); - assert_eq!(*word(w1 + 0x2000), CANARY1, "out-of-UMA global_atomic_add must not clobber w1"); - assert_eq!(*word(w0 + 0x3000), CANARY0, "out-of-UMA buffer_atomic_add must not clobber w0"); - assert_eq!(*word(w1 + 0x3000), CANARY1, "out-of-UMA global_atomic_inc must not clobber w1"); + for (form, dxil) in &dxils { + let r = runner::run_in_arena(dxil, &st, &arena).unwrap(); + assert_eq!(r.sgpr[30], 0, "{form}: out-of-UMA s_load must return 0"); + assert_eq!(r.sgpr[31], 0xABCD_0123, "{form}: hi == 0 s_load must still read window 0 (32-bit descriptor tables)"); + assert_eq!(r.vgpr[0][2], 0, "{form}: out-of-UMA buffer_load must return 0"); + assert_eq!(r.vgpr[0][3], 0x5566_7788, "{form}: valid strided V# buffer_load must mask stride out of d1"); + assert_eq!(r.vgpr[0][10], 0, "{form}: out-of-UMA global_atomic_add GLC must return 0"); + assert_eq!(r.vgpr[0][11], 0, "{form}: out-of-UMA global_atomic_inc CAS loop must return 0 and terminate"); + assert_eq!(r.vgpr[0][14], 0, "{form}: out-of-UMA buffer_atomic_add GLC must return 0"); + assert_eq!(r.vgpr[0][17], 0x99AA_BBCC, "{form}: 64-bit carry global_load must cross from w0 into w1"); + assert_eq!(r.vgpr[0][18], 0, "{form}: 64-bit signed borrow below window 0 must be rejected and read 0"); + + assert_eq!(*word(w0 + 0x1000), CANARY0, "{form}: out-of-UMA global_store must not clobber w0"); + assert_eq!(*word(w1 + 0x1000), CANARY1, "{form}: out-of-UMA buffer_store must not clobber w1"); + assert_eq!(*word(w0 + 0x2000), CANARY0, "{form}: hi == 0 global_store must not clobber w0"); + assert_eq!(*word(w1 + 0x2000), CANARY1, "{form}: out-of-UMA global_atomic_add must not clobber w1"); + assert_eq!(*word(w0 + 0x3000), CANARY0, "{form}: out-of-UMA buffer_atomic_add must not clobber w0"); + assert_eq!(*word(w1 + 0x3000), CANARY1, "{form}: out-of-UMA global_atomic_inc must not clobber w1"); + } +} + +/// HLSL of a program below `emit::FLAT_WINDOW_LOADS_FROM` with the window loads of a bigger one +/// (`emit::mem_accessors`' `flat`). +fn flat_window_loads(hlsl: &str, windows: u32) -> String { + let switched = super::emit::mem_accessors(windows, None, false); + assert!(hlsl.contains(&switched), "a small program keeps the window switch"); + hlsl.replacen(&switched, &super::emit::mem_accessors(windows, None, true), 1) +} + +/// Compute programs from `emit::FLAT_WINDOW_LOADS_FROM` on read their windows without a switch; +/// stores and atomics keep it, and smaller programs keep their HLSL (and cache keys). +#[test] +fn big_programs_read_their_windows_without_a_switch() { + let small = format!("{}{}", super::emit::MEM_ACCESSORS_HERE, "uint x = mem.Load(4u);\n"); + let (s, b) = (super::emit::windowed(&small, 4, None, false), super::emit::windowed(&small, 4, None, true)); + let line = |h: &str, f: &str| h.lines().find(|l| l.contains(f)).unwrap_or_else(|| panic!("{f}")).to_string(); + assert_eq!(s, small.replacen(super::emit::MEM_ACCESSORS_HERE, &super::emit::mem_accessors(4, None, false), 1).replace("mem.Load(4u)", "xcl_mLoad(4u)")); + for f in ["uint4 xcl_loadx4(", "uint xcl_mLoad(", "uint2 xcl_mLoad2(", "uint3 xcl_mLoad3(", "uint4 xcl_mLoad4("] { + assert!(line(&s, f).contains("switch (xcl_w)"), "{f}"); + let l = line(&b, f); + assert!(!l.contains("switch") && !l.contains("if"), "{l}"); + // each window once, the unselected ones at offset 0; out of range: 0 + for k in ["mem.", "mem1.", "mem2.", "mem3."] { + assert!(l.contains(k), "{l}"); + } + assert!(l.contains("select(xcl_w == 3u, r3, uint") || l.contains("select(xcl_w == 3u, r3, 0u)"), "{l}"); + } + // the gate: a compute program of about 1.5 MB of HLSL (scalar loads) is flat, a short one not + let load = ("S_LOAD_DWORDX4", "ENC_SMEM", &[("SDATA", 8), ("SBASE", 2), ("OFFSET", 0)][..], None); + let opt = || Options { mem_windows: 4, ..Default::default() }; + let short = translate(&prog(&[load]), &opt()).unwrap().hlsl; + let long = translate(&prog(&vec![load; 4000]), &opt()).unwrap().hlsl; + assert!(short.len() < super::emit::FLAT_WINDOW_LOADS_FROM && long.len() >= super::emit::FLAT_WINDOW_LOADS_FROM, "{} / {}", short.len(), long.len()); + assert!(line(&short, "uint4 xcl_loadx4(").contains("switch (xcl_w)")); + assert_eq!(line(&long, "uint4 xcl_loadx4("), line(&b, "uint4 xcl_loadx4(")); + for f in ["void xcl_mStore(", "void xcl_mInterlockedAdd(uint a, uint v, out uint o)", "void xcl_mInterlockedCompareExchange("] { + assert_eq!(line(&b, f), line(&s, f), "{f}"); + assert!(line(&b, f).contains("switch (xcl_w)"), "{f}"); + } + // heap windows (`Options::heap_windows`): one descriptor-heap access per load, big or not + let heap = translate(&prog(&vec![load; 4000]), &Options { heap_windows: true, ..opt() }).unwrap().hlsl; + assert!(heap.len() >= super::emit::FLAT_WINDOW_LOADS_FROM); + let l = line(&heap, "uint4 xcl_loadx4("); + assert!(l.contains("XCL_MW;") && !l.contains("select(") && !l.contains("switch"), "{l}"); +} + +/// A compute program of about 1.5 MB of HLSL (4 000 scalar loads) reads its windows without a +/// switch; a one-load program keeps it. Through `translate` only, as a title's program goes. +#[test] +fn a_big_compute_program_reads_its_windows_without_a_switch() { + let line = |h: &str, f: &str| h.lines().find(|l| l.contains(f)).unwrap_or_else(|| panic!("{f}")).to_string(); + let load = ("S_LOAD_DWORDX4", "ENC_SMEM", &[("SDATA", 8), ("SBASE", 2), ("OFFSET", 0)][..], None); + let opt = || Options { mem_windows: 4, ..Default::default() }; + let short = translate(&prog(&[load]), &opt()).unwrap().hlsl; + let long = translate(&prog(&vec![load; 4000]), &opt()).unwrap().hlsl; + assert!(line(&short, "uint4 xcl_loadx4(").contains("switch (xcl_w)")); + for f in ["uint4 xcl_loadx4(", "uint xcl_mLoad("] { + let l = line(&long, f); + assert!(!l.contains("switch"), "{l}"); + } + assert!(line(&long, "void xcl_mStore(").contains("switch (xcl_w)")); } /// The start-up check of the coherent UMA windows (`real::check_uma_import`): the GPU sees what @@ -3526,23 +3597,32 @@ fn gpu_sparse_vram_descriptors_buffers_and_xmem() { let cs = super::CsInterface { threads: [64, 1, 1], user_sgprs: 6, ..Default::default() }; let opt = on_gpu(Options { mode: Mode::Compute(cs), mem_windows: 4, ..Default::default() }); let t = translate(&p, &opt).unwrap(); - let dxil = direct_or(&p, &opt, super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap()); + // the window switch (the direct translator's form with `XCL_DIRECT_DXIL=1`), then the flat + // loads of programs from `emit::FLAT_WINDOW_LOADS_FROM` on + let dxils: Vec> = vec![ + direct_or(&p, &opt, super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap()), + super::dxc::compile(&flat_window_loads(&t.hlsl, 4), "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(), + ]; // Execute on the real D3D12.X device + queue (goes through q_execute_command_lists -> sparse::before_execute) unsafe { let dev_raw = crate::hle::d3d12x::real::device_raw(); let dev = ID3D12Device::from_raw_borrowed(&dev_raw).expect("device").clone(); let rs = crate::gpu::recomp::pso::abi_root_signature(&dev, false).expect("ABI root signature"); - let pso: ID3D12PipelineState = dev - .CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC { - pRootSignature: std::mem::ManuallyDrop::new(Some(rs.clone())), - CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr() as *const _, BytecodeLength: dxil.len() }, - ..Default::default() + let psos: Vec = dxils + .iter() + .map(|dxil| { + dev.CreateComputePipelineState(&D3D12_COMPUTE_PIPELINE_STATE_DESC { + pRootSignature: std::mem::ManuallyDrop::new(Some(rs.clone())), + CS: D3D12_SHADER_BYTECODE { pShaderBytecode: dxil.as_ptr() as *const _, BytecodeLength: dxil.len() }, + ..Default::default() + }) + .expect("CreateComputePipelineState") }) - .expect("CreateComputePipelineState"); + .collect(); let queue: ID3D12CommandQueue = dev.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC::default()).unwrap(); let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).unwrap(); - let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, Some(&pso)).unwrap(); + let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, Some(&psos[0])).unwrap(); let fence: ID3D12Fence = dev.CreateFence(0, D3D12_FENCE_FLAG_NONE).unwrap(); // User SGPRs: s[0:1] = 64-bit arg_table (Window 3), s4 = 32-bit descriptor table offset in Window 0 @@ -3554,10 +3634,10 @@ fn gpu_sparse_vram_descriptors_buffers_and_xmem() { io[5] = 0xDEAD_BEEF; // shader overwrites s5 = 0 to prove hi == 0 32-bit addressing hits Window 0 sparse VRAM std::ptr::copy_nonoverlapping(io.as_ptr() as *const u8, io_buf as *mut u8, io.len() * 4); - let record_and_run = |fence_val: u64, first: bool| { + let record_and_run = |pso: &ID3D12PipelineState, fence_val: u64, first: bool| { if !first { alloc.Reset().unwrap(); - list.Reset(&alloc, Some(&pso)).unwrap(); + list.Reset(&alloc, Some(pso)).unwrap(); } list.SetComputeRootSignature(&rs); list.SetComputeRootUnorderedAccessView(0, crate::hle::d3d12x::real::uma_va_of(io_buf).unwrap()); @@ -3577,22 +3657,30 @@ fn gpu_sparse_vram_descriptors_buffers_and_xmem() { } }; - // Submit 1: reads slot 0 -> in_a (sparse VRAM) + arg_table constant 77 (Window 3) - record_and_run(1, true); - for l in 0..64usize { - let got = *((out_buf + 4 * l) as *const u32); - assert_eq!(got, 1000 + l as u32 + 77, "submit 1 lane {l} mismatch"); - } + for (n, (form, pso)) in ["switch", "flat"].iter().zip(&psos).enumerate() { + let n = n as u64; + *(arg_table as *mut u32) = 77; + *((in_b + 4 * 3) as *mut u32) = 5000 + 2 * 3; + crate::hle::d3d12x::console_heap::write(&slot0, &vsharp(in_a)); + // Submit 1: reads slot 0 -> in_a (sparse VRAM) + arg_table constant 77 (Window 3) + std::ptr::write_bytes(out_buf as *mut u8, 0, 256); + record_and_run(pso, 2 * n + 1, n == 0); + for l in 0..64usize { + let got = *((out_buf + 4 * l) as *const u32); + assert_eq!(got, 1000 + l as u32 + 77, "{form}: submit 1 lane {l} mismatch"); + } - // Submit 2: mutate descriptor slot 0 in Window 0 sparse VRAM -> in_b, and mutate in_b[3] + arg_table - *(arg_table as *mut u32) = 13; - *((in_b + 4 * 3) as *mut u32) = 9999; - crate::hle::d3d12x::console_heap::write(&slot0, &vsharp(in_b)); - record_and_run(2, false); - for l in 0..64usize { - let expected = if l == 3 { 9999 + 13 } else { 5000 + 2 * l as u32 + 13 }; - let got = *((out_buf + 4 * l) as *const u32); - assert_eq!(got, expected, "submit 2 (mutated sparse descriptor + XMem buffer) lane {l} mismatch"); + // Submit 2: mutate descriptor slot 0 in Window 0 sparse VRAM -> in_b, and mutate in_b[3] + arg_table + *(arg_table as *mut u32) = 13; + *((in_b + 4 * 3) as *mut u32) = 9999; + crate::hle::d3d12x::console_heap::write(&slot0, &vsharp(in_b)); + std::ptr::write_bytes(out_buf as *mut u8, 0, 256); + record_and_run(pso, 2 * n + 2, false); + for l in 0..64usize { + let expected = if l == 3 { 9999 + 13 } else { 5000 + 2 * l as u32 + 13 }; + let got = *((out_buf + 4 * l) as *const u32); + assert_eq!(got, expected, "{form}: submit 2 (mutated sparse descriptor + XMem buffer) lane {l} mismatch"); + } } // Clean up