victory-gpu: VICTORY_RESERVE_RELEASE gives the render targets' room back once the world settles, keeping 512 MiB over them #481

Open
github-bot wants to merge 5 commits from github-bot/gh-481 into main AGit
Owner

@⁠skalel on GitHub · 2026-12-04 16:59 UTC · original
skalel:feat/reserve-release → main · +677 −8 · 9 files · 5 commits · open

Builds on #216 (the vram line), whose commit is the first one here; review the last four.

targets_room_kept keeps up to 3 GiB of the card for render targets until they hold half of it, 1.5 GiB, and have stopped growing for 20 s. Series S's (about 1.2 to 1.45 GB, 720p inside 1080p) never get there, so the room stays kept for the whole run: the texture side counts it as used and sits in the band that lets copies idle for 2 s go, with gigabytes of the card free. Series X's at 1080p sit just under it too (1.45 to 1.53 GB, @⁠Widget9337 on #216).

With VICTORY_RESERVE_RELEASE=1 the room is given back once the targets have grown by no 64 MiB for 20 s and either hold half of it (as before) or the world (2,000 draws a frame or more) has been drawn for 20 s. From then on, until the world is left (5 s under 2,000 draws a frame: a load to a menu or another world, whose targets are made against the full room again), what stays kept is a headroom of 512 MiB over what the targets hold, as they grow, within the 3 GiB less their bytes kept before; where the rule without the switch gives everything back (half held, settled) it keeps nothing either: Series S's targets grew 190 MB in the two minutes after the give-back, Series X's at 4K grow from 2.3 GB at the first world frame to 2.8 to 3.1 GB. Off by default; in docs/SETTINGS.md and run.conf.default, so the F1 menu lists it.

Checked

RX 6750 XT 12 GB, Ryzen 7 5700X, 31 GB, CachyOS, ray tracing off, the same save and route, about five minutes in the world each, no frame cap. Per vram line (5 s) unless said.

Series S, 1080p, FSR 4 on the host

off on
room kept for targets (median) 1,820 MB 512 MB (given back at 20 s of world)
texture copies on the card (median) 4.0 GB 5.2 GB
copies let go 3,491 3,149
copies made again within 5 s 126 63
slots waiting for a let-go copy 424 134
fps in the world (median) 19.3 18.4

Series X, 1080p, FSR 4 quality, off and on twice, in that order:

off on off on
room kept for targets (median) 1,644 MB 512 MB 1,674 MB 512 MB
texture copies on the card (median) 3.7 GB 4.7 GB 3.6 GB 4.7 GB
copies made again within 5 s 160 125 92 86
slots waiting for a let-go copy 472 331 336 240
refused passes, whole round 614 170 244 236
fps in the world (median) 16.9 15.3 16.9 15.9
fps over 8,500 draws 16.1 14.3 15.1 13.6

On Series S it takes most of the waiting slots away (-68 %). Its fps is 0.9 lower in one round each, within what rounds of the same route varied by here (an earlier round giving everything back, no headroom: 19.8); I did not repeat it as I did on Series X. On Series X it trades about 30 % fewer waiting slots for 1 to 1.5 fps less (6 to 9 %), in both pairs. None of the phases the frame line measures grew (preparation 9.1 and 9.3 ms, GPU wait 15.6 and 13.6 ms); the time is outside them, along with about 1 GB more texture copies on the card. I can't say where yet, so it stays a switch, and on Series X a choice.

By eye, black objects for a moment were there in every round, on and off: fewer waiting slots is fewer of them, not none, and the one-frame flashes of #69 are another thing.

Tests under Wine: when the room is given back (before the world, Series S's targets once the world settles, half the reserve as before, a world is thousands of draws), the headroom after it, nothing kept where off keeps nothing, and leaving the world.

Leaving the world, Series S, loading an older save mid-session: given back 22 s into the world (kept 1,933 → 512 MB), kept again 5 s into the load (1,743 MB), the second world's targets grew 1,328 → 1,468 MB with it in place, given back again 37 s in.

Not tested

  • Other cards (8 GB #76, 16 GB), Series X at 4K, ray tracing on.

🤖 Generated with Claude Code

**@⁠skalel** on GitHub · 2026-12-04 16:59 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481) `skalel:feat/reserve-release` → `main` · +677 −8 · 9 files · 5 commits · open Builds on #216 (the `vram` line), whose commit is the first one here; review the last four. `targets_room_kept` keeps up to 3 GiB of the card for render targets until they hold half of it, 1.5 GiB, and have stopped growing for 20 s. Series S's (about 1.2 to 1.45 GB, 720p inside 1080p) never get there, so the room stays kept for the whole run: the texture side counts it as used and sits in the band that lets copies idle for 2 s go, with gigabytes of the card free. Series X's at 1080p sit just under it too (1.45 to 1.53 GB, @⁠Widget9337 on #216). With `VICTORY_RESERVE_RELEASE=1` the room is given back once the targets have grown by no 64 MiB for 20 s and either hold half of it (as before) or the world (2,000 draws a frame or more) has been drawn for 20 s. From then on, until the world is left (5 s under 2,000 draws a frame: a load to a menu or another world, whose targets are made against the full room again), what stays kept is a headroom of 512 MiB over what the targets hold, as they grow, within the 3 GiB less their bytes kept before; where the rule without the switch gives everything back (half held, settled) it keeps nothing either: Series S's targets grew 190 MB in the two minutes after the give-back, Series X's at 4K grow from 2.3 GB at the first world frame to 2.8 to 3.1 GB. Off by default; in `docs/SETTINGS.md` and `run.conf.default`, so the F1 menu lists it. ## Checked RX 6750 XT 12 GB, Ryzen 7 5700X, 31 GB, CachyOS, ray tracing off, the same save and route, about five minutes in the world each, no frame cap. Per `vram` line (5 s) unless said. **Series S, 1080p, FSR 4 on the host** | | off | on | |---|---|---| | room kept for targets (median) | 1,820 MB | 512 MB (given back at 20 s of world) | | texture copies on the card (median) | 4.0 GB | 5.2 GB | | copies let go | 3,491 | 3,149 | | copies made again within 5 s | 126 | 63 | | slots waiting for a let-go copy | 424 | 134 | | fps in the world (median) | 19.3 | 18.4 | **Series X, 1080p, FSR 4 quality**, off and on twice, in that order: | | off | on | off | on | |---|---|---|---|---| | room kept for targets (median) | 1,644 MB | 512 MB | 1,674 MB | 512 MB | | texture copies on the card (median) | 3.7 GB | 4.7 GB | 3.6 GB | 4.7 GB | | copies made again within 5 s | 160 | 125 | 92 | 86 | | slots waiting for a let-go copy | 472 | 331 | 336 | 240 | | refused passes, whole round | 614 | 170 | 244 | 236 | | fps in the world (median) | 16.9 | 15.3 | 16.9 | 15.9 | | fps over 8,500 draws | 16.1 | 14.3 | 15.1 | 13.6 | On Series S it takes most of the waiting slots away (-68 %). Its fps is 0.9 lower in one round each, within what rounds of the same route varied by here (an earlier round giving everything back, no headroom: 19.8); I did not repeat it as I did on Series X. **On Series X it trades about 30 % fewer waiting slots for 1 to 1.5 fps less (6 to 9 %), in both pairs.** None of the phases the frame line measures grew (preparation 9.1 and 9.3 ms, GPU wait 15.6 and 13.6 ms); the time is outside them, along with about 1 GB more texture copies on the card. I can't say where yet, so it stays a switch, and on Series X a choice. By eye, black objects for a moment were there in every round, on and off: fewer waiting slots is fewer of them, not none, and the one-frame flashes of #69 are another thing. Tests under Wine: when the room is given back (before the world, Series S's targets once the world settles, half the reserve as before, a world is thousands of draws), the headroom after it, nothing kept where off keeps nothing, and leaving the world. Leaving the world, Series S, loading an older save mid-session: given back 22 s into the world (kept 1,933 → 512 MB), kept again 5 s into the load (1,743 MB), the second world's targets grew 1,328 → 1,468 MB with it in place, given back again 37 s in. ## Not tested - Other cards (8 GB #76, 16 GB), Series X at 4K, ray tracing on. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A `stats: vram` line after the frame line, every 5 s. It changes nothing
the run does; it is what a change to how textures and title memory share
the card can be measured by.

- How the card is shared: budget, use, the card's free memory, what the
  texture side compares with its keep line and the band it falls in
  (`host::keep_band`, which `vram_keep` now goes by), the room kept for
  render targets, title memory on the card (movable and fixed) and its
  room, host copies of textures and those idle, render targets, free room
  in texture blocks.
- What letting copies go costs, since the last line: copies let go and
  their MB, copies made again within 5 s of their let-go, slots the
  texture pass found waiting for a copy that was let go, textures let go
  at least once, streamed out, refused passes.

The band is no longer worked out from vram_keep's idle times: keep_band
holds the percentages, and vram_keep and the line both go by it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`targets_room_kept` keeps up to 3 GiB of the card for render targets until
they hold half of it, 1.5 GiB. Series S's (about 1,450 MB, 720p inside
1080p) never do, so the room stayed kept for the whole run: the texture
side counted it as used and sat in the band that lets copies idle for 2 s
go, with gigabytes of the card free (RX 6750 XT, play-20261202-112605:
90 % of the budget by its count, 2.8 GB free, 117,000 copies let go in
160 s). On Series X a 16 GB card's targets sat at 1.45 to 1.53 GB for the
first minutes, just under it.

With VICTORY_RESERVE_RELEASE=1 the room is given back, once and for good,
when the targets have grown by no 64 MiB for 20 s and either hold half of
it (as before) or the world has been drawn (2,000 draws a frame or more)
for 20 s. Off by default; listed in docs/SETTINGS.md and run.conf.default.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Given back for good, the room kept for render targets went to nothing,
and targets that grew after it grew into what textures had taken: Series
S's by 190 MB in the two minutes after it (1,233 to 1,426 MB,
play-20261204-130712), Series X's at 4K by 0.5 to 0.8 GB in their first
minutes. Now what stays kept after the give-back is 512 MiB over what the
targets hold, as they grow, within the 3 GiB less their bytes that was
kept before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 17:05:00 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-12-04 17:00 UTC · original · edited 2026-12-04 17:03 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T17:03:13.449699Z fe3f86c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-12-04 17:00 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7418277193) · edited 2026-12-04 17:03 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"fe3f86cd01fd295f0871054a0ed4dad12eea8066","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-12-04T17:03:13.449699Z">2026-12-04T17:03:13.449699Z</relative-time> | `fe3f86c` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 17:15 UTC · original · edited 2026-12-04 17:21 UTC

