Repository navigation
Conversation
Write precisely the shader-modified ranges. Rearm tracked pages before taking the live title bytes back into the shadow and advance the baseline for partial pieces that another declaration can visit. Exercise one real CPU store after the title read and another before a second overlapping copy-back.
The full page has published its shader writes and has been read back from the title. Replaying a smaller declaration can overwrite a CPU store made after that point. Check the aligned page in the per-submission compared set. Record completion after a successful full read so a readable subrange can retry after a hole.
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).
- Preserving late CPU stores across overlapping and partial snapshot writebacks (and retrying readable partial snapshots after a full-page read fails) is cleanly implemented and thoroughly tested.
cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 13 passed, 0 failed (overlapping_snapshots_keep_late_cpu_stores,partial_snapshot_after_a_full_page_preserves_a_new_cpu_store,readable_partial_snapshot_retries_after_a_full_page_read_fails).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Windows 11,
The three added tests are |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks solid. Reviewed store_snapshot_changes and the copy_back_or_not_with tracking/re-arm sequence in crates/victory-gpu/src/shadow.rs, and verified on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1:
cargo xtask policyandcargo clippy --tests -p victory-gpu(default and--features diagnostics,-D warnings) pass cleanly.store_snapshot_changesemits writes only for contiguousgpu != oldruns that still differ fromtitle, avoiding gap overwrites of concurrent CPU stores.- Keying
comparedon the aligned 64 KiB page and inserting only after a successful full-page read correctly prevents smaller overlapping declarations from replaying completed pages while still allowing readable subranges to retry after a failed full-page read. - Re-arming watch tracking (
t.taken(&whole)) before re-reading title memory into the shadow and refreshing the partial-piecebeforebaseline preserves late CPU writes across partial-before-full and overlapping partial snapshots. - All
shadow::testsplus an additional cross-page partial-before-full overlap probe pass on both RTX 5090 and WARP (13/13 passed, 0 D3D12 debug layer messages).
Reproduction
Two declarations from one submission can cover the same bytes. In the first regression test the ranges cover offsets 2–5 and 3–7. The shader output changes bytes 2 and 5. A CPU thread writes C1 at byte 4 after the first writeback reads title memory. The original code writes its earlier value, 00, over C1. The test also writes C2 before processing the second declaration and verifies that C2 survives.
The second regression test declares an aligned 64 KiB page followed by its four bytes at offsets 100–103. The full-page writeback publishes A1 A2 A3 A4. The CPU then writes C2 at offset 101. Processing the smaller declaration used to publish A2 again, overwriting the newer CPU store.
Change
The snapshot path compares shader output with the bytes saved before the submission. It writes contiguous runs of changed bytes through the existing checked write API. A CPU store in a gap between two shader changes therefore survives. After restoring write tracking on a completed full page, it reads title memory back into the shadow. It also updates the comparison baseline for a reconciled partial piece so that a later declaration can revisit it safely.
The per-submission set now records a full page after a successful full-page comparison against readable title memory. A later partial declaration now looks up the same aligned page in that set and skips it. Partial pieces do not mark the whole page complete. A failed read spanning a decommitted 4 KiB block leaves the 64 KiB page eligible for retry. A third regression test verifies that a later four-byte declaration beyond the hole still publishes its shader output.
Windows test evidence
The three regression tests in
shadow::testsuse real D3D12 devices and synthetic shadow contents, so the CPU store lands at the same point on every run:overlapping_snapshots_keep_late_cpu_storespartial_snapshot_after_a_full_page_preserves_a_new_cpu_storereadable_partial_snapshot_retries_after_a_full_page_read_failscargo test -p victory-gpu --features diagnostics --lib --locked shadow::tests:: -- --test-threads=1, on the RTX 5090 and again withVICTORY_D3D12_WARP=1(the GPU crate's WARP switch exists only indiagnosticsbuilds).63bcca4read back 00 where the CPU had written C1.b1fb182) read back A1 A2 A3 A4 after the CPU replaced A2 with C2.The decommitted-block test also passed on both devices. The 64 KiB read failed as expected and the four mapped bytes beyond the hole received A1 A2 A3 A4.
On Windows the upstream-based workspace recorded 868 passes, 6 failures and 10 ignored tests. Every failure also reproduced on the preceding snapshot commit, b1fb182. Two GPU assertions concern the native descriptor heap size and the view beyond the dynamic slots. One shader test (
heap_direct_texture_reads_mark_their_heap_index) terminated with Windows status 0xc0000005 (#2571); the remaining shader tests were then run by name. Three other shader tests failed on hardware: the stride used for a structured-buffer read, dispatch when the buffer view is absent, and the gathered values at a specified level. The same outcomes were recorded on both revisions. The adapter-dependent regression tests follow the existing skip convention if no host can be created.Comparison with prior work
The following candidates were each ported onto one local integration tree (not tested at their own heads) and run with the first regression test on an RTX 5090. The comparisons concern the snapshot path, even where a proposal mainly changes another path.
Three open PRs that change the same snapshot code were tested directly at their current heads, on the RTX 5090 and on WARP. The three tests above were added unchanged, with the same read seam in
copy_back_or_not(the title read goes through a closure, as in this PR):overlapping_snapshots_keep_late_cpu_storespartial_snapshot_after_a_full_page_preserves_a_new_cpu_storemain63bcca4(same seam)[A1, 00, 00, A2], the CPU's C1 lost[A1, A2, A3, A4], the CPU's C2 lost8b284ddebd01cd60d81cf31626ecreadable_partial_snapshot_retries_after_a_full_page_read_failspasses on all of them; it guards this PR's own change. #3318 and #3211 rework the same function for speed, and this PR will need rebasing on whichever lands first.Scope
This fix covers declared ranges with saved snapshots. Upstream’s separate marked-page path,
copy_back_marked, can still overwrite a concurrent CPU store when it writes a merged whole page. That issue remains open.RTX 5090, driver 621.14, Windows 11 build 26300, in-box WARP 10.0.26100.9818, Rust 1.98.1.
Synthetic tests only, no game data. AI-assisted (Claude Code); the runs are from my machine.
🤖 Generated with Claude Code