aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-03-15 15:54:23 -0700
committerJason Ekstrand <[email protected]>2018-06-22 20:15:54 -0700
commit21befc46ef2b7362f3d6931b771115c1a07933d3 (patch)
tree30d7641b88b73756dbb4d17bf15b394fde76a6ad /src
parent54e440945ed67a8850f4e0d6133cfb3bb7a64e68 (diff)
nir: Support deref instructions in lower_global_vars_to_local
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Acked-by: Rob Clark <[email protected]> Acked-by: Bas Nieuwenhuizen <[email protected]> Acked-by: Dave Airlie <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_lower_global_vars_to_local.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/compiler/nir/nir_lower_global_vars_to_local.c b/src/compiler/nir/nir_lower_global_vars_to_local.c
index 9b3bc4cdd23..14aa366ea3a 100644
--- a/src/compiler/nir/nir_lower_global_vars_to_local.c
+++ b/src/compiler/nir/nir_lower_global_vars_to_local.c
@@ -32,31 +32,50 @@
#include "nir.h"
+static void
+register_var_use(nir_variable *var, nir_function_impl *impl,
+ struct hash_table *var_func_table)
+{
+ if (var->data.mode != nir_var_global)
+ return;
+
+ struct hash_entry *entry =
+ _mesa_hash_table_search(var_func_table, var);
+
+ if (entry) {
+ if (entry->data != impl)
+ entry->data = NULL;
+ } else {
+ _mesa_hash_table_insert(var_func_table, var, impl);
+ }
+}
+
static bool
mark_global_var_uses_block(nir_block *block, nir_function_impl *impl,
struct hash_table *var_func_table)
{
nir_foreach_instr(instr, block) {
- if (instr->type != nir_instr_type_intrinsic)
- continue;
-
- nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
- unsigned num_vars = nir_intrinsic_infos[intrin->intrinsic].num_variables;
-
- for (unsigned i = 0; i < num_vars; i++) {
- nir_variable *var = intrin->variables[i]->var;
- if (var->data.mode != nir_var_global)
- continue;
-
- struct hash_entry *entry =
- _mesa_hash_table_search(var_func_table, var);
-
- if (entry) {
- if (entry->data != impl)
- entry->data = NULL;
- } else {
- _mesa_hash_table_insert(var_func_table, var, impl);
- }
+ switch (instr->type) {
+ case nir_instr_type_deref: {
+ nir_deref_instr *deref = nir_instr_as_deref(instr);
+ if (deref->deref_type == nir_deref_type_var)
+ register_var_use(deref->var, impl, var_func_table);
+ break;
+ }
+
+ case nir_instr_type_intrinsic: {
+ nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+ unsigned num_vars =
+ nir_intrinsic_infos[intrin->intrinsic].num_variables;
+
+ for (unsigned i = 0; i < num_vars; i++)
+ register_var_use(intrin->variables[i]->var, impl, var_func_table);
+ break;
+ }
+
+ default:
+ /* Nothing to do */
+ break;
}
}
@@ -76,9 +95,6 @@ nir_lower_global_vars_to_local(nir_shader *shader)
_mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
- nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs |
- nir_lower_atomic_counter_derefs | nir_lower_atomic_derefs | nir_lower_image_derefs);
-
nir_foreach_function(function, shader) {
if (function->impl) {
nir_foreach_block(block, function->impl)
@@ -106,5 +122,8 @@ nir_lower_global_vars_to_local(nir_shader *shader)
_mesa_hash_table_destroy(var_func_table, NULL);
+ if (progress)
+ nir_fixup_deref_modes(shader);
+
return progress;
}