Descriptors: dynamic slots go back only to the heap that took them (#392) #401

Open
github-bot wants to merge 1 commit from github-bot/gh-401 into main AGit
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-26 23:48 UTC · original
Jesper-Andersson:worktree-issue-392 → main · +68 −21 · 3 files · 1 commits · open

Fixes #392.

A command list kept its dynamic descriptor slots by the title heap's address (State::dynamic in crates/victory-gpu/src/draw.rs:501) and gave them back to whatever shader-visible heap was registered at that address when it ran, was reset or was released (descriptor::release_dynamic, descriptor.rs:862). The title can release a heap while a list still holds slots of it, and a new heap can be made at the same address. The old list then freed slots of the new heap that another list held, and two lists could write their tables into the same slots. That shows up as wrong bindings, or a device removal if a view ends up describing the wrong resource. Details are in #392. Found by reading the code; not seen in a game run.

Change

  • descriptor/host.rs: each HostHeap gets an identity from a process-wide counter (NEXT_ID, read with HostHeap::id). HostHeap::release(id, first, n) gives a range back only when id is its own.
  • descriptor.rs: release_dynamic(heap, id, first, n) passes the identity on.
  • draw.rs: State::dynamic records (heap, host heap identity, first, count) at the three places a list takes slots (one-view tables of root UAVs and root SRVs, and fresh tables), and Drop and tables_done hand it back.
  • A heap that is still there takes its own ranges back exactly as before. A release for a heap that is gone, or for a new heap at the old address, does nothing: the host heap it named, and its slots, no longer exist.
  • No switch. This is a port of fxceless/victory-fork#1324 (CwWwWwW) onto this tree, which differs in all three files, so it couldn't be cherry-picked.

Where it does nothing

  • Every release of a heap that is still alive: the identity matches, and the range goes back as before. The existing slot tests now pass the heap's own identity and are otherwise unchanged.

Checks

  • cargo test -p victory-gpu --lib --locked dynamic_s: 3 passed, including the new dynamic_slots_are_given_back_only_to_the_heap_that_took_them (from #1324): two host heaps; a range of A released with B's identity stays taken, and with A's identity it is given back. The test needs a host GPU (it returns early without one); it ran on the RTX 2070 SUPER.
  • cargo test -p victory-gpu --lib --locked: 395 passed, 0 failed, 35 ignored
  • cargo clippy -p victory-gpu --lib --tests --locked: nothing in the changed files. With -D warnings the crate doesn't get through on main itself, for reasons outside this change (list.rs totals never used, watch.rs needless &mut).
  • cargo xtask policy: ok (pre-commit hook)
  • In game: not run. The case needs the title to release a heap while a list holding its slots is unreset and a new heap to land at the same address, and I have nothing that shows that happening.

Not checked

  • Whether the title releases shader-visible heaps while lists that used them are unreset in practice, and how often the allocator reuses the address.
  • AMD, Linux/Proton.
  • fxceless/victory-fork#1324: the original fix. fxceless #1372 (forgets descriptor range caches when their heap is destroyed, using #1324's identity) and #589 (evicts dropped heaps from MEMORY.heaps) handle other state keyed by heap address and aren't part of this.
  • #232 / #265: the same address-reuse pattern for pending flips keyed by HostHeap; different state.
  • #48, #332, #96, #237, #47 change the dynamic-slot pool in the same files (search, sizing, early release). This PR only changes how a range names its heap, so conflicts should be small.

This change was made with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-26 23:48 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/401) `Jesper-Andersson:worktree-issue-392` → `main` · +68 −21 · 3 files · 1 commits · open Fixes #392. A command list kept its dynamic descriptor slots by the title heap's address (`State::dynamic` in `crates/victory-gpu/src/draw.rs:501`) and gave them back to whatever shader-visible heap was registered at that address when it ran, was reset or was released (`descriptor::release_dynamic`, `descriptor.rs:862`). The title can release a heap while a list still holds slots of it, and a new heap can be made at the same address. The old list then freed slots of the new heap that another list held, and two lists could write their tables into the same slots. That shows up as wrong bindings, or a device removal if a view ends up describing the wrong resource. Details are in #392. Found by reading the code; not seen in a game run. ## Change - `descriptor/host.rs`: each `HostHeap` gets an identity from a process-wide counter (`NEXT_ID`, read with `HostHeap::id`). `HostHeap::release(id, first, n)` gives a range back only when `id` is its own. - `descriptor.rs`: `release_dynamic(heap, id, first, n)` passes the identity on. - `draw.rs`: `State::dynamic` records `(heap, host heap identity, first, count)` at the three places a list takes slots (one-view tables of root UAVs and root SRVs, and fresh tables), and `Drop` and `tables_done` hand it back. - A heap that is still there takes its own ranges back exactly as before. A release for a heap that is gone, or for a new heap at the old address, does nothing: the host heap it named, and its slots, no longer exist. - No switch. This is a port of fxceless/victory-fork#1324 (CwWwWwW) onto this tree, which differs in all three files, so it couldn't be cherry-picked. ## Where it does nothing - Every release of a heap that is still alive: the identity matches, and the range goes back as before. The existing slot tests now pass the heap's own identity and are otherwise unchanged. ## Checks - `cargo test -p victory-gpu --lib --locked dynamic_s`: 3 passed, including the new `dynamic_slots_are_given_back_only_to_the_heap_that_took_them` (from #1324): two host heaps; a range of A released with B's identity stays taken, and with A's identity it is given back. The test needs a host GPU (it returns early without one); it ran on the RTX 2070 SUPER. - `cargo test -p victory-gpu --lib --locked`: 395 passed, 0 failed, 35 ignored - `cargo clippy -p victory-gpu --lib --tests --locked`: nothing in the changed files. With `-D warnings` the crate doesn't get through on main itself, for reasons outside this change (`list.rs` `totals` never used, `watch.rs` needless `&mut`). - `cargo xtask policy`: ok (pre-commit hook) - In game: not run. The case needs the title to release a heap while a list holding its slots is unreset and a new heap to land at the same address, and I have nothing that shows that happening. ## Not checked - Whether the title releases shader-visible heaps while lists that used them are unreset in practice, and how often the allocator reuses the address. - AMD, Linux/Proton. ## Related - fxceless/victory-fork#1324: the original fix. fxceless #1372 (forgets descriptor range caches when their heap is destroyed, using #1324's identity) and #589 (evicts dropped heaps from `MEMORY.heaps`) handle other state keyed by heap address and aren't part of this. - #232 / #265: the same address-reuse pattern for pending flips keyed by `HostHeap`; different state. - #48, #332, #96, #237, #47 change the dynamic-slot pool in the same files (search, sizing, early release). This PR only changes how a range names its heap, so conflicts should be small. This change was made with AI assistance (Claude Code).
A list kept its dynamic slots by the title heap's address and gave them
back to whatever heap was registered there when it was reset or released.
The title can release a heap while a list still holds its slots, and a
new heap can be made at the same address; the old list then freed the new
heap's slots that another list held.

Each HostHeap now has an identity (NEXT_ID). State::dynamic records it
with each range, and HostHeap::release / release_dynamic give a range back
only when it is that heap's. A release for a heap that is gone, or for a
new heap at the old address, does nothing.

Ported from fxceless/victory-fork#1324 (CwWwWwW), with its two-heaps test.

Fixes #392

This change was made with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:56:38 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/401/head:github-bot/gh-401'
git switch 'github-bot/gh-401'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-401'
git switch 'github-bot/gh-401'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-401'
git switch 'github-bot/gh-401'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-401'
git switch 'main'
git merge --squash 'github-bot/gh-401'
git switch 'main'
git merge --ff-only 'github-bot/gh-401'
git switch 'main'
git merge 'github-bot/gh-401'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.