GPU: a marked copy-back keeps a declared range's snapshot in step #2513
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!2513
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2513/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?
@Calvix2k on GitHub · 2026-11-25 15:04 UTC · original
Calvix2k:codex/gpu-marked-copy-back-snapshot→main· +60 −3 · 1 files · 1 commits · closed without mergingFixes #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.
A marked copy-back puts the shaders' bytes into title memory and lets the copy take the title's others. A declared range over the same page keeps its snapshot from before the submission, so a later copy-back compares the copy against those older bytes, takes the title's own writes for the GPU's and puts the copy's older values back over them — the failure `copy_back`'s comment warns about ("putting back the copy's older bytes there broke the title's own records"). The bytes a marked copy-back writes into title memory now go into the overlapping part of every declared range's snapshot as well, which is what `update_busy` does for the copy. The new test is #2436's scenario: a shader byte, a title write during the submission, the marked copy-back, then the title writes both bytes again — they stay. Before the change it fails at the first of the two (the shader's byte goes back over the title's).@oni-swr on GitHub · 2026-11-25 15:34 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 15:54 UTC · original
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
@Calvix2k on GitHub · 2026-11-25 16:03 UTC · original
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