From 63a656797b0b4e199968a4e6ec59e70ad9e996b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Thu, 22 Aug 2024 16:39:51 +0200 Subject: [PATCH] nir: only print divergence information if metadata is valid This disables printing of vertex divergence as well as outdated divergence information. Also remove info::divergence_analysis_run and use nir_metadata_divergence instead. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rhys Perry Part-of: --- src/compiler/nir/nir_divergence_analysis.c | 3 --- src/compiler/nir/nir_print.c | 10 +++++++--- src/compiler/shader_info.h | 3 --- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index 1a119482f74..ec783786d0d 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -1460,7 +1460,6 @@ nir_divergence_analysis(nir_shader *shader) nir_foreach_function_impl(impl, shader) { nir_metadata_require(impl, nir_metadata_divergence); } - shader->info.divergence_analysis_run = true; } /* Compute divergence between vertices of the same primitive. This uses @@ -1470,8 +1469,6 @@ nir_divergence_analysis(nir_shader *shader) void nir_vertex_divergence_analysis(nir_shader *shader) { - shader->info.divergence_analysis_run = false; - struct divergence_state state = { .stage = shader->info.stage, .shader = shader, diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 200009e7476..36446f654c3 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -80,6 +80,9 @@ typedef struct { */ unsigned padding_for_no_dest; + /* Whether divergence metadata is valid. */ + bool divergence_valid; + bool gather_debug_info; nir_instr_debug_info last_debug_info; @@ -112,7 +115,7 @@ static const char *sizes[] = { "x??", " ", "x2 ", "x3 ", "x4 ", static const char * divergence_status(print_state *state, bool divergent) { - if (state->shader->info.divergence_analysis_run) + if (state->divergence_valid) return divergent ? "div " : "con "; return ""; @@ -148,7 +151,7 @@ print_def(nir_def *def, print_state *state) static unsigned calculate_padding_for_no_dest(print_state *state) { - const unsigned div = state->shader->info.divergence_analysis_run ? 4 : 0; + const unsigned div = state->divergence_valid ? 4 : 0; const unsigned ssa_size = 5; const unsigned percent = 1; const unsigned ssa_index = count_digits(state->max_dest_index); @@ -2295,6 +2298,7 @@ print_function_impl(nir_function_impl *impl, print_state *state, bool print_name FILE *fp = state->fp; state->max_dest_index = impl->ssa_alloc; + state->divergence_valid = impl->valid_metadata & nir_metadata_divergence; if (print_name) { fprintf(fp, "\nimpl %s ", impl->function->name); @@ -2636,7 +2640,6 @@ print_shader_info(const struct shader_info *info, FILE *fp) print_nz_bool(fp, "uses_texture_gather", info->uses_texture_gather); print_nz_bool(fp, "uses_resource_info_query", info->uses_resource_info_query); - print_nz_bool(fp, "divergence_analysis_run", info->divergence_analysis_run); print_nz_x8(fp, "bit_sizes_float", info->bit_sizes_float); print_nz_x8(fp, "bit_sizes_int", info->bit_sizes_int); @@ -2863,6 +2866,7 @@ nir_print_instr(const nir_instr *instr, FILE *fp) if (instr->block) { nir_function_impl *impl = nir_cf_node_get_function(&instr->block->cf_node); state.shader = impl->function->shader; + state.divergence_valid = impl->valid_metadata & nir_metadata_divergence; } print_instr(instr, &state, 0); diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h index d40d4ac2307..ce334909664 100644 --- a/src/compiler/shader_info.h +++ b/src/compiler/shader_info.h @@ -185,9 +185,6 @@ typedef struct shader_info { /* Whether texture size, levels, or samples is queried. */ bool uses_resource_info_query:1; - /** Has divergence analysis ever been run? */ - bool divergence_analysis_run:1; - /* Bitmask of bit-sizes used with ALU instructions. */ uint8_t bit_sizes_float; uint8_t bit_sizes_int;