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

Closed
github-bot wants to merge 1 commit from gh-pr/1831/head into gh-pr/1831/base
Owner

@⁠CaravelaLabs on GitHub · 2026-11-24 23:07 UTC · original
CaravelaLabs:caravela/wine-copy-back → main · +6 −1 · 1 files · 1 commits · closed without merging

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.

**@⁠CaravelaLabs** on GitHub · 2026-11-24 23:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1831) `CaravelaLabs:caravela/wine-copy-back` → `main` · +6 −1 · 1 files · 1 commits · closed without merging 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.
WriteProcessMemory fails with ERROR_PARTIAL_COPY on write-watched pages not
written since they were committed (Wine 11.22, Proton Experimental 11.0), so
what shaders wrote there did not reach title memory. A failed 4 KiB piece is
now read into the page instead; the kernel still checks the destination.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:04 +00:00
github-bot closed this pull request 2026-11-26 04:46:04 +00:00
Author
Owner

@⁠0xKaji on GitHub · 2026-11-24 23:25 UTC · original

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.

**@⁠0xKaji** on GitHub · 2026-11-24 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1831#issuecomment-7147390751) 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.
Author
Owner

@⁠CaravelaLabs on GitHub · 2026-11-25 00:36 UTC · original

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.

**@⁠CaravelaLabs** on GitHub · 2026-11-25 00:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1831#issuecomment-7148686793) 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

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