perf(victory-gpu): fence-safe LRU texture eviction and kept-view yielding #354
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/354"
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 LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T12:14:12Z.
Summary
Rebased onto current
main(132da61,#563+#564) with all three behavioral switches strictly opt-in (default OFF) per maintainer review (fxceless/victory-fork#1289/avatarmanz/VIctory-7900XTX#212).Defaults & Default-Path Parity
VICTORY_TEXTURE_LRU_EVICT(default OFF, active only for1/true/on): fence-safe LRU texture eviction stays inactive by default.VICTORY_KEPT_VIEWS_YIELD(default OFF, active only for1/true/on): superseded kept-view yielding stays inactive by default (keeping_slotsallocates 0 capacity when off).VICTORY_KEEP_SHOWNpressure drop (default OFF):keep_shown_withshort-circuits to1without callinghas_room_lately()(no 100 ms pressure check on draws) unlessVICTORY_KEPT_VIEWS_YIELDis explicitly enabled.texture::staging()untouched vs132da61: only adds serial-scopedtake_staged(resource, serial)and propagates©todefer_texture/defer_gpu_texture.texture_lru.rsstays under 400 lines (397lines) and logs refusals viatracing::warn!.Source:/Co-authored-by:trailers andTHIRD_PARTY.mdrow).Honest Performance Note
Verification
Verified locally on Windows 11 (
third_party/victoryworkspace) after the final edit:cargo xtask policy(380 files ok)cargo clippy --no-deps -p victory-gpu --locked --all-targets(default &--features diagnostics: 0 errors, 0 own warnings)VICTORY_D3D12_WARP=0) and WARP (VICTORY_D3D12_WARP=1, default env):texture_lru::tests::: 5/5 passeddescriptor::host::kept_yield_tests::: 5/5 passeddetile::tests::: 5/5 passedtexture::detile_fallback_tests::: 2/2 passedfeedback::tests::: 2/2 passedhost::budget_pool::tests::: 1/1 passedresource::tests::slot_eviction: 2/2 passedresource::tests::refused_texture_allocation_has_one_retry: 1/1 passedChecklist
Source:/Co-authored-by:trailers +THIRD_PARTY.mdrow)staging()unchanged from132da61Imported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T14:22:40Z.
Test report, for information. I stacked this PR with #381 and #382 and the open #278, #279, #291, #292, #307 and #360–#362, on
mainat8ed1109. Setup: RTX 5080, Series X, one 600 s run in the world,VICTORY_INDIRECT_RAW=3,VICTORY_TEXTURE_AUTO_MIP_CLAMP=auto,VICTORY_STAGE_POOL_MB=2048.Results:
One merge note: with #278 applied,
SHADER_HEAPSis aRwLock. TheSHADER_HEAPS.lock()in this PR'sdescriptor.rs(the eviction walk) then has to becomeheaps_read(). That is the only change I needed to build the two together.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T14:27:42Z.
Pushed
6539f20(synced from fxceless/victory-fork#128916a6f8e) fixing a live bindless texture regression isolated during RTX 3080 A/B testing on#1289:HostList::stamp_textures()only stamps textures tracked inHostList::states(barriers), not bindless textures bound once into shader-visibleHostHeap::keptand read continuously by shaders. Passingallow_heap_unmake: trueby default inevict_if_pressured()could unmake live shader-visibleHostHeapSRVs onto the 240-frame cooldown under VRAM pressure.allow_heap_unmake(across both passes ofevict_if_pressured()) andNEED_HEAP_EVICTreads/writes strictly behind opt-inVICTORY_TEXTURE_LRU_HEAP_EVICT=1(default off), and completed theVICTORY_TEXTURE_LRU_EVICT=0kill-switch inhosted(). By default (VICTORY_TEXTURE_LRU_EVICT=1), LRU eviction only reclaims fence-completed idle textures withreferences == 1(never pinned by any liveHostHeapslot), keepingVICTORY_TEXTURE_AUTO_MIP_CLAMPandflush_unclamped_rebinds()unchanged.resource::tests::default_lru_eviction_preserves_live_host_heap_textures_until_opt_in(11/11targeted tests passing on both hardware D3D12 and WARP withVICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1,199 files okinxtask policy,0clippy warnings inresource.rs).Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T17:25:35Z.
Updated
perf/texture-vram-lru-mipcapto7031e42(rebased cleanly ontomainef4791epreserving#396and#398, mergeable):Summary
VICTORY_KEPT_VIEWS_YIELD=1): Trackskeepingslots wherekeep_views()retained an older copy while a sharper view waits (clearing onkeep(),unmake(), or pressure), and invokesyield_kept_views()under VRAM pressure (!room()orwant > 0) to free stale superseded copies without touching non-superseded active textures.VICTORY_TEXTURE_LRU_HEAP_EVICT=1, OFF by default): Tracks per-slotlast_used_frame(mirror(..., for_draw = true)andkeep()), drains unpinnedrefs == 1victims first, then evicts coldHostHeapslots oldest-last_used_framefirst while protecting taken dynamic slots, non-heap COM pins (refs > 1 + kept_refs), and slots withinVICTORY_TEXTURE_LRU_HEAP_IDLE_FRAMES(default120), with a30-frame recreate cooldown.Verification (
7031e42,VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1)cargo xtask policy: 214 files ok;clippy(default &diagnostics): 0 new warnings in PR filesmip_clamp_and_evict_kept_tests(6/6),resource::(24/24)victory-gpu --lib: default256/256+ 3 pre-existingmainfailures (4 ignored),diagnostics269/269+ same 3 pre-existingmainfailures (4 ignored)Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T19:11:30Z.
Rebased onto
main(50936c0->5865586, resolvingdescriptor/host.rsandtexture.rswith #395prepare::take_ready/staged_from/build_staging_untimed).Verified locally (
VICTORY_D3D12_DEBUG=1):cargo xtask policy(215 files ok),cargo clippy -p victory-gpu --features diagnostics --all-targetsexit0;texture::8/8,resource::24/24,draw::5/5(1 ignored) passed (descriptor::36/37with only upstreamspans_say_the_next_start_and_the_lowest_level_viewedfailing).Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T19:19:14Z.
Noting that #409 (
37d4686) replacedthird_party/victorywith the combinedavatarmanz + cool_foxbase, putting this branch inCONFLICTINGright after the50936c0rebase.The clean
avatarmanz-lineage version is open atavatarmanz/VIctory-7900XTX#212(andfxceless/victory-fork#1289); happy to re-port onto37d4686+once#409settles if you want it here.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T13:29:44Z.
Rebased onto latest
main(fa6b209, updatedthird_party/victorybase) ined2b10e:VICTORY_TEXTURE_LRU_EVICT, default ON), Tier 2 supersededkeep_viewsyielding (VICTORY_KEPT_VIEWS_YIELD, default ON), opt-in Tier 3 shader-heap unmaking (VICTORY_TEXTURE_LRU_HEAP_EVICT=1, default OFF), and opt-in budget-aware mip-tail clamping (VICTORY_TEXTURE_AUTO_MIP_CLAMP, default OFF) withadjust_srv_for_base_mipandensure_unclamped/PendingUnclampABA-safe rebinds.Step::Textureto carryArc<HostTexture>alongsideArc<Staging>soHostList::stamp_texturesstamps and pins skipped/deferred texture uploads across flights, and aligneddescriptor/host.rsunit tests cleanly withe04cc0b'sHostHeap::release()kept-resource cleanup.--features diagnostics,VICTORY_D3D12_DEBUG=1,--test-threads=1):clippyclean on touched files;xtask policy(296 files ok); HWresource::tests24/24 (1 ignored),mip_clamp_and_evict_kept_tests9/9,descriptor::host::tests39/39,bake_flip_tests4/4,textures_are_kept1/1; WARPmip_clamp_and_evict_kept_tests9/9,mip_clamp12/12,tier3/3,lru4/4.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T15:40:04Z.
Thanks for the fence-safe eviction work. Before merge:
Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T19:51:21Z.
@LooperSalty Thank you for the clear review on
#354. Acknowledged on all four points:#354cleanly into smaller PRs starting with the fence-safe texture LRU eviction alone (~<= 400 lines), leaving opt-in mip clamping (VICTORY_TEXTURE_AUTO_MIP_CLAMP) and heap eviction (VICTORY_TEXTURE_LRU_HEAP_EVICT) for separate follow-up PRs.evict_if_pressuredwhen an allocation still fails after eviction, and document thatVICTORY_TEXTURE_LRU_EVICT,VICTORY_KEPT_VIEWS_YIELD, andVICTORY_KEEP_SHOWNpressure reduction are active on the default path.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T21:58:50Z.
Thanks for splitting this; the refusal trace and the file sizes are fine now, and the eviction checks (fence complete, single
Arc, COM refs, serial recheck) look sound. Two points from the earlier review are still open:texture_lru.rs:20, on unlessVICTORY_TEXTURE_LRU_EVICT=0), kept-view yield (descriptor/host.rs:5134, on unlessVICTORY_KEPT_VIEWS_YIELD=0) andKEEP_SHOWNfalling to 0 under pressure (descriptor/host.rs:5161) are all on by default, and the description says the gain is unmeasured.KEEP_SHOWN=0shows zeros or the neutral texture, a visible regression, and it flips on a 100 ms room check read per draw. Please make these opt-in until there is a Full HD, warm-cache A/B (median and 1% low) on the default path.Source:/Co-authored-by:trailers andTHIRD_PARTY.mdhas no row.Also note that
texture.rsstaging()changes unconditionally (stricter cache hit,on_demandfromcopy.tiled), which is a default-path change too, and that this conflicts with #555 and #347 inhost.rs/resource.rs/texture.rs.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T22:01:30Z.
@LooperSalty Split and updated as requested:
#354,b106642) is now narrowed strictly to fence-safe LRU texture eviction (VICTORY_TEXTURE_LRU_EVICT, default ON) + Tier-2 superseded kept-view yielding (VICTORY_KEPT_VIEWS_YIELD, default ON, withVICTORY_KEEP_SHOWNdropping to0under VRAM pressure unless explicitly set):texture_lru.rs(384lines),texture_lru_tests.rs(301lines), anddescriptor/kept_yield_tests.rs(187lines), shrinking theresource.rsdiff to+99/-53lines.tracing::warn!logging (submit_pressureandallocation_refused) retaining the eviction outcome, resource info, evicted count/bytes, and remaining budget status when pressure persists or an allocation is refused.#555,6708faf):https://github.com/LooperSalty/AnyXboxX/pull/555(VICTORY_TEXTURE_AUTO_MIP_CLAMP, default OFF).VICTORY_TEXTURE_LRU_HEAP_EVICT=1, default OFF): staged cleanly on top of#354atVladimir-Human/AnyXboxX:perf/texture-optin-heap-evict(2e9a6e4), ready to open as a standalone PR once#354merges.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T07:24:52Z.
Rebased on current
main(132da61, preserving#563ȴ) and addressed both remaining review items at commite0950ac:VICTORY_TEXTURE_LRU_EVICT,VICTORY_KEPT_VIEWS_YIELD, and theKEEP_SHOWNpressure drop to explicit opt-in (switch::opt_inmatching1/true/ononly). With yield OFF,keep_shown_withshort-circuits to1without calling the 100 ms pressure check andkeeping_slotsstays empty.Source:/Co-authored-by:trailers and the French row inTHIRD_PARTY.mdforfxceless/victory-fork#1289andavatarmanz/VIctory-7900XTX#212.texture.rsstaging()parity: Leftstaging()completely untouched vs132da61(#354only addstake_staged(resource, serial)and passes©todefer_texture/defer_gpu_texture).Verified locally on HW and WARP after the final edit:
cargo xtask policy(380 ok), hunk-accurateclippy(default &diagnostics: 0 own warnings),texture_lru::tests::5/5,kept_yield_tests::5/5,detile::tests::5/5,detile_fallback_tests::2/2,feedback::tests::2/2,budget_pool::tests::1/1,slot_eviction2/2, andrefused_texture_allocation_has_one_retry1/1. Note:#555has already been rebased on132da61; once one of#354/#555merges we'll rebase the other cleanly.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.