Let a shadow write-back clear the write watch's protection of its range in one call on Linux (shadow_bulk_write = 1).

On Linux the write watch protects pages, so a write-back from shadow storage into guest memory took a fault
at the first store into every page. plat_mem_prepare_write clears the protection of a range with one
UFFDIO_WRITEPROTECT call; the pages count as written, as they would after the faults. Off by default;
Windows has nothing to clear.

Pull request #327 by theurbanninja1993-sketch (a draft on GitHub). The platform function and its Linux
test are taken as they are. The call moved: the write-back it was written for is now shadow_write_back in
runtime/vk_memory.c (a file other sessions are changing), where it covers the runs of pages a submission
changed, and the setting is registered in cfg.c and described in nx2navi.ini.example, which also says
that the lazy write-back stays off with shadow storage.

The Windows files compile; the Linux code and its test are not compiled or run here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 06:31:27 -05:00
parent 3134f52475
commit 4d12238e69
7 changed files with 72 additions and 3 deletions

View File

@@ -649,8 +649,12 @@
# wb_split = 1
# 1: what the game's shaders write into its memory is copied back from the video card once, and after that only when
# the game's CPU code touches it (most of it never is: 66 MiB a frame in Hyrule Field). 0: copied back at the end of
# every GPU submission, as before. On Linux it is off unless set here.
# every GPU submission, as before. On Linux it is off unless set here, and with shadow storage (Linux, Wine) it stays
# off.
# wb_lazy = 1
# Linux, shadow storage: 1 clears the write watch's protection of a range in one call before the GPU's bytes are copied
# back into the game's memory, instead of taking a fault at the first store into each page.
# shadow_bulk_write = 0
# 1: the game's flushes of mirrored memory are copied into the mirrors even where the write watch already sees every
# page the game wrote; 0 (default) copies only the written pages there, which saved 47-57 MiB of copies a frame in
# Kokiri Forest.