Skip to content

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

Closed
MartinIndra02 wants to merge 1 commit into
fxceless:mainfrom
MartinIndra02:perf/fxceless-vram-eviction
Closed

MartinIndra02 wants to merge 1 commit into
fxceless:mainfrom
MartinIndra02:perf/fxceless-vram-eviction

Conversation

@MartinIndra02

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown

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

Setup

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

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.

RecompLive pushed a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
Audio: an XMA loop's skip is of its first frame, not of its last
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
Audio: an XMA loop's skip is of its first frame, not of its last
(cherry picked from commit 2a45e75)
@MartinIndra02

Copy link
Copy Markdown
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants