summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2015-06-12 09:07:09 -0700
committerMatt Turner <[email protected]>2015-09-25 14:08:31 -0700
commit3c57a102ebd2efc427a59bf8eb441b4e5dec8553 (patch)
treeb78c4169b55fbbdff2a9e021578c0d2d14df46d9
parentd4b0e0b717b698682700bf1cd9d448043a57701d (diff)
mesa: Add locking to sampler objects.
Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/samplerobj.c10
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d53d99ad843..5445d39c560 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -944,6 +944,7 @@ typedef enum
*/
struct gl_sampler_object
{
+ mtx_t Mutex;
GLuint Name;
GLint RefCount;
GLchar *Label; /**< GL_KHR_debug */
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 241b5cb31fd..c7b96664c21 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -88,11 +88,11 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
GLboolean deleteFlag = GL_FALSE;
struct gl_sampler_object *oldSamp = *ptr;
- /*mtx_lock(&oldSamp->Mutex);*/
+ mtx_lock(&oldSamp->Mutex);
assert(oldSamp->RefCount > 0);
oldSamp->RefCount--;
deleteFlag = (oldSamp->RefCount == 0);
- /*mtx_unlock(&oldSamp->Mutex);*/
+ mtx_unlock(&oldSamp->Mutex);
if (deleteFlag) {
assert(ctx->Driver.DeleteSamplerObject);
@@ -105,7 +105,7 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
if (samp) {
/* reference new sampler */
- /*mtx_lock(&samp->Mutex);*/
+ mtx_lock(&samp->Mutex);
if (samp->RefCount == 0) {
/* this sampler's being deleted (look just above) */
/* Not sure this can every really happen. Warn if it does. */
@@ -116,7 +116,7 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
samp->RefCount++;
*ptr = samp;
}
- /*mtx_unlock(&samp->Mutex);*/
+ mtx_unlock(&samp->Mutex);
}
}
@@ -127,6 +127,7 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
static void
_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
{
+ mtx_init(&sampObj->Mutex, mtx_plain);
sampObj->Name = name;
sampObj->RefCount = 1;
sampObj->WrapS = GL_REPEAT;
@@ -169,6 +170,7 @@ static void
_mesa_delete_sampler_object(struct gl_context *ctx,
struct gl_sampler_object *sampObj)
{
+ mtx_destroy(&sampObj->Mutex);
free(sampObj->Label);
free(sampObj);
}