perf(victory-gpu): enable thin-list state cache under VICTORY_STATE_CACHE and optimize thin/rootcache hot paths #7
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/MahanYTT--VIctory-MA!7
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-7"
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?
@MahanYTT on GitHub · 2026-12-04 17:49 UTC · original
MahanYTT:perf/thin-state-cache→mega-upgrade-v3· +727 −123 · 2 files · 2 commits · merged 2026-12-04 20:18 UTCRoot Causes Found
VICTORY_STATE_CACHE=1never enabled thin-list state elision (repeated state calls left out 0on all 538 log lines):thin::coalesce()was gated solely behind an off-by-defaultVICTORY_THIN_COALESCE=1env var and ignoredVICTORY_STATE_CACHE(crate::rootcache::on()).thin::repeats()only caught immediately-adjacent identical plain calls in the same un-handed-over chunk:op <= Plain::SET_PIPELINEagainstself.last, missing non-adjacent state re-binds across draws, calls spanninghand_over()piece splits (~303 pieces/frame),SAMPLE_MASK, and allput_withstate calls (VIEWPORTS,SCISSORS,BLEND_FACTOR,HEAPS,COMPUTE_CONSTANTS,GRAPHICS_CONSTANTS,INDEX_BUFFER,VERTEX_BUFFERS).thin.rsandrootcache.rs:REPEATS.fetch_add(1, Relaxed)on every elided call would bounce a shared cache line across title threads; now batched perFrontand flushed onhand_over()/run_here()/leave().run_plainused match guards (n if n == Plain::$op as u64), preventing LLVM jump-table generation across 45k+ calls/frame; replaced withplain_op::*constants.binds_only(op)did a 20-element linear array scan on every command whenVICTORY_WAIT_SHARE=1; replaced with O(1) range checks.Recording::dropallocated a temporaryVec<Vec<u64>>on every dropped recording to callgive_back; changedgive_backtoimpl IntoIterator<Item = Vec<u64>>.rootcache::Side::clear()memset 1,024 bytes ([Given; 64]) on every root signature / heap / reset invalidation; replaced with agiven_known: u64bitmask (O(1) clear).rootcache::Cacheonly flushedissued/skippedstats onDrop, so pooled command lists inBACKSnever reported live telemetry; now flushes onclear()as well asDropwithout double-counting.Changes (Exclusive Scope)
crates/victory-gpu/src/list/thin.rscoalesce()to honor explicitVICTORY_THIN_COALESCEand otherwise followcrate::rootcache::on()(VICTORY_STATE_CACHE), with runtime toggle sync (Front::sync_state_cache).FrontFrontStateguest-state shadow cache coveringSET_PIPELINE,TOPOLOGY,STENCIL_REF,DEPTH_BOUNDS,SAMPLE_MASK, graphics/compute root tables, root views, single/multi-dword root constants,VIEWPORTS,SCISSORS,BLEND_FACTOR,HEAPS,INDEX_BUFFER, andVERTEX_BUFFERS.RESET,CLEAR_STATE,MIRROR_FRAME(invalidates cached pipeline so mirror-frame binds always emit),Front::leave(), and dynamic switch flips, while persisting acrosshand_over()piece splits.REPEATSupdates perFront, convertedrun_plainto jump-tableplain_opconsts, convertedbinds_onlyto O(1) range checks, and removed the temporaryVecinRecording::drop.crates/victory-gpu/src/rootcache.rsgiven_known: u64bitmask toSidesoSide::clear()is O(1) instead of zeroing 1 KB per side.Cache::flush_stats()called from bothclear()andDropso pooled command lists report live state-cache telemetry without double-counting.Tests
crates/victory-gpu/src/list/thin.rs(repeat_tests): non-adjacent & cross-draw elision, work commands never elided, persistence across piece splits, invalidation onCLEAR_STATE/RESET, andFrontStateroot constants/views/IA/viewport/scissor/blend/heap semantics.clear_flushes_stats_without_double_counting_on_dropandgiven_knownassertions incrates/victory-gpu/src/rootcache.rs.rootcache.rsandFrontState/binds_only/try_slice_oflogic locally withcargo test(14 passed, 0 failed) andcargo clippy --all-targets -- -D warnings(0 warnings); full Windows CI build/tests will run on this PR.