Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / compiler / nir / nir_lower_global_vars_to_local.c
index 9ca4aadb88acc6a5e404a794d488e18125cacfd6..770c33ca872bb7581cf6a4dd0bac5dc40214117c 100644 (file)
@@ -36,7 +36,7 @@ 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)
+   if (var->data.mode != nir_var_shader_temp)
       return;
 
    struct hash_entry *entry =
@@ -74,12 +74,7 @@ nir_lower_global_vars_to_local(nir_shader *shader)
     * nir_function_impl that uses the given variable.  If a variable is
     * used in multiple functions, the data for the given key will be NULL.
     */
-   struct hash_table *var_func_table =
-      _mesa_hash_table_create(NULL, _mesa_hash_pointer,
-                              _mesa_key_pointer_equal);
-
-   nir_assert_unlowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs |
-         nir_lower_atomic_counter_derefs | nir_lower_atomic_derefs | nir_lower_image_derefs);
+   struct hash_table *var_func_table = _mesa_pointer_hash_table_create(NULL);
 
    nir_foreach_function(function, shader) {
       if (function->impl) {
@@ -88,16 +83,16 @@ nir_lower_global_vars_to_local(nir_shader *shader)
       }
    }
 
-   struct hash_entry *entry;
-   hash_table_foreach(var_func_table, entry) {
-      nir_variable *var = (void *)entry->key;
-      nir_function_impl *impl = entry->data;
+   nir_foreach_variable_with_modes_safe(var, shader, nir_var_shader_temp) {
+      struct hash_entry *entry = _mesa_hash_table_search(var_func_table, var);
+      if (!entry)
+         continue;
 
-      assert(var->data.mode == nir_var_global);
+      nir_function_impl *impl = entry->data;
 
       if (impl != NULL) {
          exec_node_remove(&var->node);
-         var->data.mode = nir_var_local;
+         var->data.mode = nir_var_function_temp;
          exec_list_push_tail(&impl->locals, &var->node);
          nir_metadata_preserve(impl, nir_metadata_block_index |
                                      nir_metadata_dominance |
@@ -111,5 +106,10 @@ nir_lower_global_vars_to_local(nir_shader *shader)
    if (progress)
       nir_fixup_deref_modes(shader);
 
+   nir_foreach_function(function, shader) {
+      if (function->impl)
+         nir_metadata_preserve(function->impl, nir_metadata_all);
+   }
+
    return progress;
 }