Structure builder and rays: dispatches counted in threads, empty slots never entered, pages that are not there never hit; vertex signatures as DXC orders them
From DexNom/VIctory (GPL-3.0-or-later) bc3cd4b0 and 5f4c3df4: - DispatchX's flag 0x20 says the counts are threads (bc3cd4b0). Taken for groups, a rehydration stage ran up to 64 times its threads and stored over the structures after its own. The lanes past the count leave at once, in every builder program of one dimension without a group barrier (there: in two, by digest). VICTORY_THREAD_DIMENSIONS=0: as before. - A child that is not there may have inverted infinite bounds: it was entered at minus infinity, came first and ended the walk (bc3cd4b0). - A node in a page without a copy reads zeros, a child and a box: no hit (bc3cd4b0). - Signature rows in the order of their names; vertex outputs interpolated as the title's PSV0 says; an unread input packed beside a per-vertex one is constant too (5f4c3df4), with their tests. Every shader is translated again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
0769cc9dc8
commit
bc83b16387
11 files changed
+443
-44
No files matched your search
@@ -1161,6 +1161,10 @@ impl State {
|
||||
if kind == USER_MEMORY_BASE {
|
||||
return memory.map_or(0, |m| m.base);
|
||||
}
|
||||
// All of every group, unless the dispatch says otherwise.
|
||||
if kind == victory_shader::emit::USER_DISPATCH_THREADS_X {
|
||||
return 0;
|
||||
}
|
||||
if kind == USER_ROOT_ADDRESS || kind == USER_ROOT_ADDRESS + 1 {
|
||||
return match self.roots_ref(compute).get(usize::from(slot)) {
|
||||
Some(&Root::View(address)) if kind == USER_ROOT_ADDRESS => address as u32,
|
||||
@@ -2526,7 +2530,7 @@ impl State {
|
||||
}
|
||||
|
||||
/// Runs a dispatch on the host.
|
||||
pub(crate) fn dispatch(&mut self, list: &HostList, x: u32, y: u32, z: u32) {
|
||||
pub(crate) fn dispatch(&mut self, list: &HostList, x: u32, y: u32, z: u32, flags: u32) {
|
||||
// It may write the arguments a window holds clamped.
|
||||
self.window = None;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
@@ -2578,6 +2582,23 @@ impl State {
|
||||
crate::capture::op(list as *const _ as usize, || format!("builder {}", p.name));
|
||||
self.list_dropped_roots([x, y, z]);
|
||||
}
|
||||
// Counted in threads: whole groups of them, and the program is told
|
||||
// how many of the last one run, where it asks (its `bind` set that to
|
||||
// all of them).
|
||||
let size = (flags & THREAD_DIMENSIONS != 0 && thread_dimensions())
|
||||
.then(|| p.stages.first().and_then(|s| s.translated().threads))
|
||||
.flatten();
|
||||
let threads = [x, y, z];
|
||||
let [x, y, z] = size.map_or(threads, |size| dispatch_groups(threads, size));
|
||||
if size.is_some() {
|
||||
if !crate::pipeline::is_builder(self.pipeline as This) {
|
||||
once!(pipeline = p.name, "a dispatch counted in threads that is not the structure builder's");
|
||||
}
|
||||
if let Some((param, word)) = compute_word(p, victory_shader::emit::USER_DISPATCH_THREADS_X) {
|
||||
// SAFETY: an open list; the root signature has the word.
|
||||
unsafe { list.list.SetComputeRoot32BitConstant(param, threads[0], word) };
|
||||
}
|
||||
}
|
||||
// SAFETY: an open list with everything set.
|
||||
unsafe { list.list.Dispatch(x, y, z) };
|
||||
self.buffers_written();
|
||||
@@ -3765,6 +3786,45 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
/// `DispatchX`: the counts are threads (the console's dispatch initiator bit
|
||||
/// "use thread dimensions"; DexNom/VIctory bc3cd4b0). Taken for groups, a
|
||||
/// rehydration stage of the structure builder ran up to 64 times its threads
|
||||
/// and stored over the structures after its own (runs light-1 to light-9).
|
||||
const THREAD_DIMENSIONS: u32 = 0x20;
|
||||
|
||||
/// `VICTORY_THREAD_DIMENSIONS=0`: such counts are taken for groups, as before.
|
||||
fn thread_dimensions() -> bool {
|
||||
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var_os("VICTORY_THREAD_DIMENSIONS").is_none_or(|v| v != "0"))
|
||||
}
|
||||
|
||||
/// The groups of `size` threads that hold `threads`.
|
||||
fn dispatch_groups(threads: [u32; 3], size: [u32; 3]) -> [u32; 3] {
|
||||
std::array::from_fn(|i| threads[i].div_ceil(size[i]))
|
||||
}
|
||||
|
||||
/// Where a compute pipeline's user data has a word the host computes: the
|
||||
/// root parameter and the dword in it.
|
||||
fn compute_word(p: &HostPipeline, kind: u32) -> Option<(u32, u32)> {
|
||||
let stage = p.stages.first().filter(|_| p.compute)?;
|
||||
let (param, _) = stage.user_data?;
|
||||
let word = stage.translated().host.user_data.iter().find(|u| u.root == RootType::Other(kind))?;
|
||||
Some((param, word.index))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod thread_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn threads_are_counted_in_the_programs_groups() {
|
||||
assert_eq!(dispatch_groups([8847, 1, 1], [64, 1, 1]), [139, 1, 1]);
|
||||
assert_eq!(dispatch_groups([74, 1, 1], [64, 1, 1]), [2, 1, 1]);
|
||||
assert_eq!(dispatch_groups([32, 1, 1], [32, 1, 1]), [1, 1, 1]);
|
||||
assert_eq!(dispatch_groups([0, 12, 9], [64, 4, 4]), [0, 3, 3]);
|
||||
}
|
||||
}
|
||||
|
||||
/// The host command signature for one argument of `kind` with records
|
||||
/// `stride` bytes apart (no root arguments, so no root signature), made
|
||||
/// once.
|
||||
|
||||
Reference in new issue
Block a user