diff --git a/crates/xcl/src/gpu/dxil/geometry_tests.rs b/crates/xcl/src/gpu/dxil/geometry_tests.rs index 57d4cce9a9..e11e3963cc 100644 --- a/crates/xcl/src/gpu/dxil/geometry_tests.rs +++ b/crates/xcl/src/gpu/dxil/geometry_tests.rs @@ -88,6 +88,23 @@ fn geometry_forms_validate() { } } +/// A GS that reads its ES inputs (v9..) translates with the windows in the descriptor heap: +/// `mems` only counts them there, the inputs come from window 0's view in the heap. +#[test] +fn geometry_inputs_with_heap_windows_validate() { + let (mut code, mut g) = branchy_program(); + // v53 = v9 (input 0, x) before the GS ends: the inputs are fetched + let end = code.len() - 8; + let mv = encode("V_MOV_B32", "ENC_VOP1", &[("VDST", 53), ("SRC0", 256 + 9)], None).unwrap(); + code.splice(end..end, mv); + g.es_inputs = vec![sig("TEXCOORD", 0, 0, 3)]; + for split in [false, true] { + for windows in [1, 4, 4 | crate::gpu::recomp::HEAP_WINDOWS] { + translate_geometry(&code, opts(split, windows), &g).unwrap_or_else(|e| panic!("split {split}, windows {windows:#x}: {e}")); + } + } +} + /// The records of `branchy_program` for `prims` primitives: (group, record dwords). fn expected_records(g: &GsInterface, prims: usize) -> Vec { let rec = g.record(); diff --git a/crates/xcl/src/gpu/dxil/kernel.rs b/crates/xcl/src/gpu/dxil/kernel.rs index 8687e4807a..f140f4dde4 100644 --- a/crates/xcl/src/gpu/dxil/kernel.rs +++ b/crates/xcl/src/gpu/dxil/kernel.rs @@ -823,7 +823,14 @@ fn geom_init(lw: &mut Lw, g: &GsInterface, _tid: Value, io: super::shader::RawUa let nreg = g.input_registers(); let fetched = fetched_registers(&g.es_inputs); let in_nv = lw.cmp(Pred::ULt, lane, nv); - let mem = lw.mems[0]; + // window 0; with the windows in the descriptor heap `mems` only counts them (`mem_windows`) + let mem = match lw.heap_mem { + Some(coherent) => { + let i = lw.c(crate::gpu::recomp::MEM_HEAP_BASE); + lw.s.heap_raw_buffer_uav(i, coherent) + } + None => lw.mems[0], + }; for &v in used.iter().filter(|&&v| (9..256).contains(&v)) { let k = ((v - 9) / 4) as usize; if k >= fetched.len() || fetched[k] >= nreg {