From 01548f9f01644623ff7eb9778fc78f2eb90fc99a Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Thu, 2 Mar 2017 11:24:19 -0800 Subject: nir: Return progress from nir_lower_atomics(). Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h | 2 +- src/compiler/nir/nir_lower_atomics.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e03c0560c0e..703d5d2dd18 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2540,7 +2540,7 @@ typedef struct nir_lower_bitmap_options { void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *options); -void nir_lower_atomics(nir_shader *shader, +bool nir_lower_atomics(nir_shader *shader, const struct gl_shader_program *shader_program); bool nir_lower_to_source_mods(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c index 7a213fcb46e..1993013f8f6 100644 --- a/src/compiler/nir/nir_lower_atomics.c +++ b/src/compiler/nir/nir_lower_atomics.c @@ -35,7 +35,7 @@ * that directly store the buffer index and byte offset */ -static void +static bool lower_instr(nir_intrinsic_instr *instr, const struct gl_shader_program *shader_program, nir_shader *shader) @@ -87,13 +87,13 @@ lower_instr(nir_intrinsic_instr *instr, break; default: - return; + return false; } if (instr->variables[0]->var->data.mode != nir_var_uniform && instr->variables[0]->var->data.mode != nir_var_shader_storage && instr->variables[0]->var->data.mode != nir_var_shared) - return; /* atomics passed as function arguments can't be lowered */ + return false; /* atomics passed as function arguments can't be lowered */ void *mem_ctx = ralloc_parent(instr); unsigned uniform_loc = instr->variables[0]->var->data.location; @@ -168,19 +168,23 @@ lower_instr(nir_intrinsic_instr *instr, nir_instr_insert_before(&instr->instr, &new_instr->instr); nir_instr_remove(&instr->instr); + + return true; } -void +bool nir_lower_atomics(nir_shader *shader, const struct gl_shader_program *shader_program) { + bool progress = false; + nir_foreach_function(function, shader) { if (function->impl) { nir_foreach_block(block, function->impl) { nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_intrinsic) - lower_instr(nir_instr_as_intrinsic(instr), - shader_program, shader); + progress |= lower_instr(nir_instr_as_intrinsic(instr), + shader_program, shader); } } @@ -188,4 +192,6 @@ nir_lower_atomics(nir_shader *shader, nir_metadata_dominance); } } + + return progress; } -- cgit v1.2.3