summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-08-18 16:56:39 -0700
committerEric Anholt <eric@anholt.net>2010-08-18 17:10:48 -0700
commitb83846475bac76268d75f53632faf8aad8cad02c (patch)
treec667c59b52eb4d3086432f1fc895694ab9b2007e
parent3cd233eb5714137dccb6218ad78005511bcc02bd (diff)
glsl2: Free the shader compiler at dri screen destruction.
Hooray, we can valgrind again without adding suppressions. This also adds an interface for use by an implementation of glReleaseShaderCompiler().
-rw-r--r--src/glsl/glsl_parser_extras.cpp30
-rw-r--r--src/glsl/glsl_parser_extras.h3
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c2
3 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index d1bb1ae5ec..b864218d50 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -741,3 +741,33 @@ do_common_optimization(exec_list *ir, bool linked)
return progress;
}
+
+extern "C" {
+
+/**
+ * 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();
+
+ _mesa_glsl_release_types();
+}
+
+/**
+ * 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_functions();
+}
+
+}
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 9e3cac26e2..b0b1bc31d0 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -178,6 +178,9 @@ extern void _mesa_glsl_warning(const YYLTYPE *locp,
extern "C" {
extern int preprocess(void *ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions);
+
+extern void _mesa_destroy_shader_compiler();
+extern void _mesa_destroy_shader_compiler_caches();
}
extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index 5eb8b62f45..b1a7b3ed34 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -707,6 +707,8 @@ static void driDestroyScreen(__DRIscreen *psp)
* stream open to the X-server anymore.
*/
+ _mesa_destroy_shader_compiler();
+
if (psp->DriverAPI.DestroyScreen)
(*psp->DriverAPI.DestroyScreen)(psp);