GPU: release dynamic descriptor slots only to the host heap that allocated them
Port of fxceless/victory-fork#1324 (commit 52ac4ec, GPL-3.0). HostHeap::release previously matched only the title heap's pointer address. When a title releases a shader-visible heap before lists referencing it are reset, and a new heap is allocated at the same address, resetting the older list freed dynamic slots belonging to the new heap. On NVIDIA (where VICTORY_DYNAMIC_SLOTS=524288 is active), two live command lists could then overwrite each other's descriptors. Each HostHeap now gets a monotonic identity (NEXT_ID) recorded alongside dynamic slot ranges in draw::State::dynamic and checked in HostHeap::release. Tested with VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics descriptor:: (50 passed, 0 failed), including dynamic_slots_are_given_back_only_to_the_heap_that_took_them.
This commit is contained in:
1 parent
18a8dc2640
commit
47747d6236
3 files changed
+54
-21
No files matched your search
@@ -543,9 +543,9 @@ pub(crate) struct State {
|
||||
/// Tables made afresh in this list: (table, slot count, contents) → first
|
||||
/// dynamic slot.
|
||||
fresh_tables: std::collections::HashMap<(u64, u32, u64), FreshTable, std::hash::BuildHasherDefault<crate::host::AddressHash>>,
|
||||
/// The dynamic slots the list holds: title heap, first, count; given
|
||||
/// back when the list has run, is reset or released.
|
||||
dynamic: Vec<(usize, u32, u32)>,
|
||||
/// The dynamic slots the list holds: title heap, host heap id, first,
|
||||
/// count; given back when the list has run, is reset or released.
|
||||
dynamic: Vec<(usize, u64, u32, u32)>,
|
||||
/// Root SRVs bound as one-view tables in this list: (title heap, title
|
||||
/// address; 0 for none) → dynamic slot, and the host copy the slot
|
||||
/// shows: later draws of the list bring that one up to date, whatever
|
||||
@@ -564,8 +564,8 @@ pub(crate) struct State {
|
||||
|
||||
impl Drop for State {
|
||||
fn drop(&mut self) {
|
||||
for &(heap, first, n) in &self.dynamic {
|
||||
crate::descriptor::release_dynamic(heap, first, n);
|
||||
for &(heap, id, first, n) in &self.dynamic {
|
||||
crate::descriptor::release_dynamic(heap, id, first, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -586,8 +586,8 @@ impl State {
|
||||
static ONCE: std::sync::Once = std::sync::Once::new();
|
||||
ONCE.call_once(|| tracing::warn!("a list ran again after its descriptor tables were given back"));
|
||||
}
|
||||
for (heap, first, n) in self.dynamic.drain(..) {
|
||||
crate::descriptor::release_dynamic(heap, first, n);
|
||||
for (heap, id, first, n) in self.dynamic.drain(..) {
|
||||
crate::descriptor::release_dynamic(heap, id, first, n);
|
||||
}
|
||||
self.fresh_tables.clear();
|
||||
self.recording = 0;
|
||||
@@ -2242,7 +2242,7 @@ impl State {
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
self.dynamic.push((key.0, index, 1));
|
||||
self.dynamic.push((key.0, host.id(), index, 1));
|
||||
if let Some((a, s)) = &shadow {
|
||||
// SAFETY: a live buffer.
|
||||
let base = unsafe { s.buffer.GetGPUVirtualAddress() };
|
||||
@@ -2316,7 +2316,7 @@ impl State {
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
self.dynamic.push((key.0, index, 1));
|
||||
self.dynamic.push((key.0, host.id(), index, 1));
|
||||
self.root_srv_slots
|
||||
.insert(key, (index, shadow.as_ref().map(|(_, s)| s.clone())));
|
||||
match &shadow {
|
||||
@@ -4565,7 +4565,7 @@ impl State {
|
||||
};
|
||||
self.fresh_tables.insert(key, FreshTable { first, epoch: 0, ready: Vec::new() });
|
||||
self.dynamic
|
||||
.push((std::ptr::from_ref(heap) as usize, first, n));
|
||||
.push((std::ptr::from_ref(heap) as usize, host.id(), first, n));
|
||||
// The title's own slots of this table: what the draw reads of
|
||||
// them it brings up to date here, in the dynamic slots.
|
||||
let title_first = heap.index(table).filter(|first| first + n <= host.count());
|
||||
|
||||
Reference in new issue
Block a user