GPU: card copies of title buffers keep their room from the textures picked by index (VICTORY_CARD_RESERVE=1) #723
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/fxceless--victory-fork!723
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/723/head"
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?
@LeonardoS11 on GitHub · 2026-11-25 05:43 UTC · original
LeonardoS11:fix/card-reserve→main· +56 −2 · 2 files · 1 commits · closed without mergingWhat
Since
310c6ebthe first room runs at about half the frame rate on an RTX 3080 Ti (12 GB): 540–660 ms a frame wherec96b4f2gave 270–330. This PR addsVICTORY_CARD_RESERVE=1(off by default), which brings it back to 275–293 ms.Why it got slower
shadow.rs,card_for), and only while the card is under four fifths of its budget. It is not tried again.VICTORY_TEXTURE_ROOM_PERCENT(90).310c6ebthe textures get there first. Every big buffer used after that stays in the PC's memory for good, and what shaders write to it is looked for on the CPU.The per-frame lines show it (plain
310c6eb, same scene, 300 s runs):c96b4f2310c6eb310c6eb,VICTORY_TEXTURE_BUDGET_MB=6000310c6eb,VICTORY_TEXTURE_ROOM_PERCENT=75310c6eb,VICTORY_REUPLOAD_WHEN_FULL=0310c6eb+ #676VICTORY_CARD_RESERVE=1So a lower texture budget works around it, the percentage does not (the rest of what is on the card is already past four fifths), and neither
VICTORY_REUPLOAD_WHEN_FULL=0nor #676 changes it.The change
With
VICTORY_CARD_RESERVE=1:resource::roomcounts as used the room of the card copies not made yet: whatVICTORY_CARD_BUFFERS_MBallows, less the copies alive (about 1 GB with the defaults). Textures picked by index stop that much earlier.card_fortakes a copy while the card is under the textures' share instead of four fifths, since the reserve keeps that room for it.The rule is a small pure function,
under_share(budget, used, reserve, percent), with a unit test.Why it is a switch, and what I would suggest
It is off by default because of three things I have not measured:
On a 12 GB card it is a clear win, so on by default looks reasonable to me, perhaps with the reserve capped (a tenth of the budget, say) or dropped once the world has loaded. I leave that to you; a number from an 8 GB card would settle it.
Picture
I cannot show that the picture is unchanged, because the picture of
310c6ebis not stable here from launch to launch. Of 6 launches of plain310c6ebwith no switches, the first room's walls were missing in 1 and the chain-link mesh in the window in 1. The 3 launches of this PR's executable (two with the switch, one without) all had the walls missing, and so had the plain310c6eblaunches with the texture switches of the table, which ran in the same hour. So I see no difference that follows the switch, but 3 launches are too few to say so firmly.Tested
diagbuild withdiagnostics, base310c6eb.cargo test --workspace: 511 passed, 0 failed, 9 ignored (on the GPU above). The new test isresource::tests::the_reserve_for_card_copies_counts_as_used.No title data in this PR: counts and times only.
🤖 Generated with Claude Code
@LeonardoS11 on GitHub · 2026-11-25 06:25 UTC · original
A correction to the "Picture" section above, after more launches: on this 12 GB card the switch does cost picture.
Counting the first room's walls at 295 s:
310c6eb, no switches (slow: buffers off the card)310c6ebwithVICTORY_TEXTURE_BUDGET_MB=6000(fast without this PR)So it is not this change in particular: whenever the big buffers get their copies on the card (about 940 MB) and the frame time halves, the walls' textures no longer fit ("textures picked by index: the card has no room for more; they wait"), and whenever the textures win, the buffers stay in the PC's memory and the frame time doubles. On 12 GB the two do not fit together as things are; the switch only chooses which side loses.
c96b4f2was on the fast side too, and had the walls missing in 2 of 3 launches here.That makes the "known" line of
310c6ebthe real lever for both — more than half of the texture memory on the card being held for levels the title has not loaded yet. I would keep this PR as an opt-in for now, not a default.(Launches and screenshots by me on the RTX 3080 Ti above; counted and written with Claude Code.)
@LeonardoS11 on GitHub · 2026-11-25 07:20 UTC · original
Closing:
8dd30abbrought the same thing asVICTORY_CARD_ROOM_FOR_BUFFERS=1, and withVICTORY_LEVELS_ON_DEMAND=1the buffers and the walls' textures fit together on this 12 GB card, so the trade described above goes away. Numbers from the same scene on8dd30abare in #776. (Written with Claude Code.)Pull request closed