GPU: a texture pass with no room gives up the oldest slots' host copies #140

Open
github-bot wants to merge 9 commits from github-bot/gh-140 into main AGit
Owner

@⁠undeadhuman37 on GitHub · 2026-11-24 21:48 UTC · original
undeadhuman37:fx/bindless-residency → main · +511 −68 · 6 files · 9 commits · draft

What

The index pass keeps a host copy for every slot it uploads, and a slot's copy is never idle to the sweep, so only unmapping frees it. Once the card passed 90% of its budget, room() stayed false: the pass refused 256 slots and stopped every frame for the rest of the run, and uploads froze (about 14 GB, thousands of slots still due).

Now, when a pass finds no room, up to 256 slots the pass made more than 4 s ago, oldest first, are made null so the sweep can free their copies. The memory line gets a count of slots given up. Marked shortcut: in the code: oldest made first, not least sampled, because a draw reading a texture by index leaves no trace. A slot given up stays empty until the title writes or maps it again, so a texture still on screen may draw empty meanwhile.

Tested

  • cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (499 passed, 0 failed) and cargo xtask policy pass.
  • New test eviction_takes_the_oldest_made_slots_and_spares_the_recent (synthetic, no game files).
  • Two 12-minute runs of the title, no device loss or errors. Textures waiting: about 5,250-7,260 without this change, 2,577 with it (2,314 with the descriptor-data fix as well). Frame rates were 4.5 and 4.2 against 5.1, but the runs differ in cache warmth, so they are not comparable.
  • Not tested: whether any scenery blinks out from a slot given up, and any other GPU. "Passed over, memory not mapped" stays high (10,472 and 13,924), so unmapped placed textures are the remaining blocker.
  • No game files, data, logs or captures are included.

AI use: an AI tool (Claude Code) wrote this change; a person ran and reviewed the checks.

Note on this branch: it is based on fx-main, so besides this change (one commit, 3 files) the diff also carries the other commits merged there. A one-commit version on main is prepared and not yet pushed. Eviction can leave a slot drawing empty; see the test comment below about visual differences, whose cause is not isolated.

**@⁠undeadhuman37** on GitHub · 2026-11-24 21:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/140) `undeadhuman37:fx/bindless-residency` → `main` · +511 −68 · 6 files · 9 commits · draft ## What The index pass keeps a host copy for every slot it uploads, and a slot's copy is never idle to the sweep, so only unmapping frees it. Once the card passed 90% of its budget, `room()` stayed false: the pass refused 256 slots and stopped every frame for the rest of the run, and uploads froze (about 14 GB, thousands of slots still due). Now, when a pass finds no room, up to 256 slots the pass made more than 4 s ago, oldest first, are made null so the sweep can free their copies. The memory line gets a count of slots given up. Marked `shortcut:` in the code: oldest made first, not least sampled, because a draw reading a texture by index leaves no trace. A slot given up stays empty until the title writes or maps it again, so a texture still on screen may draw empty meanwhile. ## Tested - `cargo clippy --workspace --all-targets -- -D warnings`, `cargo test --workspace` (499 passed, 0 failed) and `cargo xtask policy` pass. - New test `eviction_takes_the_oldest_made_slots_and_spares_the_recent` (synthetic, no game files). - Two 12-minute runs of the title, no device loss or errors. Textures waiting: about 5,250-7,260 without this change, 2,577 with it (2,314 with the descriptor-data fix as well). Frame rates were 4.5 and 4.2 against 5.1, but the runs differ in cache warmth, so they are not comparable. - Not tested: whether any scenery blinks out from a slot given up, and any other GPU. "Passed over, memory not mapped" stays high (10,472 and 13,924), so unmapped placed textures are the remaining blocker. - No game files, data, logs or captures are included. AI use: an AI tool (Claude Code) wrote this change; a person ran and reviewed the checks. **Note on this branch:** it is based on `fx-main`, so besides this change (one commit, 3 files) the diff also carries the other commits merged there. A one-commit version on `main` is prepared and not yet pushed. Eviction can leave a slot drawing empty; see the test comment below about visual differences, whose cause is not isolated.
The host removes the device for a constant buffer view of more than 65,536
bytes. The title's view heap holds larger sizes in slots it does not use,
and the size went to the host as it was.
No PC GPU renders to R9G9B9E5, so CreateRenderTargetView on such a
target removes the device. Add it to the existing stand-in table, next
to the 16-bit colour formats.
Slots hold the host copy of what they view, so the idle sweep never frees
copies the index pass made; once the card passed 90% of its budget room()
stayed false and uploads stopped for the rest of the run. When a pass finds
no room it now nulls up to 256 slots made more than 4 s ago, oldest first,
so the sweep can free them. The memory line counts the slots given up.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:50 +00:00
Author
Owner

@⁠m335671 on GitHub · 2026-11-24 22:59 UTC · original

Test run on an RTX 4070: the texture queue stays short for the whole run. Note that this branch also carries #25, #32 and #24 (merged into fx-main under the commit), so what follows is the four of them together, not this commit alone.

Tested

  • RTX 4070 12 GB (32-lane waves), driver 32.0.16.2124, Ryzen 9 7900, 32 GB, Windows 11 Pro 26300, Series X profile, diagnostics build.
  • This PR's head cc69162, merged with #77, #218, #51 and #81 on 2119b0e (no other conflict than both adding tests to waterfall_tests.rs).
  • Prologue checkpoint, about 11 minutes, VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024.
  • No device removal. Counts from the log lines only.

Texture queue, last 30 samples (~3 minutes) of each run

without (1684989-based + #77, ~11 min) with this branch (~11 min)
slots in the queue median 3,850, max 5,031 median 2,451, max 3,022
due median 1,702, max 4,008 median 122, max 2,069
oldest written median 134, max 2,805 frames ago median 50, max 3,523 frames ago
fps / draws (median) 4.2 / 5,069 4.1 / 5,240
  • At the end: passes that made none for lack of room: 63 (14086 slots given up to make room), card 8,277 MB of a 10,808 MB budget.
  • Without the change, textures visibly went missing or stale as the run went on. With it they stayed current.

Visual differences I saw, cause not isolated (any of the four PRs could be behind them):

  • In the first gameplay room, the wire mesh in front of the window is missing. The window shows a shimmering frosted texture, and the yard behind it is washed out. With #77/#218/#51/#81 alone, in the same spot, the mesh and the yard were there.
  • The small window in the cell door draws in front of the guard standing behind it, which cuts a hole in his torso.

Not tested: this commit without #25/#32/#24, process memory (still about 23 GB committed), other GPUs.

AI use: the run was done on my machine. Claude Code (Claude Opus 5.5) built and ran it, read the logs, worked out the figures and wrote this comment.

**@⁠m335671** on GitHub · 2026-11-24 22:59 UTC · [original](https://github.com/fxceless/victory-fork/pull/140#issuecomment-7146876389) Test run on an RTX 4070: the texture queue stays short for the whole run. Note that this branch also carries #25, #32 and #24 (merged into `fx-main` under the commit), so what follows is the four of them together, not this commit alone. **Tested** - RTX 4070 12 GB (32-lane waves), driver 32.0.16.2124, Ryzen 9 7900, 32 GB, Windows 11 Pro 26300, Series X profile, diagnostics build. - This PR's head `cc69162`, merged with #77, #218, #51 and #81 on `2119b0e` (no other conflict than both adding tests to `waterfall_tests.rs`). - Prologue checkpoint, about 11 minutes, `VICTORY_LATE_WAIT=3 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024`. - No device removal. Counts from the log lines only. **Texture queue, last 30 samples (~3 minutes) of each run** | | without (`1684989`-based + #77, ~11 min) | with this branch (~11 min) | |---|---|---| | slots in the queue | median 3,850, max 5,031 | median **2,451**, max 3,022 | | due | median **1,702**, max 4,008 | median **122**, max 2,069 | | oldest written | median 134, max 2,805 frames ago | median 50, max 3,523 frames ago | | fps / draws (median) | 4.2 / 5,069 | 4.1 / 5,240 | - At the end: `passes that made none for lack of room: 63 (14086 slots given up to make room)`, card 8,277 MB of a 10,808 MB budget. - Without the change, textures visibly went missing or stale as the run went on. With it they stayed current. **Visual differences I saw, cause not isolated** (any of the four PRs could be behind them): - In the first gameplay room, the wire mesh in front of the window is missing. The window shows a shimmering frosted texture, and the yard behind it is washed out. With #77/#218/#51/#81 alone, in the same spot, the mesh and the yard were there. - The small window in the cell door draws in front of the guard standing behind it, which cuts a hole in his torso. **Not tested:** this commit without #25/#32/#24, process memory (still about 23 GB committed), other GPUs. AI use: the run was done on my machine. Claude Code (Claude Opus 5.5) built and ran it, read the logs, worked out the figures and wrote this comment.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/descriptor/host.rs
  • crates/victory-gpu/src/draw.rs
  • crates/victory-gpu/src/resource.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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