Wine/Proton: in-process copies of title memory (VICTORY_DIRECT_COPY=1), with guard pages handled #34
No reviewers
Labels
No labels
accessibility
bench-bm-v1
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/PastiiJay--klbf-lab!34
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-34"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@zocram4cc on GitHub · 2026-11-25 19:01 UTC · original
zocram4cc:up/direct-copy→beta· +317 −7 · 2 files · 3 commits · openUnder Wine/Proton, putting back what shaders wrote is the slowest part of a world frame: Wine's
NtWriteVirtualMemorysends every byte through wineserver, even for the calling process (write_process_memoryrequest indlls/ntdll/unix/virtual.c), so copy-back takes seconds a frame and wineserver sits at ~70 % of a core with the GPU idle. This is the report in #19.Change
GPU: use VEH-guarded in-process copy for copy_mapped and write_mapped: the commit of fxceless/victory-fork#154 by @BitWuehler, cherry-picked unchanged (authorship kept). Reads and copy-back copy in-process; a vectored handler turns a fault inside the copy into a failed copy, as the kernel calls report it.VICTORY_DIRECT_COPY=1turns it on; without it nothing changes (Windows behaviour untouched).STATUS_GUARD_PAGE_VIOLATION. Title memory has guard pages, so with the copy on the process ended withunhandled exception 0x80000001after a minute or two in the world (Shadow::copy→copy_mapped→read→try_copy, symbolised from the PDB). This is the crash in #19's second run. A guard page now fails the copy like an unreadable page, and the guard flag is set again (the fault that reported it cleared it), so the title still sees its own first touch.Tests (Proton Experimental 11.0-20261112, cross-built with cargo-xwin)
direct_copy_fails_on_a_guard_page_and_keeps_it_guarded: the test process dies without the fix, passes with it.write_mapped_skips_unmapped_and_readonly_pages_and_marks_write_watchpasses with and withoutVICTORY_DIRECT_COPY=1.benchmark_direct_copy_vs_kernel_calls(--ignored --nocapture, under Wine): 64 KiB writes NtWriteVirtualMemory 1,221 MB/s vs in-process 42,068 MB/s; 256 MB read 6.0 vs 10.1 GB/s.In game (RX 6900 XT, RADV / Mesa 26.3.1, Proton Experimental, Series X, scripted input, fresh profile; world medians of a per-second frame-time log)
Measured on a build of
553bd7cwith the Wine fixes listed in #19; the copy path is the same as on this branch.VICTORY_DIRECT_COPY=1VICTORY_DIRECT_COPY=1+ guard fixThe run with the fix then stopped at the title's own breakpoint
+0x5149aec(INSTANCE_LISTpool full, Marvisak/VIctory#698), which is unrelated.Not tested on Windows. Off by default, so Windows runs are unchanged unless the switch is set.
No game files, logs or dumps attached. AI-assisted (Claude Code); runs and measurements on my machine.
@PastiiJay on GitHub · 2026-11-25 19:07 UTC · original
Thanks a lot @zocram4cc for opening these! It's great to have the Wine/Proton side covered. I'll test that nothing changes on Windows (the switch is off by default, right?) and report back here.
@zocram4cc on GitHub · 2026-11-25 19:13 UTC · original
Yes, it stays off by default. Only
VICTORY_DIRECT_COPY=1turns it on (direct_copy_enabled:std::env::var_os("VICTORY_DIRECT_COPY").is_some_and(|v| v == "1"), host.rs:6549); any other value or no variable keeps the old path.With the switch off, on Windows:
readgoes toread_kernel, which is the sameReadProcessMemorycall as before.write_mappedtakes the sameNtWriteVirtualMemory/WriteProcessMemorybranches as before (in_processis false).The one change on the default path is in
watch.rs: the body of the write-fault handler moved unchanged intohandle_write_fault, so the in-process copy can share it, and the handler now calls it. It is the same logic and lock, just moved.Thanks for testing on Windows!
@PastiiJay on GitHub · 2026-11-25 19:19 UTC · original
Perfect, thanks for the precise answer @zocram4cc. That's exactly what I wanted to check. I'll run it with the switch off on our RX 9070 XT to confirm nothing moves, then merge.
@PastiiJay on GitHub · 2026-11-25 19:56 UTC · original
@zocram4cc I've added a "Playing on Linux / Proton?" box at the top of both READMEs (main and beta) pointing Linux players to your work (#34, #35) and asking them to tag you with their results. Thanks for leading the Linux side!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.