victory-gpu: size-tiered card-buffer headroom and fence-safe LRU demotion #347
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/347"
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-26T10:37:28Z.
Summary
Opt-in (
VICTORY_CARD_DEMOTE=1, default OFF) tiered card-buffer headroom and fence-safe readback demotion rebased onto currentmain(132da61, preserving#563+#564). Ported fromfxceless/victory-fork#1280(97d270b) andavatarmanz/VIctory-7900XTX#180.Review Fixes & Design Notes
VICTORY_CARD_DEMOTE=1, default OFF): Demotion, large-buffer reserve, and small-buffer admission limits only activate for1/true/on. When off,Host::sweepnever enters readback demotion.Budget::released(shadow/card_budget.rs): Pressure demotion transfers released bytes to reusable credit consumed only when a new local card buffer allocates room, tested across repeated cycles (pressure_demotion_then_reuse_restores_card_room).host/demote.rs): ReplacedWaitForSingleObject(INFINITE)withDEADLINE_MS = 250; timeouts or wait failures log viatracing::warn!, skip demotion cleanly, and keep staging + sources pinned inDemoteCopy::pendinguntilfenceproves completion.CopyBufferRegionstate audit: Stamped/serialized auxiliary submit paths (Host::submit,upq::send,upcheck::run,stamps,tiles::UpdateTileMappingsunderqueue_lock()). Indemote_readback_inner, both device-local UAV source and custom L0 write-back staging buffers start/decay toD3D12_RESOURCE_STATE_COMMON, so standaloneExecuteCommandListsimplicitly promotes toCOPY_SOURCE/COPY_DESTand decays back toCOMMON.Source:/Co-authored-by:trailers and a French row inTHIRD_PARTY.md.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):shadow::card_budget::tests: 3/3 passedhost::demote::tests: 3/3 passedshadow::card_tier::tests: 1/1 passedshadow::compare_piece_tests: 2/2 passedshadow::: 68/68 passed (6 ignored)host::: 181/181 passed (19 ignored)tiles::: 4/4 passed (2 ignored)Checklist
Source:/Co-authored-by:trailers +THIRD_PARTY.mdrow)VICTORY_CARD_DEMOTE=1required to activate) + bounded 250 ms waitreleasedbudget test + submit-path &CopyBufferRegionauditImported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T14:43:02Z.
For information: I tried this PR in an integration build on
mainat2cc6593(after #358 and #377), stacked with #354, #345 and my #278, #279, #292, #307, #360-#362, #381 and #382. It no longer applies tomain. The conflicts are in what the code does, not just neighbouring lines: host.rs (3:QUEUE_SUBMITandcard_sent_lockedaround the same Execute/Signal calls #354 changes for its fence stamping), shadow.rs (2:note_access/note_gpu_writtennext to #377's sanitizer, and the buffer copy's construction). I left it out of that build rather than guess at the merge. A rebase on currentmainwould let it in the next one.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T15:12:39Z.
@Skyfrye Rebased onto current
main(26c11d4, post-#358/#377/#367/#383; new head00109da):shadow.rs: preserved#377(0b0deab,VICTORY_CLAMP_AFTER_WRITERsanitizer) ahead ofnote_access()/note_gpu_written()inShadow::gpu_writes, switched buffer creation to#340'snote_carded(&shadow)(Card::me/FLAGGED), and preservedCard::printsalongside the tiered admission / LRU demotion logic.host.rs&tiles.rs:QUEUE_SUBMIT/queue_lock()remains wrapped strictly around directHost::queueExecuteCommandLists/Signal/UpdateTileMappingscalls (if stacked with#354, fence stamping inside those sameExecuteCommandLists+Signalcritical sections can stay inside the existingQUEUE_SUBMITscope).cargo xtask policy(214 files ok),cargo clippy -p victory-gpu --lib --tests(0 new warnings), andVICTORY_D3D12_DEBUG=1victory-gpu --lib(shadow::45/45 incl. allvram_tier_tests,tiles::3/3; default &diagnosticsruns show only the 3 pre-existingmainfailures indescriptor::host::tests::spans_say_the_next_start_and_the_lowest_level_viewedandindirect::tests::warp_card_*).Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T19:11:25Z.
Rebased onto
main(50936c0->18e7731, keeping #429'shost::queue_lock()+runs.len() == 1fast path intiles.rs).Verified locally:
cargo xtask policy(215 files ok),cargo clippy -p victory-gpu --features diagnostics --all-targetsexit0;tiles::7/7(1 ignored,VICTORY_D3D12_DEBUGunset) andshadow::45/45passed (descriptor::30/31with 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:18Z.
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#180(andfxceless/victory-fork#1280); 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:06:44Z.
Rebased onto latest
main(b62053f, updatedthird_party/victorybase) inf5a3fb5:remaining_card_roomaccounting ontob62053f, keepinghost.rslean viahost/demote.rs.Present,ResizeBuffers(withsettle_nowoutside), andCreateSwapChainForHwndunder leafQUEUE_SUBMITagainst concurrentdemote_readbacksubmissions, checkedWaitForSingleObject == WAIT_OBJECT_0, and deferred retirement ofDemoteCopy/staging/srcsviaretire_after_nexton post-ExecuteCommandListsfailures.--features diagnostics,VICTORY_D3D12_DEBUG=1,--test-threads=1):clippyclean on touched files;xtask policy(290 files ok); HWshadow::51/51 (3 ignored),tiles::3/3 (1 ignored); WARPshadow::vram_tier_tests7/7.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T21:24:05Z.
Thanks for rebasing. Before an in-game test:
Source:/Co-authored-by:trailers andTHIRD_PARTY.mdhas no row for it. Please add both.CARD_PRESSURE_RELEASED(shadow.rs:320) is only ever increased (:1100) and is subtracted from the room at:650, so each pressure demotion shrinks the card room for the rest of the session. Please decrement it when the room is reused, or recompute it, and add a test where a demotion followed by reuse returns the room to where it was.VICTORY_CARD_DEMOTE=0, the large-buffer reserve is on, andHost::sweepnow does a GPU readback withWaitForSingleObject(INFINITE)(host/demote.rs). With no before/after fps or VRAM numbers, please make demotion opt-in until it is measured, and give the wait a deadline (log and skip on timeout).last_fenceis stamped on every submit path (not onlyHost::submit; also the tile and copy submits), and state the resource state assumed by theCopyBufferRegionindemote_readback_inner(no barrier is issued).This also conflicts textually with #549 and #350 in
shadow.rs/host.rs.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T07:28:44Z.
Rebased onto
main(132da61, preserving#563ȴ) and addressed all four review points at commita23f106:Source:/Co-authored-by:trailers referencingfxceless/victory-fork#1280andavatarmanz/VIctory-7900XTX#180, plus a French row inTHIRD_PARTY.md.shadow/card_budget.rs): Replaced monotonic subtraction with reusableBudget::releasedcredit that is only reclaimed when a new local card buffer allocates room; verified withshadow::card_budget::tests::pressure_demotion_then_reuse_restores_card_roomacross repeated demotion/reuse cycles.host/demote.rs,shadow/card_budget.rs): Made card demotion, the large-buffer reserve, and the small-buffer admission limits opt-in (default OFF) viaVICTORY_CARD_DEMOTE(1/true/on). With it off,Host::sweepskips readback demotion completely. ReplacedWaitForSingleObject(INFINITE)withDEADLINE_MS = 250: on timeout or failure it logs viatracing::warn!, skips demotion, and keeps staging + source references pinned inDemoteCopy::pendinguntilfencecompletion is observed (tested inhost::demote::tests).Host::submitstamps main-queue submits (including card compare, preludes, placed copies);card_back,upq::send,upcheck::run,stamps, andtiles::UpdateTileMappingsstamp/serialize viaqueue_lock()/ auxiliary fences so demotion never races an in-flight copy. Indemote_readback_inner, both buffers are D3D12 legacy buffers created inCOMMONand decay back toCOMMONafterExecuteCommandLists, so standalone submission implicitly promotes source toCOPY_SOURCEand staging toCOPY_DESTbefore decaying again.Verified locally on HW & WARP after the final edit:
cargo xtask policy(380 ok), hunk-accurateclippy(default &diagnostics: 0 own warnings),card_budget3/3,host::demote3/3,card_tier1/1,compare_piece_tests2/2,shadow::68/68,host::181/181,tiles::4/4. Gameplay VRAM/FPS remains unmeasured.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.