summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/ast_function.cpp1
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp1
-rw-r--r--src/compiler/glsl/builtin_functions.cpp20
-rw-r--r--src/compiler/glsl/builtin_functions.h20
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp46
-rw-r--r--src/compiler/glsl/glsl_parser_extras.h5
-rw-r--r--src/compiler/glsl/standalone.cpp5
7 files changed, 31 insertions, 67 deletions
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index 0ed47660e22..4fd9b879555 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -664,7 +664,6 @@ match_function_by_name(const char *name,
}
/* Local shader has no exact candidates; check the built-ins. */
- _mesa_glsl_initialize_builtin_functions();
sig = _mesa_glsl_find_builtin_function(state, name, actual_parameters);
/* if _mesa_glsl_find_builtin_function failed, fall back to the result
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 61351341703..37afb8bd0b0 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -6043,7 +6043,6 @@ ast_function::hir(exec_list *instructions,
*/
if (state->es_shader) {
/* Local shader has no exact candidates; check the built-ins. */
- _mesa_glsl_initialize_builtin_functions();
if (state->language_version >= 300 &&
_mesa_glsl_has_builtin_function(state, name)) {
YYLTYPE loc = this->get_location();
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);
}
diff --git a/src/compiler/glsl/builtin_functions.h b/src/compiler/glsl/builtin_functions.h
index 50f4f3b1494..ff3d4e9f436 100644
--- a/src/compiler/glsl/builtin_functions.h
+++ b/src/compiler/glsl/builtin_functions.h
@@ -26,8 +26,19 @@
struct gl_shader;
-extern void
-_mesa_glsl_initialize_builtin_functions();
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void
+_mesa_glsl_builtin_functions_init_or_ref();
+
+void
+_mesa_glsl_builtin_functions_decref(void);
+
+#ifdef __cplusplus
+
+} /* extern "C" */
extern ir_function_signature *
_mesa_glsl_find_builtin_function(_mesa_glsl_parse_state *state,
@@ -43,9 +54,6 @@ _mesa_glsl_get_builtin_function_shader(void);
extern ir_function_signature *
_mesa_get_main_function_signature(glsl_symbol_table *symbols);
-extern void
-_mesa_glsl_release_builtin_functions(void);
-
namespace generate_ir {
ir_function_signature *
@@ -71,4 +79,6 @@ udivmod64(void *mem_ctx, builtin_available_predicate avail);
}
+#endif /* __cplusplus */
+
#endif /* BULITIN_FUNCTIONS_H */
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index e4a7e3dbf70..3ee1af57d50 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2326,49 +2326,3 @@ do_common_optimization(exec_list *ir, bool linked,
return progress;
}
-
-extern "C" {
-
-/**
- * To be called at GL context ctor.
- */
-void
-_mesa_init_shader_compiler_types(void)
-{
- glsl_type_singleton_init_or_ref();
-}
-
-/**
- * To be called at GL context dtor.
- */
-void
-_mesa_destroy_shader_compiler_types(void)
-{
- glsl_type_singleton_decref();
-}
-
-/**
- * To be called at GL teardown time, this frees compiler datastructures.
- *
- * After calling this, any previously compiled shaders and shader
- * programs would be invalid. So this should happen at approximately
- * program exit.
- */
-void
-_mesa_destroy_shader_compiler(void)
-{
- _mesa_destroy_shader_compiler_caches();
-}
-
-/**
- * Releases compiler caches to trade off performance for memory.
- *
- * Intended to be used with glReleaseShaderCompiler().
- */
-void
-_mesa_destroy_shader_compiler_caches(void)
-{
- _mesa_glsl_release_builtin_functions();
-}
-
-}
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index 5aaf0bc252b..62f4e1fc848 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -1024,11 +1024,6 @@ extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
struct _mesa_glsl_parse_state *state,
struct gl_context *gl_ctx);
-extern void _mesa_init_shader_compiler_types(void);
-extern void _mesa_destroy_shader_compiler_types(void);
-extern void _mesa_destroy_shader_compiler(void);
-extern void _mesa_destroy_shader_compiler_caches(void);
-
extern void
_mesa_glsl_copy_symbols_from_table(struct exec_list *shader_ir,
struct glsl_symbol_table *src,
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index b32fb626ef6..46733d490ec 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -134,7 +134,7 @@ static void
initialize_context(struct gl_context *ctx, gl_api api)
{
initialize_context_to_defaults(ctx, api);
- glsl_type_singleton_init_or_ref();
+ _mesa_glsl_builtin_functions_init_or_ref();
/* The standalone compiler needs to claim support for almost
* everything in order to compile the built-in functions.
@@ -620,6 +620,5 @@ standalone_compiler_cleanup(struct gl_shader_program *whole_program)
delete whole_program->FragDataIndexBindings;
ralloc_free(whole_program);
- glsl_type_singleton_decref();
- _mesa_glsl_release_builtin_functions();
+ _mesa_glsl_builtin_functions_decref();
}