From 935f93f966aa298c4d4115ac766cb2ff46ad6514 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 24 Mar 2007 16:20:02 -0600 Subject: Free shader-related context state: _mesa_free_shader_state() --- src/mesa/main/context.c | 1 + src/mesa/shader/shader_api.c | 16 ++++++++++++++++ src/mesa/shader/shader_api.h | 3 +++ 3 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 0cff90c77a6..72c85de7ba2 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1439,6 +1439,7 @@ _mesa_free_context_data( GLcontext *ctx ) _mesa_free_viewport_data( ctx ); _mesa_free_colortables_data( ctx ); _mesa_free_program_data(ctx); + _mesa_free_shader_state(ctx); _mesa_free_query_data(ctx); #if FEATURE_ARB_vertex_buffer_object diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 88aa8c50f5b..002b42721df 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -211,6 +211,22 @@ _mesa_init_shader_state(GLcontext * ctx) } +/** + * Free the per-context shader-related state. + */ +void +_mesa_free_shader_state(GLcontext *ctx) +{ + if (ctx->Shader.CurrentProgram) { + ctx->Shader.CurrentProgram->RefCount--; + if (ctx->Shader.CurrentProgram->RefCount <= 0) { + _mesa_free_shader_program(ctx, ctx->Shader.CurrentProgram); + ctx->Shader.CurrentProgram = NULL; + } + } +} + + /** * Copy string from to , up to maxLength characters, returning * length of in . diff --git a/src/mesa/shader/shader_api.h b/src/mesa/shader/shader_api.h index 315f60a35f7..16ed1a0c108 100644 --- a/src/mesa/shader/shader_api.h +++ b/src/mesa/shader/shader_api.h @@ -38,6 +38,9 @@ extern void _mesa_init_shader_state(GLcontext * ctx); +extern void +_mesa_free_shader_state(GLcontext *ctx); + extern struct gl_shader_program * _mesa_new_shader_program(GLcontext *ctx, GLuint name); -- cgit v1.2.3