diff options
author | Matt Turner <[email protected]> | 2017-04-05 10:49:35 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-04-05 14:54:49 +1000 |
commit | d5ee55f028883748eadd8eec9070b475c200871c (patch) | |
tree | f01ddb413c2f84eff58ed9f4c235e6be75abff36 /src/mesa/program/program.c | |
parent | 060a6434eca9fb05ca2dfd612f8abd4786ee4549 (diff) |
mesa: Replace program locks with atomic inc/dec.
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/program/program.c')
-rw-r--r-- | src/mesa/program/program.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 0e499c655fe..277e6ce2d86 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -40,6 +40,7 @@ #include "prog_parameter.h" #include "prog_instruction.h" #include "util/ralloc.h" +#include "util/u_atomic.h" /** @@ -185,7 +186,6 @@ _mesa_init_gl_program(struct gl_program *prog, GLenum target, GLuint id, return NULL; memset(prog, 0, sizeof(*prog)); - mtx_init(&prog->Mutex, mtx_plain); prog->Id = id; prog->Target = target; prog->RefCount = 1; @@ -271,7 +271,6 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) ralloc_free(prog->nir); } - mtx_destroy(&prog->Mutex); ralloc_free(prog); } @@ -316,17 +315,11 @@ _mesa_reference_program_(struct gl_context *ctx, #endif if (*ptr) { - GLboolean deleteFlag; struct gl_program *oldProg = *ptr; - mtx_lock(&oldProg->Mutex); assert(oldProg->RefCount > 0); - oldProg->RefCount--; - deleteFlag = (oldProg->RefCount == 0); - mtx_unlock(&oldProg->Mutex); - - if (deleteFlag) { + if (p_atomic_dec_zero(&oldProg->RefCount)) { assert(ctx); _mesa_reference_shader_program_data(ctx, &oldProg->sh.data, NULL); ctx->Driver.DeleteProgram(ctx, oldProg); @@ -337,9 +330,7 @@ _mesa_reference_program_(struct gl_context *ctx, assert(!*ptr); if (prog) { - mtx_lock(&prog->Mutex); - prog->RefCount++; - mtx_unlock(&prog->Mutex); + p_atomic_inc(&prog->RefCount); } *ptr = prog; |