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

Merged
wike1701 merged 1 commit from upstream-pr/28 into main 2026-11-27 09:45:54 +00:00
wike1701 commented 2026-11-27 09:05:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wike1701 on 2026-11-27T09:05:02Z.


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).
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5524000303 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/28). Originally posted by [wike1701](https://github.com/wike1701) on 2026-11-27T09:05:02Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA!28
No description provided.