compiler/types: Simplify clearing the glsl_type_cache

Since now all the data referenced by it is allocated with the cache's
mem_ctx, it is sufficient to just free it, and then reset the cache
state to be ready for a next initialization if it happens.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25006>
This commit is contained in:
Caio Oliveira
2023-08-31 23:59:03 -07:00
committed by Marge Bot
parent 8a62b669f2
commit 7815f3cd3e
+1 -34
View File
@@ -459,13 +459,6 @@ const glsl_type *glsl_type::get_uint16_type() const
this->interface_row_major);
}
static void
hash_free_type_function(struct hash_entry *entry)
{
glsl_type *type = (glsl_type *) entry->data;
delete type;
}
void
glsl_type_singleton_init_or_ref()
{
@@ -488,34 +481,8 @@ glsl_type_singleton_decref()
return;
}
if (glsl_type_cache.explicit_matrix_types != NULL) {
_mesa_hash_table_destroy(glsl_type_cache.explicit_matrix_types,
hash_free_type_function);
glsl_type_cache.explicit_matrix_types = NULL;
}
if (glsl_type_cache.array_types != NULL) {
_mesa_hash_table_destroy(glsl_type_cache.array_types, hash_free_type_function);
glsl_type_cache.array_types = NULL;
}
if (glsl_type_cache.struct_types != NULL) {
_mesa_hash_table_destroy(glsl_type_cache.struct_types, hash_free_type_function);
glsl_type_cache.struct_types = NULL;
}
if (glsl_type_cache.interface_types != NULL) {
_mesa_hash_table_destroy(glsl_type_cache.interface_types, hash_free_type_function);
glsl_type_cache.interface_types = NULL;
}
if (glsl_type_cache.subroutine_types != NULL) {
_mesa_hash_table_destroy(glsl_type_cache.subroutine_types, hash_free_type_function);
glsl_type_cache.subroutine_types = NULL;
}
ralloc_free(glsl_type_cache.mem_ctx);
glsl_type_cache.mem_ctx = NULL;
memset(&glsl_type_cache, 0, sizeof(glsl_type_cache));
simple_mtx_unlock(&glsl_type_cache_mutex);
}