From abc8a702d0f01852f85705a87c9d624300c1efec Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Thu, 9 Mar 2017 11:01:22 -0800 Subject: [PATCH] nir: Return progress from nir_lower_io(). Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h | 2 +- src/compiler/nir/nir_lower_io.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 8e1721a92dc..388b5c85aef 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2379,7 +2379,7 @@ typedef enum { */ nir_lower_io_force_sample_interpolation = (1 << 1), } nir_lower_io_options; -void nir_lower_io(nir_shader *shader, +bool nir_lower_io(nir_shader *shader, nir_variable_mode modes, int (*type_size)(const struct glsl_type *), nir_lower_io_options); diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 1156b80ea8f..1ae2cc7fa8d 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -364,6 +364,7 @@ nir_lower_io_block(nir_block *block, { nir_builder *b = &state->builder; const nir_shader_compiler_options *options = b->shader->options; + bool progress = false; nir_foreach_instr_safe(instr, block) { if (instr->type != nir_instr_type_intrinsic) @@ -474,18 +475,20 @@ nir_lower_io_block(nir_block *block, nir_instr_insert_before(&intrin->instr, &replacement->instr); nir_instr_remove(&intrin->instr); + progress = true; } - return true; + return progress; } -static void +static bool nir_lower_io_impl(nir_function_impl *impl, nir_variable_mode modes, int (*type_size)(const struct glsl_type *), nir_lower_io_options options) { struct lower_io_state state; + bool progress = false; nir_builder_init(&state.builder, impl); state.modes = modes; @@ -493,23 +496,29 @@ nir_lower_io_impl(nir_function_impl *impl, state.options = options; nir_foreach_block(block, impl) { - nir_lower_io_block(block, &state); + progress |= nir_lower_io_block(block, &state); } nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); + return progress; } -void +bool nir_lower_io(nir_shader *shader, nir_variable_mode modes, int (*type_size)(const struct glsl_type *), nir_lower_io_options options) { + bool progress = false; + nir_foreach_function(function, shader) { if (function->impl) { - nir_lower_io_impl(function->impl, modes, type_size, options); + progress |= nir_lower_io_impl(function->impl, modes, + type_size, options); } } + + return progress; } /** -- 2.30.2