The body does say it builds on #216 and asks for the last two commits, so the base is declared — that is my miss, I read the diff and not the body. Nothing wrong with building on #216.

For the queue only: with the base at main, the PR page shows 283 of the 369 added lines as new here, so someone starting from that page reads #216's vram line a second time. If it is cheap, pointing the base at #216 while both are open makes the review exactly the two commits you named; if #216 lands first, a rebase gets the same result. Either way is fine — just noting what the diff looks like from outside.

**@⁠Luxuride** on GitHub · 2026-12-04 17:15 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7418662414) · edited 2026-12-04 17:21 UTC The body does say it builds on #216 and asks for the last two commits, so the base is declared — that is my miss, I read the diff and not the body. Nothing wrong with building on #216. For the queue only: with the base at `main`, the PR page shows 283 of the 369 added lines as new here, so someone starting from that page reads #216's `vram` line a second time. If it is cheap, pointing the base at #216 while both are open makes the review exactly the two commits you named; if #216 lands first, a rebase gets the same result. Either way is fine — just noting what the diff looks like from outside.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 17:18 UTC · original

I checked the last two commits at fe3f86c on native Windows, using one NVIDIA desktop card plus WARP. I didn't run the game. This is from reading the code, running the unit tests and replaying the decision in a local test.

With the switch off, targets_room_kept behaves exactly like main. The new block is gated on crate::vram::releasing() (resource.rs:1855), which reads the env var once through a OnceLock (vram.rs:148), so each call only pays for that lookup. The other new call is crate::vram::drew(draws) in the meter (host.rs:7881). It runs once a second rather than every frame, and with the switch off all it does is set WORLD_MS once, which nothing else reads.

