gpu(shadow): offload >=1 MiB exact views & late buffers to GPU compare and optimize CPU fallback #14
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!14
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-14"
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 18:48 UTC · original
MahanYTT:perf/shadow-cpu-compare→mega-upgrade-v3· +341 −62 · 1 files · 1 commits · merged 2026-12-04 20:18 UTCRoot Cause
Even with
VICTORY_CARD_ALL=1andVICTORY_CARD_BUFFERS_MIN_KB=64, title buffer copies>= 1 MiBcould still fall back to CPU byte-compare (shader writes looked for on the CPU per frame: 174.5 MB in 12 ranges ... (0.0 MB snapshotted), of them 174.5 MB in copies of 1 MiB or more):ExactCache::get_or_create/shadow::exact) never received aCardside:VICTORY_VIEW_BYTES(on by default) createsShadows up toEXACT_MOST(64 MiB) withwindow = falseandcard = None, bypassingbuffer_sides/card_for_countedcompletely. UnderVICTORY_RELAY=2, overlapping flights hitpending.contains(&range)(0.0 MB snapshotted) while every flight still ran CPUfind_allbyte-compare across the full view.BUFFERShad no late promotion path: UnlikeLOOSEwindows (card_late_windows), a title buffer created beforeHost::card_ready()finished (e.g. underVICTORY_MADE_ASIDE=1) or during transient VRAM pressure remained uncarded for its entire lifetime.Shadow::relay_compareddid not skip placed copies (self.place.is_some()): UnlikeShadow::writingandShadow::copy_back_with,relay_comparedstill counted placed copies inBACK_CLASS(with 0.0 MB snapshotted) andfind_allstill lockedshadow.before.find_all/find_pieces): Allocated aBox<dyn FnOnce()>per 1 MiB chunk, contended on a single sharedArc<Mutex<Found>>, sorted results, and woke the worker pool even for empty or single-chunk scans.Changes (
crates/victory-gpu/src/shadow.rs)ExactCache(shadow::exact): Promote views>= 1 MiB(EXACT_CARD_MIN..=EXACT_MOST) to two-sided card copies viabuffer_sides(..., card_for_counted, ...)so shader writes use GPU hash/compare. Keep smaller views on the fastExactPoolrecycling path, and ensure carded entries are retired rather than recycled intoExactPool.card_late_buffers): Track eligible uncarded buffers (UNCARDED_BUFFERS) and promote them (largest first, up toLATE_AT_ONCEper submission) inlet_go_idleonceHost::card_ready()is ready and no command list / pending shader write holds them.Shadow::relay_compared&find_all/find_pieces: Skipself.place.is_some()and empty ranges inrelay_comparedandfind_all; fast-path empty and single-chunk scans infind_pieces; replace per-chunkBoxjobs + shared mutex + sort with lock-free per-chunk slots overwide_each_scoped.find_pieces_fast_paths_empty_and_single_chunk_scansandexact_card_and_buffer_promotion_eligibilityinwide_tests.Verification
cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu -- -D warnings: pass (0 warnings)cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --tests -- -D warnings: pass (0 warnings)rustc --edition 2024 --testonfind_pieces,exact_card_eligible, andcard_buffer_promotabletests: 3/3 passed