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

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


---
 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 933d696..66f434c 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2539,7 +2539,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 7a213fc..1993013 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;
 }
-- 
2.10.2



More information about the mesa-dev mailing list