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

Open
github-bot wants to merge 1 commit from github-bot/gh-297 into main AGit
Owner

@⁠ySKELLETONX on GitHub · 2026-11-26 14:49 UTC · original
ySKELLETONX:fix/texture-pool-reusable-bytes → main · +76 −9 · 1 files · 1 commits · open

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.

**@⁠ySKELLETONX** on GitHub · 2026-11-26 14:49 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/297) `ySKELLETONX:fix/texture-pool-reusable-bytes` → `main` · +76 −9 · 1 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:52:23 +00:00
Author
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-27 01:41 UTC · original

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

**@⁠Jesper-Andersson** on GitHub · 2026-11-27 01:41 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/297#issuecomment-7207500712) 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/297/head:github-bot/gh-297'
git switch 'github-bot/gh-297'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-297'
git switch 'github-bot/gh-297'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-297'
git switch 'github-bot/gh-297'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-297'
git switch 'main'
git merge --squash 'github-bot/gh-297'
git switch 'main'
git merge --ff-only 'github-bot/gh-297'
git switch 'main'
git merge 'github-bot/gh-297'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.