The arithmetic can't underflow. kept_after is HEADROOM.min(most.saturating_sub(targets)) (vram.rs:142), and before the give-back it's most.saturating_sub(targets) (resource.rs:1879), so targets over 3 GiB give 0. After GIVEN is set (resource.rs:1860) the kept room depends only on the current target bytes, with no timer, so it can't flap. It stays at 512 MiB while targets are under 2.5 GiB and then shrinks to whatever is left of 3 GiB. Both timers use host::now_ms (host.rs:108). That's elapsed time from clock::Instant, the invariant TSC scaled to nanoseconds or std::time::Instant without one (clock.rs:61-70), so it's wall time and not a frame count. The world start is the first one-second average of 2,000 draws or more (vram.rs:110-112). The shared state is the two Relaxed atomics main already has for GREW plus a Relaxed bool. If two threads race at the moment of the give-back, each might return a different value once, which is harmless.

I replayed the same state machine in a local test, with 1 s steps, a 3 GiB reserve and main's rule next to the PR's.

case main kept PR kept
Series S, 652 MB before the world, 1,233 MB at the world creeping to 1,426 MB 1,839 to 1,646 MB the whole run given back 20 s into the world, then 512 MB flat
Series X 4K, 2.3 GB climbing 100 MB every 15 s to 3.1 GB 772 down to 0 identical, no give-back until growth stops
Series X 4K, settles at 2.3 GB 0 after 20 s 512 MB
targets at 1,600 MB, settled 0 after 20 s 512 MB
Series S settled, jumps to 2.6 GB, back to 1.4 GB, up again 472, then 0 after 20 s, 1,646 at 1.4 GB, 472 then 0 again 472, 512, 472, no 20 s windows
Series S settled, back to a menu (652 MB, few draws), then a second world at 2.3 GB 2,420 in the menu, 772 at the new world, 0 after 20 s 512 in the menu and at the new world
targets 2.9 GB, then 3.6 GB 172, then 0 after 20 s 172, then 0
1.4 GB settled, never 2,000 draws 1,672 1,672, kept

Two things to raise.

First, the give-back is for the rest of the session. GIVEN is only ever set, never cleared (resource.rs:1859-1870) and WORLD_MS is never reset. After a return to the menu, the room for the next world's targets is 512 MiB where main keeps about 2.4 GB, so a second load or a jump to 4K makes 1.5 GB or more of targets against a texture side that wasn't held back. That's the case the doc on targets_room_kept says the reserve is there for, since targets are made with no room test. On the other hand, nothing repeats. There's no 20 s window that brings the full room back and lets copies go again. I can't tell how bad that first load is without a game run, so it's a question rather than a finding. Would re-arming on a drop below 2,000 draws, or on targets shrinking by a lot, be worth it?

