perf(victory-gpu): add fence-safe LRU texture eviction, budget-aware mip clamping, and async reaper #354
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!354
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Vladimir-Human on GitHub · 2026-11-26 12:14 UTC · original
Vladimir-Human:perf/texture-vram-lru-mipcap→main· +6151 −2056 · 7 files · 3 commits · openSummary
Ports the verified texture VRAM fence-safe LRU eviction, budget-aware mip-tail clamping, anti-thrash descriptor slot cooldown, and optional async reaper path from fxceless/victory-fork#1289 into
third_party/victory/crates/victory-gpu, adapted cleanly atopAnyXboxX's existingVICTORY_VRAM_EVICT,VICTORY_SLOT_EVICT, partial-mipupload_from, 1-lock-per-slotHostHeap::kept/made_too, and 16-shardRETIREDarchitecture (draw.rsuntouched).What Changed
Fence-safe 2-pass LRU texture eviction (
VICTORY_TEXTURE_LRU_EVICT, default on,=0disables):last_used_frame,last_fence_value, and idempotent synchronousHostTexture::uncount(), stamped inHost::submitalongside atomicHost::last_signalled.fills && !host_wrote) textures in two TOCTOU-safe passes oncelast_fence_value <= completed_fence,Arc::strong_count == 1, and COMreferences == 1(by default never pinned in any live shader-visibleHostHeap::keptslot), respecting a1,000 ms / 2-frameidle guard (plus an emergency0 ms / 1-framefence-safe fallback on OOM or>= 95%DXGI budget pressure) and droppingStaging/ D3D12 COM objects strictly outside locks.VICTORY_VRAM_EVICT(pressure_victims),VICTORY_SLOT_EVICT(slot_evict), andlet_go_idleintact while addinglast_fence_value <= completed_fenceenforcement,TEXTURESliveness protection, and side-effect-freeroom_lately()(room_raw()).VICTORY_TEXTURE_LRU_HEAP_EVICT=1, default off so bindless textures bound once into shader-visibleHostHeapslots and read continuously by shaders are never evicted by default): underHost::submittedwhen no GPU submissions are in flight, unmakes cold shader-visible title slots and untaken dynamic table slots viadescriptor::evict_kept_resources/HostHeap::evict_kept:made_too(Release) andmadebeforeslot.take()so lock-freemirrorreaders serialize cleanly.TextureQueue::hold_evicted(240-frame anti-thrash cooldown preserved acrosstexture_slots_room, sorted behind fresh title writes).View::Shaderslots inWAITINGwithout prematuremake_waiting()resurrection; transparent re-upload occurs from console memory if sampled again later.Budget-aware mip-tail clamping (
VICTORY_TEXTURE_AUTO_MIP_CLAMP, defaultOff):1/auto: clamps eligible single-slice non-MSAA read-only 2D host textures to<= 2048on<= 12 GiBDXGI budgets and<= 1024on<= 8 GiBbudgets or>= 85%effective pressure;<N>(>= 4) sets an explicit max dimension (0/offdisables).ResourceDesc,footprint(), and console layouts completely unchanged; enforcesmip_levels > 1,base <= first_tail_mip, and BC4x4block alignment.base_mip,host_width, andhost_heightonStaging, composing cleanly withupload_from(..., first)partial-mip staging so BC1–BC7 tail (2x2/1x1) and NPOT mips hit theSTAGINGcache without rebuilding or downgrading upgraded entries.MostDetailedMip,MipLevels, andResourceMinLODClampforTexture2DandTexture2DArray(adjust_srv_for_base_mip), and upgrades seamlessly viaensure_unclamped+ ABA-safePendingUnclampdeferred SRV rebinding oncopy_resource,copy_texture_region,read_back, andresolve.Async COM retirement (
VICTORY_REAPER=1/alt, default off):"victory-reaper"intoretire()and 16-shardbury()(single batched wakeup perbury) to offload D3D12 COM destruction off submission paths whileHostTexture::uncount()updates live byte telemetry synchronously.Verification
Tested on Windows x64 (
third_party/victory):cargo run -p xtask -- policy:asset policy: 199 files ok(all touched files< 512 KiB;host.rs=429.2 KiB).cargo clippy -p victory-gpu --all-targets -- -A deprecated(default &--features diagnostics):0warnings in touched files.VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_WARP=1 VICTORY_REAPER=1--features diagnosticstargeted tests (default_lru_eviction_*,mip_clamp_policy_*,in_flight_fenced_*,fence_completed_lru_*,mip_clamped_textures_*,mip_clamp_and_evict_kept_tests3/3,first_mip_tests3/3): 11/11 passed on both hardware D3D12 and WARP (0D3D12 debug errors).VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1victory-gpulib test suites: 192 passed; 0 failed (default) and 205 passed; 0 failed (diagnostics, excluding the 3 pre-existing baseline failures in untoucheddescriptor::host/indirect).Source: fxceless/victory-fork#1289
@Skyfrye on GitHub · 2026-11-26 14:22 UTC · original
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
@Vladimir-Human on GitHub · 2026-11-26 14:27 UTC · original · edited 2026-11-26 15:37 UTC
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).6539f200fato6f18db7a4e6f18db7a4eto7031e42a91@Vladimir-Human on GitHub · 2026-11-26 17:25 UTC · original
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)7031e42a91to5865586f6b@Vladimir-Human on GitHub · 2026-11-26 19:11 UTC · original
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).@Vladimir-Human on GitHub · 2026-11-26 19:19 UTC · original
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.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.