}
if (*ptr) {
/* Unreference the old shader */
- GLboolean deleteFlag = GL_FALSE;
struct gl_shader *old = *ptr;
assert(old->RefCount > 0);
- old->RefCount--;
- deleteFlag = (old->RefCount == 0);
- if (deleteFlag) {
+ if (p_atomic_dec_zero(&old->RefCount)) {
if (old->Name != 0)
_mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name);
_mesa_delete_shader(ctx, old);
if (sh) {
/* reference new */
- sh->RefCount++;
+ p_atomic_inc(&sh->RefCount);
*ptr = sh;
}
}
}
if (*ptr) {
/* Unreference the old shader program */
- GLboolean deleteFlag = GL_FALSE;
struct gl_shader_program *old = *ptr;
assert(old->RefCount > 0);
- old->RefCount--;
- deleteFlag = (old->RefCount == 0);
- if (deleteFlag) {
+ if (p_atomic_dec_zero(&old->RefCount)) {
if (old->Name != 0)
_mesa_HashRemove(ctx->Shared->ShaderObjects, old->Name);
_mesa_delete_shader_program(ctx, old);
assert(!*ptr);
if (shProg) {
- shProg->RefCount++;
+ p_atomic_inc(&shProg->RefCount);
*ptr = shProg;
}
}