Free shader-related context state: _mesa_free_shader_state()
authorBrian <brian@nostromo.localnet.net>
Sat, 24 Mar 2007 22:20:02 +0000 (16:20 -0600)
committerBrian <brian@nostromo.localnet.net>
Sat, 24 Mar 2007 22:20:02 +0000 (16:20 -0600)
src/mesa/main/context.c
src/mesa/shader/shader_api.c
src/mesa/shader/shader_api.h

index 0cff90c77a6c586e30a2ab38cf19243933321250..72c85de7ba2a13ac419705b1899d941e0f254c8e 100644 (file)
@@ -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
index 88aa8c50f5bf39e4a5684aaa489c9a0514d2a33a..002b42721df7eb73c465ff100b494f12997f8151 100644 (file)
@@ -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 <src> to <dst>, up to maxLength characters, returning
  * length of <dst> in <length>.
index 315f60a35f7ba832ab2f50586419cafff9da2dce..16ed1a0c108a1a4b9cd40447c056750efa23b9b9 100644 (file)
@@ -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);