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

Closed
opened 2026-11-25 12:15:41 +00:00 by BastienRodz · 2 comments
BastienRodz commented 2026-11-25 12:15:41 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T12:15:41Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6604255179 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2375). Originally posted by [BastienRodz](https://github.com/BastienRodz) on 2026-11-25T12:15:41Z. --- ### 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.
shawshanker18 commented 2026-11-25 17:05:10 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by shawshanker18 on 2026-11-25T16:41:18Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168377577 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2375#issuecomment-7168377577). Originally posted by [shawshanker18](https://github.com/shawshanker18) on 2026-11-25T16:41:18Z. --- 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.
Marvisak commented 2026-11-25 19:06:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T18:49:12Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171443350 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/2375#issuecomment-7171443350). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T18:49:12Z. --- <!-- 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)_
Sign in to join this conversation.
No labels
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.

Reference
Marvisak/VIctory#2373
No description provided.