nir: Fix non-determinism in lower_global_vars_to_local
authorConnor Abbott <cwabbott0@gmail.com>
Tue, 22 Oct 2019 15:50:07 +0000 (17:50 +0200)
committerConnor Abbott <cwabbott0@gmail.com>
Thu, 14 Nov 2019 13:10:58 +0000 (13:10 +0000)
Using a hash-table walk means that variables will get inserted in
different orders on different runs. Just walk the list of globals
instead, even if some of them can't be turned into locals.

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/nir/nir_lower_global_vars_to_local.c

index 4df87aba366fdd93aceed69cca826b0e2fe7b9a0..9efc511bcad440c3a30ea91d5df43f71b0f98959 100644 (file)
@@ -83,8 +83,11 @@ nir_lower_global_vars_to_local(nir_shader *shader)
       }
    }
 
-   hash_table_foreach(var_func_table, entry) {
-      nir_variable *var = (void *)entry->key;
+   nir_foreach_variable_safe(var, &shader->globals) {
+      struct hash_entry *entry = _mesa_hash_table_search(var_func_table, var);
+      if (!entry)
+         continue;
+
       nir_function_impl *impl = entry->data;
 
       assert(var->data.mode == nir_var_shader_temp);