victory-gpu: VICTORY_RESERVE_RELEASE gives the render targets' room back once the world settles, keeping 512 MiB over them #481
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!481
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-481"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@skalel on GitHub · 2026-12-04 16:59 UTC · original
skalel:feat/reserve-release→main· +677 −8 · 9 files · 5 commits · openBuilds on #216 (the
vramline), whose commit is the first one here; review the last four.targets_room_keptkeeps 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=1the 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; indocs/SETTINGS.mdandrun.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
vramline (5 s) unless said.Series S, 1080p, FSR 4 on the host
Series X, 1080p, FSR 4 quality, off and on twice, in that order:
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
🤖 Generated with Claude Code
@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.
fe3f86cℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@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'svramline 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.@Kal0s-design on GitHub · 2026-12-04 17:18 UTC · original
I checked the last two commits at
fe3f86con 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_keptbehaves exactly like main. The new block is gated oncrate::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 iscrate::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 setWORLD_MSonce, which nothing else reads.The arithmetic can't underflow.
kept_afterisHEADROOM.min(most.saturating_sub(targets))(vram.rs:142), and before the give-back it'smost.saturating_sub(targets)(resource.rs:1879), so targets over 3 GiB give 0. AfterGIVENis 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 usehost::now_ms(host.rs:108). That's elapsed time fromclock::Instant, the invariant TSC scaled to nanoseconds orstd::time::Instantwithout 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.
Two things to raise.
First, the give-back is for the rest of the session.
GIVENis only ever set, never cleared (resource.rs:1859-1870) andWORLD_MSis 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 ontargets_room_keptsays 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 theVICTORY_VRAM_BUDGET_MBoverride, 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_resourceatfe3f86c. 352 passed, 5 failed and 23 were ignored. The failures are the twoindirect::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_texturefailed once with 2 threads and passed on its own.AI-assisted: yes
fe3f86cd01toda5414d4e9@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
@Kal0s-design thank you, the replay table made both cases easy to see. Both fixed in
da5414d: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.vram::released).docs/SETTINGS.mdandrun.conf.defaultsay 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) andleaving_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.@Kal0s-design on GitHub · 2026-12-04 18:47 UTC · original
Re-checked
da5414don native Windows (one NVIDIA desktop card plus WARP, didn't run the game).cargo test -p victory-gpu --libgives 364 passed and 5 failed. The 5 are ones I see failing natively without this PR too (the twoindirect::tests::host_list_*, the twopipeline::hostlibrary tests, and a watch test that's flaky here). All 13vram::tests pass, the three new ones included.The fix works for the case I reported.
drewclears GIVEN oncein_worldsays the world was left (vram.rs:147), andreleasedreturns 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_kepttakes the same path as main.drewstill runs every second, but WORLD_MS/OUT_MS are only read by the release branch.I replayed some sequences through
in_world+releasedwith the same GREW logic astargets_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
releasedreturns(0, true)on the next call and resource.rs:1868 sets GIVEN again right afterdrewcleared 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
e1f0e48for a world that grows again after settling (2.0 to 2.1 GB still gets 512):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 inwhere_the_room_came_back_before_nothing_is_keptwould need(0, false).Smaller things. GIVEN is loaded at resource.rs:1865 and swapped at :1868, and
targets_room_keptis also reached throughroom/room_latelyfrom the descriptor code, so adrewon the present thread clearing it in between gets overwritten by a stalegiven = true. The window is tiny, and writing only when it was loaded false (compare_exchange(false, true)whengive && !given) would close it. resource.rs:1835 still has its ownsettle = 20000next toSETTLE_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
@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 alongsidemain2382b4cwith tight texture alignment#459and#445).Across three driving runs (Ammu-Nation ↔ Jason's house):
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_mbdropped from3031→512,free_mbstayed at2385–2675 MBthroughout driving,max_band=1, and texture thrashing virtually disappeared (remade_soon=0..4,refused_passes=0;textures_let_go=0in the third run).Huge quality-of-life win for Series S on 12 GB GPUs!
@skalel on GitHub · 2026-12-04 20:03 UTC · original
@Kal0s-design thanks again, all three are fixed in
a94bb2d:(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_backreplays your case (2.3 GB left, 600 MB in the menu, the next world's targets against the whole room), and the first assert ofwhere_the_room_came_back_before_nothing_is_keptis now(0, false)with a second at 20 s of world.GIVENis set withcompare_exchange(false, true)only when it was read false.settle = 20000.targets_room_keptnow usesvram::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.
@Kal0s-design on GitHub · 2026-12-04 20:17 UTC · original
Re-checked
a94bb2don native Windows (didn't run the game). All three points look fixed to me.The first branch of
releasednow 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 adrewthat clears it in between stays cleared. Andtargets_room_keptuses 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
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.Merge
Merge the changes and update on Forgejo.