GPU: release dynamic descriptor slots only to the host heap that allocated them #28

Manually merged
github merged 1 commit from github-bot/gh-28 into main 2026-11-27 10:44:54 +00:00 AGit
Owner

@⁠wike1701 on GitHub · 2026-11-27 09:05 UTC · original
wike1701:fix/dynamic-slot-heap-identity → main · +54 −21 · 3 files · 1 commits · merged 2026-11-27 09:45 UTC

Port of fxceless/victory-fork#1324 (commit \52ac4ec, GPL-3.0).

Problem

\draw::State::dynamic\ tracks dynamic descriptor slot ranges by the title heap's pointer address, and \descriptor::release_dynamic\ releases them on whichever \HostHeap\ is currently registered at that address when a command list is reset or dropped. If the title releases a shader-visible heap while lists referencing it are still alive and a new heap is allocated at the same address, resetting the older list frees dynamic slots belonging to the new heap. On NVIDIA (where \VICTORY_DYNAMIC_SLOTS=524288\ is enabled by default), two live command lists can then collide on the same dynamic slots.

Fix

  • Assign each \HostHeap\ a monotonic identity (\NEXT_ID) and expose \HostHeap::id().
  • Record the host heap identity alongside each range in \draw::State::dynamic\ and verify \id == self.id\ in \HostHeap::release.
  • Add unit test \dynamic_slots_are_given_back_only_to_the_heap_that_took_them\ verifying that releasing with another heap's identity is a no-op while releasing with the owning heap's identity frees the slots.

Verification

  • \VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics descriptor::\ -> 52 passed, 0 failed (including the new test).
**@⁠wike1701** on GitHub · 2026-11-27 09:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/28) `wike1701:fix/dynamic-slot-heap-identity` → `main` · +54 −21 · 3 files · 1 commits · merged 2026-11-27 09:45 UTC Port of fxceless/victory-fork#1324 (commit \52ac4ec\, GPL-3.0). ### Problem \draw::State::dynamic\ tracks dynamic descriptor slot ranges by the title heap's pointer address, and \descriptor::release_dynamic\ releases them on whichever \HostHeap\ is currently registered at that address when a command list is reset or dropped. If the title releases a shader-visible heap while lists referencing it are still alive and a new heap is allocated at the same address, resetting the older list frees dynamic slots belonging to the new heap. On NVIDIA (where \VICTORY_DYNAMIC_SLOTS=524288\ is enabled by default), two live command lists can then collide on the same dynamic slots. ### Fix - Assign each \HostHeap\ a monotonic identity (\NEXT_ID\) and expose \HostHeap::id()\. - Record the host heap identity alongside each range in \draw::State::dynamic\ and verify \id == self.id\ in \HostHeap::release\. - Add unit test \dynamic_slots_are_given_back_only_to_the_heap_that_took_them\ verifying that releasing with another heap's identity is a no-op while releasing with the owning heap's identity frees the slots. ### Verification - \VICTORY_D3D12_WARP=1 cargo test -p victory-gpu --lib --features diagnostics descriptor::\ -> **52 passed, 0 failed** (including the new test).
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 09:06:27 +00:00
github manually merged commit dc6dc87098 into main 2026-11-27 10:44:54 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.