mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-20 06:09:58 -04:00
Sync the device address table's shadows once per guest submission that binds the table, and take out the port of pull request #353.
The author of pull request #353 closed it on 2026-11-11 with the words that they give no permission to use its code. Its port (3134f524) goes: the mark of a pipeline that declares the table (VkPipeInfo.gpa, vk_pipeline.c pipe_add) and of the part that draws with it (vk_mem_gpa_use in vk_exec_draw.c bind_resources and mo_emit), the sync of the table's pools in every such part's prologue (vk_mem_gpa_sync), the submission with a callback in the replay's place as it stood (vk_sync_probe_submit), and --probe-vkmem's read through the table with its shader (test_gpa_read, runtime/shaders/gpa_read.spvasm).
In its place, after pull request #551, which was written without that code: a shadow pool goes into the table and onto a list of the table's shadows (vk_memory.c shadow_table_add); the record of a binding of the table notes the guest submission (vk_exec_draw.c ssbo_info, vk_mem_shadow_table_read); and vk_mem_shadow_sync brings the CPU's writes into every shadow on the list once for that guest submission, before the part is submitted. Once is enough, because the copy-ins read the guest submission's write-watch snapshots, which a second sync would find unchanged. Measured by #551's author on Linux (RTX 4090, Kokiri Forest): 113 and 76 frames over 25 ms in 75 s against 217 and 429 with the port, 43 against 41 fps, the picture complete in both.
What this line had built on the port stays, on the new sync: the test that passes over a pool with nothing written (shadow_pool_clean), the upload of the same pages into a table pool's VRAM mirror, the write-back of stores through the table (NX2NAVI_SHADOW_TABLE_STORES, table_wb_cb, now asked once per guest submission that binds the table) and the counts of NX2NAVI_SHADOW_CHECK. The probes that record their own commands (the lost-device probe, --probe-vkmem's table parts) call vk_sync_submit_own, written anew. vk_mem_shadow_storage stays: one line that returns the mode. Finalized pools in the table were already kept for vk_mem_shutdown here.
--probe-vkmem has a check of its own for the sync (test_table_sync): the shadow of a pool that is never bound keeps its old word through a CPU write and a guest submission that does not bind the table, and holds the new one after a guest submission that does. It passes with NX2NAVI_SHADOW=1 on Windows (RTX 5090), as do the store check with NX2NAVI_SHADOW_TABLE_STORES=1 and the probe without shadow storage; --probe-devlost ends as before. Not run: the game, with or without shadow storage, and anything on Linux.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -1388,9 +1388,13 @@ static VkDescriptorBufferInfo ssbo_info(VkExec *ex, int st, const GfxShaderRes *
|
||||
// of every mirror at a table reader's draw copied stale guest bytes over what the GPU had written into the mirrors
|
||||
// earlier in the frame, and Kokiri Forest's lit areas went black. A pool read only through the table is rarely a
|
||||
// mirrored one (mirrors are made for pools bound as buffers, which sync then). With shadow storage every pool the
|
||||
// table names is a copy of guest memory, and nothing resolves the pools such a reader reaches: bind_resources
|
||||
// marks the part (vk_mem_gpa_use) and its prologue brings those copies up to date (vk_memory.c vk_mem_gpa_sync).
|
||||
// table names is a copy of guest memory, and nothing resolves the pools such a reader reaches: the binding is
|
||||
// noted here, and the copies are brought up to date before the part is submitted (vk_memory.c
|
||||
// vk_mem_shadow_table_read). A draw that reuses the descriptors of the one before it (bind_resources) comes after
|
||||
// a build in the same command buffer, and the packed descriptors of mo_desc are built in the same guest
|
||||
// submission as their draws: either way this ran for the guest submission.
|
||||
if (r->cbuf_slot == VK_GPA_CB_SLOT) {
|
||||
vk_mem_shadow_table_read();
|
||||
VkDescriptorBufferInfo t = vk_gpa_info();
|
||||
return t.buffer ? t : (VkDescriptorBufferInfo){Z.zbuf, 0, VK_WHOLE_SIZE};
|
||||
}
|
||||
@@ -3231,7 +3235,6 @@ static void bind_resources(VkExec *ex, const VkPipeInfo *info) {
|
||||
static VkDescSlot d[MAX_DESC];
|
||||
static VkBufferView bv[MAX_DESC];
|
||||
if (info->n_bindings > MAX_BINDINGS) rt_fatal("vk: %u descriptor bindings exceed the replay's %d", info->n_bindings, MAX_BINDINGS);
|
||||
if (info->gpa) vk_mem_gpa_use(); // before the early returns for reused descriptors: the shader still reads the table
|
||||
bind_stats(info);
|
||||
int gfx = info->bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||
int skip = gfx ? bind_skip_on() : 0, same = 0, was_valid = B.res_valid;
|
||||
@@ -4460,7 +4463,6 @@ static void mo_emit(VkCommandBuffer cb) {
|
||||
for (int n = 0; n < MQ.n; p = &MQ.d[n++]) {
|
||||
const MoDraw *q = &MQ.d[n];
|
||||
const VkPipeInfo *info = q->info;
|
||||
if (info->gpa) vk_mem_gpa_use(); // these draws bind packed descriptors without bind_resources, maybe in a later part
|
||||
if (q->pipe != pipe) vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_GRAPHICS, q->pipe), pipe = q->pipe, MO.e_pipe++;
|
||||
if (q->st != st) vk_pipeline_set_dynamic(cb, &MQ.st[q->st]), st = q->st, MO.e_dyn++;
|
||||
if (!p || memcmp(&q->v, &p->v, sizeof q->v)) vkCmdSetViewportWithCount(cb, 1, &q->v);
|
||||
|
||||
Reference in New Issue
Block a user