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);