GPU: a page a copy holds in part is taken after its marked copy-back #2270

Open
denkencar-sketch wants to merge 1 commit from upstream-pr/2272 into main
denkencar-sketch commented 2026-11-25 09:28:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by denkencar-sketch on 2026-11-25T09:28:56Z.


Summary

A page that a copy holds only in part was not taken after its marked copy-back (only whole pages were), so the page stayed changed and unguarded and the next submission's marked writes to it were dropped.

Testing

Test a_partly_held_page_is_taken_after_its_marked_copy_back fails on main and passes with this change. cargo test --workspace --locked passes apart from the known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

Not tried: real submissions, and a run in the game.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5488655352 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272). Originally posted by [denkencar-sketch](https://github.com/denkencar-sketch) on 2026-11-25T09:28:56Z. --- ## Summary A page that a copy holds only in part was not taken after its marked copy-back (only whole pages were), so the page stayed changed and unguarded and the next submission's marked writes to it were dropped. ## Testing Test `a_partly_held_page_is_taken_after_its_marked_copy_back` fails on `main` and passes with this change. `cargo test --workspace --locked` passes apart from the known flakes: `modules::dstorage::tests::a_page_list_filled_after_its_request_starts` fails now and then on `main` too, and so does a parallel-run flake in `victory-gpu`'s lib tests (`watch::` and `descriptor::host::` tests, 2 of 40 runs on pristine `main`). Not tried: real submissions, and a run in the game. AI-assisted.
catminou4 commented 2026-11-25 09:35:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T09:35:41Z.

Review: COMMENTED


A page a copy holds in part is taken after its marked copy-back (drops the from==page && to==page+PAGE condition). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Pairs with #2271 (shadow.rs freshness cluster).

<!-- greyfinch-sync:Marvisak/VIctory:review:6055074663 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272#pullrequestreview-6055074663). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T09:35:41Z. **Review:** COMMENTED --- A page a copy holds in part is taken after its marked copy-back (drops the from==page && to==page+PAGE condition). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Pairs with #2271 (shadow.rs freshness cluster).
welisonzika14-jpg commented 2026-11-25 12:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by welisonzika14-jpg on 2026-11-25T12:00:04Z.


First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head b4bc9b9 merged onto main 940d32f, cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast.

The PR's test shadow::tests::a_partly_held_page_is_taken_after_its_marked_copy_back passes on this card. The rest is the same as main on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in victory-gpu, 3 in victory-shader), nothing new.

One run, unit tests only, title not run.

Written with AI help (Claude/Kiro); the numbers are from runs on my machine.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7161786179 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272#issuecomment-7161786179). Originally posted by [welisonzika14-jpg](https://github.com/welisonzika14-jpg) on 2026-11-25T12:00:04Z. --- First run on NVIDIA hardware here, as far as I can see (the reviews above are static or WARP). RTX 5070 (Blackwell, driver 621.24), Ryzen 7 5700X, Windows 11, Rust 1.98.1 MSVC, no game files. Head `b4bc9b9` merged onto `main` `940d32f`, `cargo test -p victory-gpu -p victory-shader --lib --no-fail-fast`. The PR's test `shadow::tests::a_partly_held_page_is_taken_after_its_marked_copy_back` passes on this card. The rest is the same as `main` on this card: the 5 known NVIDIA failures from #1744 (2 view heap cap tests in `victory-gpu`, 3 in `victory-shader`), nothing new. One run, unit tests only, title not run. Written with AI help (Claude/Kiro); the numbers are from runs on my machine.
Marvisak commented 2026-11-25 14:07:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:32:19Z.


Automated triage for the maintainers.

Merge candidate. The rebase resolved the shadow.rs conflict, and it merges cleanly now. In Shadow::copy_back_marked (crates/victory-gpu/src/shadow.rs), the page is now taken after the copy-back even when the copy holds it only in part. On main, such a page stayed changed and unguarded, so the next submission's marked copy-back saw changed with no saved bytes and dropped the shaders' writes. I checked that this is consistent:

  • After the copy-back, the copy equals title memory on [from, to). Either the copy's bytes are written to the title, or merge_writeback gives the copy the title's bytes.
  • The Tracked is the copy's own, and Tracked::take already treats a page whose tracked part is fully in range as whole.
  • copy_back_page already takes partial pages unconditionally.

The new test a_partly_held_page_is_taken_after_its_marked_copy_back covers the second submission, and a tester ran it on NVIDIA hardware.

CI: passing (check).

Recommending a look, not approving.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163921741 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272#issuecomment-7163921741). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:32:19Z. --- <!-- victory-triage v1 head=885172cb7297e36877c7977dd4ca1668f2f1e81d verdict=merge-candidate at=2026-11-26T01:22:18Z --> Automated triage for the maintainers. **Merge candidate.** The rebase resolved the `shadow.rs` conflict, and it merges cleanly now. In `Shadow::copy_back_marked` (`crates/victory-gpu/src/shadow.rs`), the page is now taken after the copy-back even when the copy holds it only in part. On `main`, such a page stayed changed and unguarded, so the next submission's marked copy-back saw `changed` with no saved bytes and dropped the shaders' writes. I checked that this is consistent: - After the copy-back, the copy equals title memory on `[from, to)`. Either the copy's bytes are written to the title, or `merge_writeback` gives the copy the title's bytes. - The `Tracked` is the copy's own, and `Tracked::take` already treats a page whose tracked part is fully in range as whole. - `copy_back_page` already takes partial pages unconditionally. The new test `a_partly_held_page_is_taken_after_its_marked_copy_back` covers the second submission, and a tester ran it on NVIDIA hardware. CI: passing (`check`). Recommending a look, not approving. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 19:38:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T19:38:09Z.

Review: APPROVED


Reviewed and verified 885172cb7297e36877c7977dd4ca1668f2f1e81d merged onto origin/main (63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, --features diagnostics with VICTORY_D3D12_DEBUG=1, Rust 1.98.1 MSVC).

Code Audit

  • In Shadow::copy_back_marked (crates/victory-gpu/src/shadow.rs:528-530), [from, to) is always page.max(start)..(page + PAGE).min(end), i.e. the entire portion of page owned by self. Both branches leave host equal to title memory on [from, to): the None branch writes host back when different, and the Some(before) branch runs merge_writeback (L27-37), which updates both title and host to the merged bytes before writing back.
  • Because Shadow::tracked holds a per-copy Arc<Changed>, calling t.taken(&[page / PAGE]) re-arms the page guard and clears only this copy's dirty entry without clearing any other copy that shares the same 64 KiB page.

Local Verification

  • cargo xtask policy — pass (191 files ok).
  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default and --all-features) — 0 warnings.
  • cargo test --locked -p victory-gpu --features diagnostics --lib shadow::tests:: (RTX 5090 and WARP) — 10/10 passed, including a_partly_held_page_is_taken_after_its_marked_copy_back (L1647-1668).
  • Additional synthetic probe covering two adjacent non-overlapping copies sharing one 64 KiB page (Copy A [p..p+0x100] tail-partial, Copy B [p+0x100..p+0x100+PAGE] head-partial): verified Copy B's marked copy-back preserves Copy A's concurrent CPU write and leaves Copy A's dirty mark intact, subsequent concurrent CPU+GPU writes merge into both title memory and Copy B's host buffer, and consecutive marked copy-backs on tail-partial Copy A also succeed on both RTX 5090 and WARP.

