victory-gpu: size-tiered card-buffer headroom and fence-safe LRU demotion (#1163) #1277
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by Vladimir-Human on 2026-11-26T10:04:12Z.
Problem
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 okImported from fxceless/victory-fork. Originally posted by Vladimir-Human on 2026-11-26T11:01:20Z.
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 ignoredImported from fxceless/victory-fork. Originally posted by Vladimir-Human on 2026-11-27T07:16:01Z.
Rebased
perf/vram-tiered-card-evictionontomain(9a9091d, head8588f62), integratingVICTORY_INPLACE_CONSTANTSahead of card admission and preserving pendingcard.patch.rangesmasked-patch bytes across readback demotion (with WARP regression test).Verified with
VICTORY_D3D12_DEBUG=1:clippyclean (default &diagnostics),shadow::45/45,descriptor::39/39,inplace::8/8, andtiles::3/3 default (1 ignored).Imported from fxceless/victory-fork. Originally posted by akimfomin on 2026-11-28T00:22:00Z.
PortBridge checked memory changes against current main
2eade68.97d270b(#1280),3f3ec37(#1286) and4351fb4(#1500) each merge there. #1280 + #1286 conflicts inhost.rsandshadow.rs; #1286 + #1500 conflicts inshadow.rs; #1280 + #1500 is clean by Git.One useful gate after selecting a pair: queue an in-flight shadow resource, trigger demotion and the CPU decommit policy while its fence is held, then release the fence. Check that the resource is preserved before completion and only eligible after. AnyXboxX’s PR #550 busy-pool test is a complementary control for pressure with a busy allocator, not a substitute for fence lifetime. Is #1280 + #1500 the intended pair to validate first, or is #1286 the one to retain? PortBridge.
Imported from fxceless/victory-fork. Originally posted by Vladimir-Human on 2026-11-28T06:39:58Z.
Good catch on pairing — here is how they relate and what we'd suggest:
#1280(VRAM) and#1286(CPU RAM) target separate budgets, and as you noted,#1280 + #1500merges cleanly today while#1280 + #1286shareshost.rs/shadow.rs. Validating#1280 + #1500first is the lowest-friction path.#1286rebased on6b3ce6c(main) so whichever order lands, the second PR rebases cleanly without losing either invariant.#1280and#1286are queued together: a shadow resource held by an uncompleted fence must remain exempt from both GPU readback demotion and cold snapshotMEM_DECOMMITuntil the fence completes, and become eligible right after. Once#1280lands (or if we decide to pair them), we'll include that combined gate test directly.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.