From 624789e3708c87ea2a4c8d2266266b489b421cba Mon Sep 17 00:00:00 2001 From: Tapani Pälli Date: Fri, 15 Mar 2019 09:47:49 +0200 Subject: compiler/glsl: handle case where we have multiple users for types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both Vulkan and OpenGL might be using glsl_types simultaneously or we can also have multiple concurrent Vulkan instances using glsl_types. Patch adds a one time init to track number of users and will release types only when last user calls _glsl_type_singleton_decref(). This change fixes glsl_type memory leaks we have with anv driver. v2: reuse hash_mutex, cleanup, apply fix also to radv driver and rename helper functions (Jason) v3: move init, destroy to happen on GL context init and destroy Signed-off-by: Tapani Pälli Reviewed-by: Timothy Arceri Reviewed-by: Jason Ekstrand --- src/intel/vulkan/anv_device.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/intel/vulkan/anv_device.c') diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 2687c4699ca..74d4eebebc2 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -41,6 +41,7 @@ #include "git_sha1.h" #include "vk_util.h" #include "common/gen_defines.h" +#include "compiler/glsl_types.h" #include "genxml/gen7_pack.h" @@ -716,6 +717,7 @@ VkResult anv_CreateInstance( env_var_as_boolean("ANV_ENABLE_PIPELINE_CACHE", true); _mesa_locale_init(); + glsl_type_singleton_init_or_ref(); VG(VALGRIND_CREATE_MEMPOOL(instance, 0, false)); @@ -746,6 +748,7 @@ void anv_DestroyInstance( vk_debug_report_instance_destroy(&instance->debug_report_callbacks); + glsl_type_singleton_decref(); _mesa_locale_fini(); vk_free(&instance->alloc, instance); -- cgit v1.2.3