Second, the body says the 512 MiB stays after the give-back, and the comment at resource.rs:1856-1858 explains why. What it doesn't spell out is how that compares with main once targets are already at half the reserve and settled. There, main keeps 0 and the switch keeps 512 MiB (or what's left under 3 GiB). So at Series X 4K, or with 1.5 GiB of targets or more, turning it on leaves textures a little less room than off once things settle. That's probably fine, but it may be worth a line in SETTINGS.md.

On native Windows the budget and use come from video_memory (host.rs:9383-9394), which queries the LOCAL segment on every call, with the VICTORY_VRAM_BUDGET_MB override, so a budget that moves is followed. On the NVIDIA card that budget is below the adapter's dedicated memory, and it didn't move during a short idle probe with a device open. WARP reports no dedicated memory and a budget taken from system memory. The release rule itself never reads the budget. It looks only at target bytes, time and draws (vram.rs:129, resource.rs:1855-1879), and the budget only comes in where kept is compared (resource.rs:1808, pool.rs:67-68, resource.rs:2519). So the new code assumes nothing RADV-specific. The 3 GiB and 512 MiB are fixed sizes whatever the budget is, as main already does for the 3 GiB.

I ran cargo test -p victory-gpu --lib -- --test-threads=2 --skip descriptor::tests::views_die_with_their_resource at fe3f86c. 352 passed, 5 failed and 23 were ignored. The failures are the two indirect::tests::host_list_*, the two pipeline library loads and one watch test, all known on main. All 10 vram tests pass. resource::tests::buffer_data_reaches_the_host_texture failed once with 2 threads and passed on its own.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 17:18 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7418738299) I checked the last two commits at fe3f86c on native Windows, using one NVIDIA desktop card plus WARP. I didn't run the game. This is from reading the code, running the unit tests and replaying the decision in a local test. With the switch off, `targets_room_kept` behaves exactly like main. The new block is gated on `crate::vram::releasing()` (resource.rs:1855), which reads the env var once through a OnceLock (vram.rs:148), so each call only pays for that lookup. The other new call is `crate::vram::drew(draws)` in the meter (host.rs:7881). It runs once a second rather than every frame, and with the switch off all it does is set `WORLD_MS` once, which nothing else reads. The arithmetic can't underflow. `kept_after` is `HEADROOM.min(most.saturating_sub(targets))` (vram.rs:142), and before the give-back it's `most.saturating_sub(targets)` (resource.rs:1879), so targets over 3 GiB give 0. After `GIVEN` is set (resource.rs:1860) the kept room depends only on the current target bytes, with no timer, so it can't flap. It stays at 512 MiB while targets are under 2.5 GiB and then shrinks to whatever is left of 3 GiB. Both timers use `host::now_ms` (host.rs:108). That's elapsed time from `clock::Instant`, the invariant TSC scaled to nanoseconds or `std::time::Instant` without one (clock.rs:61-70), so it's wall time and not a frame count. The world start is the first one-second average of 2,000 draws or more (vram.rs:110-112). The shared state is the two Relaxed atomics main already has for GREW plus a Relaxed bool. If two threads race at the moment of the give-back, each might return a different value once, which is harmless. I replayed the same state machine in a local test, with 1 s steps, a 3 GiB reserve and main's rule next to the PR's. | case | main kept | PR kept | |---|---|---| | Series S, 652 MB before the world, 1,233 MB at the world creeping to 1,426 MB | 1,839 to 1,646 MB the whole run | given back 20 s into the world, then 512 MB flat | | Series X 4K, 2.3 GB climbing 100 MB every 15 s to 3.1 GB | 772 down to 0 | identical, no give-back until growth stops | | Series X 4K, settles at 2.3 GB | 0 after 20 s | 512 MB | | targets at 1,600 MB, settled | 0 after 20 s | 512 MB | | Series S settled, jumps to 2.6 GB, back to 1.4 GB, up again | 472, then 0 after 20 s, 1,646 at 1.4 GB, 472 then 0 again | 472, 512, 472, no 20 s windows | | Series S settled, back to a menu (652 MB, few draws), then a second world at 2.3 GB | 2,420 in the menu, 772 at the new world, 0 after 20 s | 512 in the menu and at the new world | | targets 2.9 GB, then 3.6 GB | 172, then 0 after 20 s | 172, then 0 | | 1.4 GB settled, never 2,000 draws | 1,672 | 1,672, kept | Two things to raise. First, the give-back is for the rest of the session. `GIVEN` is only ever set, never cleared (resource.rs:1859-1870) and `WORLD_MS` is never reset. After a return to the menu, the room for the next world's targets is 512 MiB where main keeps about 2.4 GB, so a second load or a jump to 4K makes 1.5 GB or more of targets against a texture side that wasn't held back. That's the case the doc on `targets_room_kept` says the reserve is there for, since targets are made with no room test. On the other hand, nothing repeats. There's no 20 s window that brings the full room back and lets copies go again. I can't tell how bad that first load is without a game run, so it's a question rather than a finding. Would re-arming on a drop below 2,000 draws, or on targets shrinking by a lot, be worth it? Second, the body says the 512 MiB stays after the give-back, and the comment at resource.rs:1856-1858 explains why. What it doesn't spell out is how that compares with main once targets are already at half the reserve and settled. There, main keeps 0 and the switch keeps 512 MiB (or what's left under 3 GiB). So at Series X 4K, or with 1.5 GiB of targets or more, turning it on leaves textures a little less room than off once things settle. That's probably fine, but it may be worth a line in SETTINGS.md. On native Windows the budget and use come from `video_memory` (host.rs:9383-9394), which queries the LOCAL segment on every call, with the `VICTORY_VRAM_BUDGET_MB` override, so a budget that moves is followed. On the NVIDIA card that budget is below the adapter's dedicated memory, and it didn't move during a short idle probe with a device open. WARP reports no dedicated memory and a budget taken from system memory. The release rule itself never reads the budget. It looks only at target bytes, time and draws (vram.rs:129, resource.rs:1855-1879), and the budget only comes in where kept is compared (resource.rs:1808, pool.rs:67-68, resource.rs:2519). So the new code assumes nothing RADV-specific. The 3 GiB and 512 MiB are fixed sizes whatever the budget is, as main already does for the 3 GiB. I ran `cargo test -p victory-gpu --lib -- --test-threads=2 --skip descriptor::tests::views_die_with_their_resource` at fe3f86c. 352 passed, 5 failed and 23 were ignored. The failures are the two `indirect::tests::host_list_*`, the two pipeline library loads and one watch test, all known on main. All 10 vram tests pass. `resource::tests::buffer_data_reaches_the_host_texture` failed once with 2 threads and passed on its own. AI-assisted: yes
github-bot force-pushed github-bot/gh-481 from fe3f86cd01 to da5414d4e9 2026-12-04 18:42:26 +00:00 Compare
Author
Owner

