From e3cf0710c54890fc783a40d7f5e9a13f628871b0 Mon Sep 17 00:00:00 2001 From: chrg6 Date: Thu, 12 Nov 2026 13:08:16 -0500 Subject: [PATCH] Record a draw's own texture binding that got the stand-in, and a sampled pool slot that is not registered. In towns, kerb, stair and wall-top edges are drawn untextured for one frame when the game registers a round of streamed textures, and no pool entry of those textures goes to the stand-in in such a frame. A binding written into a draw's own set, and a slot that is unregistered when its marks are read, left no event until now. Co-Authored-By: Claude Fable 5.2 --- runtime/flight.c | 7 +++++-- runtime/flight.h | 3 +++ runtime/vk_exec_draw.c | 19 +++++++++++++++++++ runtime/vk_texture.c | 6 +++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/runtime/flight.c b/runtime/flight.c index 890cb5d2..aaaffb79 100644 --- a/runtime/flight.c +++ b/runtime/flight.c @@ -157,7 +157,7 @@ static void copy_events(DumpJob *j, uint64_t first) { } static const char *const tex_kind_names[FLIGHT_TEX_N] = {"new", "up", "reup", "release", "takeback", "drop", "bytes", - "reg", "blank", "toblank", "blanksub"}; + "reg", "blank", "toblank", "blanksub", "direct", "unreg"}; // /events.tsv: one line per texture event of the dump's frames (flight_tex). static void write_events(const DumpJob *j) { @@ -192,12 +192,15 @@ static void write_events(const DumpJob *j) { static const char *const was[4] = {"an unused slot", "the slot named another descriptor at this storage", "the slot named other storage", "the slot named a finalized texture"}; snprintf(detail, sizeof detail, "slot %u: %s", e->us, was[e->detail & 3]); - } else if (e->kind == FLIGHT_TEX_TOBLANK || e->kind == FLIGHT_TEX_BLANKSUB) { + } else if (e->kind == FLIGHT_TEX_UNREG) { + snprintf(detail, sizeof detail, "slot %u sampled, not registered now", e->us); + } else if (e->kind == FLIGHT_TEX_TOBLANK || e->kind == FLIGHT_TEX_BLANKSUB || e->kind == FLIGHT_TEX_DIRECT) { static const char *const bit[] = {"finalized", "own entry", "released", "superseded", "overwritten", "uploaded", "storage readable", "held out", "CPU-written", "GPU-owned", "retiring", "resolves to an entry", "that entry is a volume", "that entry is another descriptor's", "no shader reads the pool as a volume"}; int o = snprintf(detail, sizeof detail, e->kind == FLIGHT_TEX_TOBLANK ? "slot %u lost its picture:" + : e->kind == FLIGHT_TEX_DIRECT ? "slot %u bound by a draw got its stand-in:" : "slot %u had no picture when its submission ended:", e->us); for (int b = 0; b < 15 && o < (int)sizeof detail - 40; b++) if (e->detail & 1u << b) o += snprintf(detail + o, sizeof detail - (size_t)o, " %s;", bit[b]); diff --git a/runtime/flight.h b/runtime/flight.h index 80a6e182..173c529f 100644 --- a/runtime/flight.h +++ b/runtime/flight.h @@ -30,6 +30,9 @@ enum { FLIGHT_TEX_NEW, FLIGHT_TEX_UP, FLIGHT_TEX_REUP, FLIGHT_TEX_RELEASE, FLIGH // detail: vk_texture_slot_why_locked's bits, what the slot's own texture was then) FLIGHT_TEX_BLANKSUB,// a slot that lost its picture during a submission still had none when the next one began: // the submission's draws read its stand-in (us and detail as TOBLANK) + FLIGHT_TEX_DIRECT, // a draw's own texture binding (not the pool's) named a slot and got the stand-in: that draw + // samples it whatever the slot resolves to later (us and detail as TOBLANK; once a frame) + FLIGHT_TEX_UNREG, // a shader sampled a pool slot that is not registered when its marks are read (us: the slot) FLIGHT_TEX_N }; // The texture's flags: a depth or stencil image, mirrored (the CPU writes its storage), bound into pool memory, an ASTC // texture, written by the GPU (VkTexImage.gpu_owned). diff --git a/runtime/vk_exec_draw.c b/runtime/vk_exec_draw.c index beb45e54..10ec6528 100644 --- a/runtime/vk_exec_draw.c +++ b/runtime/vk_exec_draw.c @@ -1876,6 +1876,24 @@ static void tex_info_lookup(VkExec *ex, const GfxShaderRes *r, uint64_t h, int s } // Returns whether the image bound was made without its top mip levels (texture detail, VkTexImage.skip). +// For the flight recorder: a draw's own binding of slot id resolved to no view, so the draw samples the stand-in. The +// pool's entries are noted where they change (pool_note_blank); a binding written into a draw's own set is not, and it +// keeps what it got. Noted once per slot and frame, for the first 256 slots of a frame. Texture lock held. +static void direct_blank(uint32_t id) { + static uint32_t seen[256]; + static uint64_t frame = ~0ull; + static int n; + uint64_t f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED); + if (f != frame) frame = f, n = 0; + for (int i = 0; i < n; i++) + if (seen[i] == id) return; + if (n == (int)(sizeof seen / sizeof *seen)) return; + seen[n++] = id; + uint64_t addr; + uint32_t fmt, w, h, why = vk_texture_slot_why_locked((int)id, &addr, &fmt, &w, &h); + flight_tex(FLIGHT_TEX_DIRECT, addr, fmt, w, h, 0, 0, why, id); +} + static int tex_info_full(VkExec *ex, const GfxShaderRes *r, uint64_t h, int storage, int separate, VkDescriptorImageInfo *out, VkImage *image) { int ms = (r->type & 0x200) != 0, reduced = 0; @@ -1906,6 +1924,7 @@ static int tex_info_full(VkExec *ex, const GfxShaderRes *r, uint64_t h, int stor } } if (!view) { + if (h && !(h >> 63) && !storage && flight_on) direct_blank((uint32_t)(h & 0xfffff)); int di = dummy_index(res_view_type(r->type), ms); view = storage ? storage_dummy(di, r->format) : Z.img[di].view; } diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index 532ee4a6..0dd7b3b7 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -2968,7 +2968,11 @@ void vk_pool_marks_read(const uint32_t *marks, uint32_t n) { if (n > (uint32_t)ntslots) n = (uint32_t)ntslots; uint32_t marked = 0; for (uint32_t id = 0; id < n; id++) { - if (!marks[id] || !tslots[id].used) continue; + if (!marks[id]) continue; + if (!tslots[id].used) { // sampled, and not a registered slot now: what it showed is not known here + if (flight_on) flight_tex(FLIGHT_TEX_UNREG, 0, 0, 0, 0, 0, 0, 0, id); + continue; + } marked++; TexSlot *s = &tslots[id]; if (s->ce && s->cgen == agen[sinfo[id] & 0xffff]) { // what the slot resolves to now