Texture flickering huge improvement. More tests by other setups needed. #543
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!543
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-543"
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?
@RhaegonGrey on GitHub · 2026-12-05 02:05 UTC · original
RhaegonGrey:texture-backlog→main· +1379 −361 · 18 files · 9 commits · openVICTORY_SMALL_BACKLOG=1(off by default): while the texture pass is behind, a texture's first host copy holds only its first page's levels (a few KiB). The slot then shows the texture blurred instead of the neutral stand-in until the whole copy is uploaded.Related: #396, #331 (texture flicker and black or grey surfaces on RX 9070 XT, with a standing queue of 20–30k textures waiting).
Explainer with the mechanism and the log numbers: https://claude.ai/artifact/P8x1ee7WoqCtLmonDZdb1p
Why
#216's description found that the long black waits are "slots of textures not made yet, which small-first does not reach".
VICTORY_SMALL_FIRSTonly covers copies that were let go for room. This switch covers the other case: textures shown for the first time while thousands of slots are due, which happens after a load or on a fast drive. In #396, 394,468 of 915,000 slots showed the neutral texture while their upload ran.What it does
SMALL_DUE) and grows on the pass's next visit if the card has room. Only a texture's first copy is made small (made_once). A copy that grew is never made small again.stats: vramline asbacklog(0/1) andbacklog_small.copylochelpers,crate::lock,switch_is_1!,Staging::take_whole.VICTORY_SMALL_BACKLOGandVICTORY_SMALL_FIRSTadded torun.conf.default(which also puts them in the menu) and todocs/SETTINGS.md.Stacking
This branch sits on #216's current head (
624d18c). #216 was split, and its small-first commits (VICTORY_SMALL_FIRST, slice 2b) are no longer in any open PR. This switch is built on them, so they are carried here with @skalel kept as their author.VICTORY_SMALL_FIRSTstays its own switch and is off by default. Until #216 is merged, its commit shows in this diff too. If you would rather have small-first in its own PR, I can split it out.Measured, and not measured
vramline shows the backlog switching on during loads and fast drives. 464,005 first copies were made small in a 40-minute run, and the parked ones grow afterwards.texture_late kind="new_texture"and a screen recording is the next step.VICTORY_BVH_BUILDER=0) could also be improved by this fix.Checked
clippy --all-targets -p victory-gpu: no new warnings compared with624d18c.resource::(29 passed),vram::(6 passed) andtexture(38 passed) pass. The fullvictory-gpusuite aborts partway in this Wine prefix, and does the same on624d18c.🤖 Generated with Claude Code
victory-gpu: VICTORY_SMALL_BACKLOG: textures first shown while the texture pass is behind get their first page's levels, and grow whole once it caught upto Texture flickering huge improvement. More tests by other setups needed.@Kal0s-design on GitHub · 2026-12-05 02:34 UTC · original
Checked
9cad413on native Windows (one NVIDIA desktop card plus WARP, didn't run the game).cargo test -p victory-gpu --lib(skippingdescriptor::tests::views_die_with_their_resourceas I do on every branch) gives 369 passed and 5 failed on the PR, and 352 passed with the same 5 failed on current main (b581f7e). The five already fail on main on this machine, namely the twoindirect::host_list_*, the twopipeline::hostlibrary loads and the flakywatch::the_rest_of_the_one_asking_has_a_number_of_its_own. All 21 new tests pass on the card, the resource ones included (a_texture_first_shown_in_a_backlog_is_small_until_it_ends,without_room_a_slot_takes_the_small_copy,a_bake_source_comes_back_wholeand the rest). I get the same result withVICTORY_SMALL_BACKLOG=1 VICTORY_SMALL_FIRST=1set for the whole suite. The branch is 16 commits behind main but merges cleanly, and the merged tree gives 373 passed with the same 5 failures.cargo check -p victorybuilds, and the victory-core menu tests that readrun.conf.defaultpass (18). Clippy--all-targets -p victory-gpushows no new warnings next to the merge base (2382b4c). Once merged it also clears main's current "room_latelyis never used" warning, becausewant_level_inuses it again.I also wrote a quick throwaway test on the card (since removed) that runs the switch from start to finish. With the backlog on, the first
Slotask gets a copy from level 3 (256x256 BC7) inSMALL_MADE. ASlotvisit and aPassvisit before the upload leave it alone. Aftersmall_filled, with the backlog off, aPassvisit grows it to base 0 in a new copy markedSMALL_NO. When that copy is let go and made again with the backlog back on, it comes back whole, somade_oncedoes its job. I tried a second one to free a texture while its small copy was parked, but the placed-texture table still held the resource, so the copy never died and that case stayed untested.On behaviour, default off holds up. Everything that makes a copy small depends either on
vram::backlog()or onsmall_first()(resource.rs:2684). Onlybacklog_duesetsvram::backlog(), andbacklog_duereturns early without the switch (vram.rs:153-156). With both switches unset every copy staysSMALL_NO,growth(SMALL_NO, ..)is alwaysNow, and the bake path moving toplaced_texture_whole(draw.rs:3316) andreadable_innermoving toplaced_texture_growing(draw.rs:6126) act the same as the oldwant_level. The cleanup in texture.rs (copylochelpers,take_whole,crate::lock,switch_is_1!) and thekeep_bandsplit in host.rs read as equivalent to me. It isn't byte-identical by default though, mostly because the vram commits from #216 come along with it. The following run with both switches unset.stats: vramline every 5 s next to the frame line (host.rs:8153 calling vram.rs:204, which takes the pool lock fortexture_room)vram::seen()before every submission inlet_go_idle(resource.rs:2757)let_go_msstamp intake_idle(resource.rs:2679-2681)ROOM_NOW/PRESSEDstores in the residency tick (um/residency.rs:677-678)SMALL_FILLED_AFTERlock at the top of every heap's pass (descriptor/host.rs:2441)GROW_PARKEDlock on every pass with room (draw.rs:3645)small_firstload per prelude upload (texture.rs:1426)madethroughhost_waits, only to bump a counter (draw.rs:4072-4076)None of these changes what gets drawn, and each one is cheap, but it might deserve a line in the description. The per-slot
host_waitslock is the one I'd put behind a switch.The hysteresis matches the description (vram.rs:124-126, 172-180), and the unit test covers on, hold and the single end.
backlog_duedoes a load, a compute and a store, not one atomic step, so if two heap passes ever run at once one of them can lose an update. I don't see that stranding anything. When the card has room,grow_parkedalready runs on every pass (draw.rs:3645), so the extra call at draw.rs:3677 only matters when there's none. Passes are also the only thing that writesBACKLOG, andbacklog_dueis skipped while baking (draw.rs:3676). So through a bake, or a stretch with no texture pass,backlog()keeps its last value and slot asks can still mark first copies small. The first pass afterwards puts that right.I don't see how a small copy could stay small for good.
SMALL_MADEbecomesSMALL_FILLEDfrom both upload paths (texture.rs:1426-1433 throughsmall_filled_after, texture/ahead.rs:365), and staging is keyed by copy serial, so a new small copy always gets its own first upload. Parked copies leave the queue afterBACKLOG_GROW_MSeven while the backlog stays on, and right away when it's off (resource.rs:2541-2545). From reading the code, a copy freed while parked leaves only a deadWeakthatgrow_parkedskips (resource.rs:2590 and theupgrade()?ingrow_parked). Copies and bakes go throughAsked::Copyand get the whole texture (a copy source that finds a level missing falls back towant_level, list.rs:1253-1264).hosted_forwon't make a small copy of a copy destination or of anything the host wrote (resource.rs:1781-1790). The digest side looks fine too.holdslives on the copy, and growing makes a newHostTexture, so a small copy'sHeld(tail levels only) can't be taken later as the fingerprint of the whole texture. While the copy is small,compare_sourcelimits itself tocopy.base(texture.rs:2098) the same way it already does for any copy made from a later level.On lock order,
park()pushes intoGROW_PARKEDwhile holding the texture'smadelock (resource.rs:1484), andgrow_parkedlets go ofGROW_PARKEDbefore it touches any copy, so I couldn't find an inversion. The new code has no unwraps outside tests.A few smaller things. The description says a parked copy is let out "1 s after it was made", but the clock starts when it's parked (
park()stampsnow_ms(), resource.rs:2588-2590). That only happens after its upload ran and a pass visit found the backlog still on or no room, so it's a bit over 1 s after the fill. Next, thesmall_firstflag onHostedis set by aSlot/Passask during the backlog (resource.rs:1458) but only used when the copy is actually made (resource.rs:1760). If the backlog ends in between, that copy still comes out small, which costs one extra small upload before it grows on the next pass with room. Last, "a texture's first copy" really means the first copy of the placed resource for that address and description.texture_atreuses the cached resource for the same pair (resource.rs:4080-4082), somade_oncestays set until that entry is trimmed. New content streamed into an old placement doesn't get the backlog treatment, and after a let-go onlyVICTORY_SMALL_FIRSTcovers it. That looks intended, but the description could say so.Claims I could match to the code are the 1024/256/500 ms marks (vram.rs:124-126),
backlogandbacklog_smallon the vram line (vram.rs:292-293), first copy only throughmade_once(resource.rs:1458, 1818), copies and bakes whole (resource.rs:1456, draw.rs:3316), both switches inrun.conf.defaultanddocs/SETTINGS.md, and the stack sitting on624d18cwith #216's commits below it.The part that matters most is what I didn't test, the flicker in game, and anything on AMD, where #396 and #331 come from. The tests and the throwaway only show that the state machine and the copy sizes behave as described on one NVIDIA card. Whether the picture actually improves is still down to the A/B run you mention.
AI-assisted: yes
@Widget9337 on GitHub · 2026-12-05 02:43 UTC · original
Tried this on an RX 9070 XT 16 GB (Ryzen 9 7950X3D, 64 GB RAM, CachyOS, this repo's Mesa and vkd3d-proton), Series X, 1080p with FSR 4 Balanced, ray tracing on,
VICTORY_VRAM_BUDGET_MB=17000. The PR merged cleanly ontomainb581f7e(plus #428 and #445), release build, onlyVICTORY_SMALL_BACKLOG=1on (VICTORY_SMALL_FIRSToff).The switch ran like it should. The
vramline had the backlog on from about a minute in, and it never went off again for the rest of the session:No errors and no device loss.
The stand-in share didn't move the neutral texture meanwhile in 42,160 of 80,000 slots (53 %), against about 51 % in my runs without the PR. Same as your own numbers, so the small copies don't seem to reach the slots that wait on the stand-in.
A regression: some bushes vanished. Low detail bushes in the distance disappeared completely as I got close, instead of switching to their full texture. With the PR off they swap normally. My guess is that it's the growth: with the backlog never ending, the small copy is let out after 1 s, and for those the full copy isn't shown in its place, so for a while there's nothing. I haven't confirmed that in the code.
The one frame flashes (#69, #463) didn't change. For those I had already ruled out the stand-in here: with the neutral texture colored magenta (45,384 slots given it), no magenta showed anywhere, and the flashes stayed black or bright (details on #463). So on this card the stand-in isn't visible, and I wouldn't expect this switch to change the flashes.
@RhaegonGrey on GitHub · 2026-12-05 03:10 UTC · original
Weird, I'm no longer having those texture issues as much as I've had before. I can turn around on stores and the house isn't glitchy all the time (seems to be for the first seconds the game is open). Could it be some sort of configuration that goes alongside this change? Here's my variables:
VICTORY_SKIP_BINK=0
VICTORY_KEEP_GPU_WRITTEN=1
VICTORY_POOL_MOVE=1
KEEP_FREE=2048
VICTORY_FSR_HOST=1
VICTORY_FSR_4K=balanced
VICTORY_PAGE_ADAPTIVE=1
VICTORY_PAGES=1
VICTORY_BVH_BUILDER=1
VICTORY_BVH_HARDWARE=1
VICTORY_FULLSCREEN_RES=3840x2160
VICTORY_FULLSCREEN=1
VICTORY_OUTPUT=3840x2160
CONSOLE=series-x
VICTORY_HW_RT_DEMOTE=1
VICTORY_SMALL_BACKLOG=1
VICTORY_SMALL_FIRST=1
@LloydNicholson on GitHub · 2026-12-05 18:57 UTC · original
An off/on test of
VICTORY_SMALL_BACKLOGon an RX 9060 XT 16 GB (RDNA 4), with a Ryzen 7 5700X on Linux. It uses this repo's Mesa and vkd3d-proton, Series X, 1080p output with FSR 4 quality, and ray tracing on (VICTORY_BVH_BUILDER=1).Setup
mainate015c66, which carries other local changes. The only conflict was intexture.rswithcea6856(the clean-up commit): our tree had extra prefix hashes there, so I kept our side.take_wholemerged with them as is.victory-gpu --libunder Wine gives 390 passed and 6 failed. The same 6 fail on our tree without the PR: the twoindirect::host_list_*and fourwatch::tests.VICTORY_SMALL_BACKLOG=0against=1onrun.sh's command line. Each drive was cut at 6 minutes after the firsttexture_lateline, and both are scored over those same 6 minutes.Results
From the last
texture_lateline of each drive (these are running counts):new_texture, nnew_texture, meannew_texture, p90 / p99away_to_upload, meanaway_to_upload, p99part_to_whole, meanbacklog=1lines (of 71)backlog_smallCaveats:
In play
The player found the on drive "much smoother". That fits the shorter tail: fewer slots stayed blank long enough to be seen.
Also seen (#216's line, both drives)
At 80–86 % of the budget, copies let go after 4 s idle were very rarely wanted again. In these two drives, 57,422 and 86,919 copies were let go, and only 64 and 79 of them were made again within 5 s. In a separate 14-minute drive, the figures were 122,584 and 210 (0.2 %). So on this card the let-go rule is not where the blank time comes from. It comes from
new_texture, which #216's description already pointed to for the long black waits, and fromaway_to_upload.🤖 Generated with Claude Code
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.