@⁠skalel on GitHub · 2026-12-04 18:39 UTC · original

@⁠Luxuride thanks. The base can't point at #216: its branch is on my fork, and a PR here can only be based on a branch of this repository. I'll rebase this one as soon as #216 lands, which leaves exactly the commits named in the body (three now). Both are rebased on current main.

**@⁠skalel** on GitHub · 2026-12-04 18:39 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7420746315) @⁠Luxuride thanks. The base can't point at #216: its branch is on my fork, and a PR here can only be based on a branch of this repository. I'll rebase this one as soon as #216 lands, which leaves exactly the commits named in the body (three now). Both are rebased on current `main`.
Author
Owner

@⁠skalel on GitHub · 2026-12-04 18:39 UTC · original

@⁠Kal0s-design thank you, the replay table made both cases easy to see. Both fixed in da5414d:

  • The give-back held for the rest of the session. Five seconds under 2,000 draws a frame now leave the world (vram::in_world): the room is kept again, and the next world counts its own 20 s. So a load back to a menu, then a second world, makes its targets against the full room, as off. A pause screen long enough to drop under 2,000 draws also takes it back; it is given back 20 s after the world is drawn again, once, not in a loop.
  • On kept 512 MiB where off keeps 0. Where off gives the room back (targets at half of it or more, settled), on now keeps nothing too, and the headroom applies only below that (vram::released). docs/SETTINGS.md and run.conf.default say both.

Tests: where_the_room_came_back_before_nothing_is_kept (your rows: 1,600 MB settled, Series X 4K settled at 2.3 GB, growing again, Series S settled, not yet) and leaving_the_world_takes_the_room_back / a_few_light_seconds_are_no_leaving.

Checked here (RX 6750 XT 12 GB, Series S, 1080p), loading an older save mid-session as the second world: given back 22 s into the world (kept 1,933 → 512 MB); the load dropped under 2,000 draws, and 5 s later the room was kept again (1,743 MB); the second world's targets grew from 1,328 to 1,468 MB with it in place, and it was given back again 37 s into that world (512 MB). Branches rebased on current main.

**@⁠skalel** on GitHub · 2026-12-04 18:39 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7420747035) @⁠Kal0s-design thank you, the replay table made both cases easy to see. Both fixed in da5414d: - **The give-back held for the rest of the session.** Five seconds under 2,000 draws a frame now leave the world (`vram::in_world`): the room is kept again, and the next world counts its own 20 s. So a load back to a menu, then a second world, makes its targets against the full room, as off. A pause screen long enough to drop under 2,000 draws also takes it back; it is given back 20 s after the world is drawn again, once, not in a loop. - **On kept 512 MiB where off keeps 0.** Where off gives the room back (targets at half of it or more, settled), on now keeps nothing too, and the headroom applies only below that (`vram::released`). `docs/SETTINGS.md` and `run.conf.default` say both. Tests: `where_the_room_came_back_before_nothing_is_kept` (your rows: 1,600 MB settled, Series X 4K settled at 2.3 GB, growing again, Series S settled, not yet) and `leaving_the_world_takes_the_room_back` / `a_few_light_seconds_are_no_leaving`. Checked here (RX 6750 XT 12 GB, Series S, 1080p), loading an older save mid-session as the second world: given back 22 s into the world (kept 1,933 → 512 MB); the load dropped under 2,000 draws, and 5 s later the room was kept again (1,743 MB); the second world's targets grew from 1,328 to 1,468 MB with it in place, and it was given back again 37 s into that world (512 MB). Branches rebased on current `main`.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 18:47 UTC · original

