nir/validate: don't validate the GC list by default
authorRhys Perry <pendingchaos02@gmail.com>
Wed, 27 Oct 2021 10:25:27 +0000 (11:25 +0100)
committerRhys Perry <pendingchaos02@gmail.com>
Mon, 21 Feb 2022 11:57:18 +0000 (11:57 +0000)
This seems really slow.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13547>

src/compiler/nir/nir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_validate.c

index 5a33ce8..7fb103f 100644 (file)
@@ -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,
index 45f025c..865b5ba 100644 (file)
@@ -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 | \
index 6721ca4..c00dec9 100644 (file)
@@ -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;