diff --git a/runtime/cfg.c b/runtime/cfg.c
index 98f71229..ef2bba8c 100644
--- a/runtime/cfg.c
+++ b/runtime/cfg.c
@@ -54,7 +54,7 @@ static const char *const known[] = {
"HDR_BLOWOUT", "HDR_CONTRAST", "HDR_EXPOSURE", "HDR_FLARE", "HDR_GAMMA", "HDR_GRADE", "HDR_HIGHLIGHT_SAT",
"HDR_HIGHLIGHTS", "HDR_HUE", "HDR_HUE_CLIP", "HDR_MATCH_SLOPE", "HDR_MIDGRAY", "HDR_SATURATION", "HDR_SHADOWS",
"HDR_TONEMAP", "HDR_TONE_SLOPE", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "LANG", "LIB_PREBUILD",
- "BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "BUILD_FREE_MB", "BUILD_RESERVE_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIB_WARM", "LINE_WIDTH", "PIPE_LINK_MS", "FRAME_HOLD_MS", "PACE_SMOOTH", "OQ_BATCH", "GATE_WAIT_MS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MEM_CENSUS", "MEM_NEED_MB", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
+ "BIG_BUILD_FREE_MB", "BIG_BUILD_MAX_MB", "BUILD_FREE_MB", "BUILD_RESERVE_MB", "LIB_PREBUILD_BIG", "LIB_PREBUILD_BIG_BG", "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIB_WARM", "LINE_WIDTH", "POOL_SHOWN_FIRST", "PIPE_LINK_MS", "FRAME_HOLD_MS", "PACE_SMOOTH", "OQ_BATCH", "GATE_WAIT_MS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MEM_CENSUS", "MEM_NEED_MB", "MENU_LANG", "MENU_SOUND_VOLUME", "MENU_TEST",
"MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_CLICK", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MICROPHONE", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MONITOR", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOUSE_TRACE", "MOVIE_HOST", "MOVIE_PACE", "MOVIE_CLOCK", "TEST_HITCH",
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
"MV_SURVEY",
@@ -132,7 +132,7 @@ static const struct { const char *key, *section; } sections[] = {
{"TIMER_1MS", "performance"}, {"PIPE_WAIT", "performance"}, {"PIPE_SKIP", "performance"}, {"ONESHOT_BUDGET", "performance"},
{"PIPE_FRAME_WAIT_MS", "performance"}, {"PIPE_SKIP_STEADY", "performance"},
{"CACHE_DIE", "performance"}, {"ONE_PER_CORE", "performance"},
- {"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"PIPE_LINK_DRAW_MS", "performance"}, {"PIPE_AHEAD", "performance"}, {"LINE_WIDTH", "performance"}, {"PIPE_FAST_WORKERS", "performance"}, {"GPL_FEEDBACK", "performance"}, {"FRAME_HOLD_MS", "performance"}, {"PACE_SMOOTH", "performance"}, {"OQ_BATCH", "performance"}, {"GATE_WAIT_MS", "performance"}, {"PIPE_PREBUILD", "performance"}, {"PIPE_SEED", "performance"},
+ {"LIB_PREBUILD", "performance"}, {"LIB_PREBUILD_THREADS", "performance"}, {"LIB_WARM", "performance"}, {"PIPE_LINK_MS", "performance"}, {"PIPE_LINK_DRAW_MS", "performance"}, {"PIPE_AHEAD", "performance"}, {"LINE_WIDTH", "performance"}, {"POOL_SHOWN_FIRST", "performance"}, {"PIPE_FAST_WORKERS", "performance"}, {"GPL_FEEDBACK", "performance"}, {"FRAME_HOLD_MS", "performance"}, {"PACE_SMOOTH", "performance"}, {"OQ_BATCH", "performance"}, {"GATE_WAIT_MS", "performance"}, {"PIPE_PREBUILD", "performance"}, {"PIPE_SEED", "performance"},
{"COMPUTE_KEEP", "performance"},
{"PREWARM_XLATE", "performance"}, {"GPL", "performance"}, {"ASTC", "performance"}, {"MEMORY", "performance"},
{"TEX_ALIAS", "performance"}, {"DEPTH_INIT_INLINE", "performance"}, {"DEPTH_ALIAS_LOG", "diagnostics"}, {"TEX_DISUSE", "performance"}, {"TEX_DISUSE_EVICT", "performance"}, {"TEX_GEN_UNDO", "performance"}, {"TEX_REUSE", "performance"}, {"TEX_SPLIT_FILL", "performance"}, {"TEX_VRAM_PRESSURE", "performance"}, {"TEX_PROC_COMMIT_MB", "performance"}, {"ASTC_BC", "performance"}, {"LOD_GUARD", "performance"}, {"FIX_C0", "performance"}, {"FIX_ZERO", "performance"}, {"WATER_PROJECTIVE", "performance"},
@@ -272,6 +272,7 @@ static const CfgMeta metas[] = {
{"MESH_FALLBACK_WORKERS", "auto", "auto|1|2|3|4", RESTART}, // vk_exec_draw.c mfb_worker_count
{"PIPE_AHEAD", "1", "0|1", RESTART}, // vk_exec.c vk_exec_ahead, vk_pipeline.c vk_pipeline_hint
{"LINE_WIDTH", "1", "0|1", RESTART}, // vk_pipeline.c key_lines
+ {"POOL_SHOWN_FIRST", "1", "0|1", RESTART}, // vk_texture.c shown_take
{"GPL_FEEDBACK", "1", "0|1", RESTART}, // vk_pipeline.c gpl_feedback
{"PIPE_FAST_WORKERS", "1", "0|1", RESTART}, // vk_pipeline.c lib_worker, fast_take
{"FRAME_HOLD_MS", "120", "0..500", RESTART}, // vk_backend.c frame_hold
diff --git a/runtime/flight.c b/runtime/flight.c
index 89827e7a..3ae714c4 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"};
+ "reg", "blank", "toblank", "blanksub"};
//
/events.tsv: one line per texture event of the dump's frames (flight_tex).
static void write_events(const DumpJob *j) {
@@ -192,10 +192,11 @@ 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) {
+ } else if (e->kind == FLIGHT_TEX_TOBLANK || e->kind == FLIGHT_TEX_BLANKSUB) {
static const char *const bit[] = {"finalized", "own entry", "released", "superseded", "overwritten", "uploaded",
"storage readable", "held out", "CPU-written", "GPU-owned", "retiring"};
- int o = snprintf(detail, sizeof detail, "slot %u lost its picture:", e->us);
+ int o = snprintf(detail, sizeof detail, e->kind == FLIGHT_TEX_TOBLANK ? "slot %u lost its picture:"
+ : "slot %u had no picture when its submission ended:", e->us);
for (int b = 0; b < 11 && o < (int)sizeof detail - 20; b++)
if (e->detail & 1u << b) o += snprintf(detail + o, sizeof detail - (size_t)o, " %s;", bit[b]);
} else if (e->kind == FLIGHT_TEX_BLANK)
diff --git a/runtime/flight.h b/runtime/flight.h
index d29c982d..c5926458 100644
--- a/runtime/flight.h
+++ b/runtime/flight.h
@@ -28,6 +28,8 @@ enum { FLIGHT_TEX_NEW, FLIGHT_TEX_UP, FLIGHT_TEX_REUP, FLIGHT_TEX_RELEASE, FLIGH
// on screen (us: the slot; detail: bit 0 the slot is finalized, bit 1 it is held out)
FLIGHT_TEX_TOBLANK, // the pool's entry of a slot went from a texture's view to the stand-in (us: the slot;
// 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_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.h b/runtime/vk.h
index 763ac012..5c858e9f 100644
--- a/runtime/vk.h
+++ b/runtime/vk.h
@@ -589,6 +589,9 @@ void vk_texture_create_budget_locked(int n); // slot lookups create at m
// descriptor exists, 4 that entry is released, 8 superseded, 16 overwritten, 32 uploaded, 64 the storage is readable,
// 128 held out by disuse, 256 CPU-written, 512 GPU-owned, 1024 retiring), with the slot's storage and size.
uint32_t vk_texture_slot_why_locked(int id, uint64_t *addr, uint32_t *format, uint32_t *w, uint32_t *h);
+// The pool's next lookup is of a slot whose entry in the set is a texture's view now (1) or a stand-in (0): a slot on
+// screen whose texture is not made is made by that lookup beside the creation budget (vk_texture.c slot_resolve).
+void vk_texture_pool_shown_locked(int shown);
uint64_t vk_texture_pool_make_ns_take(void); // ns the pool's lookups spent making and first uploading entries since the last call
int vk_texture_create_deferred_locked(void); // a lookup since the last call left a creation to the budget // one past the highest texture slot registered so far (or more)
int vk_sampler_slot_count_locked(void);
diff --git a/runtime/vk_exec_draw.c b/runtime/vk_exec_draw.c
index ca75c61a..c2924a6d 100644
--- a/runtime/vk_exec_draw.c
+++ b/runtime/vk_exec_draw.c
@@ -2456,14 +2456,48 @@ static int pool_view_blank(VkImageView v) {
// Slot id's entry of a kind went from the view was to now: noted when a texture's view gives way to the stand-in, which
// every draw of the submission that samples the slot then reads (the set is written with update-after-bind).
+static uint32_t pool_blanked[512]; // the slots that lost their picture since the last pool_blank_check
+static int pool_nblanked;
static void pool_note_blank(uint32_t id, VkImageView was, VkImageView now, int *noted) {
if (!flight_on || *noted || !was || pool_view_blank(was) || !pool_view_blank(now)) return;
uint64_t addr;
uint32_t fmt, w, h, why = vk_texture_slot_why_locked((int)id, &addr, &fmt, &w, &h);
flight_tex(FLIGHT_TEX_TOBLANK, addr, fmt, w, h, 0, 0, why, id);
+ if (pool_nblanked < (int)(sizeof pool_blanked / sizeof *pool_blanked)) pool_blanked[pool_nblanked++] = id;
*noted = 1;
}
+// A submission's first sync, before it changes anything: the slots that lost their picture during the submission
+// before and have none in any kind now went to the queue with their stand-ins. Texture lock taken here.
+static void pool_blank_check(void) {
+ if (!pool_nblanked) return;
+ vk_texture_lock();
+ for (int i = 0; i < pool_nblanked; i++) {
+ uint32_t id = pool_blanked[i];
+ int real = 0;
+ for (int k = 0; k < VK_POOL_KINDS && !real; k++) {
+ VkImageView v = PL.view[(size_t)k * VK_POOL_TEX + id];
+ real = v && !pool_view_blank(v);
+ }
+ if (real) continue;
+ uint64_t addr;
+ uint32_t fmt, w, h, why = vk_texture_slot_why_locked((int)id, &addr, &fmt, &w, &h);
+ flight_tex(FLIGHT_TEX_BLANKSUB, addr, fmt, w, h, 0, 0, why, id);
+ }
+ vk_texture_unlock();
+ pool_nblanked = 0;
+}
+
+// Whether slot id's entry of a kind in mask is a texture's view now (vk_texture_pool_shown_locked).
+static int pool_slot_shown(uint32_t id, uint32_t mask) {
+ for (int k = 0; k < VK_POOL_KINDS; k++) {
+ if (!(mask >> k & 1)) continue;
+ VkImageView v = PL.view[(size_t)k * VK_POOL_TEX + id];
+ if (v && !pool_view_blank(v)) return 1;
+ }
+ return 0;
+}
+
static int pool_fill(VkExec *ex, uint32_t id, uint32_t mask, uint64_t tok) {
int noted = 0;
vk_texture_create_deferred_locked();
@@ -2496,6 +2530,7 @@ static int pool_fill(VkExec *ex, uint32_t id, uint32_t mask, uint64_t tok) {
ps->stamp = m->stamp;
return 1;
}
+ vk_texture_pool_shown_locked(tok && pool_slot_shown(id, mask));
for (int k = 0; k < VK_POOL_KINDS; k++) {
if (!(mask >> k & 1)) continue;
GfxShaderRes r = {0};
@@ -2509,6 +2544,7 @@ static int pool_fill(VkExec *ex, uint32_t id, uint32_t mask, uint64_t tok) {
*e = ii.imageView, pool_write((uint32_t)k, id, ii.imageView, VK_NULL_HANDLE);
}
}
+ vk_texture_pool_shown_locked(0);
int ok = !vk_texture_create_deferred_locked();
uint32_t ent = 0;
int got = vk_texture_pool_note_locked((int)id, &ent);
@@ -2579,6 +2615,7 @@ static void pool_sync(VkExec *ex) {
if (!PL.layout) vk_pool_set_layout();
uint64_t from = 0, pre = PL.logn;
int took = PL.cur_fence != ex->fence;
+ if (took && flight_on) pool_blank_check(); // what the submission before went to the queue with
int switched = pool_take_set(ex, &from); // every submission its own set, before the shortcut
if (PL.sealed) return; // current when checked: a change since waits for the next sync, which takes a new set
uint64_t t0 = kern_now_ns(), f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED);
diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c
index adeb458a..ad901336 100644
--- a/runtime/vk_texture.c
+++ b/runtime/vk_texture.c
@@ -4155,6 +4155,30 @@ static int want_take(void) {
void vk_texture_create_budget_locked(int n) { create_budget = n, create_deferred = 0; }
+// NX2NAVI_POOL_SHOWN_FIRST (default 1; 0: such a slot waits for the budget like any other): the slot being looked up
+// shows a texture in the pool's set now (vk_exec_draw.c pool_fill). When its own texture is not made, the game has
+// registered the slot with another texture, and the draws that sampled the old one sample this one next: it is made at
+// this lookup, beside the count budget and the frame's creation time, SHOWN_PER_FRAME of them a present. Ocarina
+// streams its textures by detail level and registers about 32 slots with their next level every four or five frames
+// while the player moves (2,300 to 3,800 registrations in 600 frames of two recordings). A refresh made 16 of them and
+// wrote the stand-in into the set for the others until its next round, and the set is read as it is when its
+// submission goes to the queue: an object whose slot was among the others was drawn grey for a frame (three lamp
+// posts, the windows of a house front in the recordings). An area load registers thousands of slots that showed the
+// area before; past the per-present count they wait for the budget as before.
+#define SHOWN_PER_FRAME 64
+static int pool_shown;
+void vk_texture_pool_shown_locked(int shown) { pool_shown = shown; }
+static int shown_take(void) {
+ static int on = -1;
+ static uint64_t frame = ~0ull;
+ static int left;
+ if (on < 0) on = cfg_bool("NX2NAVI_POOL_SHOWN_FIRST");
+ if (!on || !pool_shown) return 0;
+ uint64_t f = __atomic_load_n(&gfx_counters.frames, __ATOMIC_RELAXED);
+ if (f != frame) frame = f, left = SHOWN_PER_FRAME;
+ return left > 0 ? left-- : 0;
+}
+
// What the pool's lookups have spent making entries (entry_of under the budget) and uploading them the first time,
// since the last call: the time vk_exec_draw.c pool_create_ns limits in a frame. Texture lock held where it is added.
static uint64_t pool_make_ns;
@@ -4224,7 +4248,7 @@ static Tex *slot_resolve(TexSlot *s, view_t *view, int *has_view) {
// was about a thousand slots at once, which vk_exec_draw.c pool_sync_entries took for an area load, several
// times a second in some places, and each time lifted the count budget and the frame's creation time.
else if (!mem_readable((uint64_t)(uintptr_t)s->t.mem, s->t.L.size)) e = NULL;
- else if (!create_budget && !(s->cwant && want_take())) create_deferred = 1;
+ else if (!create_budget && !(s->cwant && want_take()) && !shown_take()) create_deferred = 1;
else {
uint64_t m0 = kern_now_ns();
e = entry_of(&s->t);