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 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;
}
* 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;
}
* renderbuffer object."
*/
if (rb->NumSamples > 1) {
- mtx_unlock(&ctx->Shared->Mutex);
+ simple_mtx_unlock(&ctx->Shared->Mutex);
return MESA_GLINTEROP_INVALID_OPERATION;
}
*/
res = st_renderbuffer(rb)->texture;
if (!res) {
- mtx_unlock(&ctx->Shared->Mutex);
+ simple_mtx_unlock(&ctx->Shared->Mutex);
return MESA_GLINTEROP_OUT_OF_RESOURCES;
}
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;
}
* 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;
}
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;
bufObj->RefCount = -1000;
bufObj->Name = ~0;
- mtx_destroy(&bufObj->Mutex);
+ simple_mtx_destroy(&bufObj->Mutex);
free(bufObj->Label);
free(bufObj);
}
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);
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);
}
}
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;
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,
#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;
_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 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
static void
_mesa_unlock_debug_state(struct gl_context *ctx)
{
- mtx_unlock(&ctx->DebugMutex);
+ simple_mtx_unlock(&ctx->DebugMutex);
}
/**
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
ctx->Debug = NULL;
}
- mtx_destroy(&ctx->DebugMutex);
+ simple_mtx_destroy(&ctx->DebugMutex);
}
void GLAPIENTRY
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,
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];
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_renderbuffer_attachment *att;
- mtx_lock(&fb->Mutex);
+ simple_mtx_lock(&fb->Mutex);
att = get_attachment(ctx, fb, attachment, NULL);
assert(att);
invalidate_framebuffer(fb);
- mtx_unlock(&fb->Mutex);
+ simple_mtx_unlock(&fb->Mutex);
}
{
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 &&
invalidate_framebuffer(fb);
- mtx_unlock(&fb->Mutex);
+ simple_mtx_unlock(&fb->Mutex);
}
memset(fb, 0, sizeof(struct gl_framebuffer));
- mtx_init(&fb->Mutex, mtx_plain);
+ simple_mtx_init(&fb->Mutex, mtx_plain);
fb->RefCount = 1;
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);
}
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];
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);
}
if (fb) {
- mtx_lock(&fb->Mutex);
+ simple_mtx_lock(&fb->Mutex);
fb->RefCount++;
- mtx_unlock(&fb->Mutex);
+ simple_mtx_unlock(&fb->Mutex);
*ptr = fb;
}
}
#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"
*/
struct gl_sampler_object
{
- mtx_t Mutex;
+ simple_mtx_t Mutex;
GLuint Name;
GLint RefCount;
GLchar *Label; /**< GL_KHR_debug */
*/
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 */
*/
struct gl_buffer_object
{
- mtx_t Mutex;
+ simple_mtx_t Mutex;
GLint RefCount;
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
*/
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 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 */
*/
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
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 */
{
GET_CURRENT_CONTEXT(ctx);
- mtx_init(&rb->Mutex, mtx_plain);
+ simple_mtx_init(&rb->Mutex, mtx_plain);
rb->ClassID = 0;
rb->Name = name;
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);
}
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);
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;
}
}
*/
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.
}
ctx->ShareGroupReset = ctx->Shared->ShareGroupReset;
- mtx_unlock(&ctx->Shared->Mutex);
+ simple_mtx_unlock(&ctx->Shared->Mutex);
}
if (status != GL_NO_ERROR)
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);
}
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);
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);
}
}
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;
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();
_mesa_DeleteHashTable(shared->MemoryObjects);
}
- mtx_destroy(&shared->Mutex);
+ simple_mtx_destroy(&shared->Mutex);
mtx_destroy(&shared->TexMutex);
free(shared);
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);
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);
}
}
_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) {
} else {
syncObj = NULL;
}
- mtx_unlock(&ctx->Shared->Mutex);
+ simple_mtx_unlock(&ctx->Shared->Mutex);
return syncObj;
}
{
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);
}
}
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;
}
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;
_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);
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
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);
}
}
*/
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;
}
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
}
out_disable:
- mtx_unlock(&bufferObj->Mutex);
+ simple_mtx_unlock(&bufferObj->Mutex);
return found;
}
if (!vbo_use_minmax_cache(bufferObj))
return;
- mtx_lock(&bufferObj->Mutex);
+ simple_mtx_lock(&bufferObj->Mutex);
if (!bufferObj->MinMaxCache) {
bufferObj->MinMaxCache =
free(entry);
out:
- mtx_unlock(&bufferObj->Mutex);
+ simple_mtx_unlock(&bufferObj->Mutex);
}