[Mesa-dev] [RFC 2/3] mesa: use simple mtx in core mesa

Timothy Arceri tarceri at itsqueeze.com
Tue Oct 10 02:45:42 UTC 2017


---
 src/gallium/state_trackers/dri/dri2.c | 22 +++++++++++-----------
 src/mesa/main/bufferobj.c             | 14 +++++++-------
 src/mesa/main/debug_output.c          | 16 ++++++++--------
 src/mesa/main/errors.c                |  4 ++--
 src/mesa/main/fbobject.c              | 14 +++++++-------
 src/mesa/main/framebuffer.c           | 14 +++++++-------
 src/mesa/main/mtypes.h                | 15 ++++++++-------
 src/mesa/main/renderbuffer.c          | 12 ++++++------
 src/mesa/main/robustness.c            |  4 ++--
 src/mesa/main/samplerobj.c            | 12 ++++++------
 src/mesa/main/shared.c                | 12 ++++++------
 src/mesa/main/syncobj.c               | 14 +++++++-------
 src/mesa/main/texobj.c                | 16 ++++++++--------
 src/mesa/vbo/vbo_minmax_index.c       |  8 ++++----
 14 files changed, 89 insertions(+), 88 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 8672174787..e7b5572f5c 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1655,84 +1655,84 @@ dri2_interop_export_object(__DRIcontext *_ctx,
    default:
       return MESA_GLINTEROP_INVALID_TARGET;
    }
 
    /* Validate the simple case of miplevel. */
    if ((target == GL_RENDERBUFFER || target == GL_ARRAY_BUFFER) &&
        in->miplevel != 0)
       return MESA_GLINTEROP_INVALID_MIP_LEVEL;
 
    /* Validate the OpenGL object and get pipe_resource. */
-   mtx_lock(&ctx->Shared->Mutex);
+   simple_mtx_lock(&ctx->Shared->Mutex);
 
    if (target == GL_ARRAY_BUFFER) {
       /* Buffer objects.
        *
        * The error checking is based on the documentation of
        * clCreateFromGLBuffer from OpenCL 2.0 SDK.
        */
       struct gl_buffer_object *buf = _mesa_lookup_bufferobj(ctx, in->obj);
 
       /* From OpenCL 2.0 SDK, clCreateFromGLBuffer:
        *  "CL_INVALID_GL_OBJECT if bufobj is not a GL buffer object or is
        *   a GL buffer object but does not have an existing data store or
        *   the size of the buffer is 0."
        */
       if (!buf || buf->Size == 0) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OBJECT;
       }
 
       res = st_buffer_object(buf)->buffer;
       if (!res) {
          /* this shouldn't happen */
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OBJECT;
       }
 
       out->buf_offset = 0;
       out->buf_size = buf->Size;
 
       buf->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
    } else if (target == GL_RENDERBUFFER) {
       /* Renderbuffers.
        *
        * The error checking is based on the documentation of
        * clCreateFromGLRenderbuffer from OpenCL 2.0 SDK.
        */
       struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, in->obj);
 
       /* From OpenCL 2.0 SDK, clCreateFromGLRenderbuffer:
        *   "CL_INVALID_GL_OBJECT if renderbuffer is not a GL renderbuffer
        *    object or if the width or height of renderbuffer is zero."
        */
       if (!rb || rb->Width == 0 || rb->Height == 0) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OBJECT;
       }
 
       /* From OpenCL 2.0 SDK, clCreateFromGLRenderbuffer:
        *   "CL_INVALID_OPERATION if renderbuffer is a multi-sample GL
        *    renderbuffer object."
        */
       if (rb->NumSamples > 1) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OPERATION;
       }
 
       /* From OpenCL 2.0 SDK, clCreateFromGLRenderbuffer:
        *   "CL_OUT_OF_RESOURCES if there is a failure to allocate resources
        *    required by the OpenCL implementation on the device."
        */
       res = st_renderbuffer(rb)->texture;
       if (!res) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_OUT_OF_RESOURCES;
       }
 
       out->internal_format = rb->InternalFormat;
       out->view_minlevel = 0;
       out->view_numlevels = 1;
       out->view_minlayer = 0;
       out->view_numlayers = 1;
    } else {
       /* Texture objects.
@@ -1748,46 +1748,46 @@ dri2_interop_export_object(__DRIcontext *_ctx,
       /* From OpenCL 2.0 SDK, clCreateFromGLTexture:
        *   "CL_INVALID_GL_OBJECT if texture is not a GL texture object whose
        *    type matches texture_target, if the specified miplevel of texture
        *    is not defined, or if the width or height of the specified
        *    miplevel is zero or if the GL texture object is incomplete."
        */
       if (!obj ||
           obj->Target != target ||
           !obj->_BaseComplete ||
           (in->miplevel > 0 && !obj->_MipmapComplete)) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OBJECT;
       }
 
       /* From OpenCL 2.0 SDK, clCreateFromGLTexture:
        *   "CL_INVALID_MIP_LEVEL if miplevel is less than the value of
        *    levelbase (for OpenGL implementations) or zero (for OpenGL ES
        *    implementations); or greater than the value of q (for both OpenGL
        *    and OpenGL ES). levelbase and q are defined for the texture in
        *    section 3.8.10 (Texture Completeness) of the OpenGL 2.1
        *    specification and section 3.7.10 of the OpenGL ES 2.0."
        */
       if (in->miplevel < obj->BaseLevel || in->miplevel > obj->_MaxLevel) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_MIP_LEVEL;
       }
 
       if (!st_finalize_texture(ctx, st->pipe, obj, 0)) {
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_OUT_OF_RESOURCES;
       }
 
       res = st_get_texobj_resource(obj);
       if (!res) {
          /* Incomplete texture buffer object? This shouldn't really occur. */
-         mtx_unlock(&ctx->Shared->Mutex);
+         simple_mtx_unlock(&ctx->Shared->Mutex);
          return MESA_GLINTEROP_INVALID_OBJECT;
       }
 
       if (target == GL_TEXTURE_BUFFER) {
          out->internal_format = obj->BufferObjectFormat;
          out->buf_offset = obj->BufferOffset;
          out->buf_size = obj->BufferSize == -1 ? obj->BufferObject->Size :
                                                  obj->BufferSize;
 
          obj->BufferObject->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
@@ -1813,21 +1813,21 @@ dri2_interop_export_object(__DRIcontext *_ctx,
       break;
    default:
       usage = 0;
    }
 
    memset(&whandle, 0, sizeof(whandle));
    whandle.type = DRM_API_HANDLE_TYPE_FD;
 
    success = screen->resource_get_handle(screen, st->pipe, res, &whandle,
                                          usage);
-   mtx_unlock(&ctx->Shared->Mutex);
+   simple_mtx_unlock(&ctx->Shared->Mutex);
 
    if (!success)
       return MESA_GLINTEROP_OUT_OF_HOST_MEMORY;
 
    out->dmabuf_fd = whandle.handle;
    out->out_driver_data_written = 0;
 
    if (res->target == PIPE_BUFFER)
       out->buf_offset += whandle.offset;
 
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0b98483104..b7c6b8bff2 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -464,21 +464,21 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
 {
    (void) ctx;
 
    vbo_delete_minmax_cache(bufObj);
    _mesa_align_free(bufObj->Data);
 
    /* assign strange values here to help w/ debugging */
    bufObj->RefCount = -1000;
    bufObj->Name = ~0;
 
-   mtx_destroy(&bufObj->Mutex);
+   simple_mtx_destroy(&bufObj->Mutex);
    free(bufObj->Label);
    free(bufObj);
 }
 
 
 
 /**
  * Set ptr to bufObj w/ reference counting.
  * This is normally only called from the _mesa_reference_buffer_object() macro
  * when there's a real pointer change.
@@ -486,43 +486,43 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
 void
 _mesa_reference_buffer_object_(struct gl_context *ctx,
                                struct gl_buffer_object **ptr,
                                struct gl_buffer_object *bufObj)
 {
    if (*ptr) {
       /* Unreference the old buffer */
       GLboolean deleteFlag = GL_FALSE;
       struct gl_buffer_object *oldObj = *ptr;
 
-      mtx_lock(&oldObj->Mutex);
+      simple_mtx_lock(&oldObj->Mutex);
       assert(oldObj->RefCount > 0);
       oldObj->RefCount--;
       deleteFlag = (oldObj->RefCount == 0);
-      mtx_unlock(&oldObj->Mutex);
+      simple_mtx_unlock(&oldObj->Mutex);
 
       if (deleteFlag) {
 	 assert(ctx->Driver.DeleteBuffer);
          ctx->Driver.DeleteBuffer(ctx, oldObj);
       }
 
       *ptr = NULL;
    }
    assert(!*ptr);
 
    if (bufObj) {
       /* reference new buffer */
-      mtx_lock(&bufObj->Mutex);
+      simple_mtx_lock(&bufObj->Mutex);
       assert(bufObj->RefCount > 0);
 
       bufObj->RefCount++;
       *ptr = bufObj;
-      mtx_unlock(&bufObj->Mutex);
+      simple_mtx_unlock(&bufObj->Mutex);
    }
 }
 
 
 /**
  * Get the value of MESA_NO_MINMAX_CACHE.
  */
 static bool
 get_no_minmax_cache()
 {
@@ -540,21 +540,21 @@ get_no_minmax_cache()
 
 /**
  * Initialize a buffer object to default values.
  */
 void
 _mesa_initialize_buffer_object(struct gl_context *ctx,
                                struct gl_buffer_object *obj,
                                GLuint name)
 {
    memset(obj, 0, sizeof(struct gl_buffer_object));
-   mtx_init(&obj->Mutex, mtx_plain);
+   simple_mtx_init(&obj->Mutex, mtx_plain);
    obj->RefCount = 1;
    obj->Name = name;
    obj->Usage = GL_STATIC_DRAW_ARB;
 
    if (get_no_minmax_cache())
       obj->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
 }
 
 
 
@@ -863,21 +863,21 @@ copy_buffer_sub_data_fallback(struct gl_context *ctx,
 
 /**
  * Initialize the state associated with buffer objects
  */
 void
 _mesa_init_buffer_objects( struct gl_context *ctx )
 {
    GLuint i;
 
    memset(&DummyBufferObject, 0, sizeof(DummyBufferObject));
-   mtx_init(&DummyBufferObject.Mutex, mtx_plain);
+   simple_mtx_init(&DummyBufferObject.Mutex, mtx_plain);
    DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */
 
    _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
                                  ctx->Shared->NullBufferObj);
 
    _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer,
                                  ctx->Shared->NullBufferObj);
    _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer,
                                  ctx->Shared->NullBufferObj);
 
diff --git a/src/mesa/main/debug_output.c b/src/mesa/main/debug_output.c
index bc933db93d..859e1f966d 100644
--- a/src/mesa/main/debug_output.c
+++ b/src/mesa/main/debug_output.c
@@ -30,21 +30,21 @@
 #include "dispatch.h"
 #include "enums.h"
 #include "imports.h"
 #include "hash.h"
 #include "mtypes.h"
 #include "version.h"
 #include "util/hash_table.h"
 #include "util/simple_list.h"
 
 
-static mtx_t DynamicIDMutex = _MTX_INITIALIZER_NP;
+static simple_mtx_t DynamicIDMutex = _SIMPLE_MTX_INITIALIZER_NP;
 static GLuint NextDynamicID = 1;
 
 
 /**
  * A namespace element.
  */
 struct gl_debug_element
 {
    struct simple_node link;
 
@@ -187,24 +187,24 @@ gl_enum_to_debug_severity(GLenum e)
  * generate is ridiculous, so instead we have our caller pass us a pointer to
  * static storage where the ID should get stored.  This ID will be shared
  * across all contexts for that message (which seems like a desirable
  * property, even if it's not expected by the spec), but note that it won't be
  * the same between executions if messages aren't generated in the same order.
  */
 void
 _mesa_debug_get_id(GLuint *id)
 {
    if (!(*id)) {
-      mtx_lock(&DynamicIDMutex);
+      simple_mtx_lock(&DynamicIDMutex);
       if (!(*id))
          *id = NextDynamicID++;
-      mtx_unlock(&DynamicIDMutex);
+      simple_mtx_unlock(&DynamicIDMutex);
    }
 }
 
 static void
 debug_message_clear(struct gl_debug_message *msg)
 {
    if (msg->message != (char*)out_of_memory)
       free(msg->message);
    msg->message = NULL;
    msg->length = 0;
@@ -695,46 +695,46 @@ debug_pop_group(struct gl_debug_state *debug)
 
 
 /**
  * Lock and return debug state for the context.  The debug state will be
  * allocated and initialized upon the first call.  When NULL is returned, the
  * debug state is not locked.
  */
 static struct gl_debug_state *
 _mesa_lock_debug_state(struct gl_context *ctx)
 {
-   mtx_lock(&ctx->DebugMutex);
+   simple_mtx_lock(&ctx->DebugMutex);
 
    if (!ctx->Debug) {
       ctx->Debug = debug_create();
       if (!ctx->Debug) {
          GET_CURRENT_CONTEXT(cur);
-         mtx_unlock(&ctx->DebugMutex);
+         simple_mtx_unlock(&ctx->DebugMutex);
 
          /*
           * This function may be called from other threads.  When that is the
           * case, we cannot record this OOM error.
           */
          if (ctx == cur)
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "allocating debug state");
 
          return NULL;
       }
    }
 
    return ctx->Debug;
 }
 
 static void
 _mesa_unlock_debug_state(struct gl_context *ctx)
 {
-   mtx_unlock(&ctx->DebugMutex);
+   simple_mtx_unlock(&ctx->DebugMutex);
 }
 
 /**
  * Set the integer debug state specified by \p pname.  This can be called from
  * _mesa_set_enable for example.
  */
 bool
 _mesa_set_debug_state_int(struct gl_context *ctx, GLenum pname, GLint val)
 {
    struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
@@ -1266,21 +1266,21 @@ _mesa_PopDebugGroup(void)
          gl_enum_to_debug_severity(GL_DEBUG_SEVERITY_NOTIFICATION),
          msg.length, msg.message);
 
    debug_message_clear(&msg);
 }
 
 
 void
 _mesa_init_debug_output(struct gl_context *ctx)
 {
-   mtx_init(&ctx->DebugMutex, mtx_plain);
+   simple_mtx_init(&ctx->DebugMutex, mtx_plain);
 
    if (MESA_DEBUG_FLAGS & DEBUG_CONTEXT) {
       /* If the MESA_DEBUG env is set to "context", we'll turn on the
        * GL_CONTEXT_FLAG_DEBUG_BIT context flag and log debug output
        * messages to stderr (or whatever MESA_LOG_FILE points at).
        */
       struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
       if (!debug) {
          return;
       }
@@ -1294,21 +1294,21 @@ _mesa_init_debug_output(struct gl_context *ctx)
 
 void
 _mesa_free_errors_data(struct gl_context *ctx)
 {
    if (ctx->Debug) {
       debug_destroy(ctx->Debug);
       /* set to NULL just in case it is used before context is completely gone. */
       ctx->Debug = NULL;
    }
 
-   mtx_destroy(&ctx->DebugMutex);
+   simple_mtx_destroy(&ctx->DebugMutex);
 }
 
 void GLAPIENTRY
 _mesa_StringMarkerGREMEDY(GLsizei len, const GLvoid *string)
 {
    GET_CURRENT_CONTEXT(ctx);
    if (ctx->Extensions.GREMEDY_string_marker) {
       /* if length not specified, string will be null terminated: */
       if (len <= 0)
          len = strlen(string);
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index 9173788d1d..35a2f66c31 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -269,32 +269,32 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
    GLboolean do_output, do_log;
    /* Ideally this would be set up by the caller, so that we had proper IDs
     * per different message.
     */
    static GLuint error_msg_id = 0;
 
    _mesa_debug_get_id(&error_msg_id);
 
    do_output = should_output(ctx, error, fmtString);
 
-   mtx_lock(&ctx->DebugMutex);
+   simple_mtx_lock(&ctx->DebugMutex);
    if (ctx->Debug) {
       do_log = _mesa_debug_is_message_enabled(ctx->Debug,
                                               MESA_DEBUG_SOURCE_API,
                                               MESA_DEBUG_TYPE_ERROR,
                                               error_msg_id,
                                               MESA_DEBUG_SEVERITY_HIGH);
    }
    else {
       do_log = GL_FALSE;
    }
-   mtx_unlock(&ctx->DebugMutex);
+   simple_mtx_unlock(&ctx->DebugMutex);
 
    if (do_output || do_log) {
       char s[MAX_DEBUG_MESSAGE_LENGTH], s2[MAX_DEBUG_MESSAGE_LENGTH];
       int len;
       va_list args;
 
       va_start(args, fmtString);
       len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
       va_end(args);
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f4552076a2..0dd446905e 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -82,23 +82,23 @@ delete_dummy_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 static void
 delete_dummy_framebuffer(struct gl_framebuffer *fb)
 {
    /* no op */
 }
 
 
 void
 _mesa_init_fbobjects(struct gl_context *ctx)
 {
-   mtx_init(&DummyFramebuffer.Mutex, mtx_plain);
-   mtx_init(&DummyRenderbuffer.Mutex, mtx_plain);
-   mtx_init(&IncompleteFramebuffer.Mutex, mtx_plain);
+   simple_mtx_init(&DummyFramebuffer.Mutex, mtx_plain);
+   simple_mtx_init(&DummyRenderbuffer.Mutex, mtx_plain);
+   simple_mtx_init(&IncompleteFramebuffer.Mutex, mtx_plain);
    DummyFramebuffer.Delete = delete_dummy_framebuffer;
    DummyRenderbuffer.Delete = delete_dummy_renderbuffer;
    IncompleteFramebuffer.Delete = delete_dummy_framebuffer;
 }
 
 struct gl_framebuffer *
 _mesa_get_incomplete_framebuffer(void)
 {
    return &IncompleteFramebuffer;
 }
@@ -542,21 +542,21 @@ set_renderbuffer_attachment(struct gl_context *ctx,
  * Attach a renderbuffer object to a framebuffer object.
  */
 void
 _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
                                  struct gl_framebuffer *fb,
                                  GLenum attachment,
                                  struct gl_renderbuffer *rb)
 {
    struct gl_renderbuffer_attachment *att;
 
-   mtx_lock(&fb->Mutex);
+   simple_mtx_lock(&fb->Mutex);
 
    att = get_attachment(ctx, fb, attachment, NULL);
    assert(att);
    if (rb) {
       set_renderbuffer_attachment(ctx, att, rb);
       if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
          /* do stencil attachment here (depth already done above) */
          att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
          assert(att);
          set_renderbuffer_attachment(ctx, att, rb);
@@ -568,21 +568,21 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
       if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
          /* detach stencil (depth was detached above) */
          att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
          assert(att);
          remove_attachment(ctx, att);
       }
    }
 
    invalidate_framebuffer(fb);
 
-   mtx_unlock(&fb->Mutex);
+   simple_mtx_unlock(&fb->Mutex);
 }
 
 
 /**
  * Fallback for ctx->Driver.ValidateFramebuffer()
  * Check if the renderbuffer's formats are supported by the software
  * renderer.
  * Drivers should probably override this.
  */
 void
@@ -3280,21 +3280,21 @@ _mesa_get_and_validate_attachment(struct gl_context *ctx,
 
 void
 _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
                           GLenum attachment,
                           struct gl_renderbuffer_attachment *att,
                           struct gl_texture_object *texObj, GLenum textarget,
                           GLint level, GLuint layer, GLboolean layered)
 {
    FLUSH_VERTICES(ctx, _NEW_BUFFERS);
 
-   mtx_lock(&fb->Mutex);
+   simple_mtx_lock(&fb->Mutex);
    if (texObj) {
       if (attachment == GL_DEPTH_ATTACHMENT &&
           texObj == fb->Attachment[BUFFER_STENCIL].Texture &&
           level == fb->Attachment[BUFFER_STENCIL].TextureLevel &&
           _mesa_tex_target_to_face(textarget) ==
           fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
           layer == fb->Attachment[BUFFER_STENCIL].Zoffset) {
          /* The texture object is already attached to the stencil attachment
           * point. Don't create a new renderbuffer; just reuse the stencil
           * attachment's. This is required to prevent a GL error in
@@ -3339,21 +3339,21 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
    else {
       remove_attachment(ctx, att);
       if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
          assert(att == &fb->Attachment[BUFFER_DEPTH]);
          remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]);
       }
    }
 
    invalidate_framebuffer(fb);
 
-   mtx_unlock(&fb->Mutex);
+   simple_mtx_unlock(&fb->Mutex);
 }
 
 
 static void
 framebuffer_texture_with_dims_no_error(GLenum target, GLenum attachment,
                                        GLenum textarget, GLuint texture,
                                        GLint level, GLint layer)
 {
    GET_CURRENT_CONTEXT(ctx);
 
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 039762a074..663c4034d4 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -124,21 +124,21 @@ _mesa_new_framebuffer(struct gl_context *ctx, GLuint name)
  */
 void
 _mesa_initialize_window_framebuffer(struct gl_framebuffer *fb,
 				     const struct gl_config *visual)
 {
    assert(fb);
    assert(visual);
 
    memset(fb, 0, sizeof(struct gl_framebuffer));
 
-   mtx_init(&fb->Mutex, mtx_plain);
+   simple_mtx_init(&fb->Mutex, mtx_plain);
 
    fb->RefCount = 1;
 
    /* save the visual */
    fb->Visual = *visual;
 
    /* Init read/draw renderbuffer state */
    if (visual->doubleBufferMode) {
       fb->_NumColorDrawBuffers = 1;
       fb->ColorDrawBuffer[0] = GL_BACK;
@@ -177,21 +177,21 @@ _mesa_initialize_user_framebuffer(struct gl_framebuffer *fb, GLuint name)
    memset(fb, 0, sizeof(struct gl_framebuffer));
 
    fb->Name = name;
    fb->RefCount = 1;
    fb->_NumColorDrawBuffers = 1;
    fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT;
    fb->_ColorDrawBufferIndexes[0] = BUFFER_COLOR0;
    fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT;
    fb->_ColorReadBufferIndex = BUFFER_COLOR0;
    fb->Delete = _mesa_destroy_framebuffer;
-   mtx_init(&fb->Mutex, mtx_plain);
+   simple_mtx_init(&fb->Mutex, mtx_plain);
 }
 
 
 /**
  * Deallocate buffer and everything attached to it.
  * Typically called via the gl_framebuffer->Delete() method.
  */
 void
 _mesa_destroy_framebuffer(struct gl_framebuffer *fb)
 {
@@ -208,21 +208,21 @@ _mesa_destroy_framebuffer(struct gl_framebuffer *fb)
  * the gl_framebuffer object itself.
  */
 void
 _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
 {
    GLuint i;
 
    assert(fb);
    assert(fb->RefCount == 0);
 
-   mtx_destroy(&fb->Mutex);
+   simple_mtx_destroy(&fb->Mutex);
 
    for (i = 0; i < BUFFER_COUNT; i++) {
       struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
       if (att->Renderbuffer) {
          _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
       }
       if (att->Texture) {
          _mesa_reference_texobj(&att->Texture, NULL);
       }
       assert(!att->Renderbuffer);
@@ -239,36 +239,36 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
  */
 void
 _mesa_reference_framebuffer_(struct gl_framebuffer **ptr,
                              struct gl_framebuffer *fb)
 {
    if (*ptr) {
       /* unreference old renderbuffer */
       GLboolean deleteFlag = GL_FALSE;
       struct gl_framebuffer *oldFb = *ptr;
 
-      mtx_lock(&oldFb->Mutex);
+      simple_mtx_lock(&oldFb->Mutex);
       assert(oldFb->RefCount > 0);
       oldFb->RefCount--;
       deleteFlag = (oldFb->RefCount == 0);
-      mtx_unlock(&oldFb->Mutex);
+      simple_mtx_unlock(&oldFb->Mutex);
 
       if (deleteFlag)
          oldFb->Delete(oldFb);
 
       *ptr = NULL;
    }
 
    if (fb) {
-      mtx_lock(&fb->Mutex);
+      simple_mtx_lock(&fb->Mutex);
       fb->RefCount++;
-      mtx_unlock(&fb->Mutex);
+      simple_mtx_unlock(&fb->Mutex);
       *ptr = fb;
    }
 }
 
 
 /**
  * Resize the given framebuffer's renderbuffers to the new width and height.
  * This should only be used for window-system framebuffers, not
  * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object).
  * This will typically be called directly from a device driver.
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index abda1a36e4..73c07bccf7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -40,20 +40,21 @@
 
 #include "main/glheader.h"
 #include "main/config.h"
 #include "glapi/glapi.h"
 #include "math/m_matrix.h"	/* GLmatrix */
 #include "compiler/shader_enums.h"
 #include "compiler/shader_info.h"
 #include "main/formats.h"       /* MESA_FORMAT_COUNT */
 #include "compiler/glsl/list.h"
 #include "util/bitscan.h"
+#include "util/simple_mtx.h"
 #include "util/u_dynarray.h"
 
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
 /**
  * \name 64-bit extension of GLbitfield.
@@ -962,21 +963,21 @@ typedef enum
    MAX_FACES = 6
 } gl_face_index;
 
 
 /**
  * Sampler object state.  These objects are new with GL_ARB_sampler_objects
  * and OpenGL 3.3.  Legacy texture objects also contain a sampler object.
  */
 struct gl_sampler_object
 {
-   mtx_t Mutex;
+   simple_mtx_t Mutex;
    GLuint Name;
    GLint RefCount;
    GLchar *Label;               /**< GL_KHR_debug */
 
    GLenum WrapS;		/**< S-axis texture image wrap mode */
    GLenum WrapT;		/**< T-axis texture image wrap mode */
    GLenum WrapR;		/**< R-axis texture image wrap mode */
    GLenum MinFilter;		/**< minification filter */
    GLenum MagFilter;		/**< magnification filter */
    union gl_color_union BorderColor;  /**< Interpreted according to texture format */
@@ -994,21 +995,21 @@ struct gl_sampler_object
    struct util_dynarray Handles;
 };
 
 
 /**
  * Texture object state.  Contains the array of mipmap images, border color,
  * wrap modes, filter modes, and shadow/texcompare state.
  */
 struct gl_texture_object
 {
-   mtx_t Mutex;      /**< for thread safety */
+   simple_mtx_t Mutex;      /**< for thread safety */
    GLint RefCount;             /**< reference count */
    GLuint Name;                /**< the user-visible texture object ID */
    GLchar *Label;               /**< GL_KHR_debug */
    GLenum Target;              /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
    gl_texture_index TargetIndex; /**< The gl_texture_unit::CurrentTex index.
                                       Only valid when Target is valid. */
 
    struct gl_sampler_object Sampler;
 
    GLenum DepthMode;           /**< GL_ARB_depth_texture */
@@ -1384,21 +1385,21 @@ typedef enum {
    USAGE_PIXEL_PACK_BUFFER = 0x20,
    USAGE_DISABLE_MINMAX_CACHE = 0x40,
 } gl_buffer_usage;
 
 
 /**
  * GL_ARB_vertex/pixel_buffer_object buffer object
  */
 struct gl_buffer_object
 {
-   mtx_t Mutex;
+   simple_mtx_t Mutex;
    GLint RefCount;
    GLuint Name;
    GLchar *Label;       /**< GL_KHR_debug */
    GLenum Usage;        /**< GL_STREAM_DRAW_ARB, GL_STREAM_READ_ARB, etc. */
    GLbitfield StorageFlags; /**< GL_MAP_PERSISTENT_BIT, etc. */
    GLsizeiptrARB Size;  /**< Size of buffer storage in bytes */
    GLubyte *Data;       /**< Location of storage either in RAM or VRAM. */
    GLboolean DeletePending;   /**< true if buffer object is removed from the hash */
    GLboolean Written;   /**< Ever written to? (for debugging) */
    GLboolean Purgeable; /**< Is the buffer purgeable under memory pressure? */
@@ -3202,21 +3203,21 @@ struct gl_sync_object
    GLbitfield Flags;          /**< Flags passed to glFenceSync */
    GLuint StatusFlag:1;       /**< Has the sync object been signaled? */
 };
 
 
 /**
  * State which can be shared by multiple contexts:
  */
 struct gl_shared_state
 {
-   mtx_t Mutex;		   /**< for thread safety */
+   simple_mtx_t Mutex;		   /**< for thread safety */
    GLint RefCount;			   /**< Reference count */
    struct _mesa_HashTable *DisplayList;	   /**< Display lists hash table */
    struct _mesa_HashTable *BitmapAtlas;    /**< For optimized glBitmap text */
    struct _mesa_HashTable *TexObjects;	   /**< Texture objects hash table */
 
    /** Default texture objects (shared by all texture units) */
    struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
 
    /** Fallback texture used when a bound texture is incomplete */
    struct gl_texture_object *FallbackTex[NUM_TEXTURE_TARGETS];
@@ -3286,21 +3287,21 @@ struct gl_shared_state
 
 
 
 /**
  * Renderbuffers represent drawing surfaces such as color, depth and/or
  * stencil.  A framebuffer object has a set of renderbuffers.
  * Drivers will typically derive subclasses of this type.
  */
 struct gl_renderbuffer
 {
-   mtx_t Mutex; /**< for thread safety */
+   simple_mtx_t Mutex; /**< for thread safety */
    GLuint ClassID;        /**< Useful for drivers */
    GLuint Name;
    GLchar *Label;         /**< GL_KHR_debug */
    GLint RefCount;
    GLuint Width, Height;
    GLuint Depth;
    GLboolean Purgeable;  /**< Is the buffer purgeable under memory pressure? */
    GLboolean AttachedAnytime; /**< TRUE if it was attached to a framebuffer */
    /**
     * True for renderbuffers that wrap textures, giving the driver a chance to
@@ -3364,21 +3365,21 @@ struct gl_renderbuffer_attachment
 };
 
 
 /**
  * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
  * In C++ terms, think of this as a base class from which device drivers
  * will make derived classes.
  */
 struct gl_framebuffer
 {
-   mtx_t Mutex;  /**< for thread safety */
+   simple_mtx_t Mutex;  /**< for thread safety */
    /**
     * If zero, this is a window system framebuffer.  If non-zero, this
     * is a FBO framebuffer; note that for some devices (i.e. those with
     * a natural pixel coordinate system for FBOs that differs from the
     * OpenGL/Mesa coordinate system), this means that the viewport,
     * polygon face orientation, and polygon stipple will have to be inverted.
     */
    GLuint Name;
    GLint RefCount;
 
@@ -4932,21 +4933,21 @@ struct gl_context
 
    GLenum ErrorValue;        /**< Last error code */
 
    /**
     * Recognize and silence repeated error debug messages in buggy apps.
     */
    const char *ErrorDebugFmtString;
    GLuint ErrorDebugCount;
 
    /* GL_ARB_debug_output/GL_KHR_debug */
-   mtx_t DebugMutex;
+   simple_mtx_t DebugMutex;
    struct gl_debug_state *Debug;
 
    GLenum RenderMode;        /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
    GLbitfield NewState;      /**< bitwise-or of _NEW_* flags */
    uint64_t NewDriverState;  /**< bitwise-or of flags from DriverFlags */
 
    struct gl_driver_flags DriverFlags;
 
    GLboolean ViewportInitialized;  /**< has viewport size been initialized? */
 
diff --git a/src/mesa/main/renderbuffer.c b/src/mesa/main/renderbuffer.c
index 5046f9d5f4..76732cf8e3 100644
--- a/src/mesa/main/renderbuffer.c
+++ b/src/mesa/main/renderbuffer.c
@@ -33,21 +33,21 @@
 
 
 /**
  * Initialize the fields of a gl_renderbuffer to default values.
  */
 void
 _mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
 {
    GET_CURRENT_CONTEXT(ctx);
 
-   mtx_init(&rb->Mutex, mtx_plain);
+   simple_mtx_init(&rb->Mutex, mtx_plain);
 
    rb->ClassID = 0;
    rb->Name = name;
    rb->RefCount = 1;
    rb->Delete = _mesa_delete_renderbuffer;
 
    /* The rest of these should be set later by the caller of this function or
     * the AllocStorage method:
     */
    rb->AllocStorage = NULL;
@@ -94,21 +94,21 @@ _mesa_new_renderbuffer(struct gl_context *ctx, GLuint name)
 /**
  * Delete a gl_framebuffer.
  * This is the default function for renderbuffer->Delete().
  * Drivers which subclass gl_renderbuffer should probably implement their
  * own delete function.  But the driver might also call this function to
  * free the object in the end.
  */
 void
 _mesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
 {
-   mtx_destroy(&rb->Mutex);
+   simple_mtx_destroy(&rb->Mutex);
    free(rb->Label);
    free(rb);
 }
 
 static void
 validate_and_init_renderbuffer_attachment(struct gl_framebuffer *fb,
                                           gl_buffer_index bufferName,
                                           struct gl_renderbuffer *rb)
 {
    assert(fb);
@@ -194,33 +194,33 @@ _mesa_remove_renderbuffer(struct gl_framebuffer *fb,
  */
 void
 _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
                               struct gl_renderbuffer *rb)
 {
    if (*ptr) {
       /* Unreference the old renderbuffer */
       GLboolean deleteFlag = GL_FALSE;
       struct gl_renderbuffer *oldRb = *ptr;
 
-      mtx_lock(&oldRb->Mutex);
+      simple_mtx_lock(&oldRb->Mutex);
       assert(oldRb->RefCount > 0);
       oldRb->RefCount--;
       deleteFlag = (oldRb->RefCount == 0);
-      mtx_unlock(&oldRb->Mutex);
+      simple_mtx_unlock(&oldRb->Mutex);
 
       if (deleteFlag) {
          GET_CURRENT_CONTEXT(ctx);
          oldRb->Delete(ctx, oldRb);
       }
 
       *ptr = NULL;
    }
    assert(!*ptr);
 
    if (rb) {
       /* reference new renderbuffer */
-      mtx_lock(&rb->Mutex);
+      simple_mtx_lock(&rb->Mutex);
       rb->RefCount++;
-      mtx_unlock(&rb->Mutex);
+      simple_mtx_unlock(&rb->Mutex);
       *ptr = rb;
    }
 }
diff --git a/src/mesa/main/robustness.c b/src/mesa/main/robustness.c
index 47402a2930..a61c07f125 100644
--- a/src/mesa/main/robustness.c
+++ b/src/mesa/main/robustness.c
@@ -129,35 +129,35 @@ _mesa_GetGraphicsResetStatusARB( void )
                      "creation.\n");
 
       return GL_NO_ERROR;
    }
 
    if (ctx->Driver.GetGraphicsResetStatus) {
       /* Query the reset status of this context from the driver core.
        */
       status = ctx->Driver.GetGraphicsResetStatus(ctx);
 
-      mtx_lock(&ctx->Shared->Mutex);
+      simple_mtx_lock(&ctx->Shared->Mutex);
 
       /* If this context has not been affected by a GPU reset, check to see if
        * some other context in the share group has been affected by a reset.
        * If another context saw a reset but this context did not, assume that
        * this context was not guilty.
        */
       if (status != GL_NO_ERROR) {
          ctx->Shared->ShareGroupReset = true;
       } else if (ctx->Shared->ShareGroupReset && !ctx->ShareGroupReset) {
          status = GL_INNOCENT_CONTEXT_RESET_ARB;
       }
 
       ctx->ShareGroupReset = ctx->Shared->ShareGroupReset;
-      mtx_unlock(&ctx->Shared->Mutex);
+      simple_mtx_unlock(&ctx->Shared->Mutex);
    }
 
    if (status != GL_NO_ERROR)
       _mesa_set_context_lost_dispatch(ctx);
 
    if (!ctx->Driver.GetGraphicsResetStatus && (MESA_VERBOSE & VERBOSE_API))
       _mesa_debug(ctx,
                   "glGetGraphicsResetStatusARB always returns GL_NO_ERROR "
                   "because the driver doesn't track reset status.\n");
 
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 2ecb01777b..5ebf9e24f9 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -56,72 +56,72 @@ lookup_samplerobj_locked(struct gl_context *ctx, GLuint name)
 {
    return (struct gl_sampler_object *)
          _mesa_HashLookupLocked(ctx->Shared->SamplerObjects, name);
 }
 
 static void
 delete_sampler_object(struct gl_context *ctx,
                       struct gl_sampler_object *sampObj)
 {
    _mesa_delete_sampler_handles(ctx, sampObj);
-   mtx_destroy(&sampObj->Mutex);
+   simple_mtx_destroy(&sampObj->Mutex);
    free(sampObj->Label);
    free(sampObj);
 }
 
 /**
  * Handle reference counting.
  */
 void
 _mesa_reference_sampler_object_(struct gl_context *ctx,
                                 struct gl_sampler_object **ptr,
                                 struct gl_sampler_object *samp)
 {
    assert(*ptr != samp); /* The inline wrapper should prevent no-op calls */
 
    if (*ptr) {
       /* Unreference the old sampler */
       GLboolean deleteFlag = GL_FALSE;
       struct gl_sampler_object *oldSamp = *ptr;
 
-      mtx_lock(&oldSamp->Mutex);
+      simple_mtx_lock(&oldSamp->Mutex);
       assert(oldSamp->RefCount > 0);
       oldSamp->RefCount--;
       deleteFlag = (oldSamp->RefCount == 0);
-      mtx_unlock(&oldSamp->Mutex);
+      simple_mtx_unlock(&oldSamp->Mutex);
 
       if (deleteFlag)
          delete_sampler_object(ctx, oldSamp);
 
       *ptr = NULL;
    }
    assert(!*ptr);
 
    if (samp) {
       /* reference new sampler */
-      mtx_lock(&samp->Mutex);
+      simple_mtx_lock(&samp->Mutex);
       assert(samp->RefCount > 0);
 
       samp->RefCount++;
       *ptr = samp;
-      mtx_unlock(&samp->Mutex);
+      simple_mtx_unlock(&samp->Mutex);
    }
 }
 
 
 /**
  * Initialize the fields of the given sampler object.
  */
 static void
 _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
 {
-   mtx_init(&sampObj->Mutex, mtx_plain);
+   simple_mtx_init(&sampObj->Mutex, mtx_plain);
    sampObj->Name = name;
    sampObj->RefCount = 1;
    sampObj->WrapS = GL_REPEAT;
    sampObj->WrapT = GL_REPEAT;
    sampObj->WrapR = GL_REPEAT;
    sampObj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
    sampObj->MagFilter = GL_LINEAR;
    sampObj->BorderColor.f[0] = 0.0;
    sampObj->BorderColor.f[1] = 0.0;
    sampObj->BorderColor.f[2] = 0.0;
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index 53b8597d56..e3417a4df3 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -59,21 +59,21 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared);
 struct gl_shared_state *
 _mesa_alloc_shared_state(struct gl_context *ctx)
 {
    struct gl_shared_state *shared;
    GLuint i;
 
    shared = CALLOC_STRUCT(gl_shared_state);
    if (!shared)
       return NULL;
 
-   mtx_init(&shared->Mutex, mtx_plain);
+   simple_mtx_init(&shared->Mutex, mtx_plain);
 
    shared->DisplayList = _mesa_NewHashTable();
    shared->BitmapAtlas = _mesa_NewHashTable();
    shared->TexObjects = _mesa_NewHashTable();
    shared->Programs = _mesa_NewHashTable();
 
    shared->DefaultVertexProgram =
       ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true);
    shared->DefaultFragmentProgram =
       ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0, true);
@@ -428,21 +428,21 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
       _mesa_DeleteHashTable(shared->TexObjects);
    }
 
    _mesa_free_shared_handles(shared);
 
    if (shared->MemoryObjects) {
       _mesa_HashDeleteAll(shared->MemoryObjects, delete_memory_object_cb, ctx);
       _mesa_DeleteHashTable(shared->MemoryObjects);
    }
 
-   mtx_destroy(&shared->Mutex);
+   simple_mtx_destroy(&shared->Mutex);
    mtx_destroy(&shared->TexMutex);
 
    free(shared);
 }
 
 
 /**
  * gl_shared_state objects are ref counted.
  * If ptr's refcount goes to zero, free the shared state.
  */
@@ -452,31 +452,31 @@ _mesa_reference_shared_state(struct gl_context *ctx,
                              struct gl_shared_state *state)
 {
    if (*ptr == state)
       return;
 
    if (*ptr) {
       /* unref old state */
       struct gl_shared_state *old = *ptr;
       GLboolean delete;
 
-      mtx_lock(&old->Mutex);
+      simple_mtx_lock(&old->Mutex);
       assert(old->RefCount >= 1);
       old->RefCount--;
       delete = (old->RefCount == 0);
-      mtx_unlock(&old->Mutex);
+      simple_mtx_unlock(&old->Mutex);
 
       if (delete) {
          free_shared_state(ctx, old);
       }
 
       *ptr = NULL;
    }
 
    if (state) {
       /* reference new state */
-      mtx_lock(&state->Mutex);
+      simple_mtx_lock(&state->Mutex);
       state->RefCount++;
       *ptr = state;
-      mtx_unlock(&state->Mutex);
+      simple_mtx_unlock(&state->Mutex);
    }
 }
diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c
index 6a21309aad..c38a5707dd 100644
--- a/src/mesa/main/syncobj.c
+++ b/src/mesa/main/syncobj.c
@@ -170,52 +170,52 @@ _mesa_free_sync_data(struct gl_context *ctx)
  * or NULL if it isn't.
  *
  * If "incRefCount" is true, the reference count is incremented, which is
  * normally what you want; otherwise, a glDeleteSync from another thread
  * could delete the sync object while you are still working on it.
  */
 struct gl_sync_object *
 _mesa_get_and_ref_sync(struct gl_context *ctx, GLsync sync, bool incRefCount)
 {
    struct gl_sync_object *syncObj = (struct gl_sync_object *) sync;
-   mtx_lock(&ctx->Shared->Mutex);
+   simple_mtx_lock(&ctx->Shared->Mutex);
    if (syncObj != NULL
       && _mesa_set_search(ctx->Shared->SyncObjects, syncObj) != NULL
       && !syncObj->DeletePending) {
      if (incRefCount) {
        syncObj->RefCount++;
      }
    } else {
      syncObj = NULL;
    }
-   mtx_unlock(&ctx->Shared->Mutex);
+   simple_mtx_unlock(&ctx->Shared->Mutex);
    return syncObj;
 }
 
 
 void
 _mesa_unref_sync_object(struct gl_context *ctx, struct gl_sync_object *syncObj,
                         int amount)
 {
    struct set_entry *entry;
 
-   mtx_lock(&ctx->Shared->Mutex);
+   simple_mtx_lock(&ctx->Shared->Mutex);
    syncObj->RefCount -= amount;
    if (syncObj->RefCount == 0) {
       entry = _mesa_set_search(ctx->Shared->SyncObjects, syncObj);
       assert (entry != NULL);
       _mesa_set_remove(ctx->Shared->SyncObjects, entry);
-      mtx_unlock(&ctx->Shared->Mutex);
+      simple_mtx_unlock(&ctx->Shared->Mutex);
 
       ctx->Driver.DeleteSyncObject(ctx, syncObj);
    } else {
-      mtx_unlock(&ctx->Shared->Mutex);
+      simple_mtx_unlock(&ctx->Shared->Mutex);
    }
 }
 
 
 GLboolean GLAPIENTRY
 _mesa_IsSync(GLsync sync)
 {
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
@@ -285,23 +285,23 @@ fence_sync(struct gl_context *ctx, GLenum condition, GLbitfield flags)
        */
       syncObj->Name = 1;
       syncObj->RefCount = 1;
       syncObj->DeletePending = GL_FALSE;
       syncObj->SyncCondition = condition;
       syncObj->Flags = flags;
       syncObj->StatusFlag = 0;
 
       ctx->Driver.FenceSync(ctx, syncObj, condition, flags);
 
-      mtx_lock(&ctx->Shared->Mutex);
+      simple_mtx_lock(&ctx->Shared->Mutex);
       _mesa_set_add(ctx->Shared->SyncObjects, syncObj);
-      mtx_unlock(&ctx->Shared->Mutex);
+      simple_mtx_unlock(&ctx->Shared->Mutex);
 
       return (GLsync)syncObj;
    }
 
    return NULL;
 }
 
 
 GLsync GLAPIENTRY
 _mesa_FenceSync_no_error(GLenum condition, GLbitfield flags)
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index b703da01be..54478f1690 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -267,21 +267,21 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
           target == GL_TEXTURE_1D_ARRAY_EXT ||
           target == GL_TEXTURE_2D_ARRAY_EXT ||
           target == GL_TEXTURE_EXTERNAL_OES ||
           target == GL_TEXTURE_CUBE_MAP_ARRAY ||
           target == GL_TEXTURE_BUFFER ||
           target == GL_TEXTURE_2D_MULTISAMPLE ||
           target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
 
    memset(obj, 0, sizeof(*obj));
    /* init the non-zero fields */
-   mtx_init(&obj->Mutex, mtx_plain);
+   simple_mtx_init(&obj->Mutex, mtx_plain);
    obj->RefCount = 1;
    obj->Name = name;
    obj->Target = target;
    if (target != 0) {
       obj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
    }
    else {
       obj->TargetIndex = NUM_TEXTURE_TARGETS; /* invalid/error value */
    }
    obj->Priority = 1.0F;
@@ -404,21 +404,21 @@ _mesa_delete_texture_object(struct gl_context *ctx,
          }
       }
    }
 
    /* Delete all texture/image handles. */
    _mesa_delete_texture_handles(ctx, texObj);
 
    _mesa_reference_buffer_object(ctx, &texObj->BufferObject, NULL);
 
    /* destroy the mutex -- it may have allocated memory (eg on bsd) */
-   mtx_destroy(&texObj->Mutex);
+   simple_mtx_destroy(&texObj->Mutex);
 
    free(texObj->Label);
 
    /* free this object */
    free(texObj);
 }
 
 
 /**
  * Copy texture object state from one texture object to another.
@@ -544,51 +544,51 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr,
    assert(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);
+      simple_mtx_lock(&oldTex->Mutex);
       assert(oldTex->RefCount > 0);
       oldTex->RefCount--;
 
       deleteFlag = (oldTex->RefCount == 0);
-      mtx_unlock(&oldTex->Mutex);
+      simple_mtx_unlock(&oldTex->Mutex);
 
       if (deleteFlag) {
          /* Passing in the context drastically changes the driver code for
           * framebuffer deletion.
           */
          GET_CURRENT_CONTEXT(ctx);
          if (ctx)
             ctx->Driver.DeleteTexture(ctx, oldTex);
          else
             _mesa_problem(NULL, "Unable to delete texture, no context");
       }
 
       *ptr = NULL;
    }
    assert(!*ptr);
 
    if (tex) {
       /* reference new texture */
       assert(valid_texture_object(tex));
-      mtx_lock(&tex->Mutex);
+      simple_mtx_lock(&tex->Mutex);
       assert(tex->RefCount > 0);
 
       tex->RefCount++;
       *ptr = tex;
-      mtx_unlock(&tex->Mutex);
+      simple_mtx_unlock(&tex->Mutex);
    }
 }
 
 
 enum base_mipmap { BASE, MIPMAP };
 
 
 /**
  * Mark a texture object as incomplete.  There are actually three kinds of
  * (in)completeness:
@@ -1605,24 +1605,24 @@ bind_texture_object(struct gl_context *ctx, unsigned unit,
    targetIndex = texObj->TargetIndex;
    assert(targetIndex >= 0);
    assert(targetIndex < NUM_TEXTURE_TARGETS);
 
    /* Check if this texture is only used by this context and is already bound.
     * If so, just return. For GL_OES_image_external, rebinding the texture
     * always must invalidate cached resources.
     */
    if (targetIndex != TEXTURE_EXTERNAL_INDEX) {
       bool early_out;
-      mtx_lock(&ctx->Shared->Mutex);
+      simple_mtx_lock(&ctx->Shared->Mutex);
       early_out = ((ctx->Shared->RefCount == 1)
                    && (texObj == texUnit->CurrentTex[targetIndex]));
-      mtx_unlock(&ctx->Shared->Mutex);
+      simple_mtx_unlock(&ctx->Shared->Mutex);
       if (early_out) {
          return;
       }
    }
 
    /* flush before changing binding */
    FLUSH_VERTICES(ctx, _NEW_TEXTURE_OBJECT);
 
    /* If the refcount on the previously bound texture is decremented to
     * zero, it'll be deleted here.
diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c
index 1377926bba..c9d2020167 100644
--- a/src/mesa/vbo/vbo_minmax_index.c
+++ b/src/mesa/vbo/vbo_minmax_index.c
@@ -108,21 +108,21 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj,
    GLboolean found = GL_FALSE;
    struct minmax_cache_key key;
    uint32_t hash;
    struct hash_entry *result;
 
    if (!bufferObj->MinMaxCache)
       return GL_FALSE;
    if (!vbo_use_minmax_cache(bufferObj))
       return GL_FALSE;
 
-   mtx_lock(&bufferObj->Mutex);
+   simple_mtx_lock(&bufferObj->Mutex);
 
    if (bufferObj->MinMaxCacheDirty) {
       /* Disable the cache permanently for this BO if the number of hits
        * is asymptotically less than the number of misses. This happens when
        * applications use the BO for streaming.
        *
        * However, some initial optimism allows applications that interleave
        * draw calls with glBufferSubData during warmup.
        */
       unsigned optimism = bufferObj->Size;
@@ -159,39 +159,39 @@ out_invalidate:
 
       if (new_hit_count >= bufferObj->MinMaxCacheHitIndices)
          bufferObj->MinMaxCacheHitIndices = new_hit_count;
       else
          bufferObj->MinMaxCacheHitIndices = ~(unsigned)0;
    } else {
       bufferObj->MinMaxCacheMissIndices += count;
    }
 
 out_disable:
-   mtx_unlock(&bufferObj->Mutex);
+   simple_mtx_unlock(&bufferObj->Mutex);
    return found;
 }
 
 
 static void
 vbo_minmax_cache_store(struct gl_context *ctx,
                        struct gl_buffer_object *bufferObj,
                        unsigned index_size, GLintptr offset, GLuint count,
                        GLuint min, GLuint max)
 {
    struct minmax_cache_entry *entry;
    struct hash_entry *table_entry;
    uint32_t hash;
 
    if (!vbo_use_minmax_cache(bufferObj))
       return;
 
-   mtx_lock(&bufferObj->Mutex);
+   simple_mtx_lock(&bufferObj->Mutex);
 
    if (!bufferObj->MinMaxCache) {
       bufferObj->MinMaxCache =
          _mesa_hash_table_create(NULL,
                                  (uint32_t (*)(const void *))vbo_minmax_cache_hash,
                                  (bool (*)(const void *, const void *))vbo_minmax_cache_key_equal);
       if (!bufferObj->MinMaxCache)
          goto out;
    }
 
@@ -216,21 +216,21 @@ vbo_minmax_cache_store(struct gl_context *ctx,
       free(entry);
       goto out;
    }
 
    table_entry = _mesa_hash_table_insert_pre_hashed(bufferObj->MinMaxCache,
                                                     hash, &entry->key, entry);
    if (!table_entry)
       free(entry);
 
 out:
-   mtx_unlock(&bufferObj->Mutex);
+   simple_mtx_unlock(&bufferObj->Mutex);
 }
 
 
 /**
  * Compute min and max elements by scanning the index buffer for
  * glDraw[Range]Elements() calls.
  * If primitive restart is enabled, we need to ignore restart
  * indexes when computing min/max.
  */
 static void
-- 
2.13.6



More information about the mesa-dev mailing list