diff --git a/src/gallium/auxiliary/driver_trace/tr_dump.c b/src/gallium/auxiliary/driver_trace/tr_dump.c index 74cb36f1c6c..22630485e45 100644 --- a/src/gallium/auxiliary/driver_trace/tr_dump.c +++ b/src/gallium/auxiliary/driver_trace/tr_dump.c @@ -68,6 +68,7 @@ static FILE *stream = NULL; static mtx_t call_mutex = _MTX_INITIALIZER_NP; static long unsigned call_no = 0; static bool dumping = false; +static long nir_count = 0; static bool trigger_active = true; static char *trigger_filename = NULL; @@ -252,6 +253,8 @@ trace_dump_trace_begin(void) if (!filename) return false; + nir_count = debug_get_num_option("GALLIUM_TRACE_NIR", 32); + if (!stream) { if (strcmp(filename, "stderr") == 0) { @@ -654,6 +657,17 @@ void trace_dump_nir(void *nir) if (!dumping) return; + if (nir_count < 0) { + fputs("...", stream); + return; + } + + if ((nir_count--) == 0) { + fputs("Set GALLIUM_TRACE_NIR to a sufficiently big number " + "to enable NIR shader dumping.", stream); + return; + } + // NIR doesn't have a print to string function. Use CDATA and hope for the // best. if (stream) {