Repository navigation
GPU: opt-in mip cap (VICTORY_TEXTURE_MAX_DIM), low-RAM pool trimmer (VICTORY_RAM_TRIM_MB), batched descriptor mirror & bind cache - #1240
Open
RealAzemed wants to merge 2 commits into
Conversation
added 2 commits
November 26, 2026 06:25
…l trimmer & zero-page descriptor skip
… bind cache (VICTORY_BIND_CACHE=1)
e4glevlr
added a commit
to e4glevlr/victory-fork
that referenced
this pull request
Nov 26, 2026
3.1 Driver-call dedups from VIctory-NVIDIA (each on unless =0):
- ca1d519, VICTORY_BIND_CACHE: set_targets does not set the same
render targets and depth again. The views are compared (title
resource, host texture, record words), not the handles. Merged with
the target formats of Phase 2: formats are taken for every call,
views are made only when the targets change. replay() forgets the
targets for the new host list after a cut, State::reset() does on a
title reset. The other OMSetRenderTargets calls here are on lists of
their own (indirect, over) or at a list's close (the depth plane
pass), after the title's last draw.
- b32fb99, VICTORY_DECLARE_ONCE: a range shaders write is declared
once until the list next writes title memory (Copy or Run steps,
Deferred::title_written). The key holds this tree's `marked` flag
too. Exact: Shadow::writing already takes each byte once per
submission and later refreshes copy into the snapshot, so the
skipped steps only repeated a flush and a lock.
- ab86ef7: a pipeline a list binds again is not kept and named
again (HostList::bind_pipeline). With the card's clock per pipeline
(cardmeter) every bind still ends the span before it.
- c96525d: a root constant buffer not 256-byte aligned is filled
into scratch once per host list until the list next writes title
memory (HostList::fill_scratch). Each part after a cut is a host
list of its own, with its own scratch.
3.2 fxceless 32be36d (PR fxceless#1237) with PR fxceless#1245, VICTORY_LOOKUP_CACHE=1|alt
(off by default): a thread remembers what its asks for a buffer's
host copy found while the tables are unchanged. fxceless#1245: the
generation is bumped after registering under the table lock, and a
cached window is checked against the window table under its lock
before it is handed out (both fxceless#1245 tests). Here as well: a buffer's
copy in place is never cached, since in_place_let_go takes those out
when their memory is about to be remapped. Every table change in this
tree bumps the counter (register, unregister, in_place_let_go, the
idle sweep, window creation).
3.3 fxceless PR fxceless#1240, the exact parts only:
- VICTORY_RAM_TRIM_MB (off unless set): below that much available
memory, the lesser of physical RAM and remaining commit (as fxceless#822's
committed_cache_idle_ms already weighs them), the sweep runs every
500 ms and also drains the reuse pools: CPU snapshot buffers, spare
texture staging buffers, idle host lists past 16.
- A descriptor page of zeros whose slots were never looked at is not
fingerprinted (mirror_copied_page).
- Not taken: VICTORY_TEXTURE_MAX_DIM (drops detail), skipping the
zero fill of staging slices above the tail mip (would upload stale
bytes where tiles are mapped), the batched mirror (a rewrite of
mirror(), whose per-slot logic differs here), and the PR's own
VICTORY_BIND_CACHE (3.1 has one).
3.4 fxceless PRs fxceless#1230, fxceless#1232, fxceless#1233:
- fxceless#1230: contiguous readback pieces of one source join into one
CopyBufferRegion (VICTORY_READBACK_COALESCE=1; off), with its tests.
- fxceless#1232: join_ranges compacts in place (same result; test against
the allocating form).
- fxceless#1233: AVX2 changed-run detection (VICTORY_CHANGED_RUNS_AVX2=1 and a
runtime avx2 check; off). This tree has no SSE2 form of
changed_runs, so the AVX2 kernel and its mask walker were taken
alone and checked against this tree's walk
(avx2_changed_runs_match_the_walk).
3.5 WIDE scalar buffer loads (fxceless c36971b, shader part as in
VIctory-NVIDIA 200a9cc) on bit 128: bit 64 stays MERGE. Not in ALL;
VICTORY_SHADER_OPT=255 (or any value with 128) asks for it, since
parse_shader_opt now masks with KNOWN = ALL | WIDE. The cache key
already holds the whole mask. raw_dwords reads one console load four
dwords a call on both raw smem paths; test
scalar_buffer_loads_read_the_same_dwords_one_call_or_four (Windows,
software adapter).
Gate: Windows check, diagnostics check, clippy -D warnings (default and
all features), tests 342 passed / 0 failed / 8 ignored, policy 230 files
ok, viz. victory-gpu tests and the Windows-only shader tests are built
and linted, not run (pc-home offline).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.