Mesa (main): tgsi-to-nir: initialize NIR_DEBUG envvar

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 08:31:26 UTC 2021


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

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Sat Dec  4 07:39:51 2021 +0100

tgsi-to-nir: initialize NIR_DEBUG envvar

This envvar is initialized when creating a NIR shader, but it needs to
be used before. So initialize it here.

v2 (Juan):
 - Use static variable for first initialization.

Fixes: f77ccdfb4a2 ("nir: add NIR_DEBUG envvar")
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14057>

---

 src/compiler/nir/nir.c                  | 8 +++++---
 src/compiler/nir/nir.h                  | 3 +++
 src/gallium/auxiliary/nir/tgsi_to_nir.c | 4 ++++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index f8287196032..4663de619bb 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -39,7 +39,7 @@
 #include "main/menums.h" /* BITFIELD64_MASK */
 
 #ifndef NDEBUG
-uint32_t nir_debug = ~0;
+uint32_t nir_debug = 0;
 bool nir_debug_print_shader[MESA_SHADER_KERNEL + 1] = { 0 };
 
 static const struct debug_named_value nir_debug_control[] = {
@@ -90,10 +90,12 @@ static const struct debug_named_value nir_debug_control[] = {
 
 DEBUG_GET_ONCE_FLAGS_OPTION(nir_debug, "NIR_DEBUG", nir_debug_control, 0)
 
-static void
+void
 nir_process_debug_variable(void)
 {
-   if (unlikely(nir_debug == ~0)) {
+   static bool first = true;
+   if (unlikely(first)) {
+      first = false;
       nir_debug = debug_get_option_nir_debug();
       nir_debug_print_shader[MESA_SHADER_VERTEX]       = NIR_DEBUG(PRINT_VS);
       nir_debug_print_shader[MESA_SHADER_TESS_CTRL]    = NIR_DEBUG(PRINT_TCS);
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 2a664c94285..f0bd76ab247 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -124,6 +124,9 @@ nir_num_components_valid(unsigned num_components)
            num_components == 16;
 }
 
+void
+nir_process_debug_variable(void);
+
 bool nir_component_mask_can_reinterpret(nir_component_mask_t mask,
                                         unsigned old_bit_size,
                                         unsigned new_bit_size);
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 150482b1634..a3bf9a848e9 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -2580,6 +2580,10 @@ tgsi_to_nir(const void *tgsi_tokens,
    if (s)
       return s;
 
+#ifndef NDEBUG
+   nir_process_debug_variable();
+#endif
+
    if (NIR_DEBUG(TGSI)) {
       fprintf(stderr, "TGSI before translation to NIR:\n");
       tgsi_dump(tgsi_tokens, 0);



More information about the mesa-commit mailing list