GPU: evict idle title buffers, multi-key windows, and unmapped placed RT/depth textures #194

Closed
github-bot wants to merge 1 commit from gh-pr/194/head into gh-pr/194/base
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 22:25 UTC · original
MartinIndra02:perf/fxceless-vram-eviction → main · +79 −9 · 2 files · 1 commits · closed without merging

Summary

Closes three VRAM and shared-memory eviction gaps in \ ictory-gpu's idle sweeps (\shadow::let_go_idle\ and
esource::let_go_idle):

  1. Evict idle registered title buffer copies (including carded VRAM copies) in \shadow::let_go_idle:

    • Previously, \shadow::let_go_idle\ only swept \LOOSE\ (windows outside buffers) and never evicted \BUFFERS\ entries, leaving idle \DEFAULT-heap carded buffers and \CUSTOM-heap title buffer copies alive indefinitely.
    • Idle \BUFFERS\ copies with \Arc::strong_count == 1,
      eferences(&s.buffer) == 1, and !s.writes_pending()\ are now retired (and expired \Weak\ entries pruned from \CARDED). Because title memory remains authoritative once no flight is writing to the buffer, the next lookup recreates the copy cleanly.
  2. Fix multi-key window leak in \LOOSE\ (\shadow::let_go_idle):

    • A window in \LOOSE\ can be stored under multiple keys (as noted in \shadow::memory), giving it \Arc::strong_count >= 2\ even when no list or descriptor slot holds it.
    • Checking \Arc::strong_count(s) == 1\ previously prevented multi-key windows from ever being evicted. Counting map-local references per \Arc::as_ptr\ and comparing \Arc::strong_count(s) == counts[&ptr]\ evicts them cleanly (deduplicating retired \Arc\s for \LET_GO\ accounting) and skips any window with pending shader writes.
  3. Evict idle placed RT/depth/UAV textures whose backing title memory has been unmapped (
    esource::let_go_idle):

    • Render targets, depth buffers, and UAV textures with live backing memory are still preserved.
    • Placed ones whose backing pages are no longer committed (
      .host.placed && !texture::committed(r.data(), 1)), idle, and unreferenced (including any \DepthTwin) are now safely retired, reclaiming both the texture and its twin in VRAM.

Verification

  • \cargo test -p victory-gpu --lib -- --test-threads=1: 110 passed, 0 failed, 1 ignored.
  • \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and --features diagnostics): 0 warnings.
  • \cargo xtask policy: 169 files ok.

AI-assisted contribution (authored and verified with an AI coding assistant).

**@⁠MartinIndra02** on GitHub · 2026-11-24 22:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/194) `MartinIndra02:perf/fxceless-vram-eviction` → `main` · +79 −9 · 2 files · 1 commits · closed without merging ### Summary Closes three VRAM and shared-memory eviction gaps in \ ictory-gpu\'s idle sweeps (\shadow::let_go_idle\ and \ esource::let_go_idle\): 1. **Evict idle registered title buffer copies (including carded VRAM copies) in \shadow::let_go_idle\:** - Previously, \shadow::let_go_idle\ only swept \LOOSE\ (windows outside buffers) and never evicted \BUFFERS\ entries, leaving idle \DEFAULT\-heap carded buffers and \CUSTOM\-heap title buffer copies alive indefinitely. - Idle \BUFFERS\ copies with \Arc::strong_count == 1\, \ eferences(&s.buffer) == 1\, and \!s.writes_pending()\ are now retired (and expired \Weak\ entries pruned from \CARDED\). Because title memory remains authoritative once no flight is writing to the buffer, the next lookup recreates the copy cleanly. 2. **Fix multi-key window leak in \LOOSE\ (\shadow::let_go_idle\):** - A window in \LOOSE\ can be stored under multiple keys (as noted in \shadow::memory\), giving it \Arc::strong_count >= 2\ even when no list or descriptor slot holds it. - Checking \Arc::strong_count(s) == 1\ previously prevented multi-key windows from ever being evicted. Counting map-local references per \Arc::as_ptr\ and comparing \Arc::strong_count(s) == counts[&ptr]\ evicts them cleanly (deduplicating retired \Arc\s for \LET_GO\ accounting) and skips any window with pending shader writes. 3. **Evict idle placed RT/depth/UAV textures whose backing title memory has been unmapped (\ esource::let_go_idle\):** - Render targets, depth buffers, and UAV textures with live backing memory are still preserved. - Placed ones whose backing pages are no longer committed (\ .host.placed && !texture::committed(r.data(), 1)\), idle, and unreferenced (including any \DepthTwin\) are now safely retired, reclaiming both the texture and its twin in VRAM. ### Verification - \cargo test -p victory-gpu --lib -- --test-threads=1\: **110 passed, 0 failed, 1 ignored**. - \cargo clippy -p victory-gpu --all-targets -- -D warnings\ (default and \--features diagnostics\): **0 warnings**. - \cargo xtask policy\: **169 files ok**. *AI-assisted contribution (authored and verified with an AI coding assistant).*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:37:57 +00:00
github-bot closed this pull request 2026-11-26 03:37:57 +00:00
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-24 22:32 UTC · original

Live hardware verification on RTX 3080 (10 GB, Windows 11, release build merged locally with #25 + #71 + #144 + #185):

  • Reached the live 3D prologue and heavier 7,000+ draw frames cleanly with 0 device removals, 0 errors, 0 panics.
  • 4.4–4.8 fps (206–226 ms/frame) at 5,768–7,065 draws/frame, 26,254 textures uploaded (10,231 MB).
  • No visual regressions or eviction-related glitches observed.

AI-assisted log summary; counts and timings only.

**@⁠MartinIndra02** on GitHub · 2026-11-24 22:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7146347834) Live hardware verification on RTX 3080 (10 GB, Windows 11, release build merged locally with #25 + #71 + #144 + #185): - Reached the live 3D prologue and heavier 7,000+ draw frames cleanly with **0 device removals, 0 errors, 0 panics**. - **4.4–4.8 fps** (206–226 ms/frame) at **5,768–7,065 draws/frame**, **26,254** textures uploaded (10,231 MB). - No visual regressions or eviction-related glitches observed. *AI-assisted log summary; counts and timings only.*
Author
Owner

@⁠Jonirulah on GitHub · 2026-11-25 01:29 UTC · original

On native Windows, this PR makes the picture worse in the opening cutscene.

Setup

  • NVIDIA RTX 3070 Laptop GPU (8 GB), Ryzen 7 5800H, 32 GB RAM, Windows 11 LTSC 26100.
  • Release build, Series S mode (--console series-s).
  • Env: VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_LEAN_WINDOWS=1 VICTORY_PIPELINE_WAIT_MS=24.
  • Base branch: fork main (2119b0e) + #188, #270, #186, #159, #265, #97, #258, #241, #203, #261.
  • The only difference between the two runs is this PR merged on top.

Same shot (character seen from behind, looking out of the window at the prison yard):

  • Without #194: the yard renders through the window: watchtower, fence, people, sunlit dust and particles.
  • With #194: the window is a flat, blown-out white rectangle with nothing behind it, and the room background is a flat orange.

Performance: frame time is about the same (median 231 ms/frame with the PR, roughly 230-257 ms without).

Crash: the first run with this PR crashed during loading: 0xc0000005 in title code, game_scarlett_master.exe+0x164a298, reading address 0x2c. A second run did not crash, so I can't tie the crash to the PR.

Guess (untested): the sweep retires host copies of title buffers that the scene still reads through descriptors. The title's per-frame linear allocators reuse the same blocks every frame, so a copy that looks "idle" between sweeps can be needed again. After it is retired, its contents come back empty or stale.

**@⁠Jonirulah** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7149613241) On native Windows, this PR makes the picture worse in the opening cutscene. **Setup** - NVIDIA RTX 3070 Laptop GPU (8 GB), Ryzen 7 5800H, 32 GB RAM, Windows 11 LTSC 26100. - Release build, Series S mode (`--console series-s`). - Env: `VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024 VICTORY_LEAN_WINDOWS=1 VICTORY_PIPELINE_WAIT_MS=24`. - Base branch: fork `main` (`2119b0e`) + #188, #270, #186, #159, #265, #97, #258, #241, #203, #261. - The only difference between the two runs is this PR merged on top. **Same shot** (character seen from behind, looking out of the window at the prison yard): - **Without #194:** the yard renders through the window: watchtower, fence, people, sunlit dust and particles. - **With #194:** the window is a flat, blown-out white rectangle with nothing behind it, and the room background is a flat orange. **Performance:** frame time is about the same (median 231 ms/frame with the PR, roughly 230-257 ms without). **Crash:** the first run with this PR crashed during loading: `0xc0000005` in title code, `game_scarlett_master.exe+0x164a298`, reading address `0x2c`. A second run did not crash, so I can't tie the crash to the PR. **Guess (untested):** the sweep retires host copies of title buffers that the scene still reads through descriptors. The title's per-frame linear allocators reuse the same blocks every frame, so a copy that looks "idle" between sweeps can be needed again. After it is retired, its contents come back empty or stale.
Author
Owner

@⁠MartinIndra02 on GitHub · 2026-11-25 10:40 UTC · original

Closing this PR — thanks @⁠Jonirulah for catching the visual regression in the opening cutscene on RTX 3070 8 GB! Evicting \BUFFERS\ entries while descriptor tables/linear allocators still read them via GPU addresses is unsafe without tracking descriptor/allocator liveness.

**@⁠MartinIndra02** on GitHub · 2026-11-25 10:40 UTC · [original](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7160017598) Closing this PR — thanks @⁠Jonirulah for catching the visual regression in the opening cutscene on RTX 3070 8 GB! Evicting \BUFFERS\ entries while descriptor tables/linear allocators still read them via GPU addresses is unsafe without tracking descriptor/allocator liveness.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.