GPU: backport placed-page write-watch stamps from Vice-Tay #1496

Open
t90 wants to merge 2 commits from upstream-pr/1496 into main
t90 commented 2026-11-27 19:50:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by t90 on 2026-11-27T19:50:54Z.


Pages first placed at submission are copied from title memory but keep Held::taken = 0. The next refresh treats them as never uploaded and can send unchanged CPU bytes over data the structure builder has already changed on the GPU. Remember the write-watch asking from before the initial copy, so later refreshes still notice newer title writes without repeating that first whole-page upload. VICTORY_PLACE_TAKEN=0 retains the old behaviour for comparison.

Backport of Vice-Tay a33271f / #342, credited to urielbeaupre and TaynanGT. This is independent of the scalar-code PR and changes only memory.rs.

Validation on current cd93552, with the uploaded file verified identical to the tested local source:

  • New synthetic regression fails before the fix: 65,536 unchanged bytes retaken instead of zero.
  • After the fix, all six focused memory tests pass with VICTORY_D3D12_WARP=1 and --features diagnostics. The regression actually executes: no unchanged bytes are retaken, and a later four-byte CPU write reaches the mapped copy.
  • The host-resource test explicitly reports a skip if those optional resources cannot be created; no skip occurred in the verified WARP run.
  • cargo check --locked -p victory-gpu --all-features passes with existing warnings; asset policy passes (280 files).
  • Workspace Clippy with default/all features is blocked by the existing precedence warning at victory-formats/src/texture.rs:1346. The unrelated formatting/lint PRs are kept separate.

Draft pending full integration and in-game RT verification. The regression checks upload/stamp behaviour using synthetic allocations, not actual GPU-written structure readback. No measured FPS gain or complete ray-tracing correction is claimed. No game files, dumps or extracted data are included. Prepared with AI assistance.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5532299812 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1496). Originally posted by [t90](https://github.com/t90) on 2026-11-27T19:50:54Z. --- Pages first placed at submission are copied from title memory but keep `Held::taken = 0`. The next refresh treats them as never uploaded and can send unchanged CPU bytes over data the structure builder has already changed on the GPU. Remember the write-watch asking from before the initial copy, so later refreshes still notice newer title writes without repeating that first whole-page upload. `VICTORY_PLACE_TAKEN=0` retains the old behaviour for comparison. Backport of [Vice-Tay a33271f / #342](https://github.com/TaynanGT/Vice-Tay/commit/a33271f254738d0ec8bea71e70008175ae46f5c3), credited to urielbeaupre and TaynanGT. This is independent of the scalar-code PR and changes only `memory.rs`. Validation on current `cd93552`, with the uploaded file verified identical to the tested local source: - New synthetic regression fails before the fix: 65,536 unchanged bytes retaken instead of zero. - After the fix, all six focused memory tests pass with `VICTORY_D3D12_WARP=1` and `--features diagnostics`. The regression actually executes: no unchanged bytes are retaken, and a later four-byte CPU write reaches the mapped copy. - The host-resource test explicitly reports a skip if those optional resources cannot be created; no skip occurred in the verified WARP run. - `cargo check --locked -p victory-gpu --all-features` passes with existing warnings; asset policy passes (280 files). - Workspace Clippy with default/all features is blocked by the existing precedence warning at `victory-formats/src/texture.rs:1346`. The unrelated formatting/lint PRs are kept separate. Draft pending full integration and in-game RT verification. The regression checks upload/stamp behaviour using synthetic allocations, not actual GPU-written structure readback. No measured FPS gain or complete ray-tracing correction is claimed. No game files, dumps or extracted data are included. Prepared with AI assistance.
Kal0s-design commented 2026-11-28 11:21:42 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Kal0s-design on 2026-11-28T11:21:42Z.


Verified on NVIDIA (real D3D12 device, pinned 1.98.1 toolchain, build pulled nothing from the network).

The PR touches one file, so I applied its crates/victory-gpu/src/memory.rs change onto current main (6b3ce6c); it applies clean.

Tests (cargo test -p victory-gpu --lib memory::tests::): 6/6 pass, including the new a_placed_page_is_not_taken_again_until_the_title_writes. Its eprintln fires ("no unchanged bytes retaken; the later title dword reached the copy"), so Memory::new() succeeded here (it builds a real D3D12 host device) and the test ran the write-watch path instead of taking its skip branch.

Sensitivity: running that test with VICTORY_PLACE_TAKEN=0 (the flag the PR adds to keep the old refresh) fails it here —

assertion `left == right` failed: an unchanged placed page must not be uploaded again
  left: 65536
 right: 0

With the flag on, stats.changed on that first refresh is 0; with it off, it is 65536 (a whole page, PAGE == 1 << 16). After the title then writes one dword, changed is 4 and the staging copy reads back the new value. So the stamp is what stops the first refresh re-taking the placed page.

Not covered: the real in-game upload path and a live title's rendering (the test drives the write-watch memory path directly), the wider D3D12 submission around it, and concurrent first-touch of the place_taken() OnceLock.

AI-assisted: yes.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7238500264 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1496#issuecomment-7238500264). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-11-28T11:21:42Z. --- Verified on NVIDIA (real D3D12 device, pinned 1.98.1 toolchain, build pulled nothing from the network). The PR touches one file, so I applied its `crates/victory-gpu/src/memory.rs` change onto current `main` (`6b3ce6c`); it applies clean. Tests (`cargo test -p victory-gpu --lib memory::tests::`): 6/6 pass, including the new `a_placed_page_is_not_taken_again_until_the_title_writes`. Its `eprintln` fires ("no unchanged bytes retaken; the later title dword reached the copy"), so `Memory::new()` succeeded here (it builds a real D3D12 host device) and the test ran the write-watch path instead of taking its skip branch. Sensitivity: running that test with `VICTORY_PLACE_TAKEN=0` (the flag the PR adds to keep the old refresh) fails it here — ``` assertion `left == right` failed: an unchanged placed page must not be uploaded again left: 65536 right: 0 ``` With the flag on, `stats.changed` on that first refresh is 0; with it off, it is 65536 (a whole page, `PAGE == 1 << 16`). After the title then writes one dword, `changed` is 4 and the staging copy reads back the new value. So the stamp is what stops the first refresh re-taking the placed page. Not covered: the real in-game upload path and a live title's rendering (the test drives the write-watch memory path directly), the wider D3D12 submission around it, and concurrent first-touch of the `place_taken()` `OnceLock`. AI-assisted: yes.
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/1496:upstream-pr/1496'
git switch 'upstream-pr/1496'

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/1496'
git switch 'upstream-pr/1496'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1496'
git switch 'upstream-pr/1496'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1496'
git switch 'main'
git merge --squash 'upstream-pr/1496'
git switch 'main'
git merge --ff-only 'upstream-pr/1496'
git switch 'main'
git merge 'upstream-pr/1496'
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
fxceless/victory-fork!1496
No description provided.