#include "texstore.h"
#include "transformfeedback.h"
#include "varray.h"
+#include "util/u_atomic.h"
/* Debug flags */
bufObj->RefCount = -1000;
bufObj->Name = ~0;
- simple_mtx_destroy(&bufObj->Mutex);
+ simple_mtx_destroy(&bufObj->MinMaxCacheMutex);
free(bufObj->Label);
free(bufObj);
}
{
if (*ptr) {
/* Unreference the old buffer */
- GLboolean deleteFlag = GL_FALSE;
struct gl_buffer_object *oldObj = *ptr;
- simple_mtx_lock(&oldObj->Mutex);
- assert(oldObj->RefCount > 0);
- oldObj->RefCount--;
- deleteFlag = (oldObj->RefCount == 0);
- simple_mtx_unlock(&oldObj->Mutex);
-
- if (deleteFlag) {
+ if (p_atomic_dec_zero(&oldObj->RefCount)) {
assert(ctx->Driver.DeleteBuffer);
ctx->Driver.DeleteBuffer(ctx, oldObj);
}
if (bufObj) {
/* reference new buffer */
- simple_mtx_lock(&bufObj->Mutex);
- assert(bufObj->RefCount > 0);
-
- bufObj->RefCount++;
+ p_atomic_inc(&bufObj->RefCount);
*ptr = bufObj;
- simple_mtx_unlock(&bufObj->Mutex);
}
}
GLuint name)
{
memset(obj, 0, sizeof(struct gl_buffer_object));
- simple_mtx_init(&obj->Mutex, mtx_plain);
obj->RefCount = 1;
obj->Name = name;
obj->Usage = GL_STATIC_DRAW_ARB;
+ simple_mtx_init(&obj->MinMaxCacheMutex, mtx_plain);
if (get_no_minmax_cache())
obj->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
}
GLuint i;
memset(&DummyBufferObject, 0, sizeof(DummyBufferObject));
- simple_mtx_init(&DummyBufferObject.Mutex, mtx_plain);
+ simple_mtx_init(&DummyBufferObject.MinMaxCacheMutex, mtx_plain);
DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
*/
struct gl_buffer_object
{
- simple_mtx_t Mutex;
GLint RefCount;
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
struct gl_buffer_mapping Mappings[MAP_COUNT];
/** Memoization of min/max index computations for static index buffers */
+ simple_mtx_t MinMaxCacheMutex;
struct hash_table *MinMaxCache;
unsigned MinMaxCacheHitIndices;
unsigned MinMaxCacheMissIndices;
if (!vbo_use_minmax_cache(bufferObj))
return GL_FALSE;
- simple_mtx_lock(&bufferObj->Mutex);
+ simple_mtx_lock(&bufferObj->MinMaxCacheMutex);
if (bufferObj->MinMaxCacheDirty) {
/* Disable the cache permanently for this BO if the number of hits
}
out_disable:
- simple_mtx_unlock(&bufferObj->Mutex);
+ simple_mtx_unlock(&bufferObj->MinMaxCacheMutex);
return found;
}
if (!vbo_use_minmax_cache(bufferObj))
return;
- simple_mtx_lock(&bufferObj->Mutex);
+ simple_mtx_lock(&bufferObj->MinMaxCacheMutex);
if (!bufferObj->MinMaxCache) {
bufferObj->MinMaxCache =
free(entry);
out:
- simple_mtx_unlock(&bufferObj->Mutex);
+ simple_mtx_unlock(&bufferObj->MinMaxCacheMutex);
}