victory-gpu: size-tiered card-buffer headroom and fence-safe LRU demotion (#1163) #1280
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/fxceless--victory-fork!1280
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1280"
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 10:04 UTC · original
Vladimir-Human:perf/vram-tiered-card-eviction→main· +2069 −149 · 4 files · 1 commits · openProblem
Closes / addresses #1163 and 8–12 GB VRAM starvation:
VICTORY_CARD_BUFFERS_MIN_KB=64is combined withVICTORY_CARD_BUFFERS_MB=1024(or smaller caps such as512MiB), thousands of small< 1 MiBbuffers fill the flat card-buffer cap first and starve hot>= 1 MiBbuffers back to PC RAM (100–122.6 MB/frameCPU compare and severe GPU slowdown).Changes
crates/victory-gpu/src/shadow.rs):VICTORY_CARD_BUFFERS_MIN_KB < 1024, reservesmin(256 MiB, cap / 3)(env-tunable viaVICTORY_CARD_LARGE_RESERVE_MB;0disables) insideVICTORY_CARD_BUFFERS_MBfor>= 1 MiBbuffers so small-buffer floods cap atcap - reserve(CardAdmit::ReservedForLarge).< 1 MiBcard admissions above85%DXGI local video memory without inflatingCARD_REFUSED[1], keepingcard_room_kept()intact for upcoming>= 1 MiBbuffers.crates/victory-gpu/src/shadow.rs,host.rs,descriptor/host.rs):(used, access_tick), GPU flight fences (last_fence: AtomicU64, stamped inHost::submit), and UAV/shader write state (Card::gpu_written).< 1 MiBcard buffers back to host RAM (never touching hot>= 1 MiBbuffers) when:>= 1 MiBbuffer hitsCapFullorDxgiPressure(computes exact shortfall, skips futile partial demotion, runs up to 4 bounded 16 MiB batches, and re-validatesentryafter re-acquiringBUFFERS), or>= 88%(VICTORY_CARD_PRESSURE_PCT, targeting84%hysteresis) inHost::sweep, recording freed bytes inCARD_PRESSURE_RELEASEDsoused + card_room_kept()inresource::room()genuinely drops for texture streaming.Arc::strong_count == 1,host::references(&shadow.buffer) == 1,pending.is_empty(), andlast_fence <= completed_fence(+ unchanged fence across readback) aftertables_changed().Host::demote_readback(serialized by a narrow leafQUEUE_SUBMITmutex, using transient L0 staging dropped immediately after readback, withDemoteCopyreset and Win32 eventCloseHandleon drop) and merging all bytes outsidecard.dirtyintocard.stagingbefore promotingcard.stagingtoshadow.buffer. Opt-out viaVICTORY_CARD_DEMOTE=0.shadow.rs,host.rs):card_demoted_count,card_demoted_bytes, andcard_reserved_large_rejectsviacard_tier_stats()and the periodic card-buffer log line.Verification
shadow::vram_tier_tests::*):small_buffer_flood_cannot_starve_large_buffers_with_tiered_reservedxgi_pressure_target_reclaims_headroom_on_8gb_and_12gb_cardscard_room_kept_and_admit_shortfall_preserve_vram_accounting_invariantswarp_small_buffer_flood_reserves_headroom_and_demotes_for_large_bufferswarp_demotion_preserves_exact_bytes_across_gpu_writes_and_cpu_dirty_rangeswarp_demotion_never_evicts_inflight_or_referenced_card_bufferswarp_dxgi_8gb_and_12gb_pressure_demotes_cold_small_and_keeps_hot_largeVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu vram_tier_tests -- --test-threads=1: 7 passed; 0 failed (0 D3D12 debug errors)cargo test -p victory-gpu -- --test-threads=1: 219 passed; 0 failed; 6 ignoredcargo test -p victory-gpu --all-features -- --test-threads=1: 237 passed; 0 failed; 7 ignoredcargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated&--all-features: 0 warnings/errors in modified files (3 pre-existingAtomicU32::fetch_updatedeprecations in untouchedobject.rs)cargo run -p xtask -- policy:asset policy: 220 files ok@Vladimir-Human on GitHub · 2026-11-26 11:01 UTC · original
Rebased cleanly onto latest
main(06702fe, commit9418259) and added one safety hardening fix:tiles.rsUpdateTileMappingsserialization: exposedhost::queue_lock()(narrow leaf mutexQUEUE_SUBMIT, strictTiled::given -> QUEUE_SUBMITordering) and held it aroundqueue.UpdateTileMappings(...)inTiled::give_lockedso every directHost::queueoperation (ExecuteCommandLists,Signal,Wait,UpdateTileMappings) is serialized against concurrent card-demotion readbacks.Re-verified on
06702fecargo run -p xtask -- policy:asset policy: 220 files okcargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated(default &--all-features): 0 warningsVICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --lib vram_tier_tests -- --test-threads=1: 7 passed; 0 failed (0 D3D12 debug errors)cargo test -p victory-gpu -- tiles --test-threads=1: 4 passed; 0 failed; 1 ignoredcargo test -p victory-gpu -- --test-threads=1: 220 passed; 0 failed; 6 ignoredcargo test -p victory-gpu --all-features -- --test-threads=1: 239 passed; 0 failed; 7 ignoredView 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.