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:
wike1701 committed 2026-11-27 10:04:21 +01:00
1 parent 18a8dc2640
commit 47747d6236
3 files changed
+54 -21

No files matched your search

+3 -3
View File
@@ -844,15 +844,15 @@ pub(crate) fn with_heap<T>(heap: usize, f: impl FnOnce(&Heap) -> T) -> Option<T>
}
/// Gives back dynamic slots of the host heap behind the title heap at
/// `heap`, if that heap still exists.
/// `heap`, if that host heap instance (`id`) still exists.
#[cfg(windows)]
pub(crate) fn release_dynamic(heap: usize, first: u32, n: u32) {
pub(crate) fn release_dynamic(heap: usize, id: u64, first: u32, n: u32) {
let heaps = SHADER_HEAPS.read().unwrap_or_else(|e| e.into_inner());
if heaps.iter().any(|&(_, _, h)| h == heap)
// SAFETY: registered heaps are live (removed when dropped).
&& let Some(Some(host)) = unsafe { &*(heap as *const Heap) }.host.get()
{
host.release(first, n);
host.release(id, first, n);
}
}