--- src/mesa/main/mtypes.h | 1 - src/mesa/main/texobj.c | 17 +++-------------- 2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b8329a0..43d2f67 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1180,7 +1180,6 @@ struct gl_sampler_object */ struct gl_texture_object { - mtx_t Mutex; /**< for thread safety */ GLint RefCount; /**< reference count */ GLuint Name; /**< the user-visible texture object ID */ GLchar *Label; /**< GL_KHR_debug */ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index cd7cfd6..7c0ae93 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -42,6 +42,7 @@ #include "texstate.h" #include "mtypes.h" #include "program/prog_instruction.h" +#include "util/u_atomic.h" @@ -281,7 +282,6 @@ _mesa_initialize_texture_object( struct gl_context *ctx, memset(obj, 0, sizeof(*obj)); /* init the non-zero fields */ - mtx_init(&obj->Mutex, mtx_plain); obj->RefCount = 1; obj->Name = name; obj->Target = target; @@ -403,9 +403,6 @@ _mesa_delete_texture_object(struct gl_context *ctx, _mesa_reference_buffer_object(ctx, &texObj->BufferObject, NULL); - /* destroy the mutex -- it may have allocated memory (eg on bsd) */ - mtx_destroy(&texObj->Mutex); - free(texObj->Label); /* free this object */ @@ -538,20 +535,14 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, if (*ptr) { /* Unreference the old texture */ - GLboolean deleteFlag = GL_FALSE; struct gl_texture_object *oldTex = *ptr; assert(valid_texture_object(oldTex)); (void) valid_texture_object; /* silence warning in release builds */ - mtx_lock(&oldTex->Mutex); assert(oldTex->RefCount > 0); - oldTex->RefCount--; - - deleteFlag = (oldTex->RefCount == 0); - mtx_unlock(&oldTex->Mutex); - if (deleteFlag) { + if (p_atomic_dec_zero(&oldTex->RefCount)) { /* Passing in the context drastically changes the driver code for * framebuffer deletion. */ @@ -569,7 +560,6 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, if (tex) { /* reference new texture */ assert(valid_texture_object(tex)); - mtx_lock(&tex->Mutex); if (tex->RefCount == 0) { /* this texture's being deleted (look just above) */ /* Not sure this can every really happen. Warn if it does. */ @@ -577,10 +567,9 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, *ptr = NULL; } else { - tex->RefCount++; + p_atomic_inc(&tex->RefCount); *ptr = tex; } - mtx_unlock(&tex->Mutex); } } -- 2.3.6 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev