GPU: keep what shaders may write by page, in reused page buffers #497
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!497
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/497/head"
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?
@wbkepler on GitHub · 2026-11-24 04:08 UTC · original
wbkepler:gpu/snapshot-pages→main· +326 −80 · 2 files · 2 commits · closed without mergingStacked on #464. This branch contains #464's commit; only the second commit is new. It is independent of #490.
Problem
Before a submission runs,
Shadow::writingkeeps the bytes of each range its shaders may write, socopy_backcan tell what the GPU changed. Until now that was one buffer per host copy, grown to the bounding range of every range declared in the submission. The world declares overlapping views of its 174 MB heap dozens of times per submission. Each growth:In the world, temporary fault counters around
writingshowed 98K–450K page faults per frame (#464 runs).Change
crates/victory-gpu/src/shadow.rsonly:copy_backcompares page by page, as it did per 64 KiB piece, and checks that the page's snapshot covers the piece. Its 64 KiB scratch buffer comes from the same pool instead of a freshvec![0; 64 KiB]per call.Measured
Diagnostics build, RTX 5090, same save, start screen to world,
copystatworld windows. The snapshot faults are a temporary counter aroundwriting.writing(temporary counter)Example world lines:
2.6 fps, 377.7 ms/frame (210.1 preparing: copies 103.4 ms ...), snapshot faults 142,4932.3 fps, 444.4 ms/frame (172.5 preparing: copies 105.6 ms ...), 1544 draws/frame, snapshot faults 26,271The fault counter clearly drops. Preparing time varies with the scene too much to attribute a precise saving.
Most of the remaining faults come from refreshes, copy-back reads of title memory, and texture refreshes, not from snapshots. That is a separate follow-up.
Tests
New tests, run with a host device and skipped without one:
shadow::tests::copy_back_takes_only_what_the_gpu_wrote: two overlapping ranges over three unaligned title pages, with a refresh between the declarations. Only the bytes the GPU changed go back. A title write made meanwhile stays, and the copy takes it. The page buffers return to the pool.shadow::tests::declaring_a_range_again_keeps_its_snapshot: a range declared again after a GPU write keeps its first snapshot, so the write is still found and copied back.Gate:
cargo fmt --check(shadow.rs): passes.cargo clippy --workspace --all-targetsandcargo clippy -p victory --features diagnostics --all-targets: no new warnings.cargo test --workspace: passes.cargo xtask policy: passes.🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-24 16:28 UTC · original
From a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data involved.
A follow-up on top of this PR (and #440, plus our #1215): the page snapshots and the copy-back comparison run on a persistent pool of
victory-copy-Nthreads, so a world submission that snapshots hundreds of MB no longer does it on one thread. The pool is created once (creating threads per call crashed in the title's thread-attach callbacks).Branch, one commit on top of #440 + #497 + #1215: https://github.com/LooperSalty/VIctory/tree/perf/copy-pool-stacked (commit 8cce780).
cargo test -p victory-gpu -p victory-shaderis green on it.Measured, world stage, DRED off: snapshot about 50 ms, copy back about 73 ms per frame; with the rest of our perf set the world runs at 2.3-2.5 fps (it was 0.2).
@wbkepler on GitHub · 2026-11-24 20:51 UTC · original
Rebased onto current main (
ffe310e) as92e1d4d, restacked on the rebased #464 (9dd1507); no content conflicts after restacking. Gate clean.Thanks @LooperSalty for the persistent copy-thread-pool follow-up branch built on top of this PR. Once this one lands it can be proposed as its own PR (nothing imported here).
AI-assisted (Claude Code); checked on Windows 11 / RTX 5090.
Pull request closed