diff --git a/crates/xcl/src/gpu/recomp/dxc.rs b/crates/xcl/src/gpu/recomp/dxc.rs index 68f0ee0f58..167bd4413b 100644 --- a/crates/xcl/src/gpu/recomp/dxc.rs +++ b/crates/xcl/src/gpu/recomp/dxc.rs @@ -680,7 +680,7 @@ impl LinkGate { static LINK_GATE: LinkGate = LinkGate::new(); -fn is_oom_error(err: &str) -> bool { +pub(crate) fn is_oom_error(err: &str) -> bool { let lower = err.to_ascii_lowercase(); lower.contains("0x8007000e") || lower.contains("e_outofmemory") } diff --git a/crates/xcl/src/gpu/recomp/emit.rs b/crates/xcl/src/gpu/recomp/emit.rs index ee2acf3647..7d259d55ac 100644 --- a/crates/xcl/src/gpu/recomp/emit.rs +++ b/crates/xcl/src/gpu/recomp/emit.rs @@ -72,6 +72,8 @@ pub(super) struct Em { /// LDS arrival barrier (`xcl_s_barrier`) so RDNA2 early `s_endpgm`, `LOOP_GUARD` exits, /// or split-wave64 desyncs cannot permanently hang an NVIDIA SM at `bar.sync`. safe_barrier: bool, + /// any console group barrier; with LDS, this excludes cross-wave-local remapping + has_s_barrier: bool, /// the T# SGPRs of the program's image stores and atomics (`image_write_srsrcs`) img_writes: Vec, /// compute program needs `globallycoherent` on flat memory windows (`needs_coherent_mem`) @@ -624,6 +626,7 @@ impl Em { dynamic_f16_rm: false, track_frexp_denorm: false, safe_barrier: false, + has_s_barrier: false, img_writes: Vec::new(), coherent_mem: false, } @@ -689,6 +692,7 @@ impl Em { } } self.dynamic_f16_rm = writes_nonzero_dp && self.has_f16_round_op && !self.has_f64_round_op; + self.has_s_barrier = has_s_barrier; self.safe_barrier = has_s_barrier && self.compute_or_mesh_hw_waves().is_some_and(|w| w > 1) && std::env::var("XCL_SAFE_BARRIER").map_or(true, |v| v.trim() != "0"); @@ -4758,11 +4762,42 @@ impl Em { } } + /// Split-wave64 compute whose console waves share neither LDS nor a group barrier: groups per + /// console group, scaled dispatch dimension, and the one-wave hardware group shape. + pub(crate) fn remap(&self) -> Option<(u32, usize, [u32; 3])> { + if self.opt.no_remap || !self.x64() || self.uses_lds || self.has_s_barrier { + return None; + } + let Mode::Compute(cs) = &self.opt.mode else { return None }; + let [x, y, z] = cs.threads; + let threads = x.checked_mul(y)?.checked_mul(z)?; + if x == 0 || threads <= 64 || threads % 64 != 0 { + return None; + } + if x >= 64 && x % 64 == 0 && y == 1 && z == 1 { + return Some((x / 64, 0, [64, 1, 1])); + } + if x <= 64 && 64 % x == 0 { + let rows = 64 / x; + if rows <= y && y % rows == 0 && z == 1 { + return Some((y / rows, 1, [x, rows, 1])); + } + } + None + } + + fn x64_hw_threads(&self) -> u32 { + self.remap().map_or(self.x64_threads(), |_| 64) + } + /// Split wave64: meet through bounded arrival counters (`XCL_X_SPIN 1`) by default so /// divergent wave32 halves can never permanently deadlock a GPU SM at an unbounded /// `GroupMemoryBarrierWithGroupSync()`. Set `XCL_WAVE64_SPIN=0` to force group barriers /// for 1-wave64 groups. fn x64_spin(&self) -> bool { + if self.remap().is_some() { + return false; + } self.x64_threads() > 64 || std::env::var("XCL_WAVE64_SPIN").map_or(true, |v| v.trim() != "0") } @@ -4775,7 +4810,7 @@ impl Em { /// Storage and functions of the split wave64 form (`PRELUDE_X64`). fn x64_prelude(&self, h: &mut String) { - let threads = self.x64_threads(); + let threads = self.x64_hw_threads(); let waves = threads.div_ceil(64).max(1) as usize; let slot = self.x64_words; // slots (console wave, half, parity), the arrival counters (console wave, half), the @@ -4982,6 +5017,8 @@ impl Em { h.push_str("groupshared uint xcl_lds[8192]; // D3D12 limit: 32 KB (the console allows 64 KB)\n"); } let [x, y, z] = cs.threads; + let remap = self.remap(); + let [nx, ny, nz] = remap.map_or([x, y, z], |(_, _, hw)| hw); // split wave64: the same group in hardware wave32s (a console wave = two of them) let hw_lanes = if self.x64() { 32 } else { lanes }; // 2-D / 3-D groups: the PC driver need not form its waves from consecutive @@ -5002,12 +5039,16 @@ impl Em { self.safe_barrier_prelude(&mut h); let _ = writeln!( h, - "[WaveSize({hw_lanes})]\n[numthreads({x}, {y}, {z})]\nvoid main(uint3 gid : SV_GroupID, uint3 gtid : SV_GroupThreadID, uint gi : SV_GroupIndex)\n{{" + "[WaveSize({hw_lanes})]\n[numthreads({nx}, {ny}, {nz})]\nvoid main(uint3 gid : SV_GroupID, uint3 gtid : SV_GroupThreadID, uint gi : SV_GroupIndex)\n{{" ); if self.safe_barrier { h.push_str(" xcl_s_barrier_init(gi);\n"); } - if self.x64() { + if let Some((ratio, dim, _)) = remap { + let d = ["x", "y", "z"][dim]; + h.push_str(" uint xcl_local = xcl_x_thread(gi);\n lane_id = xcl_local & 63u;\n xcl_half = (xcl_local >> 5) & 1u;\n xcl_cw = 0u;\n xcl_xn = XCL_X_THREADS > ((xcl_local & ~31u) ^ 32u) ? min(32u, XCL_X_THREADS - ((xcl_local & ~31u) ^ 32u)) : 0u;\n"); + let _ = writeln!(h, " uint xcl_tid = (gid.{d} % {ratio}u) * 64u + xcl_local;\n gtid = uint3(xcl_tid % {x}u, (xcl_tid / {x}u) % {y}u, xcl_tid / {}u);\n gi = xcl_tid;", x * y); + } else if self.x64() { // the console thread's ids (`xcl_x_thread`), not this hardware thread's self.x64_entry(&mut h); let _ = writeln!(h, " gtid = uint3(xcl_tid % {x}u, (xcl_tid / {x}u) % {y}u, xcl_tid / {}u);\n gi = xcl_tid;", x * y); @@ -5028,7 +5069,11 @@ impl Em { for (k, c) in ["x", "y", "z"].iter().enumerate() { if cs.tgid[k] { if sg.contains(&next) { - let _ = writeln!(h, " {} = gid.{c};", sname(next).unwrap()); + let div = match remap { + Some((ratio, dim, _)) if ["x", "y", "z"][dim] == *c => format!(" / {ratio}u"), + _ => String::new(), + }; + let _ = writeln!(h, " {} = gid.{c}{div};", sname(next).unwrap()); } next += 1; } diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs index b5c1a14237..3a7b0520fb 100644 --- a/crates/xcl/src/gpu/recomp/mod.rs +++ b/crates/xcl/src/gpu/recomp/mod.rs @@ -533,11 +533,13 @@ pub struct Options { /// structured control flow when the program allows it (false, or `XCL_RECOMP_NO_STRUCTURED`: /// always the guarded block chain) pub structured: bool, + /// force the console-sized form used when an indirect dispatch cannot scale GPU arguments + pub no_remap: bool, } impl Default for Options { fn default() -> Self { - Options { mode: Mode::Kernel, wave64: true, hw_wave: 0, split_wave64: false, static_sampler_base: 0, mem_windows: 1, heap_windows: false, structured: true } + Options { mode: Mode::Kernel, wave64: true, hw_wave: 0, split_wave64: false, static_sampler_base: 0, mem_windows: 1, heap_windows: false, structured: true, no_remap: false } } } @@ -557,6 +559,8 @@ pub struct Translation { /// console root signature's static samplers): (S#, comparison), register /// `static_sampler_base + i` in space 1 pub static_samplers: Vec<([u32; 4], bool)>, + /// `(hardware groups per console group, scaled dimension)` for wave-local split-wave64 compute + pub dispatch_remap: Option<(u32, u32)>, } impl Translation { @@ -1637,7 +1641,8 @@ fn translate_inner(code: &[u8], opt: &Options) -> Result { } let hlsl = em.finish(&body); let static_samplers = em.static_used.clone(); - Ok(Translation { hlsl, unsupported: em.unsupported, unsupported_why: em.unsupported_why, ignored: em.ignored, instructions: insts.len(), blocks, static_samplers }) + let dispatch_remap = em.remap().map(|(ratio, dim, _)| (ratio, dim as u32)); + Ok(Translation { hlsl, unsupported: em.unsupported, unsupported_why: em.unsupported_why, ignored: em.ignored, instructions: insts.len(), blocks, static_samplers, dispatch_remap }) } #[cfg(test)] diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index 958dbf675c..fa695d84a9 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -169,6 +169,7 @@ pub struct Compiled { pub dispatch_chain: Option>, pub dxil: Vec, pub samplers: Vec, + pub dispatch_remap: Option<(u32, u32)>, } /// Translate a console shader for `stage` to signed DXIL (DXC, disk-cached); its static @@ -225,7 +226,7 @@ mod translated { use std::path::{Path, PathBuf}; use std::sync::OnceLock; - const MAGIC: &[u8; 8] = b"XCLTRAN2"; + const MAGIC: &[u8; 8] = b"XCLTRAN3"; const ERR_MAGIC: &[u8; 8] = b"XCLTERR1"; const MAX_CACHED_ERR_BYTES: usize = 64 * 1024; @@ -357,6 +358,9 @@ mod translated { *r = rest; Some(u32::from_le_bytes(*v)) }; + let ratio = u32_(&mut r)?; + let dim = u32_(&mut r)?; + let dispatch_remap = (ratio > 1 && dim < 3).then_some((ratio, dim)); let n = u32_(&mut r)? as usize; if n > r.len() / 17 { return None; @@ -378,7 +382,7 @@ mod translated { let start = b.len() - len; b.copy_within(start.., 0); b.truncate(len); - return Some(Compiled { dxil: b, samplers, dispatch_chain: None }); + return Some(Compiled { dxil: b, samplers, dispatch_chain: None, dispatch_remap }); } else { let dwords_per_group = u32_(&mut rest)?; let count = u32_(&mut rest)?; @@ -395,7 +399,7 @@ mod translated { if !rest.is_empty() { return None; } Some(std::sync::Arc::new(crate::gpu::dxil::kernel::DispatchChain { dwords_per_group, pieces })) }; - Some(Compiled { dxil: whole.to_vec(), samplers, dispatch_chain }) + Some(Compiled { dxil: whole.to_vec(), samplers, dispatch_chain, dispatch_remap }) } pub(super) fn store_in(path: &Path, ident: u64, blob: &[u8], c: &Compiled) { @@ -403,6 +407,9 @@ mod translated { return; } let mut b = header(ident, blob); + let (ratio, dim) = c.dispatch_remap.unwrap_or((1, 0)); + b.extend_from_slice(&ratio.to_le_bytes()); + b.extend_from_slice(&dim.to_le_bytes()); b.extend_from_slice(&(c.samplers.len() as u32).to_le_bytes()); for (s, cmp) in &c.samplers { s.iter().for_each(|v| b.extend_from_slice(&v.to_le_bytes())); @@ -694,7 +701,7 @@ fn compile_console_shader(blob: &[u8], stage: Stage, sampler_base: u32, windows: Err(e) => direct_fallback(if stage == Stage::Vertex { "VS" } else { "PS" }, &e), } } - let (mut t, profile) = console_translation(blob, stage, sampler_base, windows, split_wave64)?; + let (mut t, profile) = console_translation(blob, stage, sampler_base, windows, split_wave64, false)?; if enormous(stage, t.hlsl.len()) && !crate::gpu::dxil::kernel::enabled() { if dxc::defer() { return Err("DXIL not compiled yet".into()); @@ -742,7 +749,7 @@ fn compile_console_shader(blob: &[u8], stage: Stage, sampler_base: u32, windows: t.hlsl = t.hlsl.replacen(" if (!xcl_live) discard;\n return xo;\n}", &format!(" xo.t0 = {expr};\n return xo;\n}}"), 1); } let dxil = dxc::compile_cached(&t.hlsl, "main", profile)?.0; - Ok((Compiled { dispatch_chain: None, dxil, samplers: t.static_samplers }, false)) + Ok((Compiled { dispatch_chain: None, dxil, samplers: t.static_samplers, dispatch_remap: t.dispatch_remap }, false)) } /// Every `X_T.Sample(args)` of generated HLSL as `X_T.SampleLevel(args, 0.0f)`. @@ -800,7 +807,7 @@ fn debug_color(blob: &[u8]) -> Option<[f32; 3]> { /// The HLSL (and its DXC profile) `console_to_dxil` compiles. pub fn console_to_hlsl(blob: &[u8], stage: Stage) -> Result<(String, &'static str), String> { - console_translation(blob, stage, 0, mem_windows(), false).map(|(t, p)| (t.hlsl, p)) + console_translation(blob, stage, 0, mem_windows(), false, false).map(|(t, p)| (t.hlsl, p)) } /// Upper entry cap for `ShaderCache` (the 64 MiB byte limit is the primary bound; a retail game @@ -1019,7 +1026,12 @@ pub fn compute_user_sgprs(blob: &[u8]) -> Option { /// The HLSL and profile a console program compiles from at pipeline creation (for /// `xcl shaders --export-hlsl`: compile-time investigations outside a title). pub fn console_hlsl(blob: &[u8], stage: Stage, windows: u32, split_wave64: bool) -> Result<(String, &'static str), String> { - console_translation(blob, stage, 0, windows, split_wave64).map(|(t, p)| (t.hlsl, p)) + console_translation(blob, stage, 0, windows, split_wave64, false).map(|(t, p)| (t.hlsl, p)) +} + +pub fn console_dxil_noremap(blob: &[u8], split_wave64: bool, windows: u32) -> Result, String> { + let (t, profile) = console_translation(blob, Stage::Compute, 0, windows, split_wave64, true)?; + Ok(dxc::compile_cached(&t.hlsl, "main", profile)?.0) } /// A direct DXIL translation that fell back to the HLSL path: one structured log line @@ -1046,7 +1058,7 @@ fn direct_compute(blob: &[u8], sampler_base: u32, windows: u32, split_wave64: bo Ok(k) => { crate::gpu::dxil::coverage::record_translated("CS per-lane"); dump_direct(blob, &k.dxil); - return Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers }); + return Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers, dispatch_remap: None }); } Err(e) => { let reason = crate::gpu::dxil::coverage::record_fallback("CS per-lane", &e); @@ -1056,7 +1068,7 @@ fn direct_compute(blob: &[u8], sampler_base: u32, windows: u32, split_wave64: bo } let k = crate::gpu::dxil::kernel::translate_compute_on(code, o, &cs, split_wave64)?; dump_direct(blob, &k.dxil); - Ok(Compiled { dispatch_chain: k.dispatch_chain, dxil: k.dxil, samplers: k.static_samplers }) + Ok(Compiled { dispatch_chain: k.dispatch_chain, dxil: k.dxil, samplers: k.static_samplers, dispatch_remap: None }) } /// `XCL_DXIL_DUMP=[,…]` (`[SHADER]` hashes, or `all`): writes the direct path's @@ -1091,16 +1103,16 @@ fn direct_graphics(blob: &[u8], stage: Stage, sampler_base: u32, windows: u32) - _ => return Err("the shader stage does not match its slot in the PSO".into()), }; dump_direct(blob, &k.dxil); - Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers }) + Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers, dispatch_remap: None }) } -pub(crate) fn console_translation(blob: &[u8], stage: Stage, sampler_base: u32, windows: u32, split_wave64: bool) -> Result<(super::Translation, &'static str), String> { +pub(crate) fn console_translation(blob: &[u8], stage: Stage, sampler_base: u32, windows: u32, split_wave64: bool, no_remap: bool) -> Result<(super::Translation, &'static str), String> { if let Some(f) = fspx(blob) { if stage != Stage::Compute { return Err("an FSPX (driver) container in a graphics slot".into()); } let cs = super::CsInterface::from_rsrc2(f.threads, f.rsrc2); - let t = translate(f.code, &Options { mode: Mode::Compute(cs), wave64: super::detect_wave64(f.code), split_wave64, static_sampler_base: sampler_base, mem_windows: windows, ..Default::default() })?; + let t = translate(f.code, &Options { mode: Mode::Compute(cs), wave64: super::detect_wave64(f.code), split_wave64, static_sampler_base: sampler_base, mem_windows: windows, no_remap, ..Default::default() })?; if !t.complete() { let missing: Vec<&String> = t.unsupported.keys().collect(); return Err(format!("incomplete translation, missing: {missing:?}")); @@ -1129,7 +1141,7 @@ pub(crate) fn console_translation(blob: &[u8], stage: Stage, sampler_base: u32, }; let p = f.programs.first().ok_or("FSSM without a program")?; let code = &f.data[p.offset..p.offset + p.len]; - let t = translate(code, &Options { mode, wave64: super::fssm_wave64(f, code), split_wave64, static_sampler_base: sampler_base, mem_windows: windows, ..Default::default() })?; + let t = translate(code, &Options { mode, wave64: super::fssm_wave64(f, code), split_wave64, static_sampler_base: sampler_base, mem_windows: windows, no_remap, ..Default::default() })?; if !t.complete() { let missing: Vec<&String> = t.unsupported.keys().collect(); return Err(format!("incomplete translation, missing: {missing:?}")); @@ -1166,7 +1178,7 @@ fn finish_two_pass(t: super::Translation, record: super::MsInterface, ps: Option return Err(format!("incomplete translation, missing: {missing:?}")); } let cs = dxc::compile_cached(&t.hlsl, "main", "cs_6_6")?.0; - finish_two_pass_compiled(Compiled { dispatch_chain: None, dxil: cs, samplers: t.static_samplers }, record, ps) + finish_two_pass_compiled(Compiled { dispatch_chain: None, dxil: cs, samplers: t.static_samplers, dispatch_remap: None }, record, ps) } fn compile_console_mesh( @@ -1192,7 +1204,7 @@ fn compile_console_mesh( Ok(k) => { crate::gpu::dxil::coverage::record_translated("MS"); dump_direct(blob, &k.dxil); - return Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers }); + return Ok(Compiled { dispatch_chain: None, dxil: k.dxil, samplers: k.static_samplers, dispatch_remap: None }); } Err(e) => direct_fallback("MS", &e), } @@ -1203,7 +1215,7 @@ fn compile_console_mesh( return Err(format!("incomplete translation, missing: {missing:?}")); } let dxil = dxc::compile_cached(&t.hlsl, "main", "cs_6_6")?.0; - Ok(Compiled { dispatch_chain: None, dxil, samplers: t.static_samplers }) + Ok(Compiled { dispatch_chain: None, dxil, samplers: t.static_samplers, dispatch_remap: None }) } fn console_mesh_with( @@ -1533,10 +1545,10 @@ mod shader_cache_tests { fn translations_on_disk_need_the_same_bytes_and_identity() { let dir = std::env::temp_dir().join(format!("xcl-translated-{}", std::process::id())); let path = dir.join("t.bin"); - let c = Compiled { dispatch_chain: None, dxil: synthetic_dxil(5), samplers: vec![([7, 8, 9, 10], true), ([1, 2, 3, 4], false)] }; + let c = Compiled { dispatch_chain: None, dxil: synthetic_dxil(5), samplers: vec![([7, 8, 9, 10], true), ([1, 2, 3, 4], false)], dispatch_remap: Some((2, 1)) }; translated::store_in(&path, 42, b"console", &c); let back = translated::load_in(&path, 42, b"console").expect("stored"); - assert_eq!((back.dxil, back.samplers), (c.dxil.clone(), c.samplers.clone())); + assert_eq!((back.dxil, back.samplers, back.dispatch_remap), (c.dxil.clone(), c.samplers.clone(), c.dispatch_remap)); assert!(translated::load_in(&path, 43, b"console").is_none(), "another identity"); assert!(translated::load_in(&path, 42, b"consolf").is_none(), "other bytes"); let full = std::fs::read(&path).unwrap(); @@ -1769,7 +1781,7 @@ mod shader_cache_tests { // Store a valid entry first, then corrupt only the DXIL payload while keeping the // XCLTRAN2 header and payload length intact (e.g. zeroed blocks after a hard reset). - let valid = Compiled { dispatch_chain: None, dxil: synthetic_dxil(1), samplers: vec![([1, 2, 3, 4], false)] }; + let valid = Compiled { dispatch_chain: None, dxil: synthetic_dxil(1), samplers: vec![([1, 2, 3, 4], false)], dispatch_remap: None }; translated::store_in(&path, ident, blob, &valid); let mut raw = std::fs::read(&path).unwrap(); let dxil_start = raw.len() - valid.dxil.len(); @@ -1788,7 +1800,7 @@ mod shader_cache_tests { let mut calls = 0usize; let rebuilt = translated::cached_in(&dir, ident, blob, Stage::Compute, 0, 1, false, || { calls += 1; - Ok(Compiled { dispatch_chain: None, dxil: synthetic_dxil(9), samplers: vec![([5, 6, 7, 8], true)] }) + Ok(Compiled { dispatch_chain: None, dxil: synthetic_dxil(9), samplers: vec![([5, 6, 7, 8], true)], dispatch_remap: None }) }) .unwrap(); assert_eq!(calls, 1); @@ -1812,20 +1824,20 @@ mod shader_cache_tests { let path = translated::file(&dir, ident, blob, Stage::Compute, 0, 1, false); let err = translated::cached_in(&dir, ident, blob, Stage::Compute, 0, 1, false, || { - Ok(Compiled { dispatch_chain: None, dxil: b"not DXIL".to_vec(), samplers: Vec::new() }) + Ok(Compiled { dispatch_chain: None, dxil: b"not DXIL".to_vec(), samplers: Vec::new(), dispatch_remap: None }) }) .err() .expect("invalid fresh DXIL must be rejected"); assert!(err.contains("invalid DXIL container"), "{err}"); assert!(!path.exists(), "invalid fresh DXIL must not be written to disk"); - translated::store_in(&path, ident, blob, &Compiled { dispatch_chain: None, dxil: b"not DXIL".to_vec(), samplers: Vec::new() }); + translated::store_in(&path, ident, blob, &Compiled { dispatch_chain: None, dxil: b"not DXIL".to_vec(), samplers: Vec::new(), dispatch_remap: None }); assert!(!path.exists(), "store_in must not write an invalid DXIL container"); // A real container emitted by the direct DXIL backend must be accepted and cached. let real_direct = crate::gpu::dxil::shader::Shader::new(crate::gpu::dxil::container::Stage::Compute, (6, 6)).finish([1, 1, 1], None); let stored = translated::cached_in(&dir, ident, blob, Stage::Compute, 0, 1, false, || { - Ok(Compiled { dispatch_chain: None, dxil: real_direct.clone(), samplers: Vec::new() }) + Ok(Compiled { dispatch_chain: None, dxil: real_direct.clone(), samplers: Vec::new(), dispatch_remap: None }) }) .unwrap(); assert_eq!(stored.dxil, real_direct); @@ -1842,6 +1854,7 @@ mod shader_cache_tests { dispatch_chain: None, dxil: synthetic_dxil(marker), samplers: vec![([marker as u32; 4], false)], + dispatch_remap: None, } } @@ -1983,6 +1996,7 @@ mod shader_cache_tests { dispatch_chain: None, dxil, samplers: Vec::new(), + dispatch_remap: None, }) }) }); @@ -2017,6 +2031,7 @@ mod shader_cache_tests { dispatch_chain: None, dxil: vec![0; limit + 1], samplers: Vec::new(), + dispatch_remap: None, }), ); assert!(cache.get(&key(4), b"d").is_none()); @@ -2183,6 +2198,7 @@ mod shader_cache_tests { dispatch_chain: None, dxil, samplers: Vec::new(), + dispatch_remap: None, }) }) }); @@ -2271,7 +2287,7 @@ mod shader_cache_tests { let (res, missed) = dxc::cached_only(|| { translated::cached_in(&dir, ident_v1, deferred_blob, Stage::Compute, 0, 1, false, || { let dxil = dxc::compile_cached_in(&dir, "deferred probe", "main", "cs_6_6")?.0; - Ok(Compiled { dxil, samplers: Vec::new(), dispatch_chain: None }) + Ok(Compiled { dxil, samplers: Vec::new(), dispatch_chain: None, dispatch_remap: None }) }) }); assert!(res.is_err() && missed); diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index f738b41485..e2f49929fd 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -1612,6 +1612,14 @@ pub fn try_create_texture(desc: &D3D12_RESOURCE_DESC) -> Result<(), String> { /// A compute shader with the console dispatch ABI (`Mode::Compute`): `groups` thread groups, /// u0 = user SGPRs, u2 = flat memory. Returns the memory afterwards. pub fn dispatch(dxil: &[u8], groups: [u32; 3], sgprs: &[u32], mem: &[u32]) -> Result, String> { + dispatch_remapped(dxil, groups, None, sgprs, mem) +} + +pub fn dispatch_remapped(dxil: &[u8], mut groups: [u32; 3], remap: Option<(u32, u32)>, sgprs: &[u32], mem: &[u32]) -> Result, String> { + if let Some((ratio, dim)) = remap { + let count = groups.get_mut(dim as usize).ok_or("invalid remap dimension")?; + *count = count.checked_mul(ratio).ok_or("remapped dispatch overflows")?; + } let mut g = GPU.lock().unwrap(); let gpu = g.get_or_insert_with(init).as_mut().map_err(|x| x.clone())?; let pso: ID3D12PipelineState = unsafe { diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 0b018edc36..37fd347cd4 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -72,10 +72,13 @@ fn kernel_wave(code: &[u8], wave64: bool) -> (Vec, Vec) { /// `XCL_DIRECT_DXIL=1`: the direct DXIL translator's kernel for a kernel-mode program with /// one memory window (else `hlsl`, the HLSL path's container). +fn direct_enabled(opt: &Options) -> bool { + runner::direct_dxil() && opt.mem_windows <= 4 && (opt.hw_wave == 0 || (opt.hw_wave == 32 && !opt.wave64)) +} + fn direct_or(code: &[u8], opt: &Options, hlsl: Vec) -> Vec { use crate::gpu::dxil::kernel::{translate, translate_compute, KernelOptions}; - let windows = opt.mem_windows <= 4 && (opt.hw_wave == 0 || (opt.hw_wave == 32 && !opt.wave64)); - if !runner::direct_dxil() || !windows { + if !direct_enabled(opt) { return hlsl; } let split = opt.wave64 && (opt.split_wave64 || runner::split_wave64()); @@ -7305,6 +7308,7 @@ fn gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves() { assert_eq!(t.hlsl.matches("= xcl_x_ballot(and(").count(), 1, "the v_cmp: read whole by the odd waves"); assert_eq!(t.hlsl.matches("= xcl_x_ballot_local(and(").count(), 2, "the carries"); } + let remap = if direct_enabled(&opt) { None } else { t.dispatch_remap }; let dxil = direct_or(&p, &opt, dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}"))); let base = 0x100usize; let mut io = vec![0u32; 128]; @@ -7312,7 +7316,7 @@ fn gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves() { io[1] = dims[0]; io[2] = dims[0] * dims[1]; let groups = 3usize; - let out = runner::dispatch(&dxil, [groups as u32, 1, 1], &io, &vec![0u32; (base + groups * 256 * 16) / 4]).unwrap(); + let out = runner::dispatch_remapped(&dxil, [groups as u32, 1, 1], remap, &io, &vec![0u32; (base + groups * 256 * 16) / 4]).unwrap(); for g in 0..groups { for tid in 0..threads as usize { let (w, l) = (tid / 64, (tid % 64) as u32); @@ -7380,9 +7384,10 @@ fn gpu_split_wave64_waves_diverge() { let opt = on_gpu(Options { mode: Mode::Compute(cs), wave64: true, ..Default::default() }); let t = translate(&p, &opt).unwrap(); assert!(t.complete(), "{:?}", t.unsupported_why); - if runner::split_wave64() && std::env::var("XCL_WAVE64_SPIN").map_or(true, |v| v.trim() != "0") { + if runner::split_wave64() && t.dispatch_remap.is_none() && std::env::var("XCL_WAVE64_SPIN").map_or(true, |v| v.trim() != "0") { assert!(t.hlsl.contains("[WaveSize(32)]") && t.hlsl.contains("#define XCL_X_SPIN 1"), "{dims:?}"); } + let remap = if direct_enabled(&opt) { None } else { t.dispatch_remap }; let dxil = direct_or(&p, &opt, dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}"))); let base = 0x100usize; let mut io = vec![0u32; 128]; @@ -7390,7 +7395,7 @@ fn gpu_split_wave64_waves_diverge() { io[1] = dims[0]; io[2] = dims[0] * dims[1]; let groups = 3usize; - let out = runner::dispatch(&dxil, [groups as u32, 1, 1], &io, &vec![0u32; (base + groups * 256 * 8) / 4]).unwrap(); + let out = runner::dispatch_remapped(&dxil, [groups as u32, 1, 1], remap, &io, &vec![0u32; (base + groups * 256 * 8) / 4]).unwrap(); for g in 0..groups { for tid in 0..threads as usize { let (w, l) = (tid / 64, tid % 64); @@ -7403,6 +7408,37 @@ fn gpu_split_wave64_waves_diverge() { } } +#[test] +fn wave_local_remap_decision_and_console_ids() { + use super::{CsInterface, Mode, Options}; + let store = prog(&[ + ("V_MOV_B32", "ENC_VOP1", &[("VDST", 7), ("SRC0", 128)], None), + ("GLOBAL_STORE_DWORD", "ENC_FLAT_GLBL", &[("ADDR", 6), ("DATA", 0), ("SADDR", 0x7D)], None), + ]); + let translate_as = |code: &[u8], threads, tgid, no_remap| { + let cs = CsInterface { threads, user_sgprs: 2, tgid, tg_size: false, tid_components: 3 }; + translate(code, &Options { mode: Mode::Compute(cs), wave64: true, split_wave64: true, no_remap, ..Default::default() }).unwrap() + }; + for (threads, remap, shape, group_id) in [ + ([128, 1, 1], Some((2, 0)), "numthreads(64, 1, 1)", "gid.x / 2u"), + ([8, 16, 1], Some((2, 1)), "numthreads(8, 8, 1)", "gid.y / 2u"), + ([256, 1, 1], Some((4, 0)), "numthreads(64, 1, 1)", "gid.x / 4u"), + ] { + let t = translate_as(&store, threads, [true; 3], false); + assert_eq!(t.dispatch_remap, remap, "{threads:?}"); + assert!(t.hlsl.contains(shape) && t.hlsl.contains(group_id), "{threads:?}"); + assert!(t.hlsl.contains("#define XCL_X_SPIN 0"), "{threads:?}"); + } + let barrier = prog(&[("S_BARRIER", "ENC_SOPP", &[], None)]); + let lds = prog(&[("DS_WRITE_B32", "ENC_DS", &[("ADDR", 1), ("DATA0", 0)], None)]); + for (code, threads) in [(&store[..], [8, 8, 4]), (&store[..], [96, 1, 1]), (&barrier, [128, 1, 1]), (&lds, [128, 1, 1])] { + assert_eq!(translate_as(code, threads, [false; 3], false).dispatch_remap, None, "{threads:?}"); + } + let fallback = translate_as(&store, [128, 1, 1], [false; 3], true); + assert_eq!(fallback.dispatch_remap, None); + assert!(fallback.hlsl.contains("numthreads(128, 1, 1)") && fallback.hlsl.contains("#define XCL_X_SPIN 1")); +} + /// What the split wave64 form costs (`cargo test --release -- --ignored bench_split_wave64 /// --nocapture`): a loop of a few VALU instructions and one mask (`v_cmp`, an exchange in the /// split form), plus a readfirstlane (another exchange) in the second variant, as a wave32 @@ -7510,8 +7546,9 @@ fn gpu_compute_tg_size_counts_a_partial_last_wave() { let t = translate(&p, &opt).unwrap(); assert!(t.complete(), "{:?}", t.unsupported_why); // `XCL_DIRECT_DXIL=1`: the direct translator's kernel, which sets up TG_SIZE on its own + let remap = if direct_enabled(&opt) { None } else { t.dispatch_remap }; let dxil = direct_or(&p, &opt, super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}\n{}", t.hlsl))); - let mem = runner::dispatch(&dxil, [1, 1, 1], &[0u32; 128], &vec![0xFFFF_FFFFu32; threads as usize]).unwrap(); + let mem = runner::dispatch_remapped(&dxil, [1, 1, 1], remap, &[0u32; 128], &vec![0xFFFF_FFFFu32; threads as usize]).unwrap(); let waves = threads.div_ceil(lanes); for (k, &got) in mem.iter().take(threads as usize).enumerate() { assert_eq!(got, waves | (k as u32 / lanes) << 6, "{threads} threads, wave{lanes}: thread {k}"); diff --git a/crates/xcl/src/hle/d3d12x/bind.rs b/crates/xcl/src/hle/d3d12x/bind.rs index ea4a481462..cdd26ca9bf 100644 --- a/crates/xcl/src/hle/d3d12x/bind.rs +++ b/crates/xcl/src/hle/d3d12x/bind.rs @@ -358,6 +358,19 @@ pub(super) unsafe extern "system" fn execute_indirect(this: *mut c_void, sig: us match bind_abi(this, list, pso, gfx) { Ok(()) => { if compute { + if super::real::pso_dispatch_remap(pso).is_some() { + match super::real::remap_fallback::whole(pso) { + Ok(fallback) => list.SetPipelineState(&fallback), + Err(e) => { + 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: ExecuteIndirect remap fallback skipped: {e}"); + } + count(DISPATCHES_SKIPPED); + return; + } + } + } match super::real::dispatch_chain::whole(pso) { Ok(Some(whole)) => list.SetPipelineState(&whole), Ok(None) => {} diff --git a/crates/xcl/src/hle/d3d12x/pso_async.rs b/crates/xcl/src/hle/d3d12x/pso_async.rs index b7517dd645..d54bb6c580 100644 --- a/crates/xcl/src/hle/d3d12x/pso_async.rs +++ b/crates/xcl/src/hle/d3d12x/pso_async.rs @@ -653,6 +653,21 @@ pub(super) fn build_pieces(jobs: Vec) -> Vec { results } +/// Run one demanded auxiliary pipeline build on the foreground worker queue and wait for it. +/// Unlike `build_pieces`, the caller never drains or executes the job itself. +pub(super) fn build_foreground(job: Job) -> usize { + let build = Arc::new(Build::new(job, false)); + build.want(); + schedule(&build, Priority::Foreground, false, None); + let _held = Held::new(); + let _stall = crate::stall::span(crate::stall::StallKind::PipelineWait); + let mut done = build.done.lock().unwrap(); + while !*done { + done = build.cv.wait(done).unwrap(); + } + build.real.load(Ordering::Acquire) +} + /// Release a pipeline state XCL owns (raw pointer, 0 = none). pub fn release(p: usize) { if p != 0 { @@ -870,6 +885,15 @@ fn preload_enabled() -> bool { mod used_tests { use super::*; + #[test] + fn demanded_auxiliary_build_runs_on_a_worker() { + let caller = std::thread::current().id(); + assert_eq!(build_foreground(Box::new(move || { + assert_ne!(std::thread::current().id(), caller); + 0x7E57_C0DE + })), 0x7E57_C0DE); + } + #[test] fn coalescing_counter_math_tracks_lifetime_current_and_peak() { let counters = CoalescingCounters::new(); diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 5982136182..63a04da32d 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -1865,6 +1865,10 @@ fn forget_pso(pso: usize) { if let Some(m) = PSO_USER_SGPRS.lock().unwrap().as_mut() { m.remove(&pso); } + if let Some(m) = PSO_DISPATCH_REMAP.lock().unwrap().as_mut() { + m.remove(&pso); + } + remap_fallback::forget(pso); super::device_x::forget_base(pso); // the compute pass goes with the last user of its entry (`Drop for TwoPassPso`) let gone = TWO_PASS.lock().unwrap().as_mut().and_then(|m| m.remove(&pso)); @@ -3949,6 +3953,7 @@ fn note_pso_rs(pso: *mut c_void, rs: *mut c_void) { /// user SGPRs of the console CS of a translated compute pipeline static PSO_USER_SGPRS: Mutex>> = Mutex::new(None); +static PSO_DISPATCH_REMAP: Mutex>> = Mutex::new(None); /// How many user SGPRs the console compute shader of a translated pipeline has (None: not /// known). What is above the driver's four holds root arguments (`console_list::inline_for`). @@ -3957,6 +3962,24 @@ pub fn pso_user_sgprs(pso: usize) -> Option { PSO_USER_SGPRS.lock().unwrap().as_ref()?.get(&pso).copied() } +pub fn pso_dispatch_remap(pso: usize) -> Option<(u32, u32)> { + let pso = super::pso_async::resolve(pso); + PSO_DISPATCH_REMAP.lock().unwrap().as_ref()?.get(&pso).copied() +} + +fn note_pso_dispatch_remap(pso: *mut c_void, remap: Option<(u32, u32)>) { + if pso.is_null() { + return; + } + let mut guard = PSO_DISPATCH_REMAP.lock().unwrap(); + let map = guard.get_or_insert_with(HashMap::new); + if let Some(remap) = remap { + map.insert(pso as usize, remap); + } else { + map.remove(&(pso as usize)); + } +} + /// The root signature a translated pipeline state was created with. pub fn pso_root_signature(pso: usize) -> Option { let pso = super::pso_async::resolve(pso); @@ -4464,6 +4487,9 @@ unsafe fn translated_compute_pso_once(this: *mut c_void, f: PsoFn, desc: *const if let Some(n) = crate::gpu::recomp::pso::compute_user_sgprs(cs) { PSO_USER_SGPRS.lock().unwrap().get_or_insert_with(HashMap::new).insert(*ppv as usize, n); } + note_pso_dispatch_remap(*ppv, compiled.dispatch_remap); + remap_fallback::note(*ppv as usize, this, f, rs as usize, d.Flags, d.NodeMask, record, cs, + wave32_only(this), crate::gpu::recomp::pso::mem_windows(), compiled.dispatch_remap.is_some()); note_translated_compute(hr, ppv); crate::xlog_info!( "D3D12.X: compute PSO with the translated console CS ({} B DXIL, {} ms{})", @@ -4477,6 +4503,75 @@ unsafe fn translated_compute_pso_once(this: *mut c_void, f: PsoFn, desc: *const pub(super) mod dispatch_chain; pub(crate) use dispatch_chain::log_counts as log_dispatch_chain_counts; +pub(super) mod remap_fallback { + use super::*; + use std::sync::{Arc, LazyLock}; + + struct Fallback { + device: ID3D12Device, + create: PsoFn, + signature: ID3D12RootSignature, + flags: D3D12_PIPELINE_STATE_FLAGS, + node: u32, + record: u64, + cs: Vec, + split_wave64: bool, + windows: u32, + whole: dispatch_chain::WholeBuild, + } + + static FALLBACKS: LazyLock>>> = LazyLock::new(Default::default); + + pub(super) fn compile_error_hr(err: &str) -> HRESULT { + if crate::gpu::recomp::dxc::is_oom_error(err) { E_OUTOFMEMORY } else { E_INVALIDARG } + } + + pub(super) unsafe fn note(pso: usize, this: *mut c_void, create: PsoFn, rs: usize, + flags: D3D12_PIPELINE_STATE_FLAGS, node: u32, record: u64, cs: &[u8], split_wave64: bool, windows: u32, remapped: bool) { + if remapped && pso != 0 { + let Some(device) = ID3D12Device::from_raw_borrowed(&this) else { return }; + let raw_rs = rs as *mut c_void; + let Some(signature) = ID3D12RootSignature::from_raw_borrowed(&raw_rs) else { return }; + let old = FALLBACKS.lock().unwrap().insert(pso, Arc::new(Fallback { + device: device.clone(), create, signature: signature.clone(), flags, node, record, cs: cs.to_vec(), split_wave64, windows, + whole: dispatch_chain::WholeBuild::new(), + })); + drop(old); + } + } + + pub(in crate::hle::d3d12x) unsafe fn whole(pso: usize) -> Result { + let pso = super::super::pso_async::resolve(pso); + let fb = FALLBACKS.lock().unwrap().get(&pso).cloned().ok_or("no remap fallback")?; + fb.whole.get_or_build(std::time::Instant::now(), || { + let status = Arc::new(std::sync::atomic::AtomicI32::new(E_INVALIDARG)); + let (job_fb, job_status) = (fb.clone(), status.clone()); + let raw = super::super::pso_async::build_foreground(Box::new(move || unsafe { + let dxil = match crate::gpu::recomp::pso::console_dxil_noremap(&job_fb.cs, job_fb.split_wave64, job_fb.windows) { + Ok(dxil) => dxil, + Err(e) => { + job_status.store(compile_error_hr(&e), Ordering::Release); + return 0 + } + }; + let desc = D3D12_COMPUTE_PIPELINE_STATE_DESC { NodeMask: job_fb.node, Flags: job_fb.flags, ..Default::default() }; + let mut raw = std::ptr::null_mut(); + let (hr, _, _) = compute_container(job_fb.device.as_raw(), job_fb.create, &desc, + job_fb.signature.as_raw(), &dxil, job_fb.record, &pc_iid(Kind::PipelineState), &mut raw, ComputeBuild::Whole); + job_status.store(hr, Ordering::Release); + if hr >= 0 { raw as usize } else { 0 } + })); + if raw != 0 { Ok(ID3D12PipelineState::from_raw(raw as *mut c_void)) } + else { Err(status.load(Ordering::Acquire)) } + }).map_err(|hr| format!("un-remapped compute pipeline ({hr:#x})")) + } + + pub(super) fn forget(pso: usize) { + let gone = FALLBACKS.lock().unwrap().remove(&pso); + drop(gone); + } +} + #[derive(Clone, Copy, PartialEq)] enum ComputeBuild { Whole, diff --git a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs index d7c0b603a3..8b84548a04 100644 --- a/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs +++ b/crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs @@ -50,17 +50,17 @@ impl PipelineBuilder { /// One exact chain's whole-form outcome. The owning `Chain` fixes device, DXIL, root signature, /// flags and node; releasing/recreating the pipeline gets a fresh outcome. -struct WholeBuild { +pub(super) struct WholeBuild { result: OnceLock>, retry_at: Mutex>, } impl WholeBuild { - fn new() -> Self { + pub(super) fn new() -> Self { Self { result: OnceLock::new(), retry_at: Mutex::new(None) } } - fn get_or_build(&self, now: std::time::Instant, build: impl FnOnce() -> Result) -> Result { + pub(super) fn get_or_build(&self, now: std::time::Instant, build: impl FnOnce() -> Result) -> Result { if let Some(result) = self.result.get() { return result.clone(); } @@ -234,13 +234,35 @@ unsafe fn scratch_buffer(dev: &ID3D12Device, bytes: u64) -> Option) -> Option<[u32; 3]> { + if let Some((ratio, dim)) = remap { + let count = grid.get_mut(dim as usize)?; + let scaled = count.checked_mul(ratio)?; + // D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION (an SDK macro, not in windows-rs). + if scaled > 65_535 { + return None; + } + *count = scaled; + } + Some(grid) +} + /// Called with the original six ABI views bound. The extended signature is /// common to every piece and the whole fallback. Choose before recording any /// part of the dispatch, including when scratch allocation fails. pub(in crate::hle::d3d12x) unsafe fn dispatch(list: &ID3D12GraphicsCommandList, pso: usize, allocator: usize, grid: [u32; 3]) -> Result<(), String> { let [x, y, z] = grid; let chain = CHAINS.lock().unwrap().get(&pso).cloned(); - let Some(chain) = chain else { list.Dispatch(x, y, z); return Ok(()) }; + let Some(chain) = chain else { + match remapped_grid(grid, super::pso_dispatch_remap(pso)) { + Some([x, y, z]) => list.Dispatch(x, y, z), + None => { + list.SetPipelineState(&super::remap_fallback::whole(pso)?); + list.Dispatch(x, y, z); + } + } + return Ok(()) + }; if grid.contains(&0) { return Ok(()); } // A title Reset can switch to a different PC allocator while this // recording is still submitted on the old one. Retain by backing. @@ -274,6 +296,24 @@ mod tests { const MB: u64 = 1 << 20; + #[test] + fn remapped_grid_scales_only_its_dimension_and_refuses_overflow() { + assert_eq!(remapped_grid([3, 5, 7], Some((4, 1))), Some([3, 20, 7])); + assert_eq!(remapped_grid([3, 5, 7], None), Some([3, 5, 7])); + assert_eq!(remapped_grid([32_768, 1, 1], Some((2, 0))), None); + assert_eq!(remapped_grid([u32::MAX, 1, 1], Some((2, 0))), None); + assert_eq!(remapped_grid([1, 1, 1], Some((2, 3))), None); + } + + #[test] + fn released_pipeline_does_not_lend_its_remap_to_address_reuse() { + let pso = 0x7E57_6400usize; + super::super::note_pso_dispatch_remap(pso as *mut c_void, Some((4, 0))); + assert_eq!(super::super::pso_dispatch_remap(pso), Some((4, 0))); + super::super::forget_pso_for_test(pso); + assert_eq!(super::super::pso_dispatch_remap(pso), None); + } + #[test] fn a_list_recorded_after_another_goes_on_in_its_scratch() { use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_11_0; @@ -345,4 +385,18 @@ mod tests { assert_eq!(whole.get_or_build(at + WHOLE_RETRY * 2, || { calls += 1; Ok(8) }), Ok(7)); assert_eq!(calls, 2, "the successful retry is retained"); } + + #[test] + fn remap_compile_oom_retries_but_deterministic_failure_is_final() { + let at = std::time::Instant::now(); + let oom = super::super::remap_fallback::compile_error_hr("DXC: E_OUTOFMEMORY (0x8007000E)"); + let whole: WholeBuild = WholeBuild::new(); + assert_eq!(whole.get_or_build(at, || Err(oom)), Err(crate::util::E_OUTOFMEMORY)); + assert_eq!(whole.get_or_build(at + WHOLE_RETRY, || Ok(7)), Ok(7)); + + let compile = super::super::remap_fallback::compile_error_hr("dxc: invalid operation"); + let deterministic: WholeBuild = WholeBuild::new(); + assert_eq!(deterministic.get_or_build(at, || Err(compile)), Err(crate::util::E_INVALIDARG)); + assert_eq!(deterministic.get_or_build(at + WHOLE_RETRY, || Ok(8)), Err(crate::util::E_INVALIDARG)); + } } diff --git a/crates/xcl/src/shaders.rs b/crates/xcl/src/shaders.rs index 993515f228..b9caef5c28 100644 --- a/crates/xcl/src/shaders.rs +++ b/crates/xcl/src/shaders.rs @@ -1144,7 +1144,7 @@ fn measure_pso_result(input: &Input, hash: u64, repeat: usize, windows: u32, spl unsafe { dev9.ShaderCacheControl(cache_kinds, D3D12_SHADER_CACHE_CONTROL_FLAG_DISABLE) } .map_err(|e| Unavailable(format!("cannot disable the driver cache (Windows Developer Mode is required): {e}")))?; let split = split.unwrap_or_else(|| recomp::pso::split_wave64_forced() || recomp::pso::wave32_only_for_device(&pipeline.dev)); - let (translation, profile) = recomp::pso::console_translation(&blob, recomp::pso::Stage::Compute, 0, windows, split).map_err(|e| Failed(format!("{name}: {e}")))?; + let (translation, profile) = recomp::pso::console_translation(&blob, recomp::pso::Stage::Compute, 0, windows, split, false).map_err(|e| Failed(format!("{name}: {e}")))?; let dxc_start = std::time::Instant::now(); let dxil = recomp::dxc::compile(&translation.hlsl, "main", profile, &[]).map_err(|e| Failed(format!("DXC: {e}")))?; let dxc_ms = dxc_start.elapsed().as_millis(); @@ -1275,7 +1275,7 @@ mod pipeline_cap_tests { pipelines.max_dxil = dxil.len() - 1; let start = Instant::now(); - pipelines.make_with_cache_path(&recomp::pso::Compiled { dispatch_chain: None, dxil: dxil.clone(), samplers: vec![] }, Some(path.clone())); + pipelines.make_with_cache_path(&recomp::pso::Compiled { dispatch_chain: None, dxil: dxil.clone(), samplers: vec![], dispatch_remap: None }, Some(path.clone())); let elapsed = start.elapsed(); let capped = pipelines.capped.load(Ordering::Relaxed); let made = pipelines.made.load(Ordering::Relaxed); @@ -1356,6 +1356,7 @@ mod pipeline_cap_tests { })), dxil: whole.clone(), samplers: vec![], + dispatch_remap: None, }; pipelines.max_dxil = max_piece;