victory-gpu: add fence-safe texture LRU eviction and budget-aware mip clamping #212
No reviewers
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX!212
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-212"
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 11:49 UTC · original
Vladimir-Human:perf/texture-vram-lru-mipcap→main· +6304 −1995 · 8 files · 3 commits · openSummary
Ports the verified fence-safe texture LRU eviction and budget-aware mip-tail clamping architecture from
fxceless/victory-fork#1289ontoVIctory-7900XTX(base0dec5dc), preventing VRAM exhaustion and stale descriptor pinning on 8–12 GB GPUs while preservingVIctory-7900XTX'sheld_only/HostTexture::base, shardedMade/quick/keptdescriptor heaps,pool::texture_room(),bury_lag(), andtexstore.What changed (7 files,
+2609/-93,host.rs503,502 B < 512 KiB)VICTORY_TEXTURE_LRU_EVICT, default on;=0disables):last_used_frame,last_fence_value, and idempotentHostTexture::uncount()(synchronously updatingHOST_TEXTURES/KINDS/MIP_CLAMP_STATSeven withbury_lag() > 0), stamped at submission inHost::submitalongside atomicHost::last_signalled.last_fence_value <= completed_fence,Arc::strong_count == 1, COMreferences == 1) title-filled (fills && !host_wrote) textures in two TOCTOU-safe passes under pressure (room(),hosted()proactive + OOM retry, andevict_if_pressured()underHost::submittedwhen!behind, joining any backgroundvictory-heap-syncvianeeds_submit_maintenance()strictly before mutating heaps).descriptor::evict_kept_resources/HostHeap::evict_keptunmakes cold title slots and untaken dynamic slots (clearingquickandmadebeforeslot.take(), dropping duplicate COM refs outside locks whileHosted::maderetains ref #1 so Pass 2'shost::retirehandles final destruction, preserving 240-frameTextureQueue::hold_evictedcooldown acrosstexture_slots_room, and never resurrecting evictedView::Shadertextures inmake_waiting()).let_go_idle()with a fence-completion check, out-of-locktake_staged, and synchronoushost.uncount().VICTORY_TEXTURE_AUTO_MIP_CLAMP, defaultOff;1/autoclamps<=2048on<=12 GiBand<=1024on<=8 GiBor>=85%pressure; numeric>=4sets explicit max dim):held_only(base = held_base.max(clamp)), updatesResourceDesc::from_levelto usemip_count(self), stopswant_level()atbase_level.max(clamped_mip)without thrashing, and re-checksno_mip_clampafter OOM retry.Stagingvia(serial, on_demand, level0, mips, host_width, host_height)without downgrading upgraded entries or missing BC tail/NPOT block-aligned footprints.adjust_srv_for_base_mipfor bothTexture2DandTexture2DArrayand wiresensure_unclamped+ ABA-safePendingUnclampdeferred SRV rebinding acrosscopy_resource,copy_texture_region,read_back, andresolve.host::vram_keep(<78%->600s,78..85%->30stoward75%,85..90%->3stoward82%,>=90%->1stoward82%).descriptor::host::keep_shown()via side-effect-free 100 ms cachedresource::room_raw_lately()so replaced stale textures stop pinning descriptor COM references under VRAM pressure while preserving explicitVICTORY_KEEP_SHOWNoverrides andKin::Same.Verification (
VICTORY_D3D12_DEBUG=1,VICTORY_D3D12_WARP=1,VICTORY_REAPER=1)cargo run -p xtask -- policy:asset policy: 264 files okcargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default &--features diagnostics): 0 warningsdescriptor::host::mip_clamp_and_evict_kept_tests(4/4): SRV 2D/2DArray shifting,evict_kepttitle + untaken dynamic slots, 240-frame cooldown acrosstexture_slots_room,keep_shownVRAM gatingresource::tests::{mip_clamp_policy_*, in_flight_fenced_*, fence_completed_lru_*, mip_clamped_textures_*, held_only_and_auto_mip_clamp_*}(5/5,>=19 MiBmeasuredGetResourceAllocationInfosavings per clamped 2K RGBA8 / 4K BC7 texture on host & WARP)texture::allocation_costs::bc7_tail_mip_staging_hits_cache_without_rebuilding(1/1,Arc::ptr_eqhit on 64x64 BC7 tail mip & 100x100 NPOT BC7)host::tests::textures_are_kept_while_the_card_has_room(1/1)VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu -- --test-threads=1: 380 passed; 0 failed; 34 ignoredVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 432 passed; 0 failed; 34 ignored +replay1 passed; 0 failed1e710c4bbetocf994641cd@Vladimir-Human on GitHub · 2026-11-26 14:11 UTC · original
Rebased cleanly onto latest
main(c9c932c:port/guard+port/journal+ README) atde0175d+cf99464and applied the bindlessHostHeapLRU eviction fix (following@Garu667's isolation onfxceless/victory-fork#1289):de0175d): Resolved the 1-filecrates/victory-gpu/src/host.rsconflict (514,966 B < 512 KiB), preservingport/journal(3406192)needed()/heaps_waitedaccounting acrossneeds_submit_maintenance(), and clearedclippy::unnecessary-mut-passedinwatch.rs:title_memory_remapped.HostHeapfix (cf99464,crates/victory-gpu/src/resource.rs):HostList::stamp_textures()only stamps barrier-tracked textures, not bindless textures pinned in shader-visibleHostHeaps. Gatedallow_heap_unmakeinevict_if_pressured()strictly behind opt-inVICTORY_TEXTURE_LRU_HEAP_EVICT=1(lru_heap_evict_enabled(), default OFF) and skipped arming/readingNEED_HEAP_EVICTwhen disabled, while preserving defaultrefs == 1fence-completed LRU eviction,VICTORY_TEXTURE_AUTO_MIP_CLAMP,host::vram_keep, anddescriptor::host::keep_showngating.resource::tests::default_lru_eviction_never_evicts_host_heap_pinned_bindless_texturesand re-verifiedxtask policy(265 files ok),cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default &--features diagnostics:0warnings),VICTORY_D3D12_DEBUG=1 VICTORY_D3D12_WARP=1 VICTORY_REAPER=1targeted tests (11/11 passed), andVICTORY_D3D12_DEBUG=1victory-gpu(392 passed; 0 failed; 34 ignoreddefault;444 passed; 0 failed; 34 ignored+replay1/1with--features diagnostics).@Vladimir-Human on GitHub · 2026-11-26 17:22 UTC · original
Updated
perf/texture-vram-lru-mipcaptoa811586(mergeable atopmainc9c932c):Summary
VICTORY_KEPT_VIEWS_YIELD=1): Trackskeepingslots wherekeep_views()retained an older copy while a sharper view waits, clearskeepingonkeep(),unmake(),texture_slot_flip(), andHostHeap::drop(KEEPING_SLOTS_TOTAL), and invokesyield_kept_views()under VRAM pressure (!room()orwant > 0) to free stale superseded copies without touching active non-superseded 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 (
a811586,VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1)cargo xtask policy: 265 files ok;clippy(default &diagnostics): 0 warningsdescriptor::host::(47/47),resource::(22/22)victory-gpu --lib: default400/400(34 ignored),diagnostics452/452(34 ignored)a811586070to7e607f56e6@Vladimir-Human on GitHub · 2026-11-27 07:17 UTC · original
Rebased cleanly onto latest
main(014d52d: RX 9070 XT fixes, submission-prelude texture uploads, port 1 ordering, and port RT) at912e560->80f1031->7e607f5:descriptor/host.rs: Preservedkeep_shown()gating through side-effect-freeresource::room_raw_lately()(avoiding calling side-effectingresource::room_lately()underHostHeapMadeshard locks while preserving explicitVICTORY_KEEP_SHOWNoverrides) and unifiedfrom_base(desc, base, own_mips)ontoadjust_srv_for_base_mip.resource.rs: Preserved upstreamover_cap(VICTORY_TEXTURE_MAX) insidebase_level(desc, first, allow_cap)while respectingr.host.no_mip_clamponensure_unclamped.host.rs(522,452 B < 512 KiB): ExtendedHostList::stamp_texturesto also stampStep::Texture(upload)prelude-uploaded copies (after releasingself.states) and added#[cfg(test)] flush_retired_for_test()in LRU test setup sobury_lagdeferred COM refs from earlier tests cannot drop mid-test.VICTORY_D3D12_DEBUG=1 VICTORY_REAPER=1):xtask policy272 files ok;clippy -p victory-gpu --all-targets -- -A deprecated(default &diagnostics) 0 warnings in touched files; default HWtexture:: resource:: descriptor:: tiles:: shadow:: textures_are_kept123 passed; 0 failed; 5 ignored; WARPdiagnosticsresource:: descriptor::host:: texture::allocation_costs:: textures_are_kept72 passed; 0 failed; 3 ignored.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.