victory-gpu/hle: opt-in ReBAR, VRAM LRU, SEC_COMMIT L0 views, RT skin_hair skip & VRAM/L0/RAM leak fixes #3503
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3503"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by Rulemore on 2026-11-30T00:08:13Z.
Summary
This PR adds opt-in ReBAR / VRAM LRU /
SEC_COMMITzero-copy L0 / selective RT-skip modes and fixes a set of concrete VRAM, Shared L0, and Host RAM leaks acrossvictory-gpuandvictory-hle. All new modes are strictly opt-in behind switches; existing upstream defaults (VICTORY_LAZY_TWINS,VICTORY_SPARE_SCALE,VICTORY_CARD_CPU_HEAP, etc.) are left unchanged.Part 1 — Opt-In ReBAR, VRAM LRU,
SEC_COMMITL0 & RT Skip ModesD3D12_HEAP_TYPE_GPU_UPLOAD) Routing (shadow.rs,host.rs,xmem.rs)VICTORY_RO_BAR=1: routes GPU-read-only buffers intoGPU_UPLOADReBAR memory.VICTORY_CARD_BAR=1: hybrid ReBAR routing forCardbuffers overlapping GPU-RO memory (direct BAR writes on 64 KiB-aligned RO pieces, staged RW tail for exact GPU compare hashes).VICTORY_WINDOWS_BAR_MB) and propagates write-combined tracking acrossxmemplaceholder splits andVirtualProtect.TAKEN_OVERDescriptor Rebinding (shadow.rs,descriptor.rs)VICTORY_CARD_WINDOWS_IDLE_MSandVICTORY_CARD_BUFFERS_IDLE_MS: demotes cold VRAM windows/buffers (>= 1 MiBfor buffers under VRAM pressure) back to L0 and promotes hot copies back to VRAM, rebinding stale descriptor slots viadescriptor::rebind_taken_over().SEC_COMMITXMem Section Views (xmem.rs,inplace.rs,shadow.rs,draw.rs)VICTORY_XMEM_COMMIT_SECTIONS=1: allocates physical sections inSEC_COMMITchunks (default 256 MiB viaVICTORY_XMEM_CHUNK_MB) and cachesOpenExistingHeapFromFileMappingL0 views for zero-copy placement.pipeline/make.rs)VICTORY_RT_SKIP_DEAD=no_vbufferandVICTORY_RT_SKIP_DEAD=skin_hairmodes so dead BVH skin/hair builds can be skipped while preservingCS_ScreenProbes_TraceRaysandCS_RaytraceVBufferreflections (no black ponds/glass).Part 2 — Safe Memory Leak & Non-Release Fixes (Defaults Preserved)
resource.rs: Fixed deadNEXT_DEAD_RT_SWEEPcondition (!r.host.placed→matches!(r.backing, Backing::Committed(_))) and addedTwinArc::strong_count == 1+ COMreferences == 1safety checks.pool.rs: Capped empty blocks inSMALL(<= 64 KiBtexture pool) totexture_limit.min(SPARE)and disabled 12-blockRipepre-allocation onSMALL(saving up to 704 MiB VRAM).shadow.rs:BUFFERSduringlet_go_idle()(guarded byplace.is_none() && card.is_none() && !mapped && !written && !has_pending && Arc::strong_count == 1 && references == 1, two-phase read→write lock soBUFFERS_CHANGEDonly bumps on actual evictions).trim_snapshot_pool()to shrink retainedPOOLsnapshots (up to 512 MiB) down to 32 MiB (0under pressure).EXACT.mapintrim_exact_pool().Arc::strong_countguards todemote_idle_card_buffers/promote_hot_buffers, missingself.forward(...)inShadow::shader_writes(), andany_taken_over()trigger forrebind_taken_over().descriptor.rs,descriptor/host.rs,sampled.rs:View::Constantslots (HostHeap::constants) sorebind_taken_over()releasesTAKEN_OVERshadows pinned inHostHeap::kept.[1]and[13]inSpans::bytesto prevent unboundedHashMapgrowth from console stack garbage.sampled::clear_evicted()(on slot overwrite) andsampled::forget_heap()(onHeap::drop).texture.rs,texture/ahead.rs,host.rs,procmem.rs,xmem.rs,dstorage.rs:READbuffers back to 4 MiB, capped staging idle timeout to 30 s (10 sunder pressure) + drainedSPARE_LINEARunder pressure, retired outgrownshared_zerosinstead of leaking into aVec, clearedTHROUGHinunstage(), cleaned up orphanoncestaging inahead::claim, drainedSPARE_SHARED+uav_poolinfree_all_spares(), ran 10 sSPARE/SPARE_SHAREDtrim unlessVICTORY_ALLOCATOR_TRIM=0, addedprocmem::section_gone()inxmem::Section::drop, and guardedWALLS_FILESwithwalls_trace() > 0.Verification
cargo test -p victory-gpu --lib -- --test-threads=1(including new tests forVICTORY_RO_BAR,VICTORY_CARD_BAR,VRAM LRU,sampled::clear_evicted/forget_heap, andtrim_snapshot_pool): 932 passed, 0 failed.cargo test -p victory-hle --lib -- --test-threads=1 xmem::tests dstorage: passed.cargo xtask policy --staged: passed on all modified files.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T10:31:22Z.
I tested a pressure-only version of the exact-view sweep on main at
41adb55. The existing sweep drains the recycle pool under pressure. A scene can leave idle entries inEXACT.maptoo, because lookup pruning requires at least 256 entries and another miss. The forced scan here addresses that. Running it on normal ticks can also move reusable views into quarantine, so I tried keeping normal cache hits and forcing the map sweep only while the existing host-pressure signal is on.The small companion patch shares the pruning guard and the existing age, Arc and COM checks. It removes eligible views under the lookup lock, then hands them to
host::retireafter unlocking. The normal submission watermark and deferred release still apply.On an RTX 4060, a standalone fixture held an idle 16 MiB committed L0 view. With simulated pressure, DXGI non-local usage stayed at 108 MiB on main and fell from 108 to 92 MiB with the patch. The ordinary tick kept the view, and the pressure tick kept a freshly used view, one held by a list reference, and one held by a descriptor reference. The fixture ran with
VICTORY_BURY_LAG=0and no submissions in flight to measure the release. It also passed on WARP. The focused diagnostics suite passed 73 tests.One-file commit against main
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:51:37Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed