GPU: copies of title buffers get bounds, and the system segment's #3930

Open
kotekompotek wants to merge 3 commits from upstream-pr/3930 into main
kotekompotek commented 2026-12-01 05:39:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-12-01T05:39:49Z.


Summary

  • Depends on #3928 (loose-copy LRU bounds); this extends the same treatment to find()'s copies of whole title buffers.
  • Entry now records the presented frame its copy was last asked for. Past the soft bound (1 GB) find() and the per-frame evict_loose() retire idle buffer copies least-recently-used first; past the hard bound (1.5 GB) — or when QueryVideoMemoryInfo says the GPU-visible system segment has no room for the copy plus a 256 MB reserve — the copy is refused rather than racing the driver's limit.
  • segment_short() reads the non-local segment budget (video_memory()[1]), so both the loose and buffer maps trim to zero when the driver budget is nearly exhausted — the point where an idle-floor no longer frees headroom.
  • Measured on the GTX 1050 (2 GB, ~3.79 GB system budget): the previous build still removed the device during story streaming even with loose copies bounded (system segment 3905/3791 MB, buffers ≈735 MB uncapped). With this applied the title ran story mode for 14m25s before crashing on its own memory ceiling (Breakpad memory.load_percent 98, TileHeap 2761/3977Mb) — the host device survived.

Test plan

  • cargo check -p victory-gpu --features diagnostics clean
  • cargo test -p victory-gpu --features diagnostics shadow — 10/10 pass
  • In-game: prior run removed the device at story-streaming minute ~9; patched run survived 14m25s into live story mode

Generated with Devin

<!-- greyfinch-sync:Marvisak/VIctory:issue:5579798477 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3930). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-12-01T05:39:49Z. --- ## Summary - **Depends on #3928** (loose-copy LRU bounds); this extends the same treatment to `find()`'s copies of whole title buffers. - `Entry` now records the presented frame its copy was last asked for. Past the soft bound (1 GB) `find()` and the per-frame `evict_loose()` retire idle buffer copies least-recently-used first; past the hard bound (1.5 GB) — or when `QueryVideoMemoryInfo` says the GPU-visible **system segment** has no room for the copy plus a 256 MB reserve — the copy is **refused** rather than racing the driver's limit. - `segment_short()` reads the non-local segment budget (`video_memory()[1]`), so both the loose and buffer maps trim to zero when the driver budget is nearly exhausted — the point where an idle-floor no longer frees headroom. - Measured on the GTX 1050 (2 GB, ~3.79 GB system budget): the previous build still removed the device during story streaming even with loose copies bounded (system segment `3905/3791 MB`, buffers ≈735 MB uncapped). With this applied the title ran story mode for **14m25s** before crashing on its *own* memory ceiling (Breakpad `memory.load_percent 98`, `TileHeap 2761/3977Mb`) — the host device survived. #### Test plan - [x] `cargo check -p victory-gpu --features diagnostics` clean - [x] `cargo test -p victory-gpu --features diagnostics shadow` — 10/10 pass - [x] In-game: prior run removed the device at story-streaming minute ~9; patched run survived 14m25s into live story mode Generated with [Devin](https://devin.ai)
passerbyyhx commented 2026-12-01 12:30:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T12:30:30Z.


On 7a6a8225 I injected non-local segment readings while leaving whole-buffer allocation and GPU readback on the hardware device. A reported budget of 805 decimal MB falls below the 768 MiB credibility cutoff and allowed the copy. With credible budgets of 1,024 MB and 3,500 MB, the effective reserves were 128,000,000 and 268,435,456 bytes, respectively.

A four-byte lookup triggered allocation of the whole registered buffer. At exact headroom, a 1,000,000-byte buffer and a 564,544-byte buffer were admitted in their respective cases. Adding one byte to either requested buffer caused refusal and retirement of the cached buffer. Lowering reported usage by 1 MB allowed both refused buffers to be created, with GPU readbacks of 0x137a51fe and 0x137a51ff.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7311231057 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3930#issuecomment-7311231057). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-12-01T12:30:30Z. --- On `7a6a8225` I injected non-local segment readings while leaving whole-buffer allocation and GPU readback on the hardware device. A reported budget of 805 decimal MB falls below the 768 MiB credibility cutoff and allowed the copy. With credible budgets of 1,024 MB and 3,500 MB, the effective reserves were 128,000,000 and 268,435,456 bytes, respectively. A four-byte lookup triggered allocation of the whole registered buffer. At exact headroom, a 1,000,000-byte buffer and a 564,544-byte buffer were admitted in their respective cases. Adding one byte to either requested buffer caused refusal and retirement of the cached buffer. Lowering reported usage by 1 MB allowed both refused buffers to be created, with GPU readbacks of `0x137a51fe` and `0x137a51ff`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3930:upstream-pr/3930'
git switch 'upstream-pr/3930'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3930'
git switch 'upstream-pr/3930'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3930'
git switch 'upstream-pr/3930'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3930'
git switch 'main'
git merge --squash 'upstream-pr/3930'
git switch 'main'
git merge --ff-only 'upstream-pr/3930'
git switch 'main'
git merge 'upstream-pr/3930'
git push origin 'main'
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
Marvisak/VIctory!3930
No description provided.