From d12f15f1ccc3a1288615a62f2ad9c996183af665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Wed, 31 Jul 2019 08:58:59 +0300 Subject: [PATCH] glsl: make final glsl_type decref to release builtin functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise existing builtins refer to types in hash tables that we have already removed. Initialize builtin functions again when initializing types. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110796 Signed-off-by: Tapani Pälli --- src/compiler/glsl/glsl_parser_extras.cpp | 4 +++- src/compiler/glsl_types.cpp | 5 +++-- src/compiler/glsl_types.h | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index c6068ac9327..f3b71f3a506 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2335,6 +2335,7 @@ void _mesa_init_shader_compiler_types(void) { glsl_type_singleton_init_or_ref(); + _mesa_glsl_initialize_builtin_functions(); } /** @@ -2343,7 +2344,8 @@ _mesa_init_shader_compiler_types(void) void _mesa_destroy_shader_compiler_types(void) { - glsl_type_singleton_decref(); + if (glsl_type_singleton_decref()) + _mesa_glsl_release_builtin_functions(); } /** diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 10cfa3b4b1e..8a503926e5c 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -482,7 +482,7 @@ glsl_type_singleton_init_or_ref() mtx_unlock(&glsl_type::hash_mutex); } -void +bool glsl_type_singleton_decref() { mtx_lock(&glsl_type::hash_mutex); @@ -492,7 +492,7 @@ glsl_type_singleton_decref() /* Do not release glsl_types if they are still used. */ if (--glsl_type_users) { mtx_unlock(&glsl_type::hash_mutex); - return; + return false; } if (glsl_type::explicit_matrix_types != NULL) { @@ -527,6 +527,7 @@ glsl_type_singleton_decref() } mtx_unlock(&glsl_type::hash_mutex); + return true; } diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index 40f148a2171..a9df516dd28 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -49,7 +49,7 @@ struct glsl_symbol_table; extern void glsl_type_singleton_init_or_ref(); -extern void +extern bool glsl_type_singleton_decref(); extern void @@ -1145,7 +1145,7 @@ private: */ /*@{*/ friend void glsl_type_singleton_init_or_ref(void); - friend void glsl_type_singleton_decref(void); + friend bool glsl_type_singleton_decref(void); friend void _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *); /*@}*/ }; -- 2.20.1