void
init_gl_program(struct gl_program *prog, GLenum target, bool is_arb_asm)
{
- mtx_init(&prog->Mutex, mtx_plain);
-
prog->RefCount = 1;
prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
prog->is_arb_asm = is_arb_asm;
#include "prog_parameter.h"
#include "prog_instruction.h"
#include "util/ralloc.h"
+#include "util/u_atomic.h"
/**
return NULL;
memset(prog, 0, sizeof(*prog));
- mtx_init(&prog->Mutex, mtx_plain);
prog->Id = id;
prog->Target = target;
prog->RefCount = 1;
ralloc_free(prog->nir);
}
- mtx_destroy(&prog->Mutex);
ralloc_free(prog);
}
#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);
assert(!*ptr);
if (prog) {
- mtx_lock(&prog->Mutex);
- prog->RefCount++;
- mtx_unlock(&prog->Mutex);
+ p_atomic_inc(&prog->RefCount);
}
*ptr = prog;