GPU: a partial refresh of an armed page leaves its saved bytes stale, so marked copy-back undoes title writes #2375

Closed
opened 2026-11-26 05:03:52 +00:00 by github-bot · 2 comments
Owner

@⁠BastienRodz on GitHub · 2026-11-25 12:15 UTC · original

What happens

Since cd94d35, a range a list declares as written through marked views arms its 64 KiB pages (Shadow::writing(.., marked = true) → Tracked::arm). The title's first write to an armed page saves the page's bytes from before it (Changed::save), and after the submission Shadow::copy_back_marked takes what differs from those saved bytes as the shaders' writes.

If a refresh in the same submission copies only part of that page into the host copy (Shadow::update_busy under a range shaders write, or update_free beside a sub-page one), Tracked::take leaves the page changed and its saved bytes untouched. update_busy updates only the snapshots of unmarked ranges (Shadow::before). The copy now holds the title's newer bytes there, but the saved bytes still hold the older ones, so copy-back:

  • takes the refreshed bytes for GPU writes and puts them back over a later title write to the same bytes;
  • misses a shader write that sets such a byte back to its saved value.

A synthetic run shows both. Title bytes 0x55/0x44 written after arming and refreshed, then the title writes 0x66 and a shader writes 0x00: copy-back leaves 0x55 and 0x44.

Expected

copy_back_marked's own description: "What they changed is what differs from the copy's bytes before the submission". update_busy keeps that for unmarked ranges: "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." Saved bytes of armed pages should follow a partial refresh the same way.

Where

crates/victory-gpu/src/shadow.rs (Shadow::copy, update_busy, copy_back_marked) and crates/victory-gpu/src/watch.rs (Tracked, Saved). Introduced by cd94d35. #2172 (whole-page refreshes for marked views) avoids the partial refresh for marked view ranges but not for a refresh of another range in the same page.

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 12:15 UTC · [original](https://github.com/Marvisak/VIctory/issues/2375) ### What happens Since `cd94d35`, a range a list declares as written through marked views arms its 64 KiB pages (`Shadow::writing(.., marked = true)` → `Tracked::arm`). The title's first write to an armed page saves the page's bytes from before it (`Changed::save`), and after the submission `Shadow::copy_back_marked` takes what differs from those saved bytes as the shaders' writes. If a refresh in the same submission copies only part of that page into the host copy (`Shadow::update_busy` under a range shaders write, or `update_free` beside a sub-page one), `Tracked::take` leaves the page changed and its saved bytes untouched. `update_busy` updates only the snapshots of unmarked ranges (`Shadow::before`). The copy now holds the title's newer bytes there, but the saved bytes still hold the older ones, so copy-back: - takes the refreshed bytes for GPU writes and puts them back over a later title write to the same bytes; - misses a shader write that sets such a byte back to its saved value. A synthetic run shows both. Title bytes `0x55`/`0x44` written after arming and refreshed, then the title writes `0x66` and a shader writes `0x00`: copy-back leaves `0x55` and `0x44`. ### Expected `copy_back_marked`'s own description: "What they changed is what differs from the copy's bytes before the submission". `update_busy` keeps that for unmarked ranges: "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." Saved bytes of armed pages should follow a partial refresh the same way. ### Where `crates/victory-gpu/src/shadow.rs` (`Shadow::copy`, `update_busy`, `copy_back_marked`) and `crates/victory-gpu/src/watch.rs` (`Tracked`, `Saved`). Introduced by `cd94d35`. #2172 (whole-page refreshes for marked views) avoids the partial refresh for marked view ranges but not for a refresh of another range in the same page. 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:03:52 +00:00
Author
Owner

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

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

  • Merges clean.
  • partial_refresh_under_marked_range_updates_saved_bytes passes.
  • No failures beyond main's 2 (NVIDIA view-heap cap).

It conflicts with #2437 (#2436) and #2434: all three change copy_back_marked. See the order suggested on #2436.

**@⁠shawshanker18** on GitHub · 2026-11-25 16:41 UTC · [original](https://github.com/Marvisak/VIctory/issues/2375#issuecomment-7168377577) Tested #2377 on `main` (`67e8ae1`), on Windows 11 with an RTX 4050 Laptop. Command: `cargo test -p victory-gpu --lib`. - Merges clean. - `partial_refresh_under_marked_range_updates_saved_bytes` passes. - No failures beyond `main`'s 2 (NVIDIA view-heap cap). It conflicts with #2437 (#2436) and #2434: all three change `copy_back_marked`. See the order suggested on #2436.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:49 UTC · original

Automated triage for the maintainers.

Confirmed in main. In crates/victory-gpu/src/shadow.rs, Shadow::update_busy copies the runs Tracked::take returns. It then writes the new bytes only into the unmarked snapshots in self.before. The bytes Tracked saved for an armed page (read back through t.saved(..) in Shadow::copy_back_marked) are left as they were. copy_back_marked then treats bytes that differ from those saved bytes as the shaders' writes, so a partial refresh of an armed page produces the effects described here.

Open PR #2377 updates the saved bytes. It was tested on current main in the comment above. It conflicts with #2434 and #2437, which also change copy_back_marked, so the merge order matters.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/2375#issuecomment-7171443350) <!-- victory-issue-triage v1 verdict=confirmed seen=2026-11-25T16:41:18Z at=2026-11-25T18:57:00Z --> Automated triage for the maintainers. Confirmed in main. In `crates/victory-gpu/src/shadow.rs`, `Shadow::update_busy` copies the runs `Tracked::take` returns. It then writes the new bytes only into the unmarked snapshots in `self.before`. The bytes `Tracked` saved for an armed page (read back through `t.saved(..)` in `Shadow::copy_back_marked`) are left as they were. `copy_back_marked` then treats bytes that differ from those saved bytes as the shaders' writes, so a partial refresh of an armed page produces the effects described here. Open PR #2377 updates the saved bytes. It was tested on current main in the comment above. It conflicts with #2434 and #2437, which also change `copy_back_marked`, so the merge order matters. --- _Generated by [Claude Code](https://claude.ai/code)_
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#2375
No description provided.