diff --git a/crates/xcl/src/gpu/dxil/kernel.rs b/crates/xcl/src/gpu/dxil/kernel.rs index 371ac0622c..efcf15a00c 100644 --- a/crates/xcl/src/gpu/dxil/kernel.rs +++ b/crates/xcl/src/gpu/dxil/kernel.rs @@ -15,7 +15,7 @@ use super::cfg::{Cfg, Term}; use super::container::Stage; use super::lower::{ComputeInit, Init, Lw, Partner, VAR_BUDGET, VAR_SCC, VAR_VGPR}; use super::module::{Block, Pred, Value}; -use super::shader::Shader; +use super::shader::{RawUav, Shader}; use super::ssa::Ssa; use crate::gpu::recomp::{CsInterface, MsInterface, PsInterface, VsInterface, KERNEL_SCC_SLOT, KERNEL_SGPRS, KERNEL_VGPRS, MESH_HEADER}; @@ -26,7 +26,8 @@ pub struct KernelOptions { /// the GPU runs only 32-lane waves: a wave64 program runs as two halves pub split: bool, /// 4 GiB memory windows the program may address (`recomp::Options::mem_windows`): - /// `mem` at u2, then `mem1`.. at u3.. + /// `mem` at u2, then `mem1`.. at u3.. (with `recomp::HEAP_WINDOWS`: descriptors + /// `MEM_HEAP_BASE`.. of the resource heap) pub mem_windows: u32, /// first register (space 1) of the static samplers (another stage may come first) pub sampler_base: u32, @@ -35,7 +36,7 @@ pub struct KernelOptions { /// Version of the direct translator's output, part of the on-disk translation cache's /// identity (`recomp::pso`): bump it on any change that alters the emitted containers /// (the `gpu/dxil` sources are not in build.rs's translator source hash). -pub const TRANSLATOR_VERSION: u32 = 4; +pub const TRANSLATOR_VERSION: u32 = 5; /// `XCL_DIRECT_DXIL=1`: console compute shaders (and the kernel tests) go through this /// translator, with the HLSL path as the fallback for what it cannot translate yet. @@ -100,11 +101,6 @@ pub fn translate_compute(code: &[u8], o: KernelOptions, cs: &CsInterface) -> Res } fn translate_entry(code: &[u8], o: KernelOptions, entry: Entry) -> Result { - // memory windows through the descriptor heap (`recomp::HEAP_WINDOWS` in the count, - // `XCL_HEAP_WINDOWS=1`) are not translated yet: the caller falls back to HLSL - if o.mem_windows & crate::gpu::recomp::HEAP_WINDOWS != 0 { - return Err("unsupported: heap memory windows (XCL_HEAP_WINDOWS)".into()); - } // SSA construction recurses along the CFG (one level per guarded memory access between // a register's definition and its use): a thread with a large stack for big programs let code = code.to_vec(); @@ -120,6 +116,20 @@ fn translate_entry(code: &[u8], o: KernelOptions, entry: Entry) -> Result (Vec, Option) { + let heap = mem_windows & crate::gpu::recomp::HEAP_WINDOWS != 0; + let n = (mem_windows & !crate::gpu::recomp::HEAP_WINDOWS).clamp(1, 4); + if heap && n > 1 { + let z = s.m.i32c(0); + return (vec![RawUav { handle: z, binding: None }; n as usize], Some(coherent)); + } + ((0..n).map(|k| if coherent { s.raw_uav_coherent(2 + k, 0) } else { s.raw_uav(2 + k, 0) }).collect(), None) +} + fn translate_on_this_thread(code: &[u8], o: KernelOptions, entry: Entry) -> Result { let cfg = Cfg::build(code)?; let split = o.wave64 && o.split; @@ -142,9 +152,7 @@ fn translate_on_this_thread(code: &[u8], o: KernelOptions, entry: Entry) -> Resu let mut s = Shader::new(stage, (6, 6)); let io = s.raw_uav(0, 0); let res = if kernel || ms.is_some() { Some(s.raw_uav(1, 0)) } else { None }; - // compute work across groups relies on coherent memory (as the HLSL compute mode's - // `globallycoherent` windows) - let mems: Vec<_> = (0..o.mem_windows.clamp(1, 4)).map(|k| if cs.is_some() { s.raw_uav_coherent(2 + k, 0) } else { s.raw_uav(2 + k, 0) }).collect(); + let (mems, heap_mem) = mem_windows(&mut s, o.mem_windows, cs.is_some()); let i32 = s.m.i32(); let z = s.m.i32c(0); let mut lw = Lw { @@ -158,6 +166,7 @@ fn translate_on_this_thread(code: &[u8], o: KernelOptions, entry: Entry) -> Resu upper: z, half: z, mems, + heap_mem, res, fmt_table: None, ntmp: 0, diff --git a/crates/xcl/src/gpu/dxil/lower.rs b/crates/xcl/src/gpu/dxil/lower.rs index b1499d1381..cbb17b93bd 100644 --- a/crates/xcl/src/gpu/dxil/lower.rs +++ b/crates/xcl/src/gpu/dxil/lower.rs @@ -145,6 +145,9 @@ pub struct Lw { pub half: Value, /// the memory windows `mem`, `mem1`.. (u2..) pub mems: Vec, + /// the windows come from the descriptor heap (`lower_window`; `mems` only counts them): + /// Some(globallycoherent) + pub heap_mem: Option, pub res: Option, /// the buffer format table (`FMT_INFO`), created on first use pub fmt_table: Option, diff --git a/crates/xcl/src/gpu/dxil/lower_image.rs b/crates/xcl/src/gpu/dxil/lower_image.rs index fd93832e67..dc37a95569 100644 --- a/crates/xcl/src/gpu/dxil/lower_image.rs +++ b/crates/xcl/src/gpu/dxil/lower_image.rs @@ -312,7 +312,7 @@ impl Lw { let off = self.bin(BinOp::Shl, off, k3); let full = self.add(b64, off); let (_, hi) = self.unpack64(full); - self.window(hi); + self.window_hi(hi, false); } let ty = self.andc(node, 7); let sort = { diff --git a/crates/xcl/src/gpu/dxil/lower_mem.rs b/crates/xcl/src/gpu/dxil/lower_mem.rs index 9b80d12221..97c0e3bd7f 100644 --- a/crates/xcl/src/gpu/dxil/lower_mem.rs +++ b/crates/xcl/src/gpu/dxil/lower_mem.rs @@ -6,6 +6,7 @@ use super::lower::{err, Dst, LResult, Lw, VAR_VGPR}; use super::module::{BinOp, Pred, RmwOp, Value}; use super::ops::AtomicOp; +use super::lower_window::Ea; use super::shader::RawUav; use crate::gpu::rdna2::{self, Decoded}; use crate::gpu::recomp::emit::buf_format_info; @@ -118,6 +119,9 @@ impl Lw { /// a switch over the windows when the program may address several, as the HLSL kernel's /// `xcl_m*` accessors; returns `f`'s value (i32 or i64). fn with_mem(&mut self, f: &mut dyn FnMut(&mut Lw, RawUav) -> Option) -> Option { + if let Some(coherent) = self.heap_mem { + return self.with_heap_mem(coherent, f); + } if self.mems.len() <= 1 { let m = self.mems[0]; return f(self, m); @@ -130,17 +134,9 @@ impl Lw { let mut kind = 0u8; // 0 none, 1 i32, 2 i64 let mems = self.mems.clone(); for (k, &m) in mems.iter().enumerate() { - // window 0 is the default (`switch` default: any value but 1..) - let is = if k == 0 { - let mut any = self.b(false); - for j in 1..mems.len() as u32 { - let e = self.cmpc(Pred::Eq, w, j); - any = self.lor(any, e); - } - self.lnot(any) - } else { - self.cmpc(Pred::Eq, w, k as u32) - }; + // a window outside them matches none (the `switch` default: reads 0, stores + // and atomics dropped) + let is = self.cmpc(Pred::Eq, w, k as u32); let _ = self.guarded(is, &mut |lw| { if let Some(v) = f(lw, m) { let t = lw.s.m.type_of(v); @@ -166,13 +162,6 @@ impl Lw { } } } - /// `xcl_w = hi & 3` (several memory windows only). - pub fn window(&mut self, hi: Value) { - if self.mems.len() > 1 { - let v = self.andc(hi, 3); - self.wr(super::lower::VAR_WIN, v); - } - } fn mraw_atomic(&mut self, op: AtomicOp, a: Value, v: Value) -> Value { self.with_mem(&mut |lw, m| Some(lw.s.raw_atomic(m, op, a, v))).expect("atomic value") } @@ -659,9 +648,9 @@ impl Lw { let mut vals = Vec::new(); if name.starts_with("s_buffer_load") { let (d0, d1, d2) = (self.sreg(sbase), self.sreg(sbase + 1), self.sreg(sbase + 2)); - self.window(d1); let k = self.c(imm); let off = self.add(k, soff); + self.buffer_window(d0, d1, &[Ea::U(k), Ea::U(soff)], false); let st = self.lshrc(d1, 16); let st = self.andc(st, 0x3FFF); let sz = self.cmpc(Pred::Eq, st, 0); @@ -679,8 +668,8 @@ impl Lw { let imm = ((imm << 11) as i32 >> 11) as u32; let b = self.sreg(sbase); let hi = self.sreg(sbase + 1); - self.window(hi); let k = self.c(imm); + self.window_at(hi, b, &[Ea::S(k), Ea::U(soff)], false); let a = self.add(b, k); let a = self.add(a, soff); for i in 0..count { @@ -734,7 +723,6 @@ impl Lw { let soff = self.code32(f("SOFFSET"), None, false).ok_or_else(|| format!("{}: op", rdna2::format(d)))?; let (offen, idxen) = (f("OFFEN") != 0, f("IDXEN") != 0); let (d0, d1, d2, d3) = (self.sreg(srsrc), self.sreg(srsrc + 1), self.sreg(srsrc + 2), self.sreg(srsrc + 3)); - self.window(d1); let index = if idxen { self.vreg(vaddr) } else { self.c(0) }; let voff = if offen { self.vreg(vaddr + idxen as u64) } else { self.c(0) }; let stride = self.lshrc(d1, 16); @@ -744,6 +732,7 @@ impl Lw { let a = self.add(a, off); let si = self.mul(stride, index); let a = self.add(a, si); + self.buffer_window(d0, d1, &[Ea::U(soff), Ea::U(voff), Ea::K(f("OFFSET") as u32), Ea::Mul(stride, index)], name.contains("store")); let act = self.act(); let szero = self.cmpc(Pred::Eq, stride, 0); let idx_ok = self.cmp(Pred::ULt, index, d2); @@ -1206,7 +1195,6 @@ impl Lw { let soff = self.code32(f("SOFFSET"), None, false).ok_or_else(|| format!("{}: op", rdna2::format(d)))?; let (offen, idxen) = (f("OFFEN") != 0, f("IDXEN") != 0); let (d0, d1, d2) = (self.sreg(srsrc), self.sreg(srsrc + 1), self.sreg(srsrc + 2)); - self.window(d1); let index = if idxen { self.vreg(vaddr) } else { self.c(0) }; let voff = if offen { self.vreg(vaddr + idxen as u64) } else { self.c(0) }; let x2 = op.ends_with("_x2"); @@ -1219,6 +1207,7 @@ impl Lw { let a = self.add(a, off); let si = self.mul(stride, index); let a = self.add(a, si); + self.buffer_window(d0, d1, &[Ea::U(soff), Ea::U(voff), Ea::K(f("OFFSET") as u32), Ea::Mul(stride, index)], true); let a = self.andc(a, !(bytes - 1)); let szero = self.cmpc(Pred::Eq, stride, 0); let e = self.addc(off, bytes); @@ -1260,11 +1249,11 @@ impl Lw { // ------------------------------------------------------------ FLAT / global - fn flat_base(&mut self, d: &Decoded) -> (Value, bool) { + fn flat_base(&mut self, d: &Decoded, write: bool) -> (Value, bool) { let global = d.enc.name == "ENC_FLAT_GLBL"; let addr = self.vreg(Self::fv(d, "ADDR")); let saddr = Self::fv(d, "SADDR"); - self.flat_window(d); + self.flat_window(d, write); let base = if global && saddr != 0x7D && saddr != 0x7F { let s = self.sreg(saddr); self.add(s, addr) @@ -1276,16 +1265,6 @@ impl Lw { (self.addc(base, off), global) } - /// `flat_window`: the window of a FLAT / global address (SADDR pair or the 64-bit VGPR address). - fn flat_window(&mut self, d: &Decoded) { - if self.mems.len() > 1 { - let global = d.enc.name == "ENC_FLAT_GLBL"; - let saddr = Self::fv(d, "SADDR"); - let hi = if global && saddr != 0x7D && saddr != 0x7F { self.sreg(saddr + 1) } else { self.vreg(Self::fv(d, "ADDR") + 1) }; - self.window(hi); - } - } - pub fn flat(&mut self, d: &Decoded, name: &str) -> LResult<()> { let op = name.trim_start_matches("global_").trim_start_matches("flat_").trim_start_matches("scratch_"); if d.enc.name == "ENC_FLAT_SCRATCH" { @@ -1296,7 +1275,7 @@ impl Lw { } let act = self.act(); if let Some((n, signed, store, half)) = flat_small(op) { - let (a, _) = self.flat_base(d); + let (a, _) = self.flat_base(d, store); if store { let v = self.vreg(Self::fv(d, "DATA")); let data = self.d16_data(v, half); @@ -1325,7 +1304,7 @@ impl Lw { _ => return err(d, "FLAT"), }; let a = if op.ends_with("_addtid") { - self.flat_window(d); + self.addtid_window(d, store); let saddr = Self::fv(d, "SADDR"); let lane = self.lane; let l4 = self.shlc(lane, 2); @@ -1340,7 +1319,7 @@ impl Lw { let off = if d.enc.name == "ENC_FLAT_GLBL" { (((raw << 20) as i32) >> 20) as u32 } else { raw }; self.addc(base, off) } else { - self.flat_base(d).0 + self.flat_base(d, store).0 }; if store { let vals: Vec = (0..count).map(|i| self.vreg(Self::fv(d, "DATA") + i)).collect(); @@ -1365,7 +1344,7 @@ impl Lw { } fn flat_atomic(&mut self, d: &Decoded, op: &str) -> LResult<()> { - let (a, _) = self.flat_base(d); + let (a, _) = self.flat_base(d, true); let x2 = op.ends_with("_x2"); let op = op.trim_end_matches("_x2"); let a = self.andc(a, if x2 { !7 } else { !3 }); diff --git a/crates/xcl/src/gpu/dxil/lower_window.rs b/crates/xcl/src/gpu/dxil/lower_window.rs new file mode 100644 index 0000000000..06efbe2f0e --- /dev/null +++ b/crates/xcl/src/gpu/dxil/lower_window.rs @@ -0,0 +1,174 @@ +//! Memory window selection and the windows taken from the descriptor heap: the direct +//! translator's form of the HLSL kernel's `window_read` / `window_write` and of its +//! `xcl_m*` accessors with `Options::heap_windows` (`recomp::emit::mem_accessors`). + +use super::lower::{Lw, VAR_WIN}; +use super::module::{Pred, Value}; +use super::shader::RawUav; +use crate::gpu::rdna2::Decoded; + +/// A term of a 64-bit effective address (`window_at`). +#[derive(Clone, Copy)] +pub enum Ea { + /// a 32-bit value, zero-extended + U(Value), + /// a 32-bit constant, zero-extended + K(u32), + /// a 32-bit value, sign-extended + S(Value), + /// the 64-bit product of two 32-bit values + Mul(Value, Value), +} + +impl Lw { + /// The program may address several memory windows. + pub fn windowed(&self) -> bool { + self.mems.len() > 1 + } + + /// The high dword of the UMA base (`IO_UMA_BASE_HI` of the io buffer, `xcl_uma_base`). + fn uma_base(&mut self) -> Value { + let io = self.init.io.expect("io"); + let off = self.c(crate::gpu::recomp::IO_UMA_BASE_HI as u32 * 4); + self.s.raw_load(io, off, 1)[0] + } + + /// Selects the window of an access whose 64-bit effective address is `hi:lo` plus + /// `adds` (carry / borrow into the high dword), as the HLSL kernel: a read with + /// `hi == 0` (32-bit console descriptor table pointers) goes to window 0; any other + /// high dword outside `[uma_base, uma_base + windows)` selects no window (reads 0, + /// stores and atomics are dropped). Several windows only. + pub fn window_at(&mut self, hi: Value, lo: Value, adds: &[Ea], write: bool) { + if !self.windowed() { + return; + } + let mut ea = self.pack64(lo, hi); + for &t in adds { + let x = match t { + Ea::U(v) => self.zext64(v), + Ea::K(k) => self.c64(k as u64), + Ea::S(v) => self.sext64(v), + Ea::Mul(a, b) => { + let (a, b) = (self.zext64(a), self.zext64(b)); + self.mul(a, b) + } + }; + ea = self.add(ea, x); + } + let (_, h) = self.unpack64(ea); + self.window_hi(h, write); + } + + /// `window_at` of a high dword already computed (`window_read` / `window_write`). + pub fn window_hi(&mut self, hi: Value, write: bool) { + if !self.windowed() { + return; + } + let base = self.uma_base(); + let mut w = self.sub(hi, base); + if !write { + let z = self.cmpc(Pred::Eq, hi, 0); + let zero = self.c(0); + w = self.sel(z, zero, w); + } + self.wr(VAR_WIN, w); + } + + /// The window of a buffer access: V# base `d1[15:0]:d0` plus `adds` (the stride bits + /// `d1[29:16]` are not part of the address). + pub fn buffer_window(&mut self, d0: Value, d1: Value, adds: &[Ea], write: bool) { + if self.windowed() { + let hi = self.andc(d1, 0xFFFF); + self.window_at(hi, d0, adds, write); + } + } + + /// The window of a FLAT / global access: SADDR pair + VGPR offset, or the 64-bit VGPR + /// address, plus the instruction offset (signed for global). + pub fn flat_window(&mut self, d: &Decoded, write: bool) { + if !self.windowed() { + return; + } + let global = d.enc.name == "ENC_FLAT_GLBL"; + let saddr = Self::fv(d, "SADDR"); + let addr = Self::fv(d, "ADDR"); + let raw = Self::fv(d, "OFFSET") as u32; + let off = if global { + Ea::S(self.c((((raw << 20) as i32) >> 20) as u32)) + } else { + Ea::U(self.c(raw)) + }; + if global && saddr != 0x7D && saddr != 0x7F { + let (lo, hi, v) = (self.sreg(saddr), self.sreg(saddr + 1), self.vreg(addr)); + self.window_at(hi, lo, &[Ea::U(v), off], write); + } else { + let (lo, hi) = (self.vreg(addr), self.vreg(addr + 1)); + self.window_at(hi, lo, &[off], write); + } + } + + /// The window of a `global_*_addtid` access: SADDR pair (or 0) + 4 × lane + offset. + pub fn addtid_window(&mut self, d: &Decoded, write: bool) { + if !self.windowed() { + return; + } + let global = d.enc.name == "ENC_FLAT_GLBL"; + let saddr = Self::fv(d, "SADDR"); + let raw = Self::fv(d, "OFFSET") as u32; + let off = if global { + Ea::S(self.c((((raw << 20) as i32) >> 20) as u32)) + } else { + Ea::U(self.c(raw)) + }; + let lane = self.lane; + let l4 = self.shlc(lane, 2); + let (lo, hi) = match saddr { + 0x7D | 0x7F => (self.c(0), self.c(0)), + _ => (self.sreg(saddr), self.sreg(saddr + 1)), + }; + self.window_at(hi, lo, &[Ea::U(l4), off], write); + } + + /// `with_mem` with the windows in the descriptor heap (`Options::heap_windows`): window + /// `w` is the raw UAV `ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + w)]` + /// (`globallycoherent` where the root windows are); a `w` outside the windows does what + /// the HLSL accessor does (reads 0, stores and atomics dropped). + pub(super) fn with_heap_mem( + &mut self, + coherent: bool, + f: &mut dyn FnMut(&mut Lw, RawUav) -> Option, + ) -> Option { + let windows = self.mems.len() as u32; + let w = self.rd(VAR_WIN); + let (tl, th) = (self.tmp_var(), self.tmp_var()); + let z = self.c(0); + self.wr(tl, z); + self.wr(th, z); + let mut kind = 0u8; // 0 none, 1 i32, 2 i64 + let inside = self.cmpc(Pred::ULt, w, windows); + let _ = self.guarded(inside, &mut |lw| { + let i = lw.addc(w, crate::gpu::recomp::MEM_HEAP_BASE); + let m = lw.s.heap_raw_buffer_uav(i, coherent); + if let Some(v) = f(lw, m) { + if lw.s.m.type_of(v) == lw.s.m.i64() { + let (l, h) = lw.unpack64(v); + lw.wr(tl, l); + lw.wr(th, h); + kind = 2; + } else { + lw.wr(tl, v); + kind = 1; + } + } + Ok(()) + }); + match kind { + 0 => None, + 1 => Some(self.rd(tl)), + _ => { + let (l, h) = (self.rd(tl), self.rd(th)); + Some(self.pack64(l, h)) + } + } + } +} diff --git a/crates/xcl/src/gpu/dxil/mod.rs b/crates/xcl/src/gpu/dxil/mod.rs index 64cb156681..902a2198d8 100644 --- a/crates/xcl/src/gpu/dxil/mod.rs +++ b/crates/xcl/src/gpu/dxil/mod.rs @@ -24,6 +24,7 @@ mod lower_image; mod lower_mem; mod lower_valu; mod lower_wide; +mod lower_window; pub mod module; pub mod ops; pub mod ops_core; diff --git a/crates/xcl/src/gpu/dxil/shader.rs b/crates/xcl/src/gpu/dxil/shader.rs index 19118e3878..bbe90ac00b 100644 --- a/crates/xcl/src/gpu/dxil/shader.rs +++ b/crates/xcl/src/gpu/dxil/shader.rs @@ -292,6 +292,16 @@ impl Shader { RawUav { handle, binding: None } } + /// A `RWByteAddressBuffer` from `ResourceDescriptorHeap[NonUniformResourceIndex(index)]`, + /// `globallycoherent` if `coherent` (the heap memory windows). + pub fn heap_raw_buffer_uav(&mut self, index: Value, coherent: bool) -> RawUav { + self.require(Feature::RawAndStructuredBuffers); + let h = self.handle_from_heap(index, false, true); + // resource properties: IsUAV (bit 12) | IsGloballyCoherent (bit 14) + let handle = self.annotate(h, kind::RAW_BUFFER | 0x1000 | if coherent { 0x4000 } else { 0 }, 0); + RawUav { handle, binding: None } + } + pub(super) fn res_ret(&mut self, t: Ty) -> Ty { let name = format!("dx.types.ResRet.{}", self.type_suffix(t)); let i32 = self.m.i32(); diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 0705c45933..5847c1c639 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -79,7 +79,9 @@ fn direct_or(code: &[u8], opt: &Options, hlsl: Vec) -> Vec { return hlsl; } let split = opt.wave64 && (opt.split_wave64 || runner::split_wave64()); - let o = KernelOptions { wave64: opt.wave64, split, mem_windows: opt.mem_windows, sampler_base: opt.static_sampler_base }; + // heap windows: `HEAP_WINDOWS` in the count, as `pso::mem_windows` passes it + let mem_windows = if opt.heap_windows && opt.mem_windows > 1 { opt.mem_windows | super::HEAP_WINDOWS } else { opt.mem_windows }; + let o = KernelOptions { wave64: opt.wave64, split, mem_windows, sampler_base: opt.static_sampler_base }; match &opt.mode { Mode::Kernel => translate(code, o).unwrap_or_else(|e| panic!("direct DXIL: {e}")), Mode::Compute(cs) => translate_compute(code, o, cs).unwrap_or_else(|e| panic!("direct DXIL: {e}")).dxil, @@ -468,6 +470,7 @@ fn atomic_fmin_fmax_x2_are_native_64_bit_atomics() { super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}\n{}", t.hlsl)); super::dxc::compile(&w.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}\n{}", w.hlsl)); direct_check(&code, &Options { mem_windows: 2, ..Default::default() }); + direct_check(&code, &Options { mem_windows: 2, heap_windows: true, ..Default::default() }); } } @@ -3273,8 +3276,7 @@ fn memory_windows_above_4_gib(heap: bool) { assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap, "heap windows: no switch over windows"); assert_eq!(t.hlsl.contains("ResourceDescriptorHeap[NonUniformResourceIndex(0u + xcl_w)]"), heap); let hlsl_dxil = || super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(); - // the direct translator binds windows as root UAVs only (no heap windows yet) - let dxil = if heap { hlsl_dxil() } else { direct_or(&p, &on_gpu(Options { mem_windows: 2, ..Default::default() }), hlsl_dxil()) }; + let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil()); let hi = |a: u64| (a >> 32) as u32; let mut st = KernelState::default(); st.sgpr[2..4].copy_from_slice(&[(w1 + 0x1000) as u32, hi(w1)]); @@ -3381,7 +3383,8 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { let p = prog(&refs); 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 dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(); + 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); 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