mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-17 13:39:58 -04:00
Add wb_probe = 1, which finds out who reads what the GPU wrote back into guest memory.
Per-pass GPU timestamps put the write-back of GPU-written storage buffers at 3.6 to 5.3 ms of GPU time a frame in play, against 1.8 to 2.5 ms for all of the game's own passes and dispatches: about 67 MiB a frame goes from the mirrors back into guest memory, from the same eleven pools all session, in case the CPU or a host path reads it. Nothing said whether anything does. With wb_probe = 1 the 2 MiB regions that lie wholly inside a range just written back are made inaccessible. The first read or write of such a region faults; the handler gives the region back the protection it had (read-only when frozen, else read-write), notes the address, the instruction and the thread, and the access runs again. The bytes are in guest memory all along, so nothing changes for the game. A log block every perf window gives the regions armed, the probes a read or a write ended, and the first accesses by instruction. Every thaw ends the probe of its region first, which covers file reads into guest memory and mapping changes; a file write from guest memory thaws its buffer while the probe is on; a probed region is not frozen anew. The platform layer gets a hook for every read or write access fault beside the write-fault hook; it is installed only with the setting. --probe-gfx-abi checks that nothing is armed without it and, run with NX2NAVI_WB_PROBE=1, that reads and writes end a probe and run again, that a frozen region thaws after it and that mem_thaw ends and holds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1006,11 +1006,15 @@ uint64_t plat_mem_written(uint64_t addr, uint64_t n, uint64_t *pages, uint64_t m
|
||||
// SDL), then goes to the crash hook (main.c), which reports it and ends the process. Without a crash hook the fault
|
||||
// gets the default action. Runs on the thread's signal stack.
|
||||
static int (*fault_hook)(uint64_t addr);
|
||||
static int (*access_hook)(uint64_t addr, int write, uint64_t ip); // every read or write fault, before fault_hook
|
||||
static void (*crash_fn)(const PlatCrash *c);
|
||||
|
||||
static void fault_handler(int sig, siginfo_t *si, void *uc) {
|
||||
ucontext_t *u = uc;
|
||||
long err = u->uc_mcontext.gregs[REG_ERR];
|
||||
if (sig == SIGSEGV && access_hook && !(err & 16) &&
|
||||
access_hook((uint64_t)(uintptr_t)si->si_addr, (err & 2) != 0, (uint64_t)u->uc_mcontext.gregs[REG_RIP]))
|
||||
return;
|
||||
if (sig == SIGSEGV && fault_hook && (err & 2) && fault_hook((uint64_t)(uintptr_t)si->si_addr)) return;
|
||||
uintptr_t rip = (uintptr_t)u->uc_mcontext.gregs[REG_RIP];
|
||||
Dl_info at, self;
|
||||
@@ -1050,6 +1054,11 @@ void plat_mem_fault_hook(int (*fn)(uint64_t addr)) {
|
||||
fault_install();
|
||||
}
|
||||
|
||||
void plat_mem_access_hook(int (*fn)(uint64_t addr, int write, uint64_t ip)) {
|
||||
access_hook = fn;
|
||||
fault_install();
|
||||
}
|
||||
|
||||
void plat_crash_context(const char *s) { (void)s; } // the Windows crash notes only
|
||||
int plat_crash_filter_reassert(char *who, size_t n) { (void)who, (void)n; return 0; } // Windows only
|
||||
|
||||
|
||||
Reference in New Issue
Block a user