Mesa (master): nir: Fix non-determinism in lower_global_vars_to_local

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 14 13:25:23 UTC 2019


Module: Mesa
Branch: master
Commit: f9fd04aca15fd00889caa666ba38007268e67f5c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f9fd04aca15fd00889caa666ba38007268e67f5c

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Tue Oct 22 17:50:07 2019 +0200

nir: Fix non-determinism in lower_global_vars_to_local

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 at google.com>
Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/compiler/nir/nir_lower_global_vars_to_local.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 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 4df87aba366..9efc511bcad 100644
--- a/src/compiler/nir/nir_lower_global_vars_to_local.c
+++ b/src/compiler/nir/nir_lower_global_vars_to_local.c
@@ -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);




More information about the mesa-commit mailing list