Re-checked da5414d on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).

cargo test -p victory-gpu --lib gives 364 passed and 5 failed. The 5 are ones I see failing natively without this PR too (the two indirect::tests::host_list_*, the two pipeline::host library tests, and a watch test that's flaky here). All 13 vram:: tests pass, the three new ones included.

The fix works for the case I reported. drew clears GIVEN once in_world says the world was left (vram.rs:147), and released returns 0 wherever off does (vram.rs:194, same condition as resource.rs:1877). On never keeps more than off, and the boundary is exact: at exactly half and not settled it keeps 1.5 GiB like off, at half and settled 0. No underflow, everything goes through saturating_sub. With the env var unset, targets_room_kept takes the same path as main. drew still runs every second, but WORLD_MS/OUT_MS are only read by the release branch.

I replayed some sequences through in_world + released with the same GREW logic as targets_room_kept, in a throwaway test I didn't commit. With targets around 1.3 GB it gives back after 20 s of world, takes it back at the 6th light second and the second world counts its own 20 s. Draws going 1,990 / 2,010 every second never leave, 4 light seconds don't leave, and 25 s over / 6 s under on repeat gives one take-back and one give-back per cycle, so no fast flapping.

One case still gets the old behaviour, though. If the targets are still at half or more when the world is left (a 4K world, back to the menu, targets not freed yet at that moment), the first branch of released returns (0, true) on the next call and resource.rs:1868 sets GIVEN again right after drew cleared it. If the targets then drop in the menu and the next world makes its own, they're made against 512 MiB again. In my replay (2.3 GB world, leave, targets drop to 600 MB, second world builds 1.0 to 2.3 GB) on keeps 512 MiB throughout where off keeps 2,472 down to 772. With 1.6 GB targets staying across the menu and growing to 1.7 GB in the next world, it's 512 vs 1,372.

Latching GIVEN in that branch only once the world has been drawn for 20 s fixes it in the replay and keeps the headroom from e1f0e48 for a world that grows again after settling (2.0 to 2.1 GB still gets 512):

if quiet_ms >= SETTLE_MS && targets >= most / 2 {
    (0, given || world_for_ms >= SETTLE_MS)
}

Plain (0, given) would fix it too, but then a big-target world that grows again gets off's whole room instead of the headroom. Either way the first assert in where_the_room_came_back_before_nothing_is_kept would need (0, false).

Smaller things. GIVEN is loaded at resource.rs:1865 and swapped at :1868, and targets_room_kept is also reached through room/room_lately from the descriptor code, so a drew on the present thread clearing it in between gets overwritten by a stale given = true. The window is tiny, and writing only when it was loaded false (compare_exchange(false, true) when give && !given) would close it. resource.rs:1835 still has its own settle = 20000 next to SETTLE_MS (vram.rs:154), and "on keeps nothing where off keeps nothing" depends on them staying equal. And any 5 s in the world under 2,000 draws (pause or map screen, interiors, cutscenes, if any draw that little) now takes the whole room back for 20 s or more. Probably fine, but worth checking in a log.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 18:47 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7420933572) Re-checked da5414d on native Windows (one NVIDIA desktop card plus WARP, didn't run the game). `cargo test -p victory-gpu --lib` gives 364 passed and 5 failed. The 5 are ones I see failing natively without this PR too (the two `indirect::tests::host_list_*`, the two `pipeline::host` library tests, and a watch test that's flaky here). All 13 `vram::` tests pass, the three new ones included. The fix works for the case I reported. `drew` clears GIVEN once `in_world` says the world was left (vram.rs:147), and `released` returns 0 wherever off does (vram.rs:194, same condition as resource.rs:1877). On never keeps more than off, and the boundary is exact: at exactly half and not settled it keeps 1.5 GiB like off, at half and settled 0. No underflow, everything goes through saturating_sub. With the env var unset, `targets_room_kept` takes the same path as main. `drew` still runs every second, but WORLD_MS/OUT_MS are only read by the release branch. I replayed some sequences through `in_world` + `released` with the same GREW logic as `targets_room_kept`, in a throwaway test I didn't commit. With targets around 1.3 GB it gives back after 20 s of world, takes it back at the 6th light second and the second world counts its own 20 s. Draws going 1,990 / 2,010 every second never leave, 4 light seconds don't leave, and 25 s over / 6 s under on repeat gives one take-back and one give-back per cycle, so no fast flapping. One case still gets the old behaviour, though. If the targets are still at half or more when the world is left (a 4K world, back to the menu, targets not freed yet at that moment), the first branch of `released` returns `(0, true)` on the next call and resource.rs:1868 sets GIVEN again right after `drew` cleared it. If the targets then drop in the menu and the next world makes its own, they're made against 512 MiB again. In my replay (2.3 GB world, leave, targets drop to 600 MB, second world builds 1.0 to 2.3 GB) on keeps 512 MiB throughout where off keeps 2,472 down to 772. With 1.6 GB targets staying across the menu and growing to 1.7 GB in the next world, it's 512 vs 1,372. Latching GIVEN in that branch only once the world has been drawn for 20 s fixes it in the replay and keeps the headroom from e1f0e48 for a world that grows again after settling (2.0 to 2.1 GB still gets 512): ```rust if quiet_ms >= SETTLE_MS && targets >= most / 2 { (0, given || world_for_ms >= SETTLE_MS) } ``` Plain `(0, given)` would fix it too, but then a big-target world that grows again gets off's whole room instead of the headroom. Either way the first assert in `where_the_room_came_back_before_nothing_is_kept` would need `(0, false)`. Smaller things. GIVEN is loaded at resource.rs:1865 and swapped at :1868, and `targets_room_kept` is also reached through `room`/`room_lately` from the descriptor code, so a `drew` on the present thread clearing it in between gets overwritten by a stale `given = true`. The window is tiny, and writing only when it was loaded false (`compare_exchange(false, true)` when `give && !given`) would close it. resource.rs:1835 still has its own `settle = 20000` next to `SETTLE_MS` (vram.rs:154), and "on keeps nothing where off keeps nothing" depends on them staying equal. And any 5 s in the world under 2,000 draws (pause or map screen, interiors, cutscenes, if any draw that little) now takes the whole room back for 20 s or more. Probably fine, but worth checking in a log. AI-assisted: yes
Author
Owner

