Skip to content

fix(gpu): preserve newer game writes after marked page copy-back - #437

Merged
pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
mikebuckets171:contrib/mac-marked-copyback-baseline
Nov 27, 2026
Merged

pragyaangaur merged 1 commit into
pragyaangaur:mainfrom
mikebuckets171:contrib/mac-marked-copyback-baseline

Conversation

@mikebuckets171

Copy link
Copy Markdown
Contributor

The game and the GPU can write different bytes of the same buffer during a submission. The Mac port first copies back the pages that shaders marked, then checks its saved copy for any overlapping declared write ranges. The second pass still compares against the bytes from before the first. It can mistake the values the first pass published for another GPU write, and restore them over a newer CPU write.

This is the macOS port of the fix identified by @BastienRodz in Marvisak/VIctory#2436 and #2437 (60d81cfb). The Mac implementation batches marked pages. It now advances existing snapshots over each page it merged, including a page with only a CPU change. It skips pages it could not read or did not merge, keeps the batched writes and handles partial first/last pages.

Reproduced on an M5 Pro

The regression uses one D3D12 buffer across three 64 KiB pages, with its first and last pages clipped. It marks those two pages, leaves the middle one for the declared pass, and changes three game-side bytes between the two passes. The previous shader write, the game-only change and the still-unpublished middle-page shader write are checked independently.

Synthetic fixture bytes after both passes (hex) Result
Expected 33 44 B2 55
Unmodified macOS bf99e728 + test only A1 11 B2 22 — three stale bytes
With the fix 33 44 B2 55 — all four match

On the fixed path the marked batch writes 65,520 bytes (the clipped first page); the declared pass writes 65,536 bytes (only the middle page). The CPU-only last page does not trigger a redundant write. This is a buffer correctness result; it does not establish the cause of a particular in-game visual defect or crash.

The focused release test under Wine/D3DMetal is shadow::tests::declared_writeback_preserves_title_writes_after_marked_pages. Both paths were exercised on an M5 Pro / 48 GB, macOS 27.2.1, Wine 11.0 and D3DMetal 4.0b3. This change is independent of the capture-time optimization in #436.

Checks on macOS bf99e728 and the PR

  • Native workspace: 555 passed, 0 failed, 17 ignored on both. Windows-target workspace under Wine/D3DMetal (serial): main 1,124/0/28, head 1,125/0/28 (passed/failed/ignored).
  • The exact regression failed on main plus the test alone, and passed with the fix. Release Wine shadow::: 33 passed, 0 failed, 3 ignored on this branch.
  • Applied both this change and perf(gpu): stop recopying overlapping write snapshots #436 locally in a clean merge. With release diagnostics, the combined Wine shadow:: suite passed 35/0/4, including both PRs’ regressions. The mapped capture benchmark then passed explicitly.
  • Native Clippy, strict Windows-target Clippy (default and all features), whole-tree/staged asset policy and git diff --check passed. cargo fmt --all -- --check reports the same 81 existing files on main and head; no unrelated formatting changes included.

Prepared and tested with GPT-6.2 Astra. Only synthetic test bytes and Rust source are included.

Port the fix from BastienRodz in Marvisak/VIctory#2437 (60d81cfb). Advance snapshots of marked pages after merging them in the Mac batched path. The old declared pass restored three stale bytes in a clipped three-page D3DMetal regression.

Co-authored-by: BastienRdz <58186763+BastienRodz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants