summaryrefslogtreecommitdiff
path: root/src/mesa/main/texobj.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-11-01 14:21:57 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-11-01 14:21:57 +0000
commit5ac93f86210eb5c2a8dee74ec19b0ecd54376863 (patch)
treeea7acd0170a8b35a4a331b05c5910bc574c8f050 /src/mesa/main/texobj.c
parent232a489b41097b462fc0ad2b88f0df75a1abd4c3 (diff)
Merge texmem-0-3-branch.
Diffstat (limited to 'src/mesa/main/texobj.c')
-rw-r--r--src/mesa/main/texobj.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 8b42c2a712..1d27cd3f7c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -697,7 +697,11 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
if (textures[i] > 0) {
struct gl_texture_object *delObj
= _mesa_lookup_texture(ctx, textures[i]);
+
if (delObj) {
+ GLboolean delete;
+
+ _mesa_lock_texture(ctx, delObj);
/* Check if texture is bound to any framebuffer objects.
* If so, unbind.
@@ -724,7 +728,14 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
* XXX all RefCount accesses should be protected by a mutex.
*/
delObj->RefCount--;
- if (delObj->RefCount == 0) {
+ delete = (delObj->RefCount == 0);
+ _mesa_unlock_texture(ctx, delObj);
+
+ /* We know that refcount went to zero above, so this is
+ * the only pointer left to delObj, so we don't have to
+ * worry about locking any more:
+ */
+ if (delete) {
ASSERT(delObj->Name != 0); /* Never delete default tex objs */
ASSERT(ctx->Driver.DeleteTexture);
(*ctx->Driver.DeleteTexture)(ctx, delObj);
@@ -1052,4 +1063,30 @@ _mesa_IsTexture( GLuint texture )
return t && t->Target;
}
+/* Simplest implementation of texture locking: Grab the a new mutex in
+ * the shared context. Examine the shared context state timestamp and
+ * if there has been a change, set the appropriate bits in
+ * ctx->NewState.
+ *
+ * See also _mesa_lock/unlock_texture in texobj.h
+ */
+void _mesa_lock_context_textures( GLcontext *ctx )
+{
+ _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
+
+ if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) {
+ ctx->NewState |= _NEW_TEXTURE;
+ ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp;
+ }
+}
+
+
+void _mesa_unlock_context_textures( GLcontext *ctx )
+{
+ assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
+}
+
/*@}*/
+
+