From 507a76cc47b8cedb279c42854f5fa3d1a42b1d4a Mon Sep 17 00:00:00 2001 From: Xipzer <60103178+Xipzer@users.noreply.github.com> Date: Fri, 6 Nov 2026 09:30:48 +0000 Subject: [PATCH] Argument tables: uniform-buffer-only changes copy the table and remake those slots 72% of the argument tables BotW writes follow only a uniform buffer rebind on that stage. A per-stage generation of every other argument change (g_args_ogen) lets such a table be copied from the shader's last one in the pass, with only its uniform buffer slots made again (not for shaders that read handles or pointers out of a uniform buffer, cb_only). The geometry and mesh paths that force a stage's table again move the generation too. DM_NVN_CB_CHECK=1 writes the full table as well and logs a difference; DM_NVN_CB_FAST=0 turns the path off. Measured on the Xipzer fork (BotW, Mac, encode thread on): 11,090 -> 10,670 instructions a draw (-4%). --- dm/gfx/nvn/nvn_geometry.inc | 6 ++--- dm/gfx/nvn/nvn_mtl.m | 53 ++++++++++++++++++++++++++++++------- docs/env_switches.tsv | 2 ++ 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/dm/gfx/nvn/nvn_geometry.inc b/dm/gfx/nvn/nvn_geometry.inc index 18a72a81fd..01c1a59cf3 100644 --- a/dm/gfx/nvn/nvn_geometry.inc +++ b/dm/gfx/nvn/nvn_geometry.inc @@ -540,7 +540,7 @@ static void geo_mesh_encode(id en_) { uint32_t info[8] = {0, 1, 0, 0, tris, 0, 0, 0}; memcpy(p, info, 32); memcpy(p + 32, &g_geo_mesh.a, sizeof g_geo_mesh.a); enc_r_vbuf(en, GEO_MESH_DRAW_SLOT, b.gpuAddress + o + 32); uint64_t save[5]; memcpy(save, g_geo_bind, sizeof save); memset(g_geo_bind, 0, sizeof g_geo_bind); g_geo_bind[3] = b.gpuAddress + o; - g_args_dirty[2] = 1; g_args_mesh = GEO_MESH_GS_SLOT; encode_args(en, g_geo_mesh.lean, 2, 0); g_args_mesh = 0; g_args_dirty[2] = 1; + g_args_dirty[2] = 1; g_args_ogen[2]++; g_args_mesh = GEO_MESH_GS_SLOT; encode_args(en, g_geo_mesh.lean, 2, 0); g_args_mesh = 0; g_args_dirty[2] = 1; g_args_ogen[2]++; memcpy(g_geo_bind, save, sizeof save); if (geo_mesh_take(en)) return; uint32_t pg = g_geo_mesh.prims; @@ -593,9 +593,9 @@ static void mtk_encode(id en_) { [en setArgumentTable:g_vt atStages:MTLRenderStageMesh]; uint64_t first_gpu = g_mtk.ind_first; if (!g_mtk.ind) { id b; size_t o = arena_alloc(16, &b); memcpy((uint8_t *)b.contents + o, &g_mtk.first, 4); first_gpu = b.gpuAddress + o; } - if (ts) { [en setArgumentTable:g_ot atStages:MTLRenderStageObject]; g_args_dirty[3] = 1; encode_args(en, ts, 3, 0); + if (ts) { [en setArgumentTable:g_ot atStages:MTLRenderStageObject]; g_args_dirty[3] = 1; g_args_ogen[3]++; encode_args(en, ts, 3, 0); if (rec_on()) rec_table_op(RO_T_ADDR, g_ot, first_gpu, DMSH_MESH_FIRST_SLOT); else [g_ot setAddress:first_gpu atIndex:DMSH_MESH_FIRST_SLOT]; } - g_args_dirty[4] = 1; encode_args(en, ms, 4, 1); + g_args_dirty[4] = 1; g_args_ogen[4]++; encode_args(en, ms, 4, 1); enc_r_vbuf(en, DMSH_MESH_FIRST_SLOT, first_gpu); if (g_mtk.ind) [en drawMeshThreadgroupsWithIndirectBuffer:g_mtk.ind threadsPerObjectThreadgroup:MTLSizeMake(ts ? ts->mesh_threads : 1, 1, 1) threadsPerMeshThreadgroup:MTLSizeMake(ms->mesh_threads, 1, 1)]; else [en drawMeshThreadgroups:MTLSizeMake(g_mtk.count, 1, 1) threadsPerObjectThreadgroup:MTLSizeMake(ts ? ts->mesh_threads : 1, 1, 1) threadsPerMeshThreadgroup:MTLSizeMake(ms->mesh_threads, 1, 1)]; diff --git a/dm/gfx/nvn/nvn_mtl.m b/dm/gfx/nvn/nvn_mtl.m index eb8b266e4b..9ebc60f028 100644 --- a/dm/gfx/nvn/nvn_mtl.m +++ b/dm/gfx/nvn/nvn_mtl.m @@ -3732,7 +3732,7 @@ static void ts_boundary(void) { // the end of a segment and the start of the n enum { ED_SREF = 1, ED_VP = 2, ED_SC = 4, ED_CULL = 8, ED_WIND = 16, ED_FILL = 32, ED_BIAS = 64, ED_CLIP = 128, ED_BLEND = 256 }; static int g_enc_vis, g_enc_has_vis; // This encoder's current visibility count mode (0 off / slot number + 1), and whether a visibility buffer is attached static int g_pso_dirty = 1, g_dss_dirty = 1; // Pipeline / depth-stencil related state was changed during replay -static uint64_t g_stat_args_enc, g_stat_args_reuse; // Argument buffer: new-encode / reuse counts +static uint64_t g_stat_args_enc, g_stat_args_reuse, g_stat_args_cb; static uint64_t *g_cbchk; static size_t g_cbchk_len; // Argument buffer: new-encode / reuse / uniform-only counts; g_cbchk: DM_NVN_CB_CHECK's copied table static uint64_t g_stat_draw, g_stat_pass, g_bw_load, g_bw_store, g_pass_full_rw, g_udc_saved_bytes; // Bandwidth ledger: attachment load / store bytes, number of full load-store passes // DM_NVN_PASSDUMP: records pass attachments / samples / presents one by one (textures by serial) for offline data-flow analysis; the pass numbers of P / D / R / S lines agree (= g_stat_pass after the pass is opened) // DM_NVN_PASSDUMP=frame number, or start-end (inclusive at both ends) @@ -4646,7 +4646,7 @@ @interface NvShader : NSObject { @public id fn, tf_fn, discard_fn, int gs_loc, lay_loc; char gs_comp, lay_comp; // a slice-writing geometry shader (no function: the layer comes from input gs_loc.gs_comp) / a vertex shader with layer entry points writing output lay_loc.lay_comp (dmsh_build.py gs_slice, vs_layer_entry); -1 = none uint64_t cbs_seen; uint32_t cbs_runs; // the command buffer that listed this shader last, and how many have (cbs_note) // The argument buffer encoded last time - id ab_buf; uint64_t ab_gpu; size_t ab_off; uint64_t ab_pass; uint32_t ab_binst; uint64_t ab_pgen; // ab_pass: serial of the render pass that encoded this argument block - reused only within the same pass (the arena holding a block from another pass / another submission may already have been reclaimed and rewritten); ab_pgen: g_psnap_gen when it was encoded (pools, pool_gpu) + id ab_buf; uint8_t *ab_cpu; uint64_t ab_gpu; size_t ab_off; uint64_t ab_pass; uint32_t ab_binst, ab_ogen; uint64_t ab_pgen; int8_t cb_only; // ab_ogen: g_args_ogen of its stage when it was encoded; cb_only: 1 when no slot follows a uniform buffer's content, -1 when one does, 0 not looked yet; ab_pass: serial of the render pass that encoded this argument block - reused only within the same pass (the arena holding a block from another pass / another submission may already have been reclaimed and rewritten); ab_pgen: g_psnap_gen when it was encoded (pools, pool_gpu) id bflib; int bflib_state; NSMutableArray *bffn; // bflib: the readable-tile version _bf (state as afn_state), bffn: its functions specialized by their numbers (NvBfFn, bf_fn) uint64_t mis[4]; // mis: texture slots 0-255 already reported for a type mismatch (tex_mis_note) NSString *ventry; id vfn; int vfn_state; @@ -5785,7 +5785,7 @@ static uint64_t c2_handle(int stage, unsigned b) { } // A deferred inline update changes what the draws after it read through the uniform bindings it overlaps (they get a shadow): the argument blocks of those stages are encoded again. // Only those: marking every stage made each later draw encode all of its blocks again, which with the updates kept across passes cost about 1.5 ms a frame in Breath of the Wild -static uint8_t g_args_dirty[6]; +static uint8_t g_args_dirty[6]; static uint32_t g_args_ogen[6]; static void ubd_dirty(uint64_t lo, uint64_t hi) { for (int st = 0; st < 6; st++) { if (g_args_dirty[st]) continue; for (int r = 0; r < 16; r++) { const p_bind_buf *u = &S.ubo[st][r]; if (u->addr && lo < u->addr + u->size && u->addr < hi) { g_args_dirty[st] = 1; break; } } } @@ -8338,7 +8338,8 @@ static int fb_image_view(int tid, const nvn_rbind *b, id t) { } static uint8_t g_args_dirty[6] = {1, 1, 1, 1, 1, 1}; static uint64_t g_args_reg_seen, g_args_dirty_seen, g_args_ser_seen; -static inline void args_dirty_all(void) { memset(g_args_dirty, 1, sizeof g_args_dirty); } +static uint32_t g_args_ogen[6]; // moves whenever a stage's arguments change other than by a uniform buffer bind (encode_args_'s uniform-only path) +static inline void args_dirty_all(void) { memset(g_args_dirty, 1, sizeof g_args_dirty); for (int i = 0; i < 6; i++) g_args_ogen[i]++; } // A reused block holds resource IDs: it is stale after a registration change, a guest write, or a serial's Metal object replaced (g_ser_gen: an upgraded or re-uploaded packaged texture, // an alias taken or evicted) with the same program and bindings (MacNativeGames e49aa55) static inline void args_sync_dirty(void) { @@ -8659,6 +8660,32 @@ static int encode_args_(id en, NvShader *sh, int nvn_stage, i g_stat_args_reuse++; return 1; } + // Uniform buffers alone rebound since this shader's table was written in this pass (Breath of the Wild: 72% of the tables written): the table is copied and only its + // uniform buffer slots are made again, as the full path below makes them. Not for a shader that reads handles or pointers out of a uniform buffer (their slots follow + // its content), nor where the full reuse above is refused for other reasons. DM_NVN_CB_FAST=0 writes every table in full + static int cbf = -1; if (cbf < 0) { const char *e = getenv("DM_NVN_CB_FAST"); cbf = !(e && !strcmp(e, "0")); } + if (!sh->cb_only) { int ok = 1; for (int i = 0; i < sh->rf.nb; i++) { int k = sh->rf.b[i].kind; if (k == NVN_RB_SAMPU || k == NVN_RB_TEXU || k == NVN_RB_SBUFU || k == NVN_RB_UBOP || k == NVN_RB_IMGU || k == NVN_RB_TBUFU) { ok = 0; break; } } sh->cb_only = ok ? 1 : -1; } + if (cbf && sh->cb_only > 0 && !passdump() && sh->ab_buf && sh->ab_pass == g_pass.serial && sh->ab_ogen == g_args_ogen[nvn_stage] && nvn_stage != 5 + && !(sh->rf.drv_read[0] && sh->ab_binst != g_draw_binst) && !((sh->rf.pool || sh->rf.htab) && sh->ab_pgen != g_psnap_gen) && !g_res_check_on) { + NSUInteger len = sh->arg_len ? sh->arg_len : sh->ae.encodedLength; + id ab; size_t off = arena_alloc(len, &ab); + uint64_t *d = (uint64_t *)(g_cur_arena->cpu + off); + memcpy(d, sh->ab_cpu, len); + for (int i = 0; i < sh->rf.nb; i++) { const nvn_rbind *b = &sh->rf.b[i]; if (b->kind != NVN_RB_CBUF) continue; + int reg = b->reg; const p_bind_buf *u = reg < 16 ? &S.ubo[nvn_stage][reg] : NULL; void *mb; uint64_t mo, gpu; + if (!u || !u->addr || !mtl_gpu_addr(u->addr, u->size ? u->size : 1, &mb, &mo, &gpu)) { d[b->aid] = zero_bank_gpu(); continue; } + uint64_t ul = cb_len(sh, reg, u->size); + if (g_nubd && ubd_hits(u->addr, u->addr + ul)) { uint64_t g; const uint8_t *c; if (ubd_covers(u->addr, u->addr + ul)) gpu = ubd_shadow(u->addr, u->addr + ul); + else if (ubp_get(u->addr, u->addr + ul, &g, &c)) gpu = g; else RED_ONCE(92, "a uniform update deferred inside the pass covers only part of the binding (stage %d cb%d): the content before the update is read", nvn_stage, reg); } + d[b->aid] = gpu; } + static int chk = -1; if (chk < 0) chk = getenv("DM_NVN_CB_CHECK") != NULL; + if (chk) { g_cbchk = d; g_cbchk_len = len; goto full; } // (test) the full path below writes the table too and compares + bind_args(en, nvn_stage, metal_vertex, ab, g_cur_arena->gpu + off, off, sh->rf.abi); + sh->ab_buf = ab; sh->ab_cpu = (uint8_t *)d; sh->ab_gpu = g_cur_arena->gpu + off; sh->ab_off = off; sh->ab_binst = g_draw_binst; g_args_dirty[nvn_stage] = 0; + g_stat_args_cb++; + return 1; + } +full:; NSUInteger arg_len = sh->arg_len ? sh->arg_len : sh->ae.encodedLength; uint64_t slots[NVN_REFL_MAXARG]; memset(slots, 0, arg_len < sizeof slots ? arg_len : sizeof slots); // only the bytes that are copied out (they used to be zeroed in full, before the reuse check too) #define USE(r, u) do { (void)(u); if (__builtin_expect(g_res_check_on, 0)) res_check((r), sh->key, reg); } while (0) @@ -8929,10 +8956,16 @@ static int encode_args_(id en, NvShader *sh, int nvn_stage, i } #undef USE os_unfair_lock_unlock(&g_rmu); + if (g_cbchk) for (int i = 0; i < sh->rf.nb; i++) { int k = sh->rf.b[i].kind; if (k == NVN_RB_BORDER || k == NVN_RB_PUSH || k == NVN_RB_DRV0 || k == NVN_RB_DRV2 || k == NVN_RB_SUPPORT) g_cbchk[sh->rf.b[i].aid] = slots[sh->rf.b[i].aid]; } // arena blocks made again with the same content + if (g_cbchk) { static uint64_t nc, nd; nc++; if (g_cbchk_len != arg_len || memcmp(g_cbchk, slots, arg_len)) { if (!nd++) { int w = -1; for (size_t i = 0; i < arg_len / 8; i++) if (g_cbchk[i] != slots[i]) { w = (int)i; break; } + int kind = -1, reg = -1; for (int i = 0; i < sh->rf.nb; i++) if (sh->rf.b[i].aid == w) { kind = sh->rf.b[i].kind; reg = sh->rf.b[i].reg; } + MLOG("[RED] uniform-only table differs from the full one: shader %s stage %d slot %d kind %d reg %d: fast %#llx full %#llx", sh->key, nvn_stage, w, kind, reg, w >= 0 ? (unsigned long long)g_cbchk[w] : 0ull, w >= 0 ? (unsigned long long)slots[w] : 0ull); } + if (nd && nd < 40) { int w = -1; for (size_t i = 0; i < arg_len / 8; i++) if (g_cbchk[i] != slots[i]) { w = (int)i; break; } if (w >= 0) { int kind = -1; for (int i = 0; i < sh->rf.nb; i++) if (sh->rf.b[i].aid == w) kind = sh->rf.b[i].kind; static int kc[64]; if (kind >= 0 && kind < 64 && !kc[kind]++) MLOG("[cbcheck] first difference in binding kind %d (shader %s stage %d)", kind, sh->key, nvn_stage); } } } + if (nc % 200000 == 0) MLOG("[cbcheck] %llu tables compared, %llu differ", nc, nd); g_cbchk = NULL; } id ab; size_t off = arena_alloc(arg_len, &ab); memcpy(g_cur_arena->cpu + off, slots, arg_len); // the arena arena_alloc took it from (no contents message: see ubo_read) bind_args(en, nvn_stage, metal_vertex, ab, g_cur_arena->gpu + off, off, sh->rf.abi); - sh->ab_buf = ab; sh->ab_gpu = g_cur_arena->gpu + off; sh->ab_off = off; sh->ab_pass = g_pass.serial; sh->ab_binst = g_draw_binst; sh->ab_pgen = g_psnap_gen; g_args_dirty[nvn_stage] = 0; + sh->ab_buf = ab; sh->ab_cpu = g_cur_arena->cpu + off; sh->ab_gpu = g_cur_arena->gpu + off; sh->ab_off = off; sh->ab_pass = g_pass.serial; sh->ab_binst = g_draw_binst; sh->ab_pgen = g_psnap_gen; sh->ab_ogen = g_args_ogen[nvn_stage]; g_args_dirty[nvn_stage] = 0; g_stat_args_enc++; return 1; } @@ -9192,7 +9225,7 @@ static int state_op(uint32_t op, const void *a) { case OP_BIND_VSTREAM: { const p_bind_vstream *b = a; if (S.nstream != b->n || memcmp(S.stream, b->st, 8 * b->n)) { memcpy(S.stream, b->st, 8 * b->n); S.nstream = b->n; g_pso_dirty = 1; } break; } case OP_BIND_VBUF: case OP_BIND_VBUF1: { p_bind_vbuf tmp; const p_bind_vbuf *b = vbuf_rec(op, a, &tmp); memcpy(&S.vbuf[b->first], b->r, sizeof *b->r * b->n); break; } case OP_BIND_UBO: case OP_BIND_UBO_SMALL: { p_bind_buf tmp; const p_bind_buf *b = bind_buf_rec(op, a, &tmp); if (b->stage < 6 && b->index < 16 && memcmp(&S.ubo[b->stage][b->index], b, sizeof *b)) { S.ubo[b->stage][b->index] = *b; g_args_dirty[b->stage] = 1; } break; } - case OP_BIND_SSBO: { const p_bind_buf *b = a; if (b->stage < 6 && b->index < 16 && memcmp(&S.ssbo[b->stage][b->index], b, sizeof *b)) { S.ssbo[b->stage][b->index] = *b; g_args_dirty[b->stage] = 1; } break; } + case OP_BIND_SSBO: { const p_bind_buf *b = a; if (b->stage < 6 && b->index < 16 && memcmp(&S.ssbo[b->stage][b->index], b, sizeof *b)) { S.ssbo[b->stage][b->index] = *b; g_args_dirty[b->stage] = 1; g_args_ogen[b->stage]++; } break; } case OP_BIND_TEX: case OP_BIND_TEX1: { p_bind_handles t1; const p_bind_handles *b = bind_rec(op, a, &t1); if (b->n < 0 || b->n > 32) { // the recorder never writes more than 32 (bind_handles): the record was overwritten after it was recorded static int once; if (!once++) { const uint8_t *q = (const uint8_t *)a; char hx[3 * 96 + 1]; for (int k = 0; k < 96; k++) snprintf(hx + 3 * k, 4, "%02x ", q[k - 32]); @@ -9201,9 +9234,9 @@ static int state_op(uint32_t op, const void *a) { bh_fresh(b); if (passdump()) for (int k = 0; k < b->n; k++) { int tid = (int)(b->h[k] & 0xfffff); if (tid) PD("T %llu bind st%d slot%d tid=%d sid=%d ser=%llu%s", g_stat_pass + 1, b->stage, b->first + k, tid, (int)(b->h[k] >> 20), tid < g_ntreg ? g_treg[tid].t.serial : 0ull, b->defer ? " deferred" : ""); } - if (b->stage < 6 && b->first + b->n <= NTEX && memcmp(&S.tex[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.tex[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; } break; } - case OP_BIND_SAMP: { const p_bind_handles *b = a; bh_fresh(b); if (b->stage < 6 && b->first + b->n <= 128 && memcmp(&S.samp[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.samp[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; } break; } - case OP_BIND_IMG: { const p_bind_handles *b = a; bh_fresh(b); if (b->stage < 6 && b->first >= 0 && b->first + b->n <= 32) { if (memcmp(&S.img[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.img[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; } } else RED_ONCE(31, "image slots out of range stage %d first %d count %d", b->stage, b->first, b->n); break; } + if (b->stage < 6 && b->first + b->n <= NTEX && memcmp(&S.tex[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.tex[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; g_args_ogen[b->stage]++; } break; } + case OP_BIND_SAMP: { const p_bind_handles *b = a; bh_fresh(b); if (b->stage < 6 && b->first + b->n <= 128 && memcmp(&S.samp[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.samp[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; g_args_ogen[b->stage]++; } break; } + case OP_BIND_IMG: { const p_bind_handles *b = a; bh_fresh(b); if (b->stage < 6 && b->first >= 0 && b->first + b->n <= 32) { if (memcmp(&S.img[b->stage][b->first], b->h, 8 * b->n)) { memcpy(&S.img[b->stage][b->first], b->h, 8 * b->n); g_args_dirty[b->stage] = 1; g_args_ogen[b->stage]++; } } else RED_ONCE(31, "image slots out of range stage %d first %d count %d", b->stage, b->first, b->n); break; } case OP_STENCIL: { const p_stencil *b = a; if (b->which != 2) g_dss_dirty = 1; @@ -9218,7 +9251,7 @@ static int state_op(uint32_t op, const void *a) { case OP_BLEND_COLOR: memcpy(S.blend_color, ((const p_blend_color *)a)->rgba, 16); break; case OP_ALPHA_REF: S.alpha_ref = ((const p_alpha_ref *)a)->ref; break; // data for at_bind, not part of the pipeline case OP_PUSH_CONST: { const p_push_const *b = a; memcpy(S.push[b->compute ? 1 : 0] + b->offset, b->data, b->size); - for (int st = 0; st < 6; st++) if ((st == 5) == (b->compute != 0)) g_args_dirty[st] = 1; break; } + for (int st = 0; st < 6; st++) if ((st == 5) == (b->compute != 0)) { g_args_dirty[st] = 1; g_args_ogen[st]++; } break; } case OP_COPY_STRIDE: { const p_copy_stride *cs = a; if (cs->image) S.copy_img_stride = cs->stride; else S.copy_stride = cs->stride; break; } case OP_TF_BIND: { const p_tf_bind *b = a; if (b->index >= 0 && b->index < 4) S.tf[b->index] = *b; break; } case OP_TF_STATE: { const p_tf_state *b = a; S.tf_on = b->what == 0 || b->what == 3; break; } diff --git a/docs/env_switches.tsv b/docs/env_switches.tsv index 71a188769d..73dc7dc45f 100644 --- a/docs/env_switches.tsv +++ b/docs/env_switches.tsv @@ -118,6 +118,8 @@ DM_NVN_CAPTURE diagnostic `=:1:` writes that frame (from its first DM_NVN_CBDUMP diagnostic `=`: saves each draw's whole uniform blocks as `F_p_st_cb_
.bin`, and the source bytes of buffer-to-3D-texture copies, with `DM_NVN_PASSDUMP` DM_NVN_CBDUMP_KEY diagnostic `=`: limits `DM_NVN_CBDUMP` to draws using that shader; for a vertex shader key also saves the draw's vertex streams and index buffer DM_NVN_CBLOG diagnostic `=1` logs the command memory the game adds to command buffers (`AddCommandMemory`: the first 60, then every 500th) and the out-of-memory callbacks +DM_NVN_CB_CHECK test `1` writes each uniform-only argument table in full as well and logs any difference between the two +DM_NVN_CB_FAST diagnostic `0` writes every argument table in full; by default a shader whose stage only had uniform buffers rebound since its table was written in the pass copies that table and remakes the uniform buffer slots DM_NVN_CLEARLOG diagnostic `=1` logs the first 40 colour clears drawn as a triangle (inside a pass, with a partial channel mask or a partial scissor) DM_NVN_CMDSTAT diagnostic `=1` logs every 300 frames the command recording usage: bytes and records per frame, command memory segment sizes, out-of-memory callbacks, host segments, count and bytes per command type DM_NVN_COUNT diagnostic `1` counts every NVN call (the counting trampolines) and writes the per-frame call lines; off by default (on with a `DM_NVN_TSV` table that has call rows), the count is an atomic add all recording threads share