Map Ocarina's global memory accesses through pointer tables and summed bases to storage buffers.

The translator dropped 36113 global accesses per Kokiri boot (loads read 0, stores and atomics deleted); 837 remain.
AmpereLowering computes a predicated LEA's carry sum unconditionally, so a base like c[0][0x110] no longer reaches the
address as a phi; the edge AA's tile list is written and its blend weights follow the edges. Patch 0022 extends
GlobalToStorage: a constant-buffer base inside a sum of terms, and buffers reached through a pointer the program loads
from another storage buffer at a constant offset (the pointer tables Ocarina's vertex, pixel, mesh and compute shaders
read, also through register spills and phis). Such a buffer is listed with its outer buffer and offset, and the runtime
binds it at the address read from guest memory when the stage is bound (vk_exec_draw.c ptr_addr). The fog injection's
64x36x96 volumes now hold in-scattering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-06 14:02:22 -05:00
parent eed3e6b786
commit 9b4cca39ca
8 changed files with 470 additions and 23 deletions

View File

@@ -576,6 +576,7 @@ static void describe_bindings(Str *b, const VkExec *ex, const VkPipeInfo *info)
if (r && bd->kind == GFX_RES_SSBO) { // where the address lives (c0: the stage's NVN slot table) and the stage's slots
int st = nvn_stage(bd->stage);
sp(b, " %s ssbo at c%d+%#x%s, bound:", stn[st], r->cbuf_slot, r->handle * 4, r->flags & 1 ? " written" : "");
if (r->ptr) sp(b, " (address at +%#x of that buffer)", r->ptr - 1u);
if (st == 5 && r->cbuf_slot == 0 && r->handle * 4 >= 0x10 && r->handle * 4 + 12 <= 0x10 + (int)sizeof ex->cs_push) {
uint64_t pa; uint32_t ps; // an NVN2 compute push-constant pointer {address, size}
memcpy(&pa, ex->cs_push + r->handle * 4 - 0x10, 8), memcpy(&ps, ex->cs_push + r->handle * 4 - 0x10 + 8, 4);