summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-05-19 08:59:41 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-05-19 08:59:41 -0600
commit62f96ddbbc2549bd4d50016f571cd4d1f6f6a7d6 (patch)
treec87c81922da4edcf6113fc21ff1ada6cd4734b41 /src/mesa
parenta0bfeb0c3ca58a1f4d978f2aaa343ed4009de079 (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 tabl cherry-picked from master
Diffstat (limited to 'src/mesa')
-rwxr-xr-xsrc/mesa/main/context.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 893c79f28c..2158eb6873 100755
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -593,6 +593,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);
}
@@ -686,22 +688,11 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_HashDeleteAll(ss->DisplayList, delete_displaylist_cb, ctx);
_mesa_DeleteHashTable(ss->DisplayList);
- /*
- * Free texture objects
- */
- ASSERT(ctx->Driver.DeleteTexture);
- /* the default textures */
- ctx->Driver.DeleteTexture(ctx, ss->Default1D);
- ctx->Driver.DeleteTexture(ctx, ss->Default2D);
- ctx->Driver.DeleteTexture(ctx, ss->Default3D);
- ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap);
- ctx->Driver.DeleteTexture(ctx, ss->DefaultRect);
- ctx->Driver.DeleteTexture(ctx, ss->Default1DArray);
- ctx->Driver.DeleteTexture(ctx, ss->Default2DArray);
-
- /* all other textures */
- _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx);
- _mesa_DeleteHashTable(ss->TexObjects);
+#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);
@@ -728,17 +719,28 @@ 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_DeleteHashTable(ss->FrameBuffers);
_mesa_DeleteHashTable(ss->RenderBuffers);
#endif
+ /*
+ * Free texture objects (after FBOs since some textures might have
+ * been bound to FBOs).
+ */
+ ASSERT(ctx->Driver.DeleteTexture);
+ /* the default textures */
+ ctx->Driver.DeleteTexture(ctx, ss->Default1D);
+ ctx->Driver.DeleteTexture(ctx, ss->Default2D);
+ ctx->Driver.DeleteTexture(ctx, ss->Default3D);
+ ctx->Driver.DeleteTexture(ctx, ss->DefaultCubeMap);
+ ctx->Driver.DeleteTexture(ctx, ss->DefaultRect);
+ ctx->Driver.DeleteTexture(ctx, ss->Default1DArray);
+ ctx->Driver.DeleteTexture(ctx, ss->Default2DArray);
+ /* all other textures */
+ _mesa_HashDeleteAll(ss->TexObjects, delete_texture_cb, ctx);
+ _mesa_DeleteHashTable(ss->TexObjects);
+
_glthread_DESTROY_MUTEX(ss->Mutex);
_mesa_free(ss);