summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-07-03 15:41:45 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-07-03 17:21:22 -0600
commitd015ffa6ea20f00f23513e63b5c27e5e6d0d3627 (patch)
tree77f1fd5e23cac5fc27e97c160e32593588901fad /src/mesa
parent51abbdd227224c596ae2232ff3137dc3f346d563 (diff)
mesa: fix problem freeing framebuffer/renderbuffer objects
Basically, set up no-op Delete() methods for the DummyFrame/Renderbuffer obj
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/context.c34
-rw-r--r--src/mesa/main/fbobject.c25
-rw-r--r--src/mesa/main/fbobject.h7
3 files changed, 62 insertions, 4 deletions
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index be93d844e0..33f6d2c0d0 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -691,6 +691,37 @@ delete_shader_cb(GLuint id, void *data, void *userData)
}
}
+/**
+ * Callback for deleting a framebuffer object. Called by _mesa_HashDeleteAll()
+ */
+static void
+delete_framebuffer_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_framebuffer *fb = (struct gl_framebuffer *) data;
+ /* The fact that the framebuffer is in the hashtable means its refcount
+ * is one, but we're removing from the hashtable now. So clear refcount.
+ */
+ /*assert(fb->RefCount == 1);*/
+ fb->RefCount = 0;
+
+ /* NOTE: Delete should always be defined but there are two reports
+ * of it being NULL (bugs 13507, 14293). Work-around for now.
+ */
+ if (fb->Delete)
+ fb->Delete(fb);
+}
+
+/**
+ * Callback for deleting a renderbuffer object. Called by _mesa_HashDeleteAll()
+ */
+static void
+delete_renderbuffer_cb(GLuint id, void *data, void *userData)
+{
+ struct gl_renderbuffer *rb = (struct gl_renderbuffer *) data;
+ rb->RefCount = 0; /* see comment for FBOs above */
+ rb->Delete(rb);
+}
+
/**
* Deallocate a shared state object and all children structures.
@@ -744,7 +775,9 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
_mesa_DeleteHashTable(ss->ArrayObjects);
#if FEATURE_EXT_framebuffer_object
+ _mesa_HashDeleteAll(ss->FrameBuffers, delete_framebuffer_cb, ctx);
_mesa_DeleteHashTable(ss->FrameBuffers);
+ _mesa_HashDeleteAll(ss->RenderBuffers, delete_renderbuffer_cb, ctx);
_mesa_DeleteHashTable(ss->RenderBuffers);
#endif
@@ -994,6 +1027,7 @@ init_attrib_groups(GLcontext *ctx)
#if FEATURE_evaluators
_mesa_init_eval( ctx );
#endif
+ _mesa_init_fbobjects( ctx );
#if FEATURE_feedback
_mesa_init_feedback( ctx );
#else
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 800f6ee9a3..e4ff575e18 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -66,6 +66,27 @@ static struct gl_renderbuffer DummyRenderbuffer;
(TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
+static void
+delete_dummy_renderbuffer(struct gl_renderbuffer *rb)
+{
+ /* no op */
+}
+
+static void
+delete_dummy_framebuffer(struct gl_framebuffer *fb)
+{
+ /* no op */
+}
+
+
+void
+_mesa_init_fbobjects(GLcontext *ctx)
+{
+ DummyFramebuffer.Delete = delete_dummy_framebuffer;
+ DummyRenderbuffer.Delete = delete_dummy_renderbuffer;
+}
+
+
/**
* Helper routine for getting a gl_renderbuffer.
*/
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 782ad8cb18..b6154719ab 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,9 @@
#define FBOBJECT_H
+extern void
+_mesa_init_fbobjects(GLcontext *ctx);
+
extern struct gl_renderbuffer *
_mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id);