GPU: a declared copy-back after a marked one puts the title's older bytes back #2436

Open
opened 2026-11-26 05:05:43 +00:00 by github-bot · 2 comments
Owner

@⁠BastienRodz on GitHub · 2026-11-25 13:28 UTC · original

What happens

After a submission, host.rs runs copy_back_marks (Shadow::copy_back_marked per marked page) before the copy-backs of declared ranges (Shadow::copy_back). copy_back_marked puts the shaders' bytes into title memory, and the copy takes the title's others (*h = *t). But a declared range over the same page keeps its snapshot of the bytes from before the submission (Shadow::before). When that range's copy_back runs, every byte the title wrote during the submission (now in the copy) differs from the snapshot and is taken for a shader write. If the title has written it again since the marked copy-back, the older value goes back over it.

That is the failure copy_back's comment warns about: "putting back the copy's older bytes there broke the title's own records". The window is the time between copy_back_marks and the declared copy-backs of one submission, while the title's threads keep writing these buffers.

A synthetic run with one page that is both marked and declared shows it: a shader writes byte 10, the title writes byte 40 during the submission, then writes 10 and 40 again after the marked copy-back. The declared copy-back writes the whole page back and restores the older values.

Expected

update_busy keeps the snapshot in step with the copy for the same reason: "The same bytes go into the snapshot writing took, so copy-back neither takes them for the GPU's nor puts them back over a later title write." A marked copy-back should do the same for the snapshot of declared ranges over its page.

Where

crates/victory-gpu/src/shadow.rs, Shadow::copy_back_marked (since cd94d35). The related case of two overlapping declared ranges (the copy-back not advancing its own snapshot) is part of #261.

AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.

**@⁠BastienRodz** on GitHub · 2026-11-25 13:28 UTC · [original](https://github.com/Marvisak/VIctory/issues/2436) ### What happens After a submission, `host.rs` runs `copy_back_marks` (`Shadow::copy_back_marked` per marked page) before the copy-backs of declared ranges (`Shadow::copy_back`). `copy_back_marked` puts the shaders' bytes into title memory, and the copy takes the title's others (`*h = *t`). But a declared range over the same page keeps its snapshot of the bytes from before the submission (`Shadow::before`). When that range's `copy_back` runs, every byte the title wrote during the submission (now in the copy) differs from the snapshot and is taken for a shader write. If the title has written it again since the marked copy-back, the older value goes back over it. That is the failure `copy_back`'s comment warns about: "putting back the copy's older bytes there broke the title's own records". The window is the time between `copy_back_marks` and the declared copy-backs of one submission, while the title's threads keep writing these buffers. A synthetic run with one page that is both marked and declared shows it: a shader writes byte 10, the title writes byte 40 during the submission, then writes 10 and 40 again after the marked copy-back. The declared copy-back writes the whole page back and restores the older values. ### Expected `update_busy` keeps the snapshot in step with the copy for the same reason: "The same bytes go into the snapshot `writing` took, so copy-back neither takes them for the GPU's nor puts them back over a later title write." A marked copy-back should do the same for the snapshot of declared ranges over its page. ### Where `crates/victory-gpu/src/shadow.rs`, `Shadow::copy_back_marked` (since `cd94d35`). The related case of two overlapping declared ranges (the copy-back not advancing its own snapshot) is part of #261. AI-assisted (Gemini 4 Neon found it, Claude Code reviewed and verified it); synthetic test only, no game data.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:43 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:50 UTC · original · edited 2026-11-25 18:47 UTC

Automated triage for the maintainers.

Still on main (13f91ca; nothing in crates/victory-gpu changed since da82e44): in crates/victory-gpu/src/host.rs, copy_back_marks runs before the per-range Shadow::copy_back. In crates/victory-gpu/src/shadow.rs, Shadow::copy_back_marked sets the copy's bytes to title memory (*h = *t) but leaves the before snapshot that writing took for declared ranges unchanged. copy_back_or_not then reads every byte where the copy differs from that snapshot and title memory differs from the copy as a shader write, so title bytes taken in by the marked copy-back can be written back over a later title write.

Open PR #2437 addresses it, and a test run on 67e8ae1 (RTX 4050 Laptop, Windows 11) shows its regression test passing with no new failures. #2513 has been closed without merging. #2434 (a broader rework of copy_back_marks) also merges cleanly and passes its tests. #2437, #2377 and #2434 all change copy_back_marked and conflict with each other, so the maintainers will need to pick a merge order; the tester suggests the two small ones first and #2434 rebased on top.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:50 UTC · [original](https://github.com/Marvisak/VIctory/issues/2436#issuecomment-7167359852) · edited 2026-11-25 18:47 UTC <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-25T16:41:17Z at=2026-11-25T18:53:00Z --> Automated triage for the maintainers. Still on main (13f91ca; nothing in `crates/victory-gpu` changed since da82e44): in `crates/victory-gpu/src/host.rs`, `copy_back_marks` runs before the per-range `Shadow::copy_back`. In `crates/victory-gpu/src/shadow.rs`, `Shadow::copy_back_marked` sets the copy's bytes to title memory (`*h = *t`) but leaves the `before` snapshot that `writing` took for declared ranges unchanged. `copy_back_or_not` then reads every byte where the copy differs from that snapshot and title memory differs from the copy as a shader write, so title bytes taken in by the marked copy-back can be written back over a later title write. Open PR #2437 addresses it, and a test run on 67e8ae1 (RTX 4050 Laptop, Windows 11) shows its regression test passing with no new failures. #2513 has been closed without merging. #2434 (a broader rework of `copy_back_marks`) also merges cleanly and passes its tests. #2437, #2377 and #2434 all change `copy_back_marked` and conflict with each other, so the maintainers will need to pick a merge order; the tester suggests the two small ones first and #2434 rebased on top. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠shawshanker18 on GitHub · 2026-11-25 16:41 UTC · original

Tested on main (67e8ae1), on Windows 11 with an RTX 4050 Laptop. Command: cargo test -p victory-gpu --lib.

  • #2437: merges clean; a_declared_copy_back_after_a_marked_one_keeps_newer_title_writes passes; no failures beyond main's 2 (NVIDIA view-heap cap). It fixes exactly this: copy_back_marked advances the snapshot segments over its page, as update_busy does.
  • #2434: merges clean, and its two tests pass. It is a broader rework of copy_back_marks for other bugs: copies sharing a 64 KiB page, and sub-page copies that never re-take their page.

Conflicts: #2437, #2377 (#2375) and #2434 all change copy_back_marked and conflict pairwise. #2172 merges cleanly with #2434.

The order with the least rework would be the two small ones first (#2437, #2377), then #2434 rebased on top.

**@⁠shawshanker18** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/2436#issuecomment-7168376924) Tested on `main` (`67e8ae1`), on Windows 11 with an RTX 4050 Laptop. Command: `cargo test -p victory-gpu --lib`. - **#2437:** merges clean; `a_declared_copy_back_after_a_marked_one_keeps_newer_title_writes` passes; no failures beyond `main`'s 2 (NVIDIA view-heap cap). It fixes exactly this: `copy_back_marked` advances the snapshot segments over its page, as `update_busy` does. - **#2434:** merges clean, and its two tests pass. It is a broader rework of `copy_back_marks` for other bugs: copies sharing a 64 KiB page, and sub-page copies that never re-take their page. **Conflicts:** #2437, #2377 (#2375) and #2434 all change `copy_back_marked` and conflict pairwise. #2172 merges cleanly with #2434. The order with the least rework would be the two small ones first (#2437, #2377), then #2434 rebased on top.
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#2436
No description provided.