In particular, MakeCurrent can be called on multiple threads in
parallel.
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Eric Engestrom <eric@igalia.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18050>
* to free it up correctly.
*/
if (dri2_dpy) {
- dri2_dpy->ref_count++;
+ p_atomic_inc(&dri2_dpy->ref_count);
return EGL_TRUE;
}
return EGL_FALSE;
dri2_dpy = dri2_egl_display(disp);
- dri2_dpy->ref_count++;
+ p_atomic_inc(&dri2_dpy->ref_count);
return EGL_TRUE;
}
dri2_dpy = dri2_egl_display(disp);
assert(dri2_dpy->ref_count > 0);
- dri2_dpy->ref_count--;
- if (dri2_dpy->ref_count > 0)
+ if (!p_atomic_dec_zero(&dri2_dpy->ref_count))
return;
_eglCleanupDisplay(disp);
* EGLDisplay is terminated and then initialized again while a
* context is still bound. See dri2_intitialize() for a more in depth
* explanation. */
- dri2_dpy->ref_count++;
+ p_atomic_inc(&dri2_dpy->ref_count);
}
}