gpu: keep titles' copies of half a MiB on the card, not sixteen #641
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/641"
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by superboynick on 2026-11-28T02:30:05Z.
What this changes
On a card whose VRAM budget is 12 GiB or less, the smallest title copy kept in the card's memory was 16 MiB. The CPU searches those copies for what shaders wrote, and the copies the card holds are searched on the card instead — so everything between 16 MiB and a megabyte was searched on the CPU, every frame.
The floor becomes 512 KiB (in
resolve_card_limits, which is whereVICTORY_CARD_BUFFERS_MIN_KBalready set it for anyone who asked).What I tested
RTX 5070 Ti Laptop (budget 11,176 MB), Windows 11 26100, RTX 5070 Ti driver 32.0.16.1714, Series X profile, the 36-item play set, one save, warm shader cache. Windows paired by index and kept only where
draws/frameagrees within 5%.Paired windows, 16 MiB against 512 KiB — seven of them, every one in the same direction:
Median 425.9 → 184.0 ms (−56.8 %), which is 2.35 → 5.43 fps in the dense city.
Stability
A 480 s soak at 512 KiB: 65 in-world windows, median 181.2 ms, P90 188.4 ms, no device loss, VRAM 8.1 GB of a 10.7 GB budget. Series S gains the same way (101.1 ms median in the world, against 264-310 ms before).
Nothing below half a MiB goes to the card: below that the per-copy bookkeeping costs more than the search it saves. Copies the card cannot hold stay on the CPU, so the budget still caps it — this only decides where the search happens, not how much memory is spent.
What it costs in VRAM, since that is the obvious objection
Same run, same place of the same scene, the line the layer prints right after the swap chain settles:
card_buffers_min+46 MB, about 0.6 percent, for 56.8 percent of the frame. The budget still caps what the card keeps,
and whatever does not fit stays on the CPU exactly as before, so a card with less memory loses the benefit
rather than the stability.
One more thing, in case it helps you place this: it is the same family as #6 and #7, which are already in main — the
question of which of the title's bytes sit in card memory and are looked at there, rather than on the CPU. #7's
"texture read-backs written by a thread of their own" is that question from the write-back side; this is the same
question at the search side, and it is the largest single item left in the frame here.
One risk, found after opening this, and stated rather than left for you to find
At Series S with
VICTORY_UPLOAD_AHEAD=1andVICTORY_ASYNC_SUBMIT=1alongside the 512 KiBthreshold, two runs in three device-lost (0x887A0005,
the host device went while textures picked by index were made ready). The threshold on its own does not: Series S with nothing elsechanged ran clean, 34 windows, median 103.4 ms, no loss.
That is the frame
shadow.rsalready describes — "the fault lay in a texture made in the sametenth of a second, in a new block" — and putting more of the title's copies in card memory makes
more new blocks, so that window widens. My reading is that
VICTORY_WAIT_RESIDENT(on by default)is the thing that has to keep up here, not the threshold, but I have not proven it, and it is your
call whether a default that widens a known window is worth 56 % of a frame.
So: if you take the number and not the default, the switch already exists and I will leave it at
that. I have taken the combination out of the launcher I use here and written the loss into it.
One more line for whoever runs the tests: on this branch
cargo test -p victory-gpu --libis 443 passed, 0 failed, 36 ignored (WARP, one test thread), so no assertion in the tree depended on the 16 MiB floor. Nothing else in the branch changes behaviour: the floor moves, andVICTORY_CARD_BUFFERS_MIN_KBstill overrides it.What would make it mergeable
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by wildheathen on 2026-11-28T15:40:36Z.
The existing test
shadow::window_tests::card_limits_scale_with_local_vram_budgetfails on this branch (at65dc0af,cargo test -p victory-gpu --lib -- card_limits:left: (0, 512),right: (16, 512)): its<= 12 GiBassertions still expect 16, and the doc comment abovedefault_card_limits_mbstill says 16 MiB for that tier. The commit also adds a BOM toshadow.rsand re-encodes five comment lines (179, 189, 190, 5996, 6002), so "8–12" became "8鈥?2": the en dash and the digit after it are lost.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by superboynick on 2026-11-29T08:05:43Z.
All three are right, and all three are fixed in
7fae2df7, rebased ontoe1f2eb60(the branch had drifted 320 commits behind, which is how the test caught me: it did not exist when I last ran the suite).card_limits_scale_with_local_vram_budgetnow expects0for the<= 12 GiBtier instead of16, and theresolve_card_limitscase that pinned the floor at 1 MiB now expects512 << 10.cargo test -p victory-gpu --libon this branch: 589 passed, 0 failed, 44 ignored (WARP, one thread).8–12became8鈥?2). I restored the file frommainand re-applied only the two changes by hand, so the diff is now two hunks plus the comment, with no BOM and no re-encoded lines:git diff main -- crates/victory-gpu/src/shadow.rsshows 24 insertions and 10 deletions, and every line that is not one of the two changes is byte-identical tomain.One thing I should flag rather than leave for you to find: the numbers in the description were measured before the 320 commits that rewrote this path (
0174844a's shared shadow lock,225cba4e's batchedcard.dirty,041d0ee6's scatter,38fd3d93's write-back scopes). I am re-running the seven-window pair on568c5e5→e1f2eb60now and will put the new figures in this description, or say plainly that the change is worth less than it was if that is what the fresh numbers show.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T08:28:06Z.
Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.