GPU: sparse copies snapshot and copy back their tiles on several threads #18
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/Belobug--VIctory-Belobug-AMD!18
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-18"
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?
@PikPakPik on GitHub · 2026-11-25 12:03 UTC · original
PikPakPik:perf-copies-paralleles→main· +130 −61 · 1 files · 2 commits · closed without mergingEach world frame snapshots about 620 MB of shader-written tiles before a submission and compares them after, all on the submitting thread. The diagnostics counters (
sparse writes since) show about 160 GB of ranges declared a frame for those 620 MB of distinct tiles, of which about 65 MB differ. The sampling profile (VICTORY_PROFILE) putShadow::writingat 20 % andShadow::copy_backat 18 % of the submitting thread's samples, most of itmemmoveand one lock of the tiles' map per 64 KiB.The change is in
shadow.rsonly. A range inside one already declared for the submission returns at once: its tiles' snapshots are taken, asor_insert_withleft them before. The views of a range's tiles are found under one lock (tiles_of). New snapshots and the copy-back of a range's tiles run throughhost::in_parallel, one tile per item, so no two threads touch the same memory. What is copied back and how is unchanged (merge_gpu_writes_mut,watch::writing,write_mapped).Measured on this machine (RX 9060 XT, Ryzen 7 9700X, Series X profile, diagnostics build, standing still in the world): copying back went from about 48 to 32 ms a frame, and
Shadow::writingfrom 20 % to 8.5 % of the submitting thread's samples.cargo test -p victory-gpu: 109 passed, 4 ignored; none of them reaches this path (sparsereturnsNoneundercfg(test)), so it was checked in the world only.The frame rate barely moves, from about 4.1 to 4.3 fps, and that comparison is not clean: the numbers before are from
4cbe9d7withVICTORY_SKIP_PIPELINES, those after from71652a2without it, where the refresh copies grew from about 10 to 30 ms a frame. The GPU's ~95 ms a frame is untouched.in_parallelstill creates its threads on each call, about 3 % of the samples; a pool would save that.@Ekabusto on GitHub · 2026-11-25 12:47 UTC · original
Checked locally: builds, and
cargo test -p victory-gpu --libpasses (109 passed, 4 ignored). As the description says, the tests do not reach this path. No conflicts withmainor the other open PRs.What I checked in the code:
beforestays locked for the whole parallel section and nothing is inserted into it meanwhile.watch::writingtakes the globalGUARDSmutex, andread_into/write_mappedrecover from faults through the process-wide exception handler (or fall back toRead/WriteProcessMemory).coveredearly return insparse_writingskips work only when an enclosing range is still pending in the same submission, so its snapshots are already taken.One nit: clippy reports one new
undocumented_unsafe_blockswarning atshadow.rs:2038. One// SAFETY:comment covers twounsafeblocks (hostandold); the second needs its own.Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).
@gut0to on GitHub · 2026-11-25 15:09 UTC · original
Could this snapshot/copy-back path get a small deterministic regression test? The current test configuration never reaches sparse shadows (as the PR notes), while this change adds parallel raw tile copies and pooled-buffer length updates. A test with multiple tiles, including one unchanged tile and one GPU-modified range, could check that only the modified bytes are copied back and no tile is lost or duplicated. AI-assisted review.
@gut0to on GitHub · 2026-11-25 15:09 UTC · original · reviewed
AI-assisted review: I checked the test gating and the new parallel copy-back path.
Pull request closed