mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 15:09:58 -04:00
Copy the pages the CPU wrote into a VRAM mirror when their part is handed to the queue, behind NX2NAVI_MIRROR_CAPTURE_KB.
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>
This commit is contained in:
@@ -243,6 +243,8 @@ int mem_lazy_enable(void (*fetch)(uint64_t h0, uint64_t h1, uint64_t off, uint64
|
||||
uint64_t mem_lazy_arm(uint64_t a, uint64_t n, uint64_t h0, uint64_t h1, uint64_t off, void *ctx);
|
||||
int mem_lazy_skip(uint64_t a, uint64_t n, uint64_t h0, int64_t delta, uint64_t out[][2], int max);
|
||||
int mem_lazy_armed(uint64_t a, uint64_t n);
|
||||
// Copies the ranges src[i] = {address, bytes} of guest memory whose pages read without a fault to dst[i], ok[i] set.
|
||||
int mem_copy_readable(uint8_t *const *dst, const uint64_t (*src)[2], int n, uint8_t *ok);
|
||||
void mem_lazy_window(int open);
|
||||
void mem_lazy_release(uint64_t a, uint64_t n);
|
||||
void mem_lazy_report(uint64_t frame, uint64_t skipped);
|
||||
|
||||
Reference in New Issue
Block a user