Slot eviction: textures picked by index of more than one pool piece are cut to their small levels, not put to null (depends on #4580) #4851
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4851
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4850"
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?
@Lyrnc on GitHub · 2026-12-01 11:36 UTC · original
Lyrnc:perf/evict-index-idle→main· +935 −32 · 6 files · 6 commits · closed without mergingDepends on #4581: its two commits (
02fe88f6and the early-run fix981dd225) are the first two here, and this pull request is the four commits after them. Refs #3829, #1772.What it changes
What was wrong. On main, slot eviction lets no texture go when the card is over its budget. In our 8 GB stand-in run, 27,612 of 27,804 idle-looking textures were shown by slots that shaders pick by index.
evictable_slotskeeps every such texture unless it trusts the sampled marks (VICTORY_SAMPLED_EVICT), andvictory playturns that off. Nothing else says whether such a slot is read:The marks do know. In the same run, 24,924 of those 27,612 textures (2.2 GB) had been read by no shader within the idle time.
#4581 trusts the marks once the card is at 95 % of its budget and a texture has gone 1,800 frames unread. It puts the slots of such a texture back to null, as
VICTORY_SAMPLED_EVICT=1did. Each slot then shows the neutral texture until a shader marks it, the marks are read back and the texture is uploaded again. That is a flat surface for a few frames each time such a texture comes back into view, which is the foliage flicker that madevictory playturn1off. In our run with #4581 alone, 27,358 of the 70,126 slots it put to null were read again later.What this does. With
VICTORY_SAMPLED_SHRINK(on unless0), a texture that slot eviction takes, that only slots picked by index show, and whose copy takes more than one piece of the texture pool is cut to its small levels instead. Its slots are never put back to null.cut_level,CUT_PIECE: 64 KiB of the console layout). The level is counted from the copy's own first level, since many copies already start from a later level (held levels).grow_smalltakes one out to grow it (retake:REPLACED, then the texture's slots are due at the next pass). The slots keep holding the old copy and go on showing it until the small copy's upload has run. Then they show the small one, the same way slots move to a grown copy (levels_changed_after,texture_views_remade).sampled::shrunk, kept as bits and and-ed with each readback's words). The next mark of one grows the texture back (grow_shrunk, fromwake_pending, outside the presenter's lock). It is then not taken again for the protection time. While cut textures are watched, the marks are read back every 4 frames instead of every 30.shrink_to): only a copy that no list holds (byArc), that was unused for the pass's idle time, that is still the copy the look found, that has no tiles and no colour twin, that is not small already, that has smaller levels to begin at, and that takes more than one piece. A texture placed at the address of one the host writes (possibly an alias's) is not cut. A texture that a draw's table also shows is not cut (cut_not_null). At most 1,024 cuts are tried per pass.descriptor::may_take: the retain ofevictable_slots, now a function): no table showed any of its slots lately; with the marks trusted, it is shown only by slots picked by index, none of them was marked within the idle time or since the trusted frame, and the marks are known for all of them.textures picked by index cut to their small levels by slot eviction (VICTORY_SAMPLED_SHRINK=1), since the start: N (X MB before the cut), M grown back as a shader read them (...); K not cut, let go the old way if they could be (one piece of the pool or no smaller level ..., ...); W slots watched for a read now.VICTORY_SAMPLED_SHRINK=0restores #4581 exactly. WithVICTORY_SAMPLED_EVICT=0nothing changes. It still needs the marks (VICTORY_SAMPLED_MARKS=1, which isvictory play's default).How it was tested
victory playdefaults otherwise:VICTORY_SAMPLED_MARKS=1andVICTORY_SLOT_EVICT=1, plusVICTORY_SAMPLED_EVICT=pressurefrom #4581 on the two branches.VICTORY_VRAM_BUDGET_MB=8192stands in for an 8 GB card. It is not one. The driver still has 16 GB, so nothing is paged when use goes past 8,192 MB. Read "card MB in use" as what a real 8 GB card would have to page.5fabb46e. "#4580" is this branch withVICTORY_SAMPLED_SHRINK=0, which is #4581's commit on5fabb46e(it was not built separately). "This PR" is the branch at88a44f33, which was on #4581's first commit only. The branch has since been rebased onto #4581's head with its early-run fix (981dd225), and nothing else changed. The fix's own startup runs are on #4581. All runs used one shader cache, preloaded and warmed on main (the branches change no shader), the same save, and a 12-minute scripted walk (walking from world+30 s to about world+660 s). Main and #4581 ran twice each, this PR once.8 GB stand-in. Columns are world+30-330 s / 330-630 s / 630-690 s (the last is short). Where a cell has two values separated by ";", they are the two runs.
What this shows:
981dd225) still showed it: see my comments on #4581.16 GB (the budget as is, 15,209 MB), main and this PR, one run each: the card used 13.2-13.8 GB, 87-91 % of its budget. That is below #4581's 95 %, so neither run put anything to null or cut anything, and the eviction was the same as main's.
cargo test --locked -p victory-gpu --libon88a44f33: 1,103 passed, 0 failed, 66 ignored. After the rebase onto981dd225:-- resource:: descriptor:: sampled::199 passed, 0 failed. In one of three full runs,host::refresh_tests::chunked_nothing_new_with_matches_individualfailed. It passes alone (-- host::refresh_tests: 7 passed), and it does not touch the files this changes (a write-watch timing test). New tests:descriptor::tests::the_idle_rule_takes_by_index_only_what_no_shader_read;resource::tests::the_safety_rule_cuts_only_an_idle_copy_no_list_holds;resource::tests::a_cut_begins_past_the_copys_own_first_level;resource::tests::only_textures_picked_by_index_alone_are_cut;resource::tests::a_cut_texture_keeps_its_slot_and_grows_back(on the card: a placed 512x512 texture with a slot made from its copy is cut, and the slot still shows the old copy and is never null; a copy a list holds, or one at a target's address, is not cut; the next copy is the small one; a read grows it back to the full copy, once);sampled::tests::a_read_of_a_cut_slot_grows_its_texture_once.cargo clippy --locked -p victory-gpu --lib --tests: no warning in the lines this changes. The five it prints are main's (host/font.rstwice,host/menu.rs,host/panel.rstwice; #4680 / #4708).cargo xtask policy: ok.cargo testpassed for the crates it touches: yes (victory-gpu; the change touches no other crate's code;apps/victory/src/play.rsis #4581's line).Not tested
Checked for overlap
sampled.rs; no cut).AI use
Claude Code (Claude Opus 5.5) wrote the change, its tests and this description, and read the bench logs. The bench runs are ours, on the PC named above.
🤖 Generated with Claude Code
88a44f3326to6650e3485c@trustno1-coder on GitHub · 2026-12-01 18:30 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed