gpu: reclaim idle superseded and slot-pinned dead render targets #2361

Manually merged
github merged 2 commits from github-bot/gh-2361 into main 2026-11-30 14:14:55 +00:00 AGit
Owner

@⁠nidea1 on GitHub · 2026-11-29 12:21 UTC · original
nidea1:fix/reclaim-superseded-render-targets → main · +473 −70 · 3 files · 2 commits · merged 2026-11-30 14:12 UTC

What it changes

Extends the periodic dead render-target sweep in crates/victory-gpu/src/resource.rs, crates/victory-gpu/src/descriptor.rs, and crates/victory-gpu/src/descriptor/host.rs to reclaim superseded and slot-pinned dead render targets (addressing the render-target VRAM growth tracked in #791):

  • Superseded render targets: previously, NEXT_DEAD_RT_SWEEP only reclaimed placed render targets whose title memory was unmapped (!committed), so old render targets superseded by a newer target at the same title virtual address (TARGETS_AT / superseded) stayed in VRAM indefinitely because the new target keeps that VA committed. reclaim_dead_render_targets now also reclaims superseded non-null targets after 10 s / 60 frames idle (keeping 30 s / 60 frames for unmapped targets).
  • Twin reference-count safety & accounting: checks twin's Arc::strong_count and COM reference count before reclaiming and includes twin.colour.bytes in reclaimed totals.
  • Slot-pinned dead RTs (deadlock- and race-safe): moves the sweep outside the TEXTURES lock so TARGETS_AT and SHADER_HEAPS never nest under TEXTURES. For dead RTs with Arc::strong_count == 1 whose host resource is still pinned only by stale title descriptor slots (references > 1), queries descriptor::evictable_dead_rt_slots (skipping any slot shown by a draw table or marked by sampled-marks since the 10 s cutoff, or held by non-title/sampler slots), resets only slots still holding that exact expected_raw resource pointer via HostHeap::texture_slot_evicted(index, Some(expected_raw)) without re-queuing them into the sampled texture pass, and restores slots via descriptor::texture_made if concurrent reuse occurred.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 3060 Ti 8 GB, Series S profile, 1440p, FSR 3 2x FG, RT off
  • Before: superseded render targets and slot-pinned dead render targets were never reclaimed by let_go_idle(), causing steady render-target VRAM growth on 8 GB GPUs
  • After: idle superseded and slot-pinned dead render targets are reclaimed cleanly while active, recent, or newest-at-address render targets stay intact; verified with dead_rt_reclaimable_policy_matrix, reclaim_dead_render_targets_frees_idle_superseded_and_keeps_newest_and_recent, full resource::tests:: & descriptor::tests::, and live 8 GB RTX 3060 Ti sessions
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A
  • cargo test passed for the crates it touches: yes (cargo test -p victory-gpu --lib --locked -- resource::tests:: descriptor::tests:: — 62 passed, 0 failed, 1 ignored)

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #791, #1958, #2022 (does not touch slot_evict's filled-texture eviction or idle_sweep_policy, which are already on main)
**@⁠nidea1** on GitHub · 2026-11-29 12:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2361) `nidea1:fix/reclaim-superseded-render-targets` → `main` · +473 −70 · 3 files · 2 commits · merged 2026-11-30 14:12 UTC ## What it changes Extends the periodic dead render-target sweep in `crates/victory-gpu/src/resource.rs`, `crates/victory-gpu/src/descriptor.rs`, and `crates/victory-gpu/src/descriptor/host.rs` to reclaim superseded and slot-pinned dead render targets (addressing the render-target VRAM growth tracked in #791): - **Superseded render targets:** previously, `NEXT_DEAD_RT_SWEEP` only reclaimed placed render targets whose title memory was unmapped (`!committed`), so old render targets superseded by a newer target at the same title virtual address (`TARGETS_AT` / `superseded`) stayed in VRAM indefinitely because the new target keeps that VA committed. `reclaim_dead_render_targets` now also reclaims superseded non-null targets after 10 s / 60 frames idle (keeping 30 s / 60 frames for unmapped targets). - **Twin reference-count safety & accounting:** checks `twin`'s `Arc::strong_count` and COM reference count before reclaiming and includes `twin.colour.bytes` in reclaimed totals. - **Slot-pinned dead RTs (deadlock- and race-safe):** moves the sweep outside the `TEXTURES` lock so `TARGETS_AT` and `SHADER_HEAPS` never nest under `TEXTURES`. For dead RTs with `Arc::strong_count == 1` whose host resource is still pinned only by stale title descriptor slots (`references > 1`), queries `descriptor::evictable_dead_rt_slots` (skipping any slot shown by a draw table or marked by sampled-marks since the 10 s cutoff, or held by non-title/sampler slots), resets only slots still holding that exact `expected_raw` resource pointer via `HostHeap::texture_slot_evicted(index, Some(expected_raw))` without re-queuing them into the sampled texture pass, and restores slots via `descriptor::texture_made` if concurrent reuse occurred. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): RTX 3060 Ti 8 GB, Series S profile, 1440p, FSR 3 2x FG, RT off - Before: superseded render targets and slot-pinned dead render targets were never reclaimed by `let_go_idle()`, causing steady render-target VRAM growth on 8 GB GPUs - After: idle superseded and slot-pinned dead render targets are reclaimed cleanly while active, recent, or newest-at-address render targets stay intact; verified with `dead_rt_reclaimable_policy_matrix`, `reclaim_dead_render_targets_frees_idle_superseded_and_keeps_newest_and_recent`, full `resource::tests::` & `descriptor::tests::`, and live 8 GB RTX 3060 Ti sessions - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A - `cargo test` passed for the crates it touches: yes (`cargo test -p victory-gpu --lib --locked -- resource::tests:: descriptor::tests::` — 62 passed, 0 failed, 1 ignored) ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #791, #1958, #2022 (does not touch `slot_evict`'s filled-texture eviction or `idle_sweep_policy`, which are already on `main`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 12:27:21 +00:00
github manually merged commit 32b268007d into main 2026-11-30 14:14:55 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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