Write through the device address table into guest memory too, so the GPU's writes there are no longer lost.

The table's records gain a twin: a pool with a VRAM mirror names the mirror first and its imported buffer, guest
memory, second; any other record names one buffer twice. Shaders read through the first address and store and run
atomics through both (translator patch 0034); a page without a twin sends the second write to a 4 KiB scratch buffer.
The GPU's writes through the table were not recorded as GPU writes, so they stayed in the mirror: the CPU never saw
them, and a sync of a page the CPU wrote copied the stale guest page over them. Trees drawn from records lost that
way stretched into columns reaching the sky. With NX2NAVI_MEMORY=verify the Hyrule Field walk found 16 such mirror
pages before and none or one after; GPU time per frame 5.92 ms before, 6.17 ms after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-07 20:24:41 -05:00
parent 8102b6a222
commit 4cb8188491
4 changed files with 168 additions and 14 deletions

View File

@@ -18,7 +18,8 @@ uint32_t vk_gpa_map(uint64_t lo, uint64_t hi, VkBuffer buf, uint64_t buf_lo);
void vk_gpa_unmap(uint64_t lo, uint64_t hi, uint32_t rec, uint32_t (*cover)(uint64_t page_addr));
// Unmaps every page of [lo, hi), whatever record it names (pages of a virtual pool whose physical memory goes away).
void vk_gpa_clear(uint64_t lo, uint64_t hi);
// Moves the pages of [lo, hi) that name old_rec (or none) to buf (a pool's VRAM mirror); returns the new record.
// Moves the pages of [lo, hi) that name old_rec (or none) to buf (a pool's VRAM mirror), with old_rec's buffer as their
// twin, which shaders write too; returns the new record.
uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo);
void vk_gpa_report(void);
void vk_gpa_shutdown(void);