From 18c039b2e17868b2f98841da48f811de810d176d Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Sat, 4 Dec 2021 07:39:51 +0100 Subject: [PATCH] tgsi-to-nir: initialize NIR_DEBUG envvar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Part-of: --- 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);