GPU: copy-back reaches write-watched pages under Wine #1829

Closed
CaravelaLabs wants to merge 1 commit from upstream-pr/1831 into main
CaravelaLabs commented 2026-11-24 23:07:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by CaravelaLabs on 2026-11-24T23:07:53Z.


Under Wine, WriteProcessMemory fails with ERROR_PARTIAL_COPY on MEM_WRITE_WATCH pages that have not been written since they were committed. The title's pools are allocated that way. write_mapped left a failed 4 KiB piece alone, so bytes shaders had written never reached title memory.

On main 70564ae, shadow::tests::snapshots_cover_the_declared_ranges_and_writes_go_back_once fails under Wine 11.22 + vkd3d-proton 3.1: the title bytes stay [0, 0, 0, 0], expected [1, 2, 3, 9]. With this change it passes. A 4 KiB piece that could not be written is read into the page (ReadProcessMemory into the destination), which Wine allows. Read-only and unmapped pages are still refused. Pages that could be written take the same path as before.

Radeon 8060S, RADV GFX1151, Mesa 25.2.8, Ubuntu 24.04. The device was reached. victory-gpu library tests: 67 passed, 10 failed, 1 ignored. Those 10 are the same Wine compiler and heap-cap failures already on main, not this change. Windows clippy -D warnings is clean for the workspace, with and without --all-features.

Not run on native Windows, and not with the title, so how much of the world this changes is not measured. #1215 rewrites this function onto NtWriteVirtualMemory; that path was not tested. Linux and Proton notes are also in #844; this change is not in that branch.

AI-assisted; tests run on this machine.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6593238136 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1831). Originally posted by [CaravelaLabs](https://github.com/CaravelaLabs) on 2026-11-24T23:07:53Z. --- Under Wine, `WriteProcessMemory` fails with `ERROR_PARTIAL_COPY` on `MEM_WRITE_WATCH` pages that have not been written since they were committed. The title's pools are allocated that way. `write_mapped` left a failed 4 KiB piece alone, so bytes shaders had written never reached title memory. On main `70564ae`, `shadow::tests::snapshots_cover_the_declared_ranges_and_writes_go_back_once` fails under Wine 11.22 + vkd3d-proton 3.1: the title bytes stay `[0, 0, 0, 0]`, expected `[1, 2, 3, 9]`. With this change it passes. A 4 KiB piece that could not be written is read into the page (`ReadProcessMemory` into the destination), which Wine allows. Read-only and unmapped pages are still refused. Pages that could be written take the same path as before. Radeon 8060S, RADV GFX1151, Mesa 25.2.8, Ubuntu 24.04. The device was reached. `victory-gpu` library tests: 67 passed, 10 failed, 1 ignored. Those 10 are the same Wine compiler and heap-cap failures already on main, not this change. Windows clippy `-D warnings` is clean for the workspace, with and without `--all-features`. Not run on native Windows, and not with the title, so how much of the world this changes is not measured. #1215 rewrites this function onto `NtWriteVirtualMemory`; that path was not tested. Linux and Proton notes are also in #844; this change is not in that branch. AI-assisted; tests run on this machine.
catminou4 commented 2026-11-25 00:06:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:47:35Z.

Review: COMMENTED


Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Copy-back reaches write-watched pages under…: extends the dirty-page/write-watch coverage from #1681 to copy-back paths. Consistent with that work.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049281269 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1831#pullrequestreview-6049281269). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:47:35Z. **Review:** COMMENTED --- Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Copy-back reaches write-watched pages under…: extends the dirty-page/write-watch coverage from #1681 to copy-back paths. Consistent with that work.
0xKaji commented 2026-11-25 00:06:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xKaji on 2026-11-24T23:25:51Z.


Verified 756f641 on Linux + Wine 11.22 + vkd3d-proton 3.2.0 (GE-Proton11-14) + NVIDIA RTX 3060 8 GB, cross-built with cargo xwin (x86_64-pc-windows-msvc, VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains):

  • cargo xtask policy: asset policy: 174 files ok
  • cargo xwin clippy -p victory-gpu --tests --target x86_64-pc-windows-msvc --offline -- -D warnings: 0 warnings
  • Wine GPU test (shadow::tests::snapshots_cover_the_declared_ranges_and_writes_go_back_once --test-threads=1): flips from FAIL on 70564ae (left: [0, 0, 0, 0], right: [1, 2, 3, 9]) to PASS on 756f641 (1 passed, 0 failed, 0.65s).

Code check: read() uses ReadProcessMemory(GetCurrentProcess(), ...) on the 4 KiB piece, so unmapped/protected pages are still checked safely without faulting. Looks clean.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147390751 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1831#issuecomment-7147390751). Originally posted by [0xKaji](https://github.com/0xKaji) on 2026-11-24T23:25:51Z. --- Verified `756f641` on **Linux + Wine `11.22` + `vkd3d-proton 3.2.0` (`GE-Proton11-14`) + NVIDIA RTX 3060 8 GB**, cross-built with `cargo xwin` (`x86_64-pc-windows-msvc`, `VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains`): - `cargo xtask policy`: `asset policy: 174 files ok` - `cargo xwin clippy -p victory-gpu --tests --target x86_64-pc-windows-msvc --offline -- -D warnings`: **0 warnings** - Wine GPU test (`shadow::tests::snapshots_cover_the_declared_ranges_and_writes_go_back_once --test-threads=1`): flips from **FAIL** on `70564ae` (`left: [0, 0, 0, 0], right: [1, 2, 3, 9]`) to **PASS** on `756f641` (`1 passed, 0 failed`, `0.65s`). Code check: `read()` uses `ReadProcessMemory(GetCurrentProcess(), ...)` on the 4 KiB piece, so unmapped/protected pages are still checked safely without faulting. Looks clean.
upstream-sync closed this pull request 2026-11-25 01:07:15 +00:00
CaravelaLabs commented 2026-11-25 01:08:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by CaravelaLabs on 2026-11-25T00:36:22Z.


Closing this. @jsthope's #322 is on main 4118f33 now, and write_mapped already copies through ReadProcessMemory. That is the fallback this patch was adding for Wine.

On that main, snapshots_cover_the_declared_ranges_and_writes_go_back_once passes here, 3 of 3. Wine 11.22, vkd3d-proton 3.1, Radeon 8060S (RADV GFX1151, Mesa 25.2.8). The device was reached. The failure on 70564ae (title bytes stayed 0) does not reproduce.

This head still applies, but the combined result calls that same read twice, and the comment still talks about WriteProcessMemory. Nothing left to land.

Thanks @0xKaji for checking 756f641, and @catminou4 for the look. Those were right for that head.

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148686793 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1831#issuecomment-7148686793). Originally posted by [CaravelaLabs](https://github.com/CaravelaLabs) on 2026-11-25T00:36:22Z. --- Closing this. @jsthope's #322 is on main `4118f33` now, and `write_mapped` already copies through `ReadProcessMemory`. That is the fallback this patch was adding for Wine. On that main, `snapshots_cover_the_declared_ranges_and_writes_go_back_once` passes here, 3 of 3. Wine 11.22, vkd3d-proton 3.1, Radeon 8060S (RADV GFX1151, Mesa 25.2.8). The device was reached. The failure on `70564ae` (title bytes stayed 0) does not reproduce. This head still applies, but the combined result calls that same read twice, and the comment still talks about `WriteProcessMemory`. Nothing left to land. Thanks @0xKaji for checking `756f641`, and @catminou4 for the look. Those were right for that head. AI-assisted.

Pull request closed

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!1829
No description provided.