mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 18:09:58 -04:00
The prologue of a part copies the pages the CPU wrote since a mirror's last sync from guest memory into the mirror when the GPU runs it, a frame or more after the game's submit when the GPU is behind: the GPU then reads what the game wrote there meanwhile, values meant for a later frame. With NX2NAVI_MIRROR_CAPTURE_KB=n the CPU copies up to n KiB of those pages per part into a host buffer of the submission when the part is handed over, and the prologue copies them from there. A pool keeps the GPU-time copy while a write-back of its mirror into guest memory is still on the GPU (its fence, now kept per pool), when it has a twin (the device address table's writes reach guest memory unrecorded), and for a range with a page that cannot be read without a fault (memory.c mem_copy_readable, under the freeze lock, so a lazily armed range stays with the GPU). With the default of every mirror twinned (NX2NAVI_GPA_TWIN_MAX_KB=0) it copies nothing; it is a test switch for the replay's late reads, default 0. Measured on an RTX 5090 with NX2NAVI_GPA_TWIN_MAX_KB=64 (mirrors of pools over 64 KiB without a twin), 75 s runs with warm caches, NX2NAVI_MIRROR_CAPTURE_KB 0 against 8192: Kakariko 0.95 MiB a frame copied in 149 ranges for 0.21 ms of the replay thread, 116.7 against 118.4 fps (interval median 6.26 against 6.46 ms); Hyrule Field walk 1.38 MiB in 224 ranges, 0.37 ms, 110.2 against 107.2 fps, 1% low 83.3 against 78.1. 0.08 MiB a frame stayed with the GPU-time copy. A first version that took the freeze lock and asked the system for each range's pages cost 2.9 to 4.3 ms a frame. A Kakariko run with NX2NAVI_REPLAY_ASYNC=1 and the copy on played through without errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 KiB
89 KiB