fix(gpu): settle targets_room_kept() at 720p (Series S) #563
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!563
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-563"
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?
@ratatrampa007 on GitHub · 2026-12-05 07:24 UTC · original
ratatrampa007:fix/720p-targets-settle→main· +183 −22 · 1 files · 2 commits · merged 2026-12-05 21:08 UTCSummary
targets_room_kept()incrates/victory-gpu/src/resource.rsreserves 3,072 MiB (most) for host-written render targets and releases the unused reserve to0once targets stop growing for 20 s andtargets >= most / 2(1,536 MiB).At 720p (
CONSOLE=series-s,VICTORY_OUTPUT=1280x720, scales0.85–1.0), in-world host-written render targets settle around ~1.0–1.25 GiB — always below1,536 MiB. As a result,targets_room_kept()never settles to0and permanently adds ~1.8 GiB of phantom VRAM usage to everyroom(),vram_plan(), andpool::spares()check for the entire session:room()stays closed (no room for new onesfires continuously).vram_plan()stays pinned inURGENT_MS(1.2 s) eviction mode withgrace = 0, causing relentless texture eviction/re-upload churn and permanently holding draining texture blocks.Change
targets_room_for(targets, since, now)and lowerTARGETS_SETTLE_FLOORfrommost / 2(1,536 MiB) to768 MiB(768 << 20):~652 MiBpre-world footprint documented inresource.rs(load time remains protected).~1.0–1.25 GiB) as well as 1080p/1440p (~2.25–3.1 GiB), so the unused reserve is released after 20 s of stability.resource::tests::targets_room_settles_at_720p_but_not_pre_worldcovering pre-world (652 MiB), 720p (1,004 MiB&1,260 MiB), and 1080p/1440p (2,350 MiB).Measured impact (RX 6600 8 GB, RADV, Series S
1280x720 [Native], 30 FPS cap)e92fd7a, 3 h session)tight-textures(b581f7e, 2 h session)gpu_wait_msmedianxmemon-card / free VRAM(Note: the
rdna2-3branch has the sametargets >= most / 2check atcrates/victory-gpu/src/resource.rs:2093if you want to cherry-pick it there too.)Verification
cargo run --locked -p xtask -- policy→asset policy: 359 files ok./build.sh test -p victory-gpu --lib -- targets_room→1 passed; 0 failed@Kal0s-design on GitHub · 2026-12-05 07:42 UTC · original
Checked head
bf3ce7bon native Windows (MSVC), one NVIDIA desktop card plus WARP, against main atb581f7e. I did not run the game, so everything below comes from reading the code and running the unit tests.The change does what the body says. On the default path the only difference is the floor. The reserve now drops to 0 once targets are at least 768 MiB and haven't grown 64 MiB in the last 20 s, where main needed 1,536 MiB. Under 768 MiB, or inside the 20 s, it still returns 3,072 MiB minus the targets, same as before. At 1,004 to 1,260 MiB of targets, that leftover is about 1.8 to 2.0 GiB, which matches the phantom figure in the body. The extracted targets_room_for matches the old expression. Dropping
settle > 0loses nothing since settle was a constant 20,000. Nothing can overflow, because the constants fit easily and both subtractions saturate. The env switches near this code (VICTORY_TEXTURE_ROOM_PERCENT and VICTORY_TEXTURE_ROOM_CAP_PERCENT) only move the thresholds in room(). Neither changes what targets_room_kept returns.The change applies to everyone, with no switch. It matters for any state that holds targets between 768 and 1,536 MiB for 20 s, and that band isn't limited to 720p. The body says 1080p sits at 2.25 GiB and up, and the doc comment does give 2,255 MB and up after the first frame, but it doesn't name a resolution. #481 reports Series X at 1080p sitting at 1.45 to 1.53 GB, just under the old line. If that holds, this PR also releases the reserve for Series X at 1080p, so 1080p isn't untouched in every case. Leaving the world below 768 MiB brings the full reserve back at once, and a 64 MiB step after a release brings it back for another 20 s. That matches main.
There's one thing I couldn't settle from code. The 652 MB pre-world figure comes from runs 193, 197 and 198 (doc comment above TARGETS_ROOM_MOST), and that comment doesn't say which output those runs used either. 768 MiB is only about two 64 MiB steps above it. If a menu or loading screen at a higher output holds 800 to 1,500 MiB for 20 s, this PR gives the reserve away before the first world frame, which is the spike the reserve exists for. Main keeps it in that case. A short log of the targets figure before the first world frame at 1080p and 4K would answer it.
This overlaps with #481 (still open). That PR goes after the same reserve that never comes back for Series S, but behind VICTORY_RESERVE_RELEASE and off by default. It keeps a 512 MiB headroom over the targets and waits until the world has been drawn for 20 s, where this PR releases to 0 with no world check and no headroom. #481 also reports Series S targets growing about 190 MB in the two minutes after the give-back. Here, each 64 MiB of that growth would bring back the full 1.8 GiB or so for 20 s, rather than a 512 MiB margin. Each PR merges cleanly with current main, but they edit the same lines in targets_room_kept and conflict with each other. With the switch on, #481 returns before the line this PR changes, so the new floor would only apply with the switch off. It's worth choosing one approach or reconciling them.
The rdna2-3 note is right, the same
targets >= most / 2check is at resource.rs:2093 on that branch. URGENT_MS is 1,200 ms in host.rs, and grace is 0 whenever admissions are closed, as the body says.cargo run --locked -p xtask -- policygives the same "359 files ok". The 720p footprint (1.0 to 1.25 GiB), the FPS, gpu_wait and re-upload numbers, and the 0 waiting pages all need the game, so I couldn't check them.I ran cargo test -p victory-gpu --lib resource:: with --test-threads=2, skipping views_die_with_their_resource, and got 16 passed and 1 failed. The failure was buffer_data_reaches_the_host_texture, which then passed in the full-suite runs on both the PR and main, so it looks like the usual native flake. The new targets_room_settles_at_720p_but_not_pre_world passes. On the full victory-gpu lib suite the PR got 353 passed and 5 failed, and main got 353 passed and 4 failed. The extra test on the PR side is the new one, and it passed. On both, four of the failures are the two indirect host_list tests and the two pipeline::host library tests, which fail natively on main. The PR's fifth was the flaky watch test the_rest_of_the_one_asking_has_a_number_of_its_own, which then passed 3 out of 3 reruns. cargo fmt has nothing to say about the lines this PR touches.
The new test only covers targets_room_for, not the growth tracking in targets_room_kept. So I wrote a local test, not pushed, that copies that tracking and feeds it sequences. All of these behaved as expected. 767 MiB keeps the reserve, and 768 MiB at 20,000 ms releases it, but not at 19,999. A 720p-like run (652, then 1,004, then a slow creep) releases 20 s after the last 64 MiB step. 60 MiB of creep over 20 s still releases, and a further 4 MiB brings the reserve back. Re-growth after a release brings it back for 20 s. Falling below the floor brings it back at once. A 1080p-like run (652 then 2,300) behaves exactly like main. A state held at 900 MiB for 20 s releases here and not on main. Targets moving between 740 and 800 MiB switch the kept figure between 0 and about 2.3 GiB, which can open and close room() repeatedly. Main has the same edge at 1,536 MiB, but with a lower floor more states may sit near it.
AI-assisted: yes
@ratatrampa007 on GitHub · 2026-12-05 17:04 UTC · original
Thanks @Kal0s-design for the thorough MSVC verification and for catching the 1080p/4K pre-world menu edge case!
Pushed follow-up commit
8249de4to harden this while keeping it a self-contained 1-file change incrates/victory-gpu/src/resource.rs:TargetsRoomTracker): Keeps the legacytargets >= TARGETS_ROOM_MOST / 2(1,536 MiB) path unchanged, and gates the lower768 MiBfloor on sustained active world draws usingcrate::frame::current()andcrate::draw::drawn()(>= 1,000draws/frame averaged across>= 10-frame windows for20 s). In real captures, boot/menus sit around7-85draws/frame and pause/map/save-reload screens around250-420draws/frame, whereas even compact interiors run1,050-1,900+draws/frame — so a 1080p/4K menu holding800-1,500 MiBwill never release the reserve early.1,000draws/frame for5 sclearsin_world, restoring the full3 GiBpre-world reserve for the next load.targets_room_settles_at_720p_but_not_pre_worldnow drivesTargetsRoomTrackerdirectly across high-res menu/pause protection, 720p settle timing (19.999 svs20.000 s), small-interior continuity (1,200draws/f),<64 MiBcreep,+64 MiBre-arm,5 sleave-world reset, and the legacy>= 1,536 MiBpath (resource::tests: 17 passed, 0 failed;xtask policy: 359 files ok).Re:
#481— good call flagging the overlap.#481wires an opt-inVICTORY_RESERVE_RELEASEswitch on top of#216, whereas this stays a minimal default fix with no dependency on#216and no extra env switch. Happy to keep a residual headroom cushion or reconcile with#481depending on whichever direction maintainers prefer.