From 925c5f817db7702fdd2c894fd3e122f274af71dd Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Wed, 27 Oct 2021 11:25:27 +0100 Subject: [PATCH] nir/validate: don't validate the GC list by default This seems really slow. Signed-off-by: Rhys Perry Reviewed-by: Emma Anholt Part-of: --- src/compiler/nir/nir.c | 2 ++ src/compiler/nir/nir.h | 1 + src/compiler/nir/nir_validate.c | 11 +++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 5a33ce8..7fb103f 100644 --- a/src/compiler/nir/nir.c +++ b/src/compiler/nir/nir.c @@ -51,6 +51,8 @@ static const struct debug_named_value nir_debug_control[] = { "Disable shader validation at each successful lowering/optimization call" }, { "validate_ssa_dominance", NIR_DEBUG_VALIDATE_SSA_DOMINANCE, "Validate SSA dominance in shader at each successful lowering/optimization call" }, + { "validate_gc_list", NIR_DEBUG_VALIDATE_GC_LIST, + "Validate the instruction GC list at each successful lowering/optimization call" }, { "tgsi", NIR_DEBUG_TGSI, "Dump NIR/TGSI shaders when doing a NIR<->TGSI translation" }, { "print", NIR_DEBUG_PRINT, diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 45f025c..865b5ba 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -91,6 +91,7 @@ extern bool nir_debug_print_shader[MESA_SHADER_KERNEL + 1]; #define NIR_DEBUG_PRINT_CBS (1u << 18) #define NIR_DEBUG_PRINT_KS (1u << 19) #define NIR_DEBUG_PRINT_CONSTS (1u << 20) +#define NIR_DEBUG_VALIDATE_GC_LIST (1u << 21) #define NIR_DEBUG_PRINT (NIR_DEBUG_PRINT_VS | \ NIR_DEBUG_PRINT_TCS | \ diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 6721ca4..c00dec9 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -1055,7 +1055,8 @@ validate_instr(nir_instr *instr, validate_state *state) state->instr = instr; - validate_assert(state, _mesa_set_search(state->shader_gc_list, instr)); + if (state->shader_gc_list) + validate_assert(state, _mesa_set_search(state->shader_gc_list, instr)); switch (instr->type) { case nir_instr_type_alu: @@ -1660,7 +1661,8 @@ init_validate_state(validate_state *state) state->blocks = _mesa_pointer_set_create(state->mem_ctx); state->var_defs = _mesa_pointer_hash_table_create(state->mem_ctx); state->errors = _mesa_pointer_hash_table_create(state->mem_ctx); - state->shader_gc_list = _mesa_pointer_set_create(state->mem_ctx); + state->shader_gc_list = NIR_DEBUG(VALIDATE_GC_LIST) ? + _mesa_pointer_set_create(state->mem_ctx) : NULL; state->loop = NULL; state->instr = NULL; @@ -1717,8 +1719,9 @@ nir_validate_shader(nir_shader *shader, const char *when) validate_state state; init_validate_state(&state); - list_for_each_entry(nir_instr, instr, &shader->gc_list, gc_node) { - _mesa_set_add(state.shader_gc_list, instr); + if (state.shader_gc_list) { + list_for_each_entry(nir_instr, instr, &shader->gc_list, gc_node) + _mesa_set_add(state.shader_gc_list, instr); } state.shader = shader; -- 2.7.4