summaryrefslogtreecommitdiff
path: root/src/mesa/main/context.c
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2006-12-20 09:27:42 -0700
committerBrian <brian@yutani.localnet.net>2006-12-20 09:27:42 -0700
commit9e4bae9ccac5a76a2361c5c3cbe377a3c6b6a95b (patch)
tree49457c5d38d27a54d59d3e0429f8dcd46eab6882 /src/mesa/main/context.c
parent65a18442e5d846940714bb662f5b1bb47ab60c29 (diff)
Fix shader object reference counting and hash table deallocation.
Diffstat (limited to 'src/mesa/main/context.c')
-rw-r--r--src/mesa/main/context.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 2196591ba2..0e2a780476 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -131,7 +131,7 @@
#include "math/m_xform.h"
#include "math/mathmod.h"
#endif
-#include "shaders.h"
+#include "shader_api.h"
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
@@ -877,13 +877,22 @@ delete_arrayobj_cb(GLuint id, void *data, void *userData)
}
/**
- * Callback for deleting an shader object. Called by _mesa_HashDeleteAll().
+ * Callback for deleting shader and shader programs objects.
+ * Called by _mesa_HashDeleteAll().
*/
static void
-delete_shaderobj_cb(GLuint id, void *data, void *userData)
+delete_shader_cb(GLuint id, void *data, void *userData)
{
- /* XXX probably need to fix this */
- _mesa_free(data);
+ GLcontext *ctx = (GLcontext *) userData;
+ struct gl_shader *sh = (struct gl_shader *) data;
+ if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER) {
+ _mesa_free_shader(ctx, sh);
+ }
+ else {
+ struct gl_shader_program *shProg = (struct gl_shader_program *) data;
+ ASSERT(shProg->Type == GL_SHADER_PROGRAM);
+ _mesa_free_shader_program(ctx, shProg);
+ }
}
@@ -948,11 +957,8 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_DeleteHashTable(ss->ArrayObjects);
#if FEATURE_ARB_shader_objects
- /* XXX SLANG TO-DO */
- /*
- struct _mesa_HashTable *ShaderObjects;
- struct _mesa_HashTable *ProgramObjects;
- */
+ _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx);
+ _mesa_DeleteHashTable(ss->ShaderObjects);
#endif
#if FEATURE_EXT_framebuffer_object