Count what the shadow copy-ins overwrite and cost, and keep stores through the device address table behind a switch.

NX2NAVI_SHADOW_CHECK=1 logs with the shadow line, every 60 frames: the whole copy-ins that overwrote a store a
shader made through the device address table, and the pools they fell on; the write-backs that moved bytes into
a page the CPU had written since its copy-in; the bytes both sides changed since their base copy; what the
copy-ins cost by kind, and which pools and flag sets took them. The stores are found by content: a whole
copy-in leaves a hash of the page, and the next one compares the shadow page with it first.

NX2NAVI_SHADOW_TABLE_STORES=1 keeps such stores: a page found stored into gets a base copy, so copy-ins take
only the CPU's bytes, and the fence of every submission that uses the table writes the stores back to guest
memory. --probe-vkmem checks it with a GPU write that nothing notes. It is off by default. The overwrite it
removes was the suspected cause of the flicker on Linux and is not: standing outdoors (RTX 5090 with
NX2NAVI_SHADOW=1) it happens exactly four times a frame, on ten pages in pools of 20 and 44 KiB, with the copy
that precedes the frame's stores, and no frame came out wrong with it or without it in 1,800 frames each; the
hashes cost 1.8 ms a frame of the replay (67 against 75 fps); and a count the CPU resets before the write-back
has landed would keep counting, where the whole copy-in resets it every time.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-10 23:15:02 -05:00
parent 175c1947de
commit 5b1413d817
7 changed files with 449 additions and 14 deletions

View File

@@ -348,10 +348,12 @@ void vk_mem_fatal_note(char *out, size_t n); // the memory mode and the lazy w
void vk_mem_shadow_sync(void);
// A shader of the part being recorded reads through the device address table (vk_gpa.c), also when its descriptors
// are reused: with shadow storage the part's prologue (vk_mem_gpa_sync) then brings every pool the table names up to
// date with the CPU's writes, since the pools such a shader reaches are never resolved.
// date with the CPU's writes, since the pools such a shader reaches are never resolved. fence: the submission's value,
// at which what the shaders stored through the table goes back to guest memory.
void vk_mem_gpa_use(void);
void vk_mem_gpa_sync(void);
void vk_mem_gpa_sync(uint64_t fence);
int vk_mem_shadow_storage(void); // CPU-visible pools are shadow copies of guest memory, not imports (NX2NAVI_SHADOW)
int vk_mem_shadow_table_stores(void); // shadow storage keeps what shaders store through the table (NX2NAVI_SHADOW_TABLE_STORES)
void vk_mem_gpu_pending(uint64_t addr, uint64_t size);
void vk_gpu_written(uint64_t addr, uint64_t size);
// The same for a GPU write into a VRAM mirror, which went back to guest memory with the submission: the texture checks