@⁠MikeSouza1 on GitHub · 2026-12-04 18:57 UTC · original

Tested pr-481 (VICTORY_RESERVE_RELEASE=1) in gameplay on the exact Series S case this targets: Linux (Fedora, Ryzen 5 5600G, 16 GB RAM, RX 6750 XT 12 GB RADV NAVI22), CONSOLE=series-s, VICTORY_OUTPUT=1920x1080, VICTORY_FSR_HOST=1, VICTORY_BVH_BUILDER=1 (tested alongside main 2382b4c with tight texture alignment #459 and #445).

Across three driving runs (Ammu-Nation ↔ Jason's house):

  • Triggered cleanly once targets stabilized below the old 1.5 GiB threshold:
    • the room kept for render targets is given back to textures targets_mb=1169 world_s=37 (run 1)
    • the room kept for render targets is given back to textures targets_mb=1106 world_s=23 (run 2)
  • kept_mb dropped from 3031 → 512, free_mb stayed at 2385–2675 MB throughout driving, max_band=1, and texture thrashing virtually disappeared (remade_soon=0..4, refused_passes=0; textures_let_go=0 in the third run).

Huge quality-of-life win for Series S on 12 GB GPUs!

**@⁠MikeSouza1** on GitHub · 2026-12-04 18:57 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7421171558) Tested `pr-481` (`VICTORY_RESERVE_RELEASE=1`) in gameplay on the exact Series S case this targets: Linux (Fedora, Ryzen 5 5600G, 16 GB RAM, RX 6750 XT 12 GB RADV NAVI22), `CONSOLE=series-s`, `VICTORY_OUTPUT=1920x1080`, `VICTORY_FSR_HOST=1`, `VICTORY_BVH_BUILDER=1` (tested alongside `main` `2382b4c` with tight texture alignment `#459` and `#445`). Across three driving runs (Ammu-Nation ↔ Jason's house): - Triggered cleanly once targets stabilized below the old 1.5 GiB threshold: - `the room kept for render targets is given back to textures targets_mb=1169 world_s=37` (run 1) - `the room kept for render targets is given back to textures targets_mb=1106 world_s=23` (run 2) - `kept_mb` dropped from `3031` → `512`, `free_mb` stayed at `2385–2675 MB` throughout driving, `max_band=1`, and texture thrashing virtually disappeared (`remade_soon=0..4`, `refused_passes=0`; `textures_let_go=0` in the third run). Huge quality-of-life win for Series S on 12 GB GPUs!
From review (Kal0s-design on #481): left with targets at half the room or
more (a 4K world, back to a menu before they are freed), the branch that
keeps nothing, as off, also marked the room given back right after `drew`
took it back, and the next world's targets came against 512 MiB. That
branch now marks it only once the world has been drawn for 20 s; a world
that grows again after its give-back still keeps the headroom.

GIVEN is now set only over what was read (compare_exchange), so a `drew`
on the presenting thread that took it back in between is not undone, and
`targets_room_kept`'s settle time is vram::SETTLE_MS, which `released`
goes by.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠skalel on GitHub · 2026-12-04 20:03 UTC · original

@⁠Kal0s-design thanks again, all three are fixed in a94bb2d:

  • Targets still at half or more when the world is left. That branch now marks the room given back only once the world has been drawn for 20 s, (0, given || world_for_ms >= SETTLE_MS) as you suggested, so a big-target world that grows again keeps the headroom. targets_held_past_the_world_do_not_give_the_next_room_back replays your case (2.3 GB left, 600 MB in the menu, the next world's targets against the whole room), and the first assert of where_the_room_came_back_before_nothing_is_kept is now (0, false) with a second at 20 s of world.
  • The load/swap window. GIVEN is set with compare_exchange(false, true) only when it was read false.
  • settle = 20000. targets_room_kept now uses vram::SETTLE_MS.

On the light seconds inside the world: in three of my rounds (~5 min each, Series S, driving and on foot), the only leave logged was a save load; the frame line dipped under 2,000 draws twice mid-play, but never for 5 s in a row, so the room was not taken back. A pause or map screen held longer than 5 s will take it back, and give it back 20 s after the world is drawn again.

@⁠MikeSouza1 thank you for the runs, good to see it on a second 12 GB card with the same profile.

**@⁠skalel** on GitHub · 2026-12-04 20:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7422761906) @⁠Kal0s-design thanks again, all three are fixed in a94bb2d: - **Targets still at half or more when the world is left.** That branch now marks the room given back only once the world has been drawn for 20 s, `(0, given || world_for_ms >= SETTLE_MS)` as you suggested, so a big-target world that grows again keeps the headroom. `targets_held_past_the_world_do_not_give_the_next_room_back` replays your case (2.3 GB left, 600 MB in the menu, the next world's targets against the whole room), and the first assert of `where_the_room_came_back_before_nothing_is_kept` is now `(0, false)` with a second at 20 s of world. - **The load/swap window.** `GIVEN` is set with `compare_exchange(false, true)` only when it was read false. - **`settle = 20000`.** `targets_room_kept` now uses `vram::SETTLE_MS`. On the light seconds inside the world: in three of my rounds (~5 min each, Series S, driving and on foot), the only leave logged was a save load; the frame line dipped under 2,000 draws twice mid-play, but never for 5 s in a row, so the room was not taken back. A pause or map screen held longer than 5 s will take it back, and give it back 20 s after the world is drawn again. @⁠MikeSouza1 thank you for the runs, good to see it on a second 12 GB card with the same profile.
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-04 20:17 UTC · original

Re-checked a94bb2d on native Windows (didn't run the game). All three points look fixed to me.

The first branch of released now returns (0, given || world_for_ms >= SETTLE_MS), so leaving a 4K world with its targets still held no longer marks the room given. GIVEN is only set through compare_exchange(false, true) when give && !given, so a drew that clears it in between stays cleared. And targets_room_kept uses vram::SETTLE_MS now instead of its own 20000.

The vram tests pass, including the new one. The full victory-gpu lib run only has the same native-only failures as before (the two indirect host_list tests and the two pipeline::host library loads).

I re-ran the earlier sequences as a throwaway test, comparing the kept room with the switch on and off. 2.3 GB world, then menu, targets drop to 600 MB, second world building 1.0 to 2.3 GB: on and off now match the whole way (2,072 then 772 MB while it builds, 0 once settled), so the 512 MiB problem is gone. 1.6 GB carried into the menu and growing to 1.7 GB: identical on and off. A 2.0 GB world growing to 2.1 GB after settling still keeps 512 with it on (972 off). Draws flipping between 1,990 and 2,010 count as the world and give back after about 20 s, and a 4 s light pause doesn't leave it, both as before.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-04 20:17 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/481#issuecomment-7423100429) Re-checked a94bb2d on native Windows (didn't run the game). All three points look fixed to me. The first branch of `released` now returns `(0, given || world_for_ms >= SETTLE_MS)`, so leaving a 4K world with its targets still held no longer marks the room given. GIVEN is only set through compare_exchange(false, true) when give && !given, so a `drew` that clears it in between stays cleared. And `targets_room_kept` uses vram::SETTLE_MS now instead of its own 20000. The vram tests pass, including the new one. The full victory-gpu lib run only has the same native-only failures as before (the two indirect host_list tests and the two pipeline::host library loads). I re-ran the earlier sequences as a throwaway test, comparing the kept room with the switch on and off. 2.3 GB world, then menu, targets drop to 600 MB, second world building 1.0 to 2.3 GB: on and off now match the whole way (2,072 then 772 MB while it builds, 0 once settled), so the 512 MiB problem is gone. 1.6 GB carried into the menu and growing to 1.7 GB: identical on and off. A 2.0 GB world growing to 2.1 GB after settling still keeps 512 with it on (972 off). Draws flipping between 1,990 and 2,010 count as the world and give back after about 20 s, and a 4 s light pause doesn't leave it, both as before. AI-assisted: yes
This pull request has changes conflicting with the target branch.
  • 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/481/head:github-bot/gh-481'
git switch 'github-bot/gh-481'

Merge

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