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

Open
github-bot wants to merge 1 commit from github-bot/gh-2272 into main AGit
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 09:28 UTC · original
denkencar-sketch:fix/shadow-004 → main · +29 −4 · 1 files · 1 commits · open

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.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 09:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2272) `denkencar-sketch:fix/shadow-004` → `main` · +29 −4 · 1 files · 1 commits · open ## 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.
Only whole pages were; the page stayed changed and unguarded, so the next
submission's marked writes to it were dropped.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:00:37 +00:00
Author
Owner

@⁠welisonzika14-jpg on GitHub · 2026-11-25 12:00 UTC · original

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.

**@⁠welisonzika14-jpg** on GitHub · 2026-11-25 12:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2272#issuecomment-7161786179) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:32 UTC · original · edited 2026-11-26 01:22 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 13:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2272#issuecomment-7163921741) · edited 2026-11-26 01:22 UTC <!-- 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)_
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 09:35 UTC · original · reviewed

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).

**@⁠catminou4** on GitHub · 2026-11-25 09:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/2272#pullrequestreview-6055074663) · **reviewed** 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 19:38 UTC · original · approved these changes

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 19:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2272#pullrequestreview-6079633767) · **approved these changes** 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2272/head:github-bot/gh-2272'
git switch 'github-bot/gh-2272'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2272'
git switch 'github-bot/gh-2272'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2272'
git switch 'github-bot/gh-2272'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2272'
git switch 'main'
git merge --squash 'github-bot/gh-2272'
git switch 'main'
git merge --ff-only 'github-bot/gh-2272'
git switch 'main'
git merge 'github-bot/gh-2272'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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!2272
No description provided.