GPU: a marked copy-back keeps a declared range's snapshot in step #2511
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2513"
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 Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T15:04:28Z.
Fixes #2436.
The failure, reproduced
copy_back_markedmerges the page (the shaders' bytes into title memory, the copy taking the title's others) and marks the page taken — but the snapshot a declared range over that page keeps (Shadow::before, taken before the submission) is left alone. A latercopy_backover the page then compares the copy against those older bytes, finds the title's own writes differ, takes them for the GPU's and puts the copy's older values back over them — the failurecopy_back's comment warns about.The test added here is the scenario from the issue: a shader byte at 10, the title's write at 40 during the submission, the marked copy-back, then the title writes both again. Before this change it fails at the first:
What the change does
The bytes a marked copy-back writes into title memory go into the overlapping part of every declared range's snapshot as well — the same thing
update_busydoes for the copy ("the same bytes go into the snapshot, so copy-back neither takes them for the GPU's nor puts them back over a later title write"). The segments hold offsets in the copy, so the overlap is computed in that space.Verification
a_marked_copy_back_keeps_a_declared_ranges_snapshot_in_stepfails before, passes after.cargo test -p victory-gpu --features diagnostics --libon Windows 10 19045 / RX 7800 XT: 146 passed, 2 ignored, plus the known placed-view failure on a runtime withoutID3D12Device10(#1999, identical onmain); clippy-D warningsclean.copy_back_marksand the declared copy-backs), so a title-side repro is unlikely to be visible — the synthetic test is the check.The overlapping-declared-ranges case from #261 (a copy-back not advancing its own snapshot) is untouched.
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T15:34:07Z.
Verification (Windows 11, WARP/CPU only) — head
0b92934e2e1392290330cd295c77d9e10a4921e9, with overlap against #2437Tested: the PR head =
origin/main940d32f+ the PR (merge-base940d32f, fast-forward). Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1.VICTORY_D3D12_WARP=1with--features diagnostics(the switch only works with that feature), so the host device is WARP; no physical GPU.cargo test -p victory-gpu --locked --features diagnostics --lib a_marked_copy_back_keeps -- --test-threads=1the title's later write at 10 stays,left: 170,right: 17(matches the PR text)cargo test -p victory-gpu --locked --features diagnostics --lib -- --test-threads=1cargo clippy -p victory-gpu --all-targets [--features diagnostics] --locked -- -D warningscargo xtask policyasset policy: 182 files okSide by side with #2437 (head
13c6aa2e; both fix #2436, both only touchvictory-gpu/src/shadow.rs)beforesnapshot segments to the bytes the copy and title now share. #2513 does it inline incopy_back_marked, insideif let Some(bytes) = written; #2437 does it in a newsync_snapshot(from - start, host)called unconditionally at the end ofcopy_back_marked.940d32f(merge commit7e9e3fb; both would then sync twice). On that merge: the 6shadow::testspass (both new tests), full lib 148 passed, 0 failed, 2 ignored; clippy withdiagnosticsclean; policy ok. With #2513's loop disabled in that merge, both new tests still pass, i.e. #2437 alone covers #2513's test.written == None), #2513 skips the snapshot advance. A throwaway test (title writes byte 40 = 0x11, no shader write,copy_back_marked-> 0 bytes, title writes 0x22, declaredcopy_back) fails on #2513's head: declared pass writes 65536 bytes and byte 40 reads17(0x11) instead of34(0x22). On #2437's head the same test passes (declared pass writes 0 bytes). This is the zero-write case DrDarkDK described on #2437; I did not find a covering test in #2513.title_writes_under_a_busy_range_are_copieddoc lines, so the new test carries 5 unrelated doc lines and the old test lost its doc.WARP only; the throwaway test was not committed. Synthetic data only.
AI use: Claude Code (Claude Sonnet 5.5).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:54:36Z.
Automated triage for the maintainers. Proposed close as a duplicate of the earlier open #2437, which fixes the same issue (#2436) in the same place,
Shadow::copy_back_markedincrates/victory-gpu/src/shadow.rs, and covers more. This PR advances the declared ranges' snapshot only insideif let Some(bytes) = written. When the marked pass writes nothing back but the copy still takes a title-written byte (h = twithchanged == false), the snapshot stays old, so the latercopy_backstill puts that byte back over a newer title write. #2437'ssync_snapshotruns whether or not anything was written. Also, the new test's doc comment was inserted under the existing doc lines oftitle_writes_under_a_busy_range_are_copied, so that test lost its doc. CI (check) passes. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.Generated by Claude Code
v18446744073709551615folder makes an update lose the save in release builds (follow-up to #1729) #2495Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T16:03:22Z.
Closing in favour of #2437, as the triage proposes: it is the earlier PR for the same issue (#2436), and its
sync_snapshotruns whether or not the marked pass wrote anything — the case this one leaves stale (h = twithchanged == false), so it covers more. The note about the test doc comment is right too; that test keeps its doc frommainwith this closed.No objection from me to #2437 going in.
Pull request closed