perf(victory-gpu): virtualize card staging mirror and release texture CPU staging post-upload #392
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/392"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T13:07:48Z.
Refs: #276
Summary
Reduces host RAM and Windows virtual commit footprint on 16 GB–32 GB systems without relaxing GPU fence lifetime or readback correctness:
Lazy / virtualized
Card::stagingCPU mirror (shadow.rs,host/send.rs,host.rs,host/upcheck.rs):send::own()(VICTORY_SEND_OWN != 0) and withoutVICTORY_UPCOPY_CHECK=1, replaces eager permanentID3D12Resourceupload mirrors (host.shared_buffer_staging) on card-resident buffers (lookup,by_address,by_address_in,loose) withCardCpu::Virtual(CardMirror): an anonymousVirtualAlloc(MEM_RESERVE)reservation committed lazily in 64 KiB (PAGE) chunks only when written/copied.MEM_RESERVEonly), reading as zero incopy_out/sync_range_to/card_helduntil first touched, and allocate a D3D12 staging fallback resource lazily (CardMirror::ensure_staging) only when anown.is_none()copy or diagnostic fallback actually requires one (VICTORY_CARD_LAZY_STAGING=0restores eager allocation).send::takepass_asidetrigger until non-zero word transfers are observed (total_words > 0) so pureCopyBufferRegionsends do not unnecessarily force eagerID3D12Resourcecard staging allocation.Fence-safe post-upload release of texture
CpuStagingandpool::STAGINGblock sizing (texture.rs,texture/ahead.rs,pool.rs,host.rs,host/prelude.rs,texture_detile_tests.rs):OnceLock<CpuStaging>intexture::Stagingwith releasableMutex<Option<Arc<CpuStaging>>>, reference-countedUploadGuard, andpending_uploads: AtomicU32tracked acrossHostList::hold(prelude_uploads,claim_hoisted, directupload_from) and copy-queuetexture::ahead::Jobs.Staging::cpu(returningStagingPieceback topool::STAGINGor freeing dedicated upload buffers and updatingSTAGEDaccurately inCpuStaging::drop) immediately when the final in-flight GPU fence retires (HostList::reset()/ post-SetEventOnCompletioninahead::finish) wheneveruploaded && !dirty, while lazily re-acquiring and refreshingCpuStagingif title memory changes later.CpuStagingallocation for linearmovie_planestaging entries.pool::STAGINGblock size (16 MiBon<= 18 GiB,32 MiBon<= 32 GiB,64 MiBabove) and idle spare retention viaSTAGING_SPARES(separate from VRAMTEXTURESspares), packing allocations withfullest: true.Verification
cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib -- --test-threads=1: 844 passed, 0 failed, 39 ignored (matching CI serial execution; includes new tests inshadow::card_staging_tests,pool::tests, andtexture_detile_tests).cargo +1.98.1-x86_64-pc-windows-gnu clippy -p victory-gpu --all-targets -- -D warnings: passed with zero warnings.cargo +1.98.1-x86_64-pc-windows-gnu clippy -p victory-gpu --all-targets --all-features -- -D warnings: passed with zero warnings.cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings: passed with zero warnings.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T13:33:22Z.
Triage (
bd171f16, CIcheckPASS):#40Rank 1 & Rank 2 memory work (+1,025/-286across 9 files: virtualizedCard::stagingmirror undersend::own()+ post-uploadCpuStagingrelease).#282) + Gate 3 plain--releaseA/B (FPS,private_commit_mb,working_set_mb,0crashes/DRED) +--features diagnosticsvisual PNG check.