diff --git a/runtime/vk_dump.c b/runtime/vk_dump.c index 151f39f3..f80dce4b 100644 --- a/runtime/vk_dump.c +++ b/runtime/vk_dump.c @@ -18,8 +18,8 @@ // as x/2+1/2, UNORM and sRGB bytes written as stored. Caps: MAX_PASSES passes copied, PNG_CAP bytes of PNGs. // TOTK_DUMP_TEX=|x[,...]: those texture slots, or 2D textures of that size, are copied where first sampled, // whatever their format. -// TOTK_DUMP_UBO=1: each listed pipeline also prints the first 16 vec4 of its user uniform blocks (c3 and up), read from -// guest memory when the entry is listed. A block the submission rewrites with UpdateUniformBuffer shows its value from +// TOTK_DUMP_UBO=: each listed pipeline also prints the first n vec4 of its user uniform blocks (c3 and up; 1 means 16, +// the cap is 4096), read from guest memory when the entry is listed. A block the submission rewrites with UpdateUniformBuffer shows its value from // before the submission (vk_exec_draw.c upd_note). // TOTK_DUMP_SKIP_RUNS=1: a render pass with the same targets as the render pass before it is logged but not copied // (the terrain decals draw one pass each into the G-buffer and would use up both caps). @@ -48,7 +48,7 @@ static uint64_t dump_frame, log_from; // log_from: TOTK_DUMP_LOG, first frame static char dir[400]; static FILE *passes_f, *images_f; static int seq, finished, copied; // copied: passes and dispatches of the dump frame whose images were copied -static int skip_runs, dump_ubo; // TOTK_DUMP_SKIP_RUNS, TOTK_DUMP_UBO +static int skip_runs, dump_ubo; // TOTK_DUMP_SKIP_RUNS, TOTK_DUMP_UBO (vec4 per block, 0 for none) static uint32_t want_tex[16][2]; // TOTK_DUMP_TEX: slot id and 0, or width and height static int nwant_tex; static uint64_t last_targets; // targets_sig of the last render pass; 0 after a dispatch @@ -576,7 +576,7 @@ static void describe_bindings(Str *b, const VkExec *ex, const VkPipeInfo *info) if (u->addr && vk_mem_resolve(u->addr, 1, &ms)) { uint64_t n = u->size && u->size < ms.avail ? u->size : ms.avail; const float *f = (const float *)(uintptr_t)u->addr; - for (uint64_t k = 0; k < 16 && (k + 1) * 16 <= n; k++) + for (uint64_t k = 0; k < (uint64_t)dump_ubo && (k + 1) * 16 <= n; k++) sp(b, "%s[%llu] %g %g %g %g", k % 4 ? " " : "\n ", (unsigned long long)k, f[4 * k], f[4 * k + 1], f[4 * k + 2], f[4 * k + 3]); } else { @@ -879,7 +879,10 @@ void vk_dump_init(void) { const char *sr = cfg_get("TOTK_DUMP_SKIP_RUNS"); skip_runs = sr && *sr && *sr != '0'; const char *du = cfg_get("TOTK_DUMP_UBO"); - dump_ubo = du && *du && *du != '0'; + dump_ubo = du && *du ? atoi(du) : 0; + if (dump_ubo == 1) dump_ubo = 16; + if (dump_ubo > 4096) dump_ubo = 4096; + if (dump_ubo < 0) dump_ubo = 0; const char *wt = cfg_get("TOTK_DUMP_TEX"); for (char *q = (char *)wt; q && *q && nwant_tex < 16; q += *q == ',') { uint32_t *w = want_tex[nwant_tex++];