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

Closed
MartinIndra02 wants to merge 1 commit from upstream-pr/194 into main
MartinIndra02 commented 2026-11-24 22:25:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MartinIndra02 on 2026-11-24T22:25:46Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:issue:6592638803 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/194). Originally posted by [MartinIndra02](https://github.com/MartinIndra02) on 2026-11-24T22:25:46Z. --- ### 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 commented 2026-11-24 23:09:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MartinIndra02 on 2026-11-24T22:32:14Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7146347834 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7146347834). Originally posted by [MartinIndra02](https://github.com/MartinIndra02) on 2026-11-24T22:32:14Z. --- 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.*
Jonirulah commented 2026-11-25 02:10:08 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Jonirulah on 2026-11-25T01:29:54Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7149613241 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7149613241). Originally posted by [Jonirulah](https://github.com/Jonirulah) on 2026-11-25T01:29:54Z. --- 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.
upstream-sync closed this pull request 2026-11-25 11:10:09 +00:00
MartinIndra02 commented 2026-11-25 11:10:38 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MartinIndra02 on 2026-11-25T10:40:26Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7160017598 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/194#issuecomment-7160017598). Originally posted by [MartinIndra02](https://github.com/MartinIndra02) on 2026-11-25T10:40:26Z. --- 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

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
fxceless/victory-fork!194
No description provided.