|
@@ -77,6 +77,8 @@ pub(crate) struct State {
|
|
|
/// The dynamic slots the list holds: title heap, first, count; given
|
|
/// The dynamic slots the list holds: title heap, first, count; given
|
|
|
/// back when the list is reset or released.
|
|
/// back when the list is reset or released.
|
|
|
dynamic: Vec<(usize, u32, u32)>,
|
|
dynamic: Vec<(usize, u32, u32)>,
|
|
|
|
|
+ /// A fresh table of the stage being bound could not be made.
|
|
|
|
|
+ table_failed: bool,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl Drop for State {
|
|
impl Drop for State {
|
|
@@ -344,7 +346,9 @@ impl State {
|
|
|
once!(mesh, "a draw or mesh dispatch with another kind of pipeline");
|
|
once!(mesh, "a draw or mesh dispatch with another kind of pipeline");
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- self.bind(list, p, false);
|
|
|
|
|
|
|
+ if !self.bind(list, p, false) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
let l = &list.list;
|
|
let l = &list.list;
|
|
|
// Vertex buffers the input layout reads.
|
|
// Vertex buffers the input layout reads.
|
|
|
let mut views = [D3D12_VERTEX_BUFFER_VIEW::default(); 32];
|
|
let mut views = [D3D12_VERTEX_BUFFER_VIEW::default(); 32];
|
|
@@ -403,7 +407,9 @@ impl State {
|
|
|
/// What draws and dispatches share: heaps, our root signature, the
|
|
/// What draws and dispatches share: heaps, our root signature, the
|
|
|
/// pipeline, and per stage the user data, root views and the
|
|
/// pipeline, and per stage the user data, root views and the
|
|
|
/// descriptors its tables hold.
|
|
/// descriptors its tables hold.
|
|
|
- fn bind(&mut self, list: &HostList, p: &HostPipeline, compute: bool) {
|
|
|
|
|
|
|
+ /// False if the draw or dispatch must not run: a table it reads could
|
|
|
|
|
+ /// not be made.
|
|
|
|
|
+ fn bind(&mut self, list: &HostList, p: &HostPipeline, compute: bool) -> bool {
|
|
|
let l = &list.list;
|
|
let l = &list.list;
|
|
|
// Heaps first: a root signature with directly indexed heaps must be
|
|
// Heaps first: a root signature with directly indexed heaps must be
|
|
|
// set after them.
|
|
// set after them.
|
|
@@ -446,7 +452,19 @@ impl State {
|
|
|
}
|
|
}
|
|
|
for stage in &p.stages {
|
|
for stage in &p.stages {
|
|
|
let t = stage.translated();
|
|
let t = stage.translated();
|
|
|
|
|
+ self.table_failed = false;
|
|
|
let made = self.tables(list, &t.used, compute);
|
|
let made = self.tables(list, &t.used, compute);
|
|
|
|
|
+ if self.table_failed {
|
|
|
|
|
+ static DROPPED_TABLES: AtomicU64 = AtomicU64::new(0);
|
|
|
|
|
+ let n = DROPPED_TABLES.fetch_add(1, Ordering::Relaxed) + 1;
|
|
|
|
|
+ if n.is_power_of_two() {
|
|
|
|
|
+ tracing::warn!(
|
|
|
|
|
+ dropped = n,
|
|
|
|
|
+ "a draw or dispatch dropped: no dynamic slots for its tables"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
if let Some((param, dwords)) = stage.user_data {
|
|
if let Some((param, dwords)) = stage.user_data {
|
|
|
let mut values = vec![0u32; dwords as usize];
|
|
let mut values = vec![0u32; dwords as usize];
|
|
|
for u in &t.host.user_data {
|
|
for u in &t.host.user_data {
|
|
@@ -489,6 +507,7 @@ impl State {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ true
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// Runs a dispatch on the host.
|
|
/// Runs a dispatch on the host.
|
|
@@ -513,7 +532,10 @@ impl State {
|
|
|
once!("a dispatch with a graphics pipeline");
|
|
once!("a dispatch with a graphics pipeline");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- self.bind(list, p, true);
|
|
|
|
|
|
|
+ if !self.bind(list, p, true) {
|
|
|
|
|
+ DROPPED.fetch_add(1, Ordering::Relaxed);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
#[cfg(feature = "diagnostics")]
|
|
#[cfg(feature = "diagnostics")]
|
|
|
list.note_op(|| self.op_text(format!("dispatch {x}x{y}x{z}"), true));
|
|
list.note_op(|| self.op_text(format!("dispatch {x}x{y}x{z}"), true));
|
|
|
// SAFETY: an open list with everything set.
|
|
// SAFETY: an open list with everything set.
|
|
@@ -696,6 +718,12 @@ impl State {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
let Some(first) = host.dynamic(n) else {
|
|
let Some(first) = host.dynamic(n) else {
|
|
|
|
|
+ // Without its fresh table the shader would read the title's
|
|
|
|
|
+ // slots, which for constant buffer tables hold no constant
|
|
|
|
|
+ // view: a texture or null descriptor read as a buffer gives
|
|
|
|
|
+ // a wild address on AMD and the device is removed (#59).
|
|
|
|
|
+ // The draw or dispatch is dropped instead.
|
|
|
|
|
+ self.table_failed = true;
|
|
|
continue;
|
|
continue;
|
|
|
};
|
|
};
|
|
|
self.fresh_tables.insert(key, first);
|
|
self.fresh_tables.insert(key, first);
|
|
@@ -988,10 +1016,7 @@ impl State {
|
|
|
DRAW | INDEXED => self.topology != RECTANGLES && self.prepare(list, kind == INDEXED),
|
|
DRAW | INDEXED => self.topology != RECTANGLES && self.prepare(list, kind == INDEXED),
|
|
|
MESH => self.prepare_for(list, false, true),
|
|
MESH => self.prepare_for(list, false, true),
|
|
|
DISPATCH => match crate::pipeline::host_pipeline(self.pipeline as This) {
|
|
DISPATCH => match crate::pipeline::host_pipeline(self.pipeline as This) {
|
|
|
- Some(p) if p.compute => {
|
|
|
|
|
- self.bind(list, p, true);
|
|
|
|
|
- true
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Some(p) if p.compute => self.bind(list, p, true),
|
|
|
_ => false,
|
|
_ => false,
|
|
|
},
|
|
},
|
|
|
_ => false,
|
|
_ => false,
|