summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-05-19 08:43:36 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-05-19 08:43:36 -0600
commitfbfe2a58de8a9ca31164b4c6f26191b851fe939d (patch)
tree3c5a386386fe49601b5360b3b52e041b9afbab2f
parentfd59f19cd2388519265dfba3d28e5281df6f4ba0 (diff)
Fix program refcounting assertion failure during context tear-down
When purging the program hash table, the refcount _should_ be one since the program is referenced by the hash table. Need to explicitly set to zero before calling delete(). Also, purge high-level shader hash tables before low-level program hash tables.
-rw-r--r--src/mesa/main/context.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index d46c0cb74d..2c387d8e2c 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -582,6 +582,8 @@ delete_program_cb(GLuint id, void *data, void *userData)
{
struct gl_program *prog = (struct gl_program *) data;
GLcontext *ctx = (GLcontext *) userData;
+ ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */
+ prog->RefCount = 0; /* now going away */
ctx->Driver.DeleteProgram(ctx, prog);
}
@@ -707,6 +709,12 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_HashDeleteAll(ss->DisplayList, delete_displaylist_cb, ctx);
_mesa_DeleteHashTable(ss->DisplayList);
+#if FEATURE_ARB_shader_objects
+ _mesa_HashWalk(ss->ShaderObjects, free_shader_program_data_cb, ctx);
+ _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx);
+ _mesa_DeleteHashTable(ss->ShaderObjects);
+#endif
+
#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_NV_fragment_program)
_mesa_HashDeleteAll(ss->Programs, delete_program_cb, ctx);
_mesa_DeleteHashTable(ss->Programs);
@@ -732,12 +740,6 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_HashDeleteAll(ss->ArrayObjects, delete_arrayobj_cb, ctx);
_mesa_DeleteHashTable(ss->ArrayObjects);
-#if FEATURE_ARB_shader_objects
- _mesa_HashWalk(ss->ShaderObjects, free_shader_program_data_cb, ctx);
- _mesa_HashDeleteAll(ss->ShaderObjects, delete_shader_cb, ctx);
- _mesa_DeleteHashTable(ss->ShaderObjects);
-#endif
-
#if FEATURE_EXT_framebuffer_object
_mesa_HashDeleteAll(ss->FrameBuffers, delete_framebuffer_cb, ctx);
_mesa_DeleteHashTable(ss->FrameBuffers);