summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/builtin_functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/glsl/builtin_functions.cpp')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 95d45033a01..eef5737128d 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -1254,6 +1254,8 @@ builtin_builder::initialize()
if (mem_ctx != NULL)
return;
+ glsl_type_singleton_init_or_ref();
+
mem_ctx = ralloc_context(NULL);
create_shader();
create_intrinsics();
@@ -1268,6 +1270,8 @@ builtin_builder::release()
ralloc_free(shader);
shader = NULL;
+
+ glsl_type_singleton_decref();
}
void
@@ -7277,24 +7281,28 @@ builtin_builder::_vote(const char *intrinsic_name,
/* The singleton instance of builtin_builder. */
static builtin_builder builtins;
static mtx_t builtins_lock = _MTX_INITIALIZER_NP;
+static uint32_t builtin_users = 0;
/**
* External API (exposing the built-in module to the rest of the compiler):
* @{
*/
-void
-_mesa_glsl_initialize_builtin_functions()
+extern "C" void
+_mesa_glsl_builtin_functions_init_or_ref()
{
mtx_lock(&builtins_lock);
- builtins.initialize();
+ if (builtin_users++ == 0)
+ builtins.initialize();
mtx_unlock(&builtins_lock);
}
-void
-_mesa_glsl_release_builtin_functions()
+extern "C" void
+_mesa_glsl_builtin_functions_decref()
{
mtx_lock(&builtins_lock);
- builtins.release();
+ assert(builtin_users != 0);
+ if (--builtin_users == 0)
+ builtins.release();
mtx_unlock(&builtins_lock);
}