From 450c753f8d931fa389c55b36f23c7ad76b4fe9a3 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 30 Aug 2023 23:54:04 -0700 Subject: [PATCH] compiler/types: Add a mem_ctx for the glsl_type_cache Reviewed-by: Emma Anholt Part-of: --- src/compiler/glsl_types.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index b433a61e571..0247d64cebd 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -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); }