victory-gpu: drop idle TEXTURES and SMALL pool spares over VRAM budget and critical commit #2038
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2038"
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 superhero-520 on 2026-11-29T08:06:42Z.
Summary
Rebased cleanly onto
v2026.11.29.05(41adb551), reusing upstreamSPARES,Pool::with_budget,STAGING_SPARES, andBUFFER_SPARES, while closing the remaining over-budget / critical-commit spare-heap retention gaps for bothTEXTURESandSMALLdedicated-VRAM texture pools.Root Cause
v2026.11.29.05,SPARESdefaults to2(128 MiB of 64 MiBID3D12Heapblocks per pool) and only shrinks whenresidency::pressured()is true (1spare = 64 MiB per pool) or via explicitVICTORY_TEXTURE_SPARES=0.used >= budget, common on 6 GiB GPUs such as RTX 3060 Laptop with a ~4.7–5.2 GiB local budget) or OS commit hitsresidency::critical_commit(), empty 64 MiB heaps inTEXTURES(andSMALL, when enabled) remain retained instead of being returned to D3D12/WDDM.VICTORY_RIPE_BLOCKSis enabled,Ripealso continued pre-allocating ahead heaps while VRAM was over budget.Scope &
SMALLPool Activation Notesapps/victory/src/play.rssetsVICTORY_POOL_SMALL=0, soSMALLallocates 0 heaps in default configurations; the maximum empty-spare ceiling under default settings is2 × 64 MiB = 128 MiBinTEXTURESalone.VICTORY_POOL_SMALL=1(or unset outsideplay),SMALLalso allocates 64 MiBID3D12Heaps for 4 KiB-aligned small textures and sharesSPARESwithTEXTURES(combined empty-spare ceiling256 MiB).Fix Design (
crates/victory-gpu/src/pool.rs)TEXTURES&SMALL):VRAM_TIGHT/next_vram_tight()latching atused >= budgetand clearing only below95%of budget to prevent release/reallocate oscillation near the budget boundary.texture_spare_limit()returns0whenresidency::critical_commit() || vram_tight,1under host memory pressure (matching upstream), and normalSPARESotherwise — applied to bothTEXTURESandSMALLwhile leaving host-sideSTAGINGandBUFFERspare budgets unaffected by local VRAM pressure.limit == 0(no thrashing):reclaim()intorelease_ready()(GPU-fence-safe retirement afterRESTframes) andtrim_empty() -> Vec<B>.Pool::cut(), a newly retired empty block is reused first (composing with upstreamfullest_first()) before any excess empty blocks are trimmed.room()andtake_from_with_growth()collect evictedVec<B>under the mutex and drop the D3D12 heaps outside the lock.Ripe.prefer_ripefromRipe.aheadsoVICTORY_RIPE_BLOCKSstops spawning speculative ahead heaps when VRAM is tight or commit is critical.Verification & Results
Automated & Real D3D12 Tests (RTX 3060 Laptop 6 GiB, Windows 11, D3D12 debug layer)
cargo test --locked -p victory-gpu --lib pool::tests:: -- --nocapture --test-threads=1: 36 passed, 0 failed, 3 ignored (0.69s):d3d12_over_budget_and_critical_commit_reclaim_textures_and_small_pools:TEXTURESretained heaps3 (192 MiB, empty=2)->1 (64 MiB, empty=0); reuse-at-zero new heaps= 0; cross-pool critical commit (TEXTURES + SMALL,4KiB_small_align=true): empty after= 0 + 0; debug layer errors:None.d3d12_over_budget_ripe_blocks_stops_ahead_heap_allocations: ahead heaps1 (retained=2, 128 MiB)->0 (retained=1, 64 MiB).d3d12_concurrent_zero_spare_allocation_and_reclaim_is_safe: 4 threads × 16 placements, drained cleanly to 0 afterREST, debug layer errors:None.cargo clippy --locked -p victory-gpu --all-targets&--all-features: 0 warnings inpool.rs.cargo check --profile diag --locked -p victory --features diagnostics,cargo test --locked -p victory,cargo build --release --locked -p victory,cargo run --locked -p xtask -- policy --staged: all passed.victory-gpu --libsuite: 928 passed, 2 pre-existing unrelated failures already present on untouched41adb551(shared_root_signatures_load_from_library_and_execute_across_pso_switchesmissingdxcompiler.dllin test CWD, andevery_switch_of_the_translator_is_in_the_keystaleVICTORY_SCALAR_SPLITS).Live Gameplay Smoke & Regression Check (RTX 3060 Laptop 6 GiB + Ryzen 7 5800H + 16 GB RAM)
960×540-> DLSS Performance (Model K) -> output1920×1080, RT OFF, warm pipeline library (4,972loaded,0in-world slow loads).D1):5.86 FPS(log 6.61 FPS), 0 OOM, 0 device-removed; combined with PR #2015 (E1):6.63 FPS(1% Low 2.10,P99 391.4 ms), 0 OOM, 0 device-removed (baselinev2026.11.29.053-run mean:5.68 FPS).D-fsr2&E-fsr2): FSR 3 swap chain active with0failed prepare dispatches,0OOM,0device-removed;E-fsr2matched baseline rendered FPS (6.62vs6.61 FPS) with lower P99 (386.0vs460.6 ms).Limitations & Known Risks
AI Assistance Disclosure
AI-Assisted: Rebased, refined, tested, and documented with AI assistance (Antigravity / Gemini), with all D3D12 tests, clippy/policy checks, and live hardware runs verified on local RTX 3060 Laptop hardware.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T06:35:37Z.
I reproduced an in-flight case on
b18a0ae. If a texture take starts making an ahead heap, thenroom()sets the spare limit to zero and finishes its sweep before the driver returns, the take still inserts the newly empty heap. In the deterministic regression the requested piece was valid, but the pool retained one empty block after the zero-spare sweep.Cherry-pickable fix. It rechecks before asking the driver and checks the pool's current spare limit before keeping the result. At zero it returns the requested piece and releases any completed ahead heap outside the pool mutex. The regression fails with one empty block on the PR head and passes with zero on the fix.
Windows 11, RTX 4060 8 GiB, driver 621.14. The pool test filter reported 37 passed, 0 failed, 3 ignored, including the existing real D3D12 cases. The existing over-budget test dropped its pool footprint from three retained heaps to one (192 → 64 MiB). That is heap accounting in a test with synthetic pressure. Gameplay VRAM and frame times remain unmeasured.
DXGI follow-up: I instrumented the same D3D12 test with #3766 stacked locally. In three fresh processes,
DXGI_MEMORY_SEGMENT_GROUP_LOCAL::CurrentUsagefell from 213,327,872 to 79,110,144 bytes immediately after dropping the two heaps (exactly 128 MiB). Usage stayed at that level after 250 ms and 1 s, and the budget was unchanged. The pressure trigger was simulated; the heaps and DXGI queries were real. This measures the driver-reported local usage for that test case. In-game savings still depend on whether whole heaps become empty along the route.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by tyr0nsur on 2026-11-30T09:42:26Z.
The same empty heaps can be reclaimed before the full DXGI budget is reached.
VICTORY_ROOM_REALcan already stop the texture queue at budget minus 256 MiB. With a synthetic 5,092 MiB budget and 4,882 MiB usage, the current pool policy still retained two empty heaps. The regression failed at that point before the change.Follow-up cd7d849, stacked on the previously posted
53e9d89ahead-heap fix, uses the queue’s raw line for entry. Recovery waits until there is room for both pools’ ordinary spares and keeps the existing 95% ceiling.VICTORY_ROOM_REAL=0retains budget-level entry and the original recovery rule. The texture pools still reclaim only fully empty heaps after the existing retirement delay.On RTX 4060 the regression dropped two real 64 MiB D3D12 heaps, keeping the live heap. The test process’s DXGI local usage went from 203 to 75 MiB immediately. The pressure input was simulated, and the heaps and driver query were real. The Windows pool/resource suite passed (82 passed, 4 ignored), the three focused tests passed under WARP, and staged asset policy passed. Live benefit depends on how often a route leaves whole heaps empty.
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.