mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
compiler/types: Add a mem_ctx for the glsl_type_cache
Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25006>
This commit is contained in:
parent
74d85abf00
commit
450c753f8d
1 changed files with 7 additions and 0 deletions
|
|
@ -36,6 +36,8 @@
|
|||
static simple_mtx_t glsl_type_cache_mutex = SIMPLE_MTX_INITIALIZER;
|
||||
|
||||
static struct {
|
||||
void *mem_ctx;
|
||||
|
||||
/* There might be multiple users for types (e.g. application using OpenGL
|
||||
* and Vulkan simultaneously or app using multiple Vulkan instances). Counter
|
||||
* is used to make sure we don't release the types if a user is still present.
|
||||
|
|
@ -478,6 +480,8 @@ void
|
|||
glsl_type_singleton_init_or_ref()
|
||||
{
|
||||
simple_mtx_lock(&glsl_type_cache_mutex);
|
||||
if (glsl_type_cache.users == 0)
|
||||
glsl_type_cache.mem_ctx = ralloc_context(NULL);
|
||||
glsl_type_cache.users++;
|
||||
simple_mtx_unlock(&glsl_type_cache_mutex);
|
||||
}
|
||||
|
|
@ -520,6 +524,9 @@ glsl_type_singleton_decref()
|
|||
glsl_type_cache.subroutine_types = NULL;
|
||||
}
|
||||
|
||||
ralloc_free(glsl_type_cache.mem_ctx);
|
||||
glsl_type_cache.mem_ctx = NULL;
|
||||
|
||||
simple_mtx_unlock(&glsl_type_cache_mutex);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue