GPU: opt-in mip cap (VICTORY_TEXTURE_MAX_DIM), low-RAM pool trimmer (VICTORY_RAM_TRIM_MB), batched descriptor mirror & bind cache #1240
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1240
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1240"
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?
@RealAzemed on GitHub · 2026-11-26 01:29 UTC · original
RealAzemed:perf/vram-ram-cap-batched-descriptors-bind-cache→main· +476 −19 · 8 files · 2 commits · openSummary
Four opt-in / zero-regression memory and CPU optimizations targeting 8 GB VRAM + 16 GB RAM systems and high-draw world scenes (cleanly based on
006c353, independent of #1097, #1117, and #1225):VICTORY_TEXTURE_MAX_DIM=<pixels>— Opt-in on-demand mip cap (texture.rs,resource.rs)max(width, height) > limit, whenVICTORY_LEVELS_ON_DEMAND=1) ontotiles.rstiled resources and clampsheld_levelsviacapped_first_mip()so top-detail mips above the cap are never allocated on the card.linear.fill(0)memseton unheld non-packed mip levels (mip < first_tail_mip).capped_first_mip_clamps_large_textures_and_keeps_coarsest_level).VICTORY_RAM_TRIM_MB=<MiB>— Active low-RAM pool trimmer (host.rs,shadow.rs,texture.rs,list.rs)available_physical_ram()drops below the configured threshold (e.g.VICTORY_RAM_TRIM_MB=2048), runssweep()every 500 ms and drains hoarded CPU-side pools:shadow::POOL(retained CPU snapshotVec<u8>buffers),texture::SPARE(pooled upload staging buffers),list::IDLEdown to a warm floor of 16.unset/0).Batched
HostHeap::mirror_copied_batch+ 8-byte zero-page / zero-slot skip (descriptor/host.rs)mirror_copied_page: skips untouched all-zero 4 KiB pages in one pass and skips untouched*last == 0zero slots before callingrecord_print().for &(index, handle) in &due { self.mirror(index, handle, false); }loop withmirror_copied_batch, acquiringmade,textures,placed,buffers,changed, andkeptonce per changed page instead of once per mirrored slot (~100k–300k fewer mutex lock/unlock cycles per frame on busy world frames). Preserves exact lock order and stale-slot semantics (records_copied_as_bytes_are_made_at_the_next_syncpasses).VICTORY_BIND_CACHE=1— Opt-in command-list state bind cache (draw.rs,descriptor.rs)OMSetRenderTargets(avoidingHost::rtv/Host::dsvmutex + view creation),IASetPrimitiveTopology,RSSetViewports,RSSetScissorRects,OMSetBlendFactor,OMSetStencilRef, andOMSetDepthBoundswhen the resolved state matches what is already bound on the host command list.State::reset()andState::replay(). Off by default.Verification (Ryzen 5 7500F / 16 GB 1-ch DDR5 / RTX 3070 8 GB, Proton Experimental
ntsync+vkd3d-proton)cargo test --target x86_64-pc-windows-gnu -p victory-gpuunder Proton):texture::title_memory_tests::capped_first_mip_clamps_large_textures_and_keeps_coarsest_level— PASSdescriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync— PASShost::batch::ram_idle_ms_scales_with_pressure&vram_idle_ms_scales_with_pressure— PASSVICTORY_TEXTURE_MAX_DIM=1024,VICTORY_RAM_TRIM_MB=2048,VICTORY_BIND_CACHE=1,0 unhandled exceptions):VICTORY_TEXTURE_MAX_DIM=1024:8,096large textures made (1,391alive), 88 MB VRAM allocated vs 2,932 MB (2.93 GB) saved (3,020 MBuncapped);0uploads starved for VRAM across 143,110 uploads (63.4 GBstreamed); total card usage stayed at 5.9–6.3 GiB / 8 GiB across multiple outdoor city/night/sunset scenes.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.