Texture sweep: the card's rule frees idle textures under RAM pressure too, backs off instead of churning, and keeps textures shown through slots #3475

Closed
nyxctura wants to merge 3 commits from upstream-pr/3475 into main
nyxctura commented 2026-11-29 23:44:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nyxctura on 2026-11-29T23:44:14Z.


Related: #1772, #3206.

What it changes

With the card over its texture budget and the PC short of RAM at the same time (normal on a 12 GB card with 32 GB of RAM), the sweep found ~7.5 GB of textures idle for 30 s and more and freed ~90 MB every 5 s. The texture queue said "no room, new textures wait" in 95 % of its reports: late and blurry textures, frame generation failing with "out of VRAM", and Windows paging.

Three commits:

  1. The card's rule is capped and backs off (resource.rs, host.rs, VICTORY_SWEEP_CAPPED). It frees no more than idle textures can give, pauses when too many of the textures it freed come back within 10 s (VICTORY_SWEEP_CAPPED_BACK_PERCENT), and slows down only when nothing is left to free. This ends the free-and-reload loop (#1772).
  2. The card's rule takes mapped idle copies under the PC's pressure too (VICTORY_SWEEP_CARD_MAPPED). A second "wholly unmapped" gate in the free loop, left over after 3246d252 changed the first one, skipped nearly every candidate whenever RAM was short. Also: copies the streamed-out pass freed no longer count as idle (VICTORY_SWEEP_STALE), and a 5-s "why kept" line says what holds the rest (VICTORY_SWEEP_WHY).
  3. Textures shown through slots are kept (resource.rs, descriptor/host.rs, VICTORY_SWEEP_HELD_GRACE_S). A texture picked by index never asks for its host copy again, so its used stamp goes stale while it is on screen. When the title moves its view to another slot, the old slot lets go before the new one is made, and a look in between freed it: the texture flickered (a character's arm, every few seconds). Copies held by a slot or list within the grace time stay, ones that came back are protected longer (VICTORY_SWEEP_BACK_PROTECT_S), and the back-off also counts bytes. VICTORY_SWEEP_BACK_WHO logs which code asked for a copy again.

Every change has its switch; =0 restores the old behaviour.

Screenshots

fps in the world, before vs with this PR:
image 6

With this PR: card under its budget, RAM free, frame generation running:
image 5

How it was tested

  • PC: RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 25H2.
  • Profile: Series S, 1080p → 1440p, DLSS Ultra Performance, frame generation 2x, 60 fps cap, ray tracing off.
  • Before (16.7 min in the world): "no room" in 95 % of reports, textures 1,148 MB over their line on average, 1.5 GB RAM free on average in the world (0.7 minimum), frame generation refused 13 times with "out of VRAM", 77 % of seconds with a frame over 150 ms.
  • After (7.1 min): textures 461 MB under their line, card 8.8 of 10.6 GB, 3.5 GB RAM free on average in the world (3.1 minimum), frame generation never refused, 19 % of seconds with a frame over 150 ms.
  • Flicker (commit 3): freed textures back within 10 s went from 5,675 of 101,348 (5.6 %) to 30 of 16,933 (0.2 %). With a 10 s grace it was 2.3 %; in all 64 logged cases a holder had been seen 10.1–27 s before the free, which is why the grace is set by VICTORY_SWEEP_HELD_GRACE_S (60 s used here).
  • The "after" build also had PR 3 (texture queue lock, retired objects) applied; the numbers above are ones that PR does not affect. fps went from 18.3 to 22.1 mean, but that is not this PR's alone.
  • Played on the v2026.11.29.01 base. On current main the branch builds and the victory-gpu lib suite passes (apart from every_switch_of_the_translator_is_in_the_key, which fails the same way on main without this PR).
  • cargo test passed for the crates it touches: yes. New unit tests for the back-off, capping and grace rules.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1772.

More charts

Free RAM while playing:
free RAM

Textures in use minus their line (above 0, new textures wait):
textures vs line

All three PRs at a glance:
scorecard

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5556438101 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3475). Originally posted by [nyxctura](https://github.com/nyxctura) on 2026-11-29T23:44:14Z. --- Related: #1772, #3206. ## What it changes With the card over its texture budget and the PC short of RAM at the same time (normal on a 12 GB card with 32 GB of RAM), the sweep found ~7.5 GB of textures idle for 30 s and more and freed ~90 MB every 5 s. The texture queue said "no room, new textures wait" in 95 % of its reports: late and blurry textures, frame generation failing with "out of VRAM", and Windows paging. Three commits: 1. **The card's rule is capped and backs off** (`resource.rs`, `host.rs`, `VICTORY_SWEEP_CAPPED`). It frees no more than idle textures can give, pauses when too many of the textures it freed come back within 10 s (`VICTORY_SWEEP_CAPPED_BACK_PERCENT`), and slows down only when nothing is left to free. This ends the free-and-reload loop (#1772). 2. **The card's rule takes mapped idle copies under the PC's pressure too** (`VICTORY_SWEEP_CARD_MAPPED`). A second "wholly unmapped" gate in the free loop, left over after 3246d252 changed the first one, skipped nearly every candidate whenever RAM was short. Also: copies the streamed-out pass freed no longer count as idle (`VICTORY_SWEEP_STALE`), and a 5-s "why kept" line says what holds the rest (`VICTORY_SWEEP_WHY`). 3. **Textures shown through slots are kept** (`resource.rs`, `descriptor/host.rs`, `VICTORY_SWEEP_HELD_GRACE_S`). A texture picked by index never asks for its host copy again, so its `used` stamp goes stale while it is on screen. When the title moves its view to another slot, the old slot lets go before the new one is made, and a look in between freed it: the texture flickered (a character's arm, every few seconds). Copies held by a slot or list within the grace time stay, ones that came back are protected longer (`VICTORY_SWEEP_BACK_PROTECT_S`), and the back-off also counts bytes. `VICTORY_SWEEP_BACK_WHO` logs which code asked for a copy again. Every change has its switch; `=0` restores the old behaviour. ## Screenshots **fps in the world, before vs with this PR:** ![image 6](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/6-pr2-fps-chart.png) **With this PR:** card under its budget, RAM free, frame generation running: ![image 5](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/5-pr2-after-in-world.jpg) ## How it was tested - **PC:** RTX 5070 12 GB, Ryzen 7 7800X3D, 32 GB RAM, Windows 11 25H2. - **Profile:** Series S, 1080p → 1440p, DLSS Ultra Performance, frame generation 2x, 60 fps cap, ray tracing off. - **Before (16.7 min in the world):** "no room" in 95 % of reports, textures 1,148 MB over their line on average, 1.5 GB RAM free on average in the world (0.7 minimum), frame generation refused 13 times with "out of VRAM", 77 % of seconds with a frame over 150 ms. - **After (7.1 min):** textures 461 MB under their line, card 8.8 of 10.6 GB, 3.5 GB RAM free on average in the world (3.1 minimum), frame generation never refused, 19 % of seconds with a frame over 150 ms. - **Flicker (commit 3):** freed textures back within 10 s went from 5,675 of 101,348 (5.6 %) to 30 of 16,933 (0.2 %). With a 10 s grace it was 2.3 %; in all 64 logged cases a holder had been seen 10.1–27 s before the free, which is why the grace is set by `VICTORY_SWEEP_HELD_GRACE_S` (60 s used here). - The "after" build also had PR 3 (texture queue lock, retired objects) applied; the numbers above are ones that PR does not affect. fps went from 18.3 to 22.1 mean, but that is not this PR's alone. - Played on the v2026.11.29.01 base. On current `main` the branch builds and the `victory-gpu` lib suite passes (apart from `every_switch_of_the_translator_is_in_the_key`, which fails the same way on `main` without this PR). - `cargo test` passed for the crates it touches: yes. New unit tests for the back-off, capping and grace rules. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1772. ## More charts **Free RAM while playing:** ![free RAM](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/9-pr2-free-ram.png) **Textures in use minus their line (above 0, new textures wait):** ![textures vs line](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/10-pr2-textures-vs-line.png) **All three PRs at a glance:** ![scorecard](https://raw.githubusercontent.com/nyxctura/VIctory-NVIDIA/pr-images/11-scorecard.png) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
advxrsary commented 2026-11-30 20:03:27 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by advxrsary on 2026-11-30T20:03:27Z.


@nyxctura I think I see the flicker that your third commit describes, on current main. Could you rebase this pull request on main?

What I see. Objects are drawn white for exactly one frame: plants, a palm trunk, a whole flowering tree, bushes. The frame before and the frame after are correct. In play it looks like the object flickers or disappears.

How I found it. I used a diagnostics build with VICTORY_CAPTURE_WORLD_SECONDS=20,200,1, so every presented frame was saved. Then I compared each frame with its neighbours. A blink is a block that is the same in frames k-1 and k+1, but different in frame k. Most of the strongest blinks in about 500 frames were this white object.

What I ruled out.

Check Result
Dropped draws (diagnostics drop reasons) Only the structure builder stages and two programs left out on purpose. No geometry.
Slot eviction (VICTORY_SLOT_EVICT line) 0 textures, 0 slots put back to waiting
More view slots for the title (VICTORY_DYNAMIC_SLOTS=262144, 737,855 title slots instead of 606,783) The white frames stay
First bind of a new pipeline near the blink Not for every blink

This matches what your commit 3 says: a view moves to another slot, the old slot lets go of it, and a sweep finds the copy idle before the new slot is made.

Why I cannot test it now. I tried to merge it on main 84bd61e2. There are 9 conflicts in resource.rs, descriptor.rs and descriptor/host.rs, because main has rewritten the sweep since then. I did not want to resolve the sweep logic by guessing.

Setup: RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11. Series X, 2560x1440 output, DLSS performance, frame generation x3, ray tracing off. Main 84bd61e2 with #3918 and my light commits (#4347). None of them touch the sweep.

When it is rebased, I will run the same capture and post the blink counts before and after.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7290338715 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3475#issuecomment-7290338715). Originally posted by [advxrsary](https://github.com/advxrsary) on 2026-11-30T20:03:27Z. --- @nyxctura I think I see the flicker that your third commit describes, on current main. Could you rebase this pull request on main? **What I see.** Objects are drawn white for exactly one frame: plants, a palm trunk, a whole flowering tree, bushes. The frame before and the frame after are correct. In play it looks like the object flickers or disappears. **How I found it.** I used a diagnostics build with `VICTORY_CAPTURE_WORLD_SECONDS=20,200,1`, so every presented frame was saved. Then I compared each frame with its neighbours. A blink is a block that is the same in frames k-1 and k+1, but different in frame k. Most of the strongest blinks in about 500 frames were this white object. **What I ruled out.** | Check | Result | |---|---| | Dropped draws (diagnostics drop reasons) | Only the structure builder stages and two programs left out on purpose. No geometry. | | Slot eviction (`VICTORY_SLOT_EVICT` line) | 0 textures, 0 slots put back to waiting | | More view slots for the title (`VICTORY_DYNAMIC_SLOTS=262144`, 737,855 title slots instead of 606,783) | The white frames stay | | First bind of a new pipeline near the blink | Not for every blink | This matches what your commit 3 says: a view moves to another slot, the old slot lets go of it, and a sweep finds the copy idle before the new slot is made. **Why I cannot test it now.** I tried to merge it on main 84bd61e2. There are 9 conflicts in `resource.rs`, `descriptor.rs` and `descriptor/host.rs`, because main has rewritten the sweep since then. I did not want to resolve the sweep logic by guessing. **Setup:** RTX 5080 16 GB, driver 621.24, Ryzen 7 9800X3D, Windows 11. Series X, 2560x1440 output, DLSS performance, frame generation x3, ray tracing off. Main 84bd61e2 with #3918 and my light commits (#4347). None of them touch the sweep. When it is rebased, I will run the same capture and post the blink counts before and after.
trustno1-coder commented 2026-12-01 18:51:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:51:56Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321700520 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3475#issuecomment-7321700520). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:51:56Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!3475
No description provided.