Repository navigation
GPU: under Wine, write title memory without a wineserver request - #256
yayameowmeow wants to merge 1 commit into
Conversation
write_mapped puts what shaders wrote back into title memory with NtWriteVirtualMemory (or WriteProcessMemory), which on Windows is a kernel copy. Wine implements both as a wineserver request (the server writes /proc/<pid>/mem), even for the calling process, so in gameplay every frame sent thousands of requests to one server thread that every other thread of the process also waits on. A read of the calling process is copied in place by Wine, after it checks the destination is writable, so under Wine the write is that read, from the host copy into the title page. Windows is unchanged; VICTORY_WINE_WRITES=0 writes as there. A test writes across committed pages around an uncommitted one: the pages around the hole get the bytes and nothing faults (both paths checked under Wine 11.20). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ErRusso
left a comment
There was a problem hiding this comment.
Reviewed at d945776 against 2119b0e.
The Wine path is sound: ReadProcessMemory(GetCurrentProcess(), host, title, n) copies into the title page in-process, while the existing 64 KiB/4 KiB fallback still leaves unmapped pages alone. VICTORY_WINE_WRITES=0 preserves the old call and on_wine() is cached.
Verified: host::writes::writes_skip_pages_that_are_not_mapped passes under Wine on the new path (the hole is skipped, the committed blocks receive the bytes). The author's server-count and title measurements cover the performance claim.
LGTM.
|
I tested The two offline Series S runs used the same binary, warm seed, memory/VRAM limits and NVMe caps. Four comparable post-upscale opening frames wrote about 0.8–4.5 MB each. With the legacy The in-process run returned 58 post-upscale Presents and rendered the opening sequence. It ended on the local NVMe contention guard. This was one run per API and its performance measurements cover copy-back during the opening. Codex assisted with the integration and tests. |
Problem
Under Wine (Linux, Proton),
write_mappedsends a wineserver request for every write. It puts shader results back into title memory withNtWriteVirtualMemory, orWriteProcessMemorywithVICTORY_DIRECT_WRITES=0. On Windows that is a kernel copy. Wine implements both as the server requestwrite_process_memory, which writes/proc/<pid>/mem, even when the process writes into itself. wineserver is one thread, and the process's other server calls (mappings, handles, timers) queue behind it.Counted with
WINEDEBUG=+serverin the opening gameplay scene (Wine 11.20, RX 7900 XTX / RADV): 3,400–24,000write_process_memoryrequests per 30 s.Fix
Under Wine (
ntdll!wine_get_versionpresent), the write becomes a read of our own process, from the host copy into the title page:ReadProcessMemory(GetCurrentProcess(), host, title, n).VICTORY_WINE_WRITES=0restores the old call.Verification
write_process_memoryno longer appears among the server requests (same scene,+servercount).map_view/unmap_view. Its per-process view list is searched linearly, which this PR doesn't address. With that also fixed locally, the scene runs at 0.6–0.9 s per frame instead of 2–6 s, but that number belongs to both changes.host::writes::writes_skip_pages_that_are_not_mapped: writes across two committed 64 KiB blocks around an uncommitted one and checks the committed ones got the bytes. Passes under Wine on both paths, the default andVICTORY_WINE_WRITES=0.cargo clippy --workspace --all-targets --locked -- -D warningsand the same with--all-featuresare clean (cross-built with cargo-xwin).cargo test -p victory-gpuunder Wine gives 107 passed, 4 failed. The same 4 fail on unmodifiedmainunder Wine: argument clamp, depth-plane twin, pipeline library, scratch reuse. Those are the Wine shader-compiler issues covered by GPU: compile our run-time HLSL with DXC when the system compiler refuses it (Wine/Proton) #20 / GPU: compile internal HLSL and serialize root signatures natively under Wine/Proton #127. I couldn't run the suite on Windows.🤖 Generated with Claude Code