|
|
@@ -960,15 +960,17 @@ impl State {
|
|
|
once!(kind, "a shader reads a host value this build does not know");
|
|
|
return 0;
|
|
|
}
|
|
|
- // The title address of the buffer view at that dword of the table.
|
|
|
- let address = match self.roots_ref(compute).get(usize::from(slot)) {
|
|
|
- Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4)
|
|
|
- .and_then(|view| crate::descriptor::host::buffer_range(&view))
|
|
|
- .map_or(0, |range| range.0),
|
|
|
- _ => 0,
|
|
|
- };
|
|
|
+ let address = self.view_address(compute, slot, dword);
|
|
|
if address == 0 {
|
|
|
- once!(slot, dword, "a shader takes the address of a buffer view that is not there: it reads 0");
|
|
|
+ // The first few say what lies there instead.
|
|
|
+ static SAID: AtomicU64 = AtomicU64::new(0);
|
|
|
+ if SAID.fetch_add(1, Ordering::Relaxed) < 8 {
|
|
|
+ let view = match self.roots_ref(compute).get(usize::from(slot)) {
|
|
|
+ Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4),
|
|
|
+ _ => None,
|
|
|
+ };
|
|
|
+ tracing::warn!(slot, dword, ?view, "a shader takes the address of a buffer view that is not there: it reads 0");
|
|
|
+ }
|
|
|
}
|
|
|
if kind == USER_VIEW_ADDRESS {
|
|
|
address as u32
|
|
|
@@ -977,10 +979,29 @@ impl State {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// The title address the view at dword `dword` of the table in root
|
|
|
+ /// slot `slot` starts at, 0 without one.
|
|
|
+ fn view_address(&self, compute: bool, slot: u8, dword: u32) -> u64 {
|
|
|
+ match self.roots_ref(compute).get(usize::from(slot)) {
|
|
|
+ Some(&Root::Table(table)) => crate::descriptor::view(table + u64::from(dword) * 4)
|
|
|
+ .and_then(|view| crate::descriptor::host::view_address(&view))
|
|
|
+ .unwrap_or(0),
|
|
|
+ _ => 0,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// For a shader that reads title memory by address
|
|
|
/// ([`crate::memory`]): its directory, fault notes and view slots,
|
|
|
- /// with the pages of the root views the list has set made ready.
|
|
|
- fn memory_ready(&self, list: &HostList, compute: bool, writes: bool) -> Option<crate::memory::Ready> {
|
|
|
+ /// with the pages made ready of the root views the list has set and of
|
|
|
+ /// the views whose addresses it takes (`t`: the ray-tracing structures
|
|
|
+ /// it walks).
|
|
|
+ fn memory_ready(
|
|
|
+ &self,
|
|
|
+ list: &HostList,
|
|
|
+ t: &crate::pipeline::Translated,
|
|
|
+ compute: bool,
|
|
|
+ writes: bool,
|
|
|
+ ) -> Option<crate::memory::Ready> {
|
|
|
let heap = match self.heaps[0] {
|
|
|
0 => None,
|
|
|
h => crate::descriptor::heap(h as This).host(),
|
|
|
@@ -993,6 +1014,11 @@ impl State {
|
|
|
_ => {}
|
|
|
}
|
|
|
}
|
|
|
+ for u in &t.host.user_data {
|
|
|
+ if u.root == RootType::Other(victory_shader::emit::USER_VIEW_ADDRESS) {
|
|
|
+ addresses.push(self.view_address(compute, u.slot, u.dword));
|
|
|
+ }
|
|
|
+ }
|
|
|
crate::memory::ready(list, heap, &addresses, &constants, writes)
|
|
|
}
|
|
|
|
|
|
@@ -1179,7 +1205,10 @@ impl State {
|
|
|
&& !crate::pipeline::builder_quarantined(self.pipeline as This);
|
|
|
// Title memory by address: what the shader finds it by.
|
|
|
let memory = if t.host.root_srvs.contains(&victory_shader::emit::SLOT_MEMORY) {
|
|
|
- let Some(ready) = self.memory_ready(list, compute, writes) else {
|
|
|
+ // Only through a store by address: what it stores through
|
|
|
+ // views is declared with them.
|
|
|
+ let writes = writes && t.stores_by_address;
|
|
|
+ let Some(ready) = self.memory_ready(list, &t, compute, writes) else {
|
|
|
once!("a shader that reads title memory by address without a view heap to hold its views: the draw is dropped");
|
|
|
return false;
|
|
|
};
|