GPU: exclude reserved and resting pieces from reusable texture memory #297

Open
ySKELLETONX wants to merge 1 commit from upstream-pr/297 into main
ySKELLETONX commented 2026-11-26 14:49:07 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by ySKELLETONX on 2026-11-26T14:49:07Z.


Refs #262 (reserved and resting bytes only).

texture_room() subtracts the successful textures' HELD counter from the allocated block bytes. A piece is removed from the allocator before CreatePlacedResource succeeds, and HELD is decremented as soon as the texture dies, before its mandatory 2,500 ms rest has elapsed. Both intervals therefore appear as reusable capacity even though the allocator cannot use those pieces. The block count and the independently loaded atomic counter can also describe different moments.

Track unavailable bytes in Pool, under the same mutex that reserves and reclaims ranges. A reservation increases the count; returning a piece keeps it unavailable; reclaiming its range after the rest period decreases it. texture_room() now uses this count and advances the existing rest/reclaim logic, so admission can recover even when no new allocation is being attempted. The successful-texture-only HELD counter is removed.

Three synthetic regressions cover reservation before resource creation, the rest deadline and recovery from a budget query alone, alignment padding, block retirement and slot reuse, and 400 allocation/reclaim cycles checked against the actual free ranges. These exercise the production pool with integer block handles. Two initial regressions failed with the original accounting arithmetic extracted into the queried helper.

Validation on Windows:

  • cargo test --locked -p victory-gpu --lib -- pool::tests residency::tests resource::tests --test-threads=1: 27 passed.
  • Same command with --features diagnostics: 27 passed.
  • cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings -A clippy::unnecessary_mut_passed: passed, also with diagnostics. The narrow allowance is for the existing watch.rs:3626 warning on main; that file is unchanged.
  • cargo xtask policy: 265 files OK. git diff --check passed.

This fixes aggregate accounting only. It does not make fragmented free ranges contiguous or prove that a particular allocation fits, so #262 should remain open. No gameplay A/B run, FPS improvement, or reduction in device loss is claimed. Full workspace tests were not run locally.

Prepared with OpenAI Codex assistance.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5512173186 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/297). Originally posted by [ySKELLETONX](https://github.com/ySKELLETONX) on 2026-11-26T14:49:07Z. --- Refs #262 (reserved and resting bytes only). `texture_room()` subtracts the successful textures' `HELD` counter from the allocated block bytes. A piece is removed from the allocator before `CreatePlacedResource` succeeds, and `HELD` is decremented as soon as the texture dies, before its mandatory 2,500 ms rest has elapsed. Both intervals therefore appear as reusable capacity even though the allocator cannot use those pieces. The block count and the independently loaded atomic counter can also describe different moments. Track unavailable bytes in `Pool`, under the same mutex that reserves and reclaims ranges. A reservation increases the count; returning a piece keeps it unavailable; reclaiming its range after the rest period decreases it. `texture_room()` now uses this count and advances the existing rest/reclaim logic, so admission can recover even when no new allocation is being attempted. The successful-texture-only `HELD` counter is removed. Three synthetic regressions cover reservation before resource creation, the rest deadline and recovery from a budget query alone, alignment padding, block retirement and slot reuse, and 400 allocation/reclaim cycles checked against the actual free ranges. These exercise the production pool with integer block handles. Two initial regressions failed with the original accounting arithmetic extracted into the queried helper. Validation on Windows: - `cargo test --locked -p victory-gpu --lib -- pool::tests residency::tests resource::tests --test-threads=1`: 27 passed. - Same command with `--features diagnostics`: 27 passed. - `cargo clippy --locked -p victory-gpu --lib --tests -- -D warnings -A clippy::unnecessary_mut_passed`: passed, also with diagnostics. The narrow allowance is for the existing `watch.rs:3626` warning on main; that file is unchanged. - `cargo xtask policy`: 265 files OK. `git diff --check` passed. This fixes aggregate accounting only. It does not make fragmented free ranges contiguous or prove that a particular allocation fits, so #262 should remain open. No gameplay A/B run, FPS improvement, or reduction in device loss is claimed. Full workspace tests were not run locally. Prepared with OpenAI Codex assistance.
Jesper-Andersson commented 2026-11-27 01:41:37 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Jesper-Andersson on 2026-11-27T01:41:37Z.


An 8 GB data point: RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB RAM, Windows 11. Build: main 014d52d + #203 (DLSS) + pr0vId3nce's own-bytes pool (#221) + #412, diag, Series S + DLSS, play.ps1 settings plus VICTORY_RESIDENCY=1, CARD_BUFFERS_MIN_KB=64, CARD_BUFFERS_MB=1024, WIDE_MERGE=1, WINDOW_KB=1024, SUBMIT_FRAMES=2, CARD_ROOM_FOR_TARGETS_MB=1280 (#407). One run each, about two minutes in the world, around the same place:

without with this PR and #327
the card over its budget 16 of 36 lines (at most 7,162 of 6,941 MB) 0 of 32 (at most 6,717 MB)
texture blocks / of them free 3,968 / 1,501 MB 3,520 / 1,394 MB
passes that made none for lack of room 69 211
median frame 128 ms 85 ms
p90 frame 299 ms 257 ms

Without it, the free part of the texture blocks (1.2-2.2 GB in every run here) counted as room, and the card went over its budget. With it, the room test turns textures away earlier (more lack-of-room passes) and the card stays under. Textures didn't visibly load slower. The frame time going down fits the card no longer being over its budget, but these are single runs, not matched pairs, so take the 128 -> 85 ms as rough.

Both PRs were in the build together. With VICTORY_RESIDENCY=1, #327's new sweep doesn't run (it mirrors the residency branch), so I'd credit most of this to this PR; I haven't run them apart.

Not checked: without residency, AMD, Series X.

This comment was written with AI assistance (Claude Code).

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7207500712 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/297#issuecomment-7207500712). Originally posted by [Jesper-Andersson](https://github.com/Jesper-Andersson) on 2026-11-27T01:41:37Z. --- An 8 GB data point: RTX 2070 SUPER 8 GB (driver 621.14), Ryzen 7 5800X, 32 GB RAM, Windows 11. Build: main `014d52d` + #203 (DLSS) + pr0vId3nce's own-bytes pool (#221) + #412, `diag`, Series S + DLSS, `play.ps1` settings plus `VICTORY_RESIDENCY=1`, `CARD_BUFFERS_MIN_KB=64`, `CARD_BUFFERS_MB=1024`, `WIDE_MERGE=1`, `WINDOW_KB=1024`, `SUBMIT_FRAMES=2`, `CARD_ROOM_FOR_TARGETS_MB=1280` (#407). One run each, about two minutes in the world, around the same place: | | without | with this PR and #327 | |---|---|---| | the card over its budget | 16 of 36 lines (at most 7,162 of 6,941 MB) | **0 of 32** (at most 6,717 MB) | | texture blocks / of them free | 3,968 / 1,501 MB | 3,520 / 1,394 MB | | passes that made none for lack of room | 69 | 211 | | median frame | 128 ms | **85 ms** | | p90 frame | 299 ms | 257 ms | Without it, the free part of the texture blocks (1.2-2.2 GB in every run here) counted as room, and the card went over its budget. With it, the room test turns textures away earlier (more lack-of-room passes) and the card stays under. Textures didn't visibly load slower. The frame time going down fits the card no longer being over its budget, but these are single runs, not matched pairs, so take the 128 -> 85 ms as rough. Both PRs were in the build together. With `VICTORY_RESIDENCY=1`, #327's new sweep doesn't run (it mirrors the residency branch), so I'd credit most of this to this PR; I haven't run them apart. Not checked: without residency, AMD, Series X. This comment was written with AI assistance (Claude Code).
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/297:upstream-pr/297'
git switch 'upstream-pr/297'

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/297'
git switch 'upstream-pr/297'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/297'
git switch 'upstream-pr/297'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/297'
git switch 'main'
git merge --squash 'upstream-pr/297'
git switch 'main'
git merge --ff-only 'upstream-pr/297'
git switch 'main'
git merge 'upstream-pr/297'
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
avatarmanz/VIctory-7900XTX!297
No description provided.