Looks good to merge.

<!-- greyfinch-sync:Marvisak/VIctory:review:6079633767 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272#pullrequestreview-6079633767). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T19:38:09Z. **Review:** APPROVED --- Reviewed and verified `885172cb7297e36877c7977dd4ca1668f2f1e81d` merged onto `origin/main` (`63bcca43c6a00a758510398fa43096ce7e4f7df0`) on Windows 11 x64 (RTX 5090 + Microsoft WARP, `--features diagnostics` with `VICTORY_D3D12_DEBUG=1`, Rust 1.98.1 MSVC). ### Code Audit - In `Shadow::copy_back_marked` (`crates/victory-gpu/src/shadow.rs:528-530`), `[from, to)` is always `page.max(start)..(page + PAGE).min(end)`, i.e. the entire portion of `page` owned by `self`. Both branches leave `host` equal to title memory on `[from, to)`: the `None` branch writes `host` back when different, and the `Some(before)` branch runs `merge_writeback` (`L27-37`), which updates both `title` and `host` to the merged bytes before writing back. - Because `Shadow::tracked` holds a per-copy `Arc<Changed>`, calling `t.taken(&[page / PAGE])` re-arms the page guard and clears only this copy's dirty entry without clearing any other copy that shares the same 64 KiB page. ### Local Verification - `cargo xtask policy` — pass (`191 files ok`). - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default and `--all-features`) — 0 warnings. - `cargo test --locked -p victory-gpu --features diagnostics --lib shadow::tests::` (RTX 5090 and WARP) — 10/10 passed, including `a_partly_held_page_is_taken_after_its_marked_copy_back` (`L1647-1668`). - Additional synthetic probe covering two adjacent non-overlapping copies sharing one 64 KiB page (Copy A `[p..p+0x100]` tail-partial, Copy B `[p+0x100..p+0x100+PAGE]` head-partial): verified Copy B's marked copy-back preserves Copy A's concurrent CPU write and leaves Copy A's dirty mark intact, subsequent concurrent CPU+GPU writes merge into both title memory and Copy B's host buffer, and consecutive marked copy-backs on tail-partial Copy A also succeed on both RTX 5090 and WARP. Looks good to merge.
Dukestar69 commented 2026-11-26 22:11:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:11:19Z.

Review: APPROVED


LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Taking partial pages held by a copy after marked copy-back cleanly preserves watch/dirty-page coherence.
  • cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: all passed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081020132 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2272#pullrequestreview-6081020132). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:11:19Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Taking partial pages held by a copy after marked copy-back cleanly preserves watch/dirty-page coherence. - `cargo test -p victory-gpu --lib shadow:: -- --test-threads=1`: all passed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2272:upstream-pr/2272'
git switch 'upstream-pr/2272'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2272'
git switch 'upstream-pr/2272'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2272'
git switch 'upstream-pr/2272'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2272'
git switch 'main'
git merge --squash 'upstream-pr/2272'
git switch 'main'
git merge --ff-only 'upstream-pr/2272'
git switch 'main'
git merge 'upstream-pr/2272'
git push origin 'main'
Sign in to join this conversation.
No reviewers
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!2270
No description provided.