diff --git a/crates/xcl/src/gpu/dxil/compact.rs b/crates/xcl/src/gpu/dxil/compact.rs index b5d615a297..7d5b56366b 100644 --- a/crates/xcl/src/gpu/dxil/compact.rs +++ b/crates/xcl/src/gpu/dxil/compact.rs @@ -23,7 +23,7 @@ pub struct Plan { /// Most 32-bit words of tables a program may need to take the form by itself. pub const TABLE_WORDS: usize = 8192; -/// `TABLE_WORDS` on a GPU that runs only 32-lane waves. +/// `TABLE_WORDS` on a GPU that runs only 32-lane waves, or with heap memory windows. pub const TABLE_WORDS_WAVE32: usize = 12288; impl Plan { diff --git a/crates/xcl/src/gpu/dxil/kernel.rs b/crates/xcl/src/gpu/dxil/kernel.rs index 6ef85ad800..c635e5ffc5 100644 --- a/crates/xcl/src/gpu/dxil/kernel.rs +++ b/crates/xcl/src/gpu/dxil/kernel.rs @@ -142,9 +142,9 @@ pub fn translate_compute(code: &[u8], o: KernelOptions, cs: &CsInterface) -> Res translate_compute_on(code, o, cs, true) } -/// `translate_compute` for a GPU: one that runs only 32-lane waves takes larger compact tables. -pub fn translate_compute_on(code: &[u8], o: KernelOptions, cs: &CsInterface, wave32_only: bool) -> Result { - let tables = if wave32_only { super::compact::TABLE_WORDS_WAVE32 } else { super::compact::TABLE_WORDS }; +/// `translate_compute` with the compact form's larger tables (`compact::TABLE_WORDS_WAVE32`) or not. +pub fn translate_compute_on(code: &[u8], o: KernelOptions, cs: &CsInterface, large_tables: bool) -> Result { + let tables = if large_tables { super::compact::TABLE_WORDS_WAVE32 } else { super::compact::TABLE_WORDS }; translate_entry(code, o, Entry::Compute(cs.clone()), compact_mode(), None, tables) } diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index da4b25e5fb..c586c6a76b 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -945,6 +945,11 @@ fn direct_fallback(stage: &str, err: &str) { crate::xlog_info!("[SHADER] direct DXIL fallback stage={stage} reason=\"{reason}\" detail=\"{}\" – HLSL path", err.lines().next().unwrap_or("")); } +/// Whether the compact form may take its larger tables: on a GPU with 32-lane waves only, or with heap memory windows. +fn large_tables(split_wave64: bool, windows: u32) -> bool { + split_wave64 || windows & super::HEAP_WINDOWS != 0 +} + /// A console compute shader through the direct DXIL translator (`gpu::dxil::kernel`). /// FSPX (driver) containers are left to the HLSL path. fn direct_compute(blob: &[u8], sampler_base: u32, windows: u32, split_wave64: bool) -> Result { @@ -969,7 +974,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)?; + let k = crate::gpu::dxil::kernel::translate_compute_on(code, o, &cs, large_tables(split_wave64, windows))?; dump_direct(blob, &k.dxil); Ok(Compiled { dispatch_chain: k.dispatch_chain, dxil: k.dxil, samplers: k.static_samplers }) } @@ -1381,6 +1386,20 @@ fn abi_signature(dev: &ID3D12Device, graphics: bool, samplers: &[StaticSampler], } } +#[cfg(test)] +mod large_table_tests { + use super::large_tables; + use crate::gpu::recomp::HEAP_WINDOWS; + + #[test] + fn a_gpu_with_64_lane_waves_takes_the_larger_tables_only_with_heap_windows() { + assert!(large_tables(true, 4)); + assert!(large_tables(true, 4 | HEAP_WINDOWS)); + assert!(large_tables(false, 4 | HEAP_WINDOWS)); + assert!(!large_tables(false, 4)); + } +} + #[cfg(test)] mod slab_tests { use super::dispatch_slabs;