summaryrefslogtreecommitdiff
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2017-03-02 11:24:19 -0800
committerMatt Turner <mattst88@gmail.com>2017-03-23 14:34:44 -0700
commit01548f9f01644623ff7eb9778fc78f2eb90fc99a (patch)
treec5655b6ef92dbfc0c78f70379758d5d4531f12e9 /src/compiler/nir
parent0bd615d961d117f8ae0354df813cc98ea0df4755 (diff)
nir: Return progress from nir_lower_atomics().
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir.h2
-rw-r--r--src/compiler/nir/nir_lower_atomics.c18
2 files changed, 13 insertions, 7 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index e03c0560c0..703d5d2dd1 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 7a213fcb46..1993013f8f 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;
}