summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2010-02-08 19:43:42 +0100
committerMichal Krol <[email protected]>2010-02-09 14:46:32 +0100
commiteeec2c3d951fed0d22e5dbf436d4a2d887e24221 (patch)
tree064a2ff0339c2ef48b153a2ad79f0fc470217650 /src
parent829d9bb7334ffea0d5d0c4076dd75c41525fae0c (diff)
mesa: Protect buffer objects reference counting with a mutex.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/bufferobj.c10
-rw-r--r--src/mesa/main/mtypes.h1
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 9e765b21d2f..2271550efe1 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -214,6 +214,7 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
bufObj->RefCount = -1000;
bufObj->Name = ~0;
+ _glthread_DESTROY_MUTEX(bufObj->Mutex);
_mesa_free(bufObj);
}
@@ -235,7 +236,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
GLboolean deleteFlag = GL_FALSE;
struct gl_buffer_object *oldObj = *ptr;
- /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/
+ _glthread_LOCK_MUTEX(oldObj->Mutex);
ASSERT(oldObj->RefCount > 0);
oldObj->RefCount--;
#if 0
@@ -243,7 +244,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
(void *) oldObj, oldObj->Name, oldObj->RefCount);
#endif
deleteFlag = (oldObj->RefCount == 0);
- /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/
+ _glthread_UNLOCK_MUTEX(oldObj->Mutex);
if (deleteFlag) {
@@ -265,7 +266,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
if (bufObj) {
/* reference new buffer */
- /*_glthread_LOCK_MUTEX(tex->Mutex);*/
+ _glthread_LOCK_MUTEX(bufObj->Mutex);
if (bufObj->RefCount == 0) {
/* this buffer's being deleted (look just above) */
/* Not sure this can every really happen. Warn if it does. */
@@ -280,7 +281,7 @@ _mesa_reference_buffer_object(GLcontext *ctx,
#endif
*ptr = bufObj;
}
- /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/
+ _glthread_UNLOCK_MUTEX(bufObj->Mutex);
}
}
@@ -295,6 +296,7 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
(void) target;
_mesa_bzero(obj, sizeof(struct gl_buffer_object));
+ _glthread_INIT_MUTEX(obj->Mutex);
obj->RefCount = 1;
obj->Name = name;
obj->Usage = GL_STATIC_DRAW_ARB;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 2640ba5ac42..20035417b97 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1426,6 +1426,7 @@ struct gl_viewport_attrib
*/
struct gl_buffer_object
{
+ _glthread_Mutex Mutex;
GLint RefCount;
GLuint Name;
GLenum Usage; /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */