[Mesa-dev] [PATCH 18/23] nir: Return progress from nir_lower_io().

Matt Turner mattst88 at gmail.com
Thu Mar 16 21:18:15 UTC 2017


---
 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 ed4c2c9..db47699 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2378,7 +2378,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 1156b80..1ae2cc7 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.10.2



More information about the mesa-dev mailing list