mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 07:31:06 -04:00
Fix the black 3D world under shadow storage on Linux and Proton, and copy only what each side wrote.
Shadow storage noted a GPU write with the whole range its binding names: the copy-in skipped that range and the fence copied all of it back, so CPU writes to other fields of the same records never reached the GPU. Ocarina's lighting parameter is such a field: the lighting came out NaN and the fog pass drew the scene black. Each page a noted range covers now keeps a base copy, the copy-in moves only the bytes the CPU changed and the write-back only those the GPU changed (vk_memory.c merge_page). The mirror's merge shader marks the 4 KiB pages it changed, and one job per submission copies only those back (shadow_wb_cb); the copy-in reads the CPU-side generation tables through the shared write-watch snapshots; and a caller that reads guest memory itself resolves with vk_mem_lookup, which does not queue the pool for the copy-in. Pull request #394 by jacc. Its changes are taken as they are; one hunk met the lazy write-back that came later (vk_gpu_written_back) and is merged by hand. Added here: the lazy write-back stays off with shadow storage, because its fetch copies the mirror into the pool's buffer, which is guest memory only for an imported pool. Files other sessions are changing: runtime/vk_memory.c (the shadow section, the merge record, vk_gpu_written_back, wb_lazy) and three one-word call changes in runtime/vk_usnap.c. Without shadow storage (Windows outside Wine) the merge pipeline gains an unused fifth binding and two push constants and nothing else changes. The Windows files compile; nothing was run, on Windows, Wine or Linux. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -95,8 +95,7 @@ With 16 GB of RAM, add `--jobs 4`: the compiles run beside the 26 GB RomFS image
|
||||
processor can fill memory and swap until the kernel stops processes of the desktop session (about 10 minutes on a
|
||||
12-thread Ryzen with 4 jobs). Do not play or prepare shaders while it builds.
|
||||
|
||||
On NVIDIA, start the game with `NX2NAVI_SHADOW=0` if the 3D world stays black while the HUD draws (issue #72). The
|
||||
profile, logs and settings are in the `--out` folder as on Windows.
|
||||
The profile, logs and settings are in the `--out` folder as on Windows.
|
||||
|
||||
On NVIDIA the driver keeps the shaders it compiled in `nvidia-cache` beside `ocarina`, not in `~/.cache/nvidia`, where
|
||||
one run adds at most 1 GiB while the preparation at the end of the build makes about 1.5 GB. The game makes and sets
|
||||
|
||||
@@ -245,8 +245,11 @@ Memory: on Windows the GPU imports guest memory and `GetWriteWatch` tracks the C
|
||||
re-protecting imported memory invalidates the driver's userptr buffer on every submit (about 1.3 ms per 16 MiB on
|
||||
amdgpu), and importing pins the pages, which drops their write protection. Each CPU-visible pool therefore gets a
|
||||
host-visible copy (shadow storage, `runtime/vk_memory.c`): the pages the CPU wrote go in before each submit, and the GPU's
|
||||
writes come back at its fence. In play that costs about 0.2 ms a frame and doubles the memory of those pools (about
|
||||
1.1 GB). `NX2NAVI_SHADOW=1` turns it on under Windows too. The Steam Deck's RADV has `VK_EXT_external_memory_host` as
|
||||
writes come back at its fence. Pages both sides write keep a base copy, so each direction moves only its own bytes;
|
||||
a VRAM mirror's write-back merge marks the pages it changed, and only those are compared at the fence; a lookup that
|
||||
reads guest memory itself (the uniform snapshot, `vk_mem_lookup`) does not queue its pool for the copy-in. In Kokiri
|
||||
Forest (1.1.1, RTX 4090) that costs about 1 ms a frame (copy-in 0.5 ms, write-back 0.6 ms), and the copies hold about
|
||||
5 GB. `NX2NAVI_SHADOW=1` turns it on under Windows too. The Steam Deck's RADV has `VK_EXT_external_memory_host` as
|
||||
well: the shadow copies are chosen for the measured cost above, not for a missing extension.
|
||||
|
||||
The Deck's GPU (Van Gogh) has no native ASTC, so its textures go through the compute decoder (`runtime/vk_astc.c`,
|
||||
|
||||
Reference in New Issue
Block a user