Mesa (main): trace: Allow to control nir dumping via an environment variable.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 28 10:44:29 UTC 2022


Module: Mesa
Branch: main
Commit: 5f00b54873b50113448bf2bffd9208eaf378a671
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5f00b54873b50113448bf2bffd9208eaf378a671

Author: Jose Fonseca <jfonseca at vmware.com>
Date:   Mon Jun 27 19:38:19 2022 +0100

trace: Allow to control nir dumping via an environment variable.

As requested by Mike Blumenkrantz.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17107>

---

 src/gallium/auxiliary/driver_trace/tr_dump.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

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("<string>...</string>", stream);
+      return;
+   }
+
+   if ((nir_count--) == 0) {
+      fputs("<string>Set GALLIUM_TRACE_NIR to a sufficiently big number "
+            "to enable NIR shader dumping.</string>", stream);
+      return;
+   }
+
    // NIR doesn't have a print to string function.  Use CDATA and hope for the
    // best.
    if (stream) {



More information about the mesa-commit mailing list