mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 01:49:59 -04:00
Let shaders follow guest pointers into shadow copies, and keep those copies current for the device address table's readers.
With shadow storage (Linux, and Windows builds under Wine) a CPU-visible pool is a host-visible copy with no memory object of its own, and only pools that owned one went into the device address table: pointers the game's shaders read from memory reached nothing. Shadow copies are now in the table. A shader that reads through the table resolves no pool, so nothing queued the pool it reaches for the copy-in: the part is marked where its pipeline is drawn or dispatched (VkPipeInfo.gpa, vk_mem_gpa_use), and its prologue brings the shadow of every pool in the table up to date with the CPU's writes and queues the same pages for those pools' VRAM mirrors (vk_memory.c vk_mem_gpa_sync). --probe-vkmem reads a word through the table from a pool that is never bound, before and after a plain CPU write. Pull request #353 by TophC7, ported onto the base copies of the black-world fix: - taken as it is: the table registration, the mark in vk_exec_draw.c and vk_pipeline.c, the prologue call and vk_sync_probe_submit in vk_sync.c (two hunks merged by hand), the probe's test; - written again: vk_mem_gpa_sync, on top of the snapshot-based shadow_sync_pool; a lookup no longer queues a pool for being in the table, which every shadow pool now is; - narrowed: the sync runs only with shadow storage. Without it (Windows) a mirrored pool stays unsynced for the table's readers as before, so the frame there is unchanged, and the probe makes the source's mirror only with shadow storage and skips when the device has no address table; - the probe's shader was an array of SPIR-V words in tex_probe.c; it is now the source runtime/shaders/gpa_read.spvasm, built like the other runtime shaders; - the exact re-upload count in the texture probe stays checked on Windows. Files other sessions are changing: runtime/vk_memory.c (vk_pool_init's registration, mem_resolve's touch, the new section before vk_mem_use). The Windows files compile and the shader assembles and validates; no probe was run, and nothing was run on Linux here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
10
runtime/vk.h
10
runtime/vk.h
@@ -329,6 +329,12 @@ void vk_mem_lazy_handed(void);
|
||||
// write into CPU-visible memory at record time (vk_mem_gpu_pending) and reports it at the fence with vk_gpu_written,
|
||||
// which copies the bytes back into guest memory before telling the texture cache (vk_guest_written).
|
||||
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.
|
||||
void vk_mem_gpa_use(void);
|
||||
void vk_mem_gpa_sync(void);
|
||||
int vk_mem_shadow_storage(void); // CPU-visible pools are shadow copies of guest memory, not imports (NX2NAVI_SHADOW)
|
||||
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
|
||||
@@ -579,6 +585,9 @@ void rt_write_png(const char *path, const uint8_t *rgba, uint32_t w, uint32_t h)
|
||||
// once the GPU reached it and the completion thread ran its side effects. Guest or host threads.
|
||||
void vk_sync_start(void); // vk_init (fatal without a device) and the completion thread; idempotent
|
||||
uint64_t vk_sync_submit(const uint64_t *handles, int n); // records with vk_exec_record, submits; returns the value
|
||||
// --probe-vkmem: record gives the submission's commands in place of the replay, under the same submission lock,
|
||||
// recorder, memory prologue and fence.
|
||||
uint64_t vk_sync_probe_submit(void (*record)(VkCommandBuffer, void *), void *arg);
|
||||
uint64_t vk_sync_reserve(void); // asynchronous replay: the value the next queued submission signals
|
||||
int vk_sync_fence_wait(uint64_t value, uint64_t timeout_ns); // 1 when done; 0 on timeout or a value never submitted
|
||||
// The executed timeline (vk_sync.c): a submission's own commands are through the GPU, its write-backs maybe not yet.
|
||||
@@ -676,6 +685,7 @@ typedef struct {
|
||||
// from the start of the set's descriptors. VK_NULL_HANDLE: the set is written with VkWriteDescriptorSet structs.
|
||||
VkDescriptorUpdateTemplate tpl[2];
|
||||
int pool; // a stage indexes the texture or sampler pool: bind set 2 (the pools)
|
||||
int gpa; // a stage accesses guest pointers through the device address table
|
||||
} VkPipeInfo;
|
||||
// One descriptor of the packed array a descriptor update template reads (VkPipeInfo.tpl), 24 bytes for every type; the
|
||||
// bytes a type leaves unused are zero, so equal descriptors compare equal byte for byte.
|
||||
|
||||
Reference in New Issue
Block a user