mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 23:49:56 -04:00
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:
@@ -225,7 +225,18 @@ static class SwshXlate
|
||||
res["mesh"] = new JsonObject { ["lines"] = mesh.Lines.Count, ["shared"] = mesh.SharedBytes,
|
||||
["outputs"] = new JsonArray(MeshSpirv.GenericLocations(mesh).Select(x => (JsonNode)x).ToArray()) };
|
||||
foreach (var b in p.Info.CBuffers) res["cbufs"].AsArray().Add((JsonNode)new JsonObject { ["binding"] = b.Binding, ["slot"] = b.Slot });
|
||||
foreach (var b in p.Info.SBuffers) res["sbufs"].AsArray().Add((JsonNode)new JsonObject { ["binding"] = b.Binding, ["slot"] = b.Slot, ["cb_slot"] = b.SbCbSlot, ["cb_offset"] = b.SbCbOffset, ["flags"] = (int)b.Flags });
|
||||
foreach (var b in p.Info.SBuffers)
|
||||
{
|
||||
// A buffer whose address is a pointer stored in another storage buffer (patch 0022, GlobalToStorage
|
||||
// PointerSlotFlag): cb_slot 0x20 | the slot of the outer buffer's address, cb_offset its word offset in
|
||||
// bits 0-9 and the pointer's byte offset in the outer buffer / 8 in bits 10-15. Written as the outer
|
||||
// buffer's cb_slot / cb_offset plus "ptr", the byte offset.
|
||||
bool pointer = (b.SbCbSlot & 0x20) != 0;
|
||||
var o = new JsonObject { ["binding"] = b.Binding, ["slot"] = b.Slot, ["cb_slot"] = pointer ? b.SbCbSlot & 0x1f : b.SbCbSlot,
|
||||
["cb_offset"] = pointer ? b.SbCbOffset & 0x3ff : b.SbCbOffset, ["flags"] = (int)b.Flags };
|
||||
if (pointer) o["ptr"] = (b.SbCbOffset >> 10) * 8;
|
||||
res["sbufs"].AsArray().Add((JsonNode)o);
|
||||
}
|
||||
foreach (var (list, name) in new[] { (p.Info.Textures, "textures"), (p.Info.Images, "images") })
|
||||
foreach (var t in list) res[name].AsArray().Add((JsonNode)new JsonObject { ["binding"] = t.Binding, ["type"] = (int)t.Type, ["format"] = t.Format.ToString(), ["cbuf_slot"] = t.CbufSlot, ["handle"] = t.HandleIndex, ["array"] = t.ArrayLength, ["separate"] = t.Separate, ["flags"] = (int)t.Flags,
|
||||
["pool"] = t.ArrayLength == Accessor.TexturePoolLength ? 1 : t.ArrayLength == Accessor.SamplerPoolLength ? 2 : 0 });
|
||||
|
||||
Reference in New Issue
Block a user