Repository navigation
Preserve newer guest writes across gaps and overlapping page snapshots - #2
Open
MichaelSmithAI wants to merge 5 commits into
Open
MichaelSmithAI wants to merge 5 commits into
MichaelSmithAI wants to merge 5 commits into
Conversation
A copy of view memory (physical-page views, which cannot be write-watched) guards each 64 KiB block it took read-only. A block that is not mapped (a placeholder between views of a GPU heap) cannot be made read-only, so it never became clean: every asking reported it written again, and the copy read it through the per-page fallback, whose failing kernel reads cost hundreds of ms per world frame. Note such blocks absent (only after VirtualProtect fails and the block is not committed). An absent block is not reported again until title_memory_remapped, which the runtime calls after mapping or unmapping views, clears it. The copy keeps the zeros it took. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a submission runs, the bytes of each range its shaders write are kept to tell afterwards what the GPU changed. They were one buffer per copy, grown to the bounding range of every range the submission declared: each growth took a buffer from a pool of eight (a fresh one, page faults and all, when none was free and big enough) and copied the whole old snapshot into it. Keep them per title page instead, in 64 KiB buffers from a pool of up to 4,096, each page's part grown as ranges in it are declared (newly covered bytes taken from the copy as it is then, as before). A range inside one already taken returns at once. Copy-back compares page by page as it did by 64 KiB piece, with its scratch page from the same pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wbkepler
force-pushed
the
gpu/snapshot-pages
branch
from
November 24, 2026 20:51
5ff3a35 to
92e1d4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ports the snapshot-preservation logic and regression cases from Maraco91’s #261 to the per-page storage in #497, and adds a case for two disjoint ranges within one 64 KiB page.
On
5ff3a35, a later write declaration can cover an earlier gap inside one page. Its refreshed bytes can then look like shader writes. A second copyback over an overlapping range can likewise mistake a byte taken from guest memory during the first copyback for a new shader write. In both tests the guest wrote 2 and copyback replaced it with 1.The change records the current bytes of newly declared intervals in the existing page buffers. After copyback merges a range, later overlapping ranges compare against those merged bytes. The existing check for a fully covered declaration stays in front of the range calculations. For a newly covered interval the implementation copies and sorts the span list. Its effect on title frame time has not been measured.
Verification
On an RTX 4090 under Wine with vkd3d-proton, the original Marvisak#497 branch passed the cross-page gap test and failed the same-page gap and overlapping-range tests. With the patch all five snapshot tests passed, including both original Marvisak#497 tests. The controls use a D3D12 shared buffer and simulate shader writes in its mapped memory. A separate run repeated all five passes and their completion markers. Asset policy passed.
Run
cargo test --locked -p victory-gpu --lib shadow:: -- --nocapture --test-threads=1. This work used no game files. The performance measurements in Marvisak#497 belong to its original author.AI-assisted implementation and verification.