Mesa (main): gallium/ttn: Add a debug flag for dumping the shaders.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 16 22:12:37 UTC 2021


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

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jan  8 16:04:42 2021 -0800

gallium/ttn: Add a debug flag for dumping the shaders.

Just like for ntt, it's nice to be able to dump the shader that assertion
failed on you.

Reviewed-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11915>

---

 src/gallium/auxiliary/nir/tgsi_to_nir.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index e60b92e867d..4dfb15619e0 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -23,6 +23,7 @@
  */
 
 #include "util/blob.h"
+#include "util/debug.h"
 #include "util/disk_cache.h"
 #include "util/u_memory.h"
 #include "util/ralloc.h"
@@ -2560,6 +2561,7 @@ tgsi_to_nir(const void *tgsi_tokens,
    struct nir_shader *s = NULL;
    uint8_t key[CACHE_KEY_SIZE];
    unsigned processor;
+   bool debug = env_var_as_boolean("TGSI_TO_NIR_DEBUG", false);
 
    if (allow_disk_cache)
       cache = screen->get_disk_shader_cache(screen);
@@ -2577,6 +2579,11 @@ tgsi_to_nir(const void *tgsi_tokens,
    if (s)
       return s;
 
+   if (debug) {
+      fprintf(stderr, "TGSI before translation to NIR:\n");
+      tgsi_dump(tgsi_tokens, 0);
+   }
+
    /* Not in the cache */
 
    c = ttn_compile_init(tgsi_tokens, NULL, screen);
@@ -2584,6 +2591,11 @@ tgsi_to_nir(const void *tgsi_tokens,
    ttn_finalize_nir(c, screen);
    ralloc_free(c);
 
+   if (debug) {
+      mesa_logi("NIR after translation from TGSI:\n");
+      nir_log_shaderi(s);
+   }
+
    if (cache)
       save_nir_to_disk_cache(cache, key, s);
 



More information about the mesa-commit mailing list