Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/xcl/src/gpu/dxil/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions crates/xcl/src/gpu/dxil/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Kernel, String> {
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<Kernel, String> {
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)
}

Expand Down
21 changes: 20 additions & 1 deletion crates/xcl/src/gpu/recomp/pso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Compiled, String> {
Expand All @@ -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 })
}
Expand Down Expand Up @@ -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;
Expand Down
Loading