mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 04:49:57 -04:00
Let shaders follow guest pointers into shadow copies, and keep those copies current for the device address table's readers.
With shadow storage (Linux, and Windows builds under Wine) a CPU-visible pool is a host-visible copy with no memory object of its own, and only pools that owned one went into the device address table: pointers the game's shaders read from memory reached nothing. Shadow copies are now in the table. A shader that reads through the table resolves no pool, so nothing queued the pool it reaches for the copy-in: the part is marked where its pipeline is drawn or dispatched (VkPipeInfo.gpa, vk_mem_gpa_use), and its prologue brings the shadow of every pool in the table up to date with the CPU's writes and queues the same pages for those pools' VRAM mirrors (vk_memory.c vk_mem_gpa_sync). --probe-vkmem reads a word through the table from a pool that is never bound, before and after a plain CPU write. Pull request #353 by TophC7, ported onto the base copies of the black-world fix: - taken as it is: the table registration, the mark in vk_exec_draw.c and vk_pipeline.c, the prologue call and vk_sync_probe_submit in vk_sync.c (two hunks merged by hand), the probe's test; - written again: vk_mem_gpa_sync, on top of the snapshot-based shadow_sync_pool; a lookup no longer queues a pool for being in the table, which every shadow pool now is; - narrowed: the sync runs only with shadow storage. Without it (Windows) a mirrored pool stays unsynced for the table's readers as before, so the frame there is unchanged, and the probe makes the source's mirror only with shadow storage and skips when the device has no address table; - the probe's shader was an array of SPIR-V words in tex_probe.c; it is now the source runtime/shaders/gpa_read.spvasm, built like the other runtime shaders; - the exact re-upload count in the texture probe stays checked on Windows. Files other sessions are changing: runtime/vk_memory.c (vk_pool_init's registration, mem_resolve's touch, the new section before vk_mem_use). The Windows files compile and the shader assembles and validates; no probe was run, and nothing was run on Linux here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -252,6 +252,21 @@ Forest (1.1.1, RTX 4090) that costs about 1 ms a frame (copy-in 0.5 ms, write-ba
|
||||
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 device address table (`runtime/vk_gpa.c`) names a pool's shadow copy as it names an import, so shaders follow guest
|
||||
pointers into either. A shader that reads through the table resolves nothing, so the pool it reaches is not queued for
|
||||
the copy-in: a part whose pipelines declare the table is marked at its draws and dispatches, and its prologue brings
|
||||
the shadow of every pool in the table up to date with the pages the CPU wrote and queues the same pages for those
|
||||
pools' VRAM mirrors (`vk_memory.c` `vk_mem_gpa_sync`). That copies the written pages of every CPU-visible pool in
|
||||
each such part, which the cost above does not include. What a shader stores through the table into a shadow copy does
|
||||
not come back to guest memory. `--probe-vkmem` checks the read: a shader follows the table to a word of a pool that is
|
||||
never bound, and must read `0x13579BDF` and, after a plain CPU write, `0x2468ACE0`. On Linux, run it for each backing:
|
||||
|
||||
```sh
|
||||
for shadow in 0 1; do for memory in import mirror; do
|
||||
NX2NAVI_GPA=1 NX2NAVI_SHADOW=$shadow NX2NAVI_MEMORY=$memory ./ocarina --probe-vkmem
|
||||
done; done
|
||||
```
|
||||
|
||||
The Deck's GPU (Van Gogh) has no native ASTC, so its textures go through the compute decoder (`runtime/vk_astc.c`,
|
||||
`NX2NAVI_ASTC`) as on desktop AMD GPUs without it; frame times measured there include it.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user