summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-04-05 09:28:09 -0600
committerBrian <brian@yutani.localnet.net>2007-04-05 09:28:09 -0600
commit0cae814f362bd7e648535c8ceae12ad286d20d73 (patch)
tree208f5292ace6df5b2025781e0504a822a76c80c8 /src
parent33c3739628616c0aaf10e51eae50611169ded0dd (diff)
temporary add some extra renderbuffer debug code
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/renderbuffer.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index c24e2e389f..58efa0b4f5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2222,6 +2222,8 @@ struct gl_shared_state
*/
struct gl_renderbuffer
{
+#define RB_MAGIC 0xaabbccdd
+ int Magic; /** XXX TEMPORARY DEBUG INFO */
_glthread_Mutex Mutex; /**< for thread safety */
GLuint ClassID; /**< Useful for drivers */
GLuint Name;
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index 1145e91e3b..6f1d7c3960 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -1471,6 +1471,7 @@ _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
{
_glthread_INIT_MUTEX(rb->Mutex);
+ rb->Magic = RB_MAGIC;
rb->ClassID = 0;
rb->Name = name;
rb->RefCount = 0;
@@ -2149,21 +2150,26 @@ _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
GLboolean deleteFlag = GL_FALSE;
struct gl_renderbuffer *oldRb = *ptr;
+ assert(oldRb->Magic == RB_MAGIC);
_glthread_LOCK_MUTEX(oldRb->Mutex);
+ assert(oldRb->Magic == RB_MAGIC);
ASSERT(oldRb->RefCount > 0);
oldRb->RefCount--;
/*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/
deleteFlag = (oldRb->RefCount == 0);
_glthread_UNLOCK_MUTEX(oldRb->Mutex);
- if (deleteFlag)
+ if (deleteFlag) {
+ oldRb->Magic = 0; /* now invalid memory! */
oldRb->Delete(oldRb);
+ }
*ptr = NULL;
}
assert(!*ptr);
if (rb) {
+ assert(rb->Magic == RB_MAGIC);
/* reference new renderbuffer */
_glthread_LOCK_MUTEX(rb->Mutex);
rb->RefCount++;