GPU: record per-span stamps for partial watched-page refreshes #1388
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1388"
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?
Imported from fxceless/victory-fork. Originally posted by n-romanovich on 2026-11-26T22:19:14Z.
Fixes #1344.
Previously,
Shadow::copy_staleonly updatedcopied[page - base]when a refresh covered the entire 64 KiB page (within the shadow buffer). Partial or unaligned refreshes left the page unstamped, causing repeated refreshes of the same unchanged span to re-copy boundary bytes on every frame.Changes in
crates/victory-gpu/src/shadow.rs:(lo, hi, stamp)inShadow::partialalongsideShadow::copied.copy_stale/copy_stale_with, prune any partial spans invalidated by a newer CPU write (stamp < write), copy only the uncovered gaps (including whenVICTORY_DIRTY_4Ksubpage filtering is active), and promote to a whole-page stamp when a full page is refreshed.partialstamps in sync inShadow::wrote_own.shadow::stale_testscovering unaligned cross-boundary refreshes, consecutive refreshes skipping unchanged bytes, CPU write invalidation, overlapping extensions, promotion to whole-page stamps, andVICTORY_DIRTY_4Kinteraction.Verified locally:
cargo test --locked -p victory-gpu --lib shadow(34 passed, 0 failed)cargo test --locked -p victory-gpu --features diagnostics --lib shadow(34 passed, 0 failed)cargo test --locked -p victory-gpu --lib(226 passed, 0 failed, 6 ignored)cargo build --release --locked -p victoryImported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-26T23:07:41Z.
All four focused stale-page tests passed under GE-Proton11-14 on Bazzite 44 with an RTX 5060 Laptop. I also replayed the same Series S checkpoint from identical initial caches on the same local integration of main and #257, with #1388 as the app source change.
The patched run reached the cell and recorded 206 distinct presents over 54 seconds at 3.82 FPS, with 965 MiB minimum free VRAM and no pending pipelines. Camera movement responded to input. The unpatched run reached the matched view and hit the local GPU headroom stop at 618 MiB free before completing the window. This pair establishes a working Proton run with the patch. A complete control window is still needed for an FPS or CPU-copy comparison.
Assisted by Codex (GPT-6.2-Sol High).
Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-27T02:53:42Z.
An in-game data point from a setup where nearly every buffer refresh is the case this PR is about, plus a profile that says where the rest of the time is.
Setup. RTX 3090 Ti 24 GB, Ryzen 9 9950X3D, Windows 11 26200.
main1f5d17awith #798 (the Series S profile needs it) and #1414 withVICTORY_TABLED_ALL=1. With that switch the once-a-frame pass over buffer views no longer refreshes each copy's whole span, so the draws' own refreshes are what is left: small ranges on 64 KiB pages the copy never takes whole. This PR's commit cherry-picked cleanly on top. Series S profile, the prologue's cell, hands-off, 5.5 minutes a run, two runs each way, the last four readings of the frame line.The picture in the cell is the same (four frames of each side by side).
So it does what it says: about a quarter fewer bytes read, with no fault I could find. The time does not follow the bytes, and the profile says why. Built-in sampler over 60 s of the cell, with this PR, submitting thread, ms a frame:
Shadow::update(all refreshes)watch::writes(the asking)Shadow::copy_stale(the copying)The asking is paid once per range, whether the range then copies anything or not.
watch::nothing_notedcannot answer for these ranges: it gives up on a page the copy has never taken whole (taken.contains(&0), and its comment says so: "so is, at every refresh, a page the copy's refreshes only ever hold in part"). For the same reasonVICTORY_LIGHT_REFRESH=1does not get past it here (one run with it on top: 54–57 ms).A possible next step, not written: the spans this PR keeps are what
nothing_notedis missing. A range whose pages are either taken whole or covered by spans stamped at or after the journal's last write of the page could be answered there with nothing asked. I am glad to run it here if someone writes it.Two things I did not explain. What goes up to the copies in the card's memory did not change with this PR in these runs (38–39 against 40 MB a frame), so the reads it saves are not in what is sent there; I have not looked into which copies they belong to. And on another tree (#994's head with #868 and others, same card and scene)
VICTORY_COPY_CHANGED=1took what goes up from 27.8 to 6.2 MB a frame with the frame unchanged (45–47 ms both ways): there most of it was bytes written again with the same values, and the time was not in the sending either.Numbers and text only. AI-assisted (Claude Code, Claude Fable 5.2).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.