_eglBindContextToThread(ctx, t);
}
+static void
+dri2_gl_flush()
+{
+ static void (*glFlush)(void);
+ static mtx_t glFlushMutex = _MTX_INITIALIZER_NP;
+
+ mtx_lock(&glFlushMutex);
+ if (!glFlush)
+ glFlush = _glapi_get_proc_address("glFlush");
+ mtx_unlock(&glFlushMutex);
+
+ /* if glFlush is not available things are horribly broken */
+ if (!glFlush) {
+ _eglLog(_EGL_WARNING, "DRI2: failed to find glFlush entry point");
+ return;
+ }
+
+ glFlush();
+}
+
static GLboolean
dri_is_thread_safe(void *loaderPrivate)
{
dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
_EGLSurface *rsurf, _EGLContext *ctx)
{
- struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
_EGLContext *old_ctx;
/* flush before context switch */
if (old_ctx)
- dri2_drv->glFlush();
+ dri2_gl_flush();
ddraw = (dsurf) ? dri2_dpy->vtbl->get_dri_drawable(dsurf) : NULL;
rdraw = (rsurf) ? dri2_dpy->vtbl->get_dri_drawable(rsurf) : NULL;
EGLint flags, EGLTime timeout)
{
_EGLContext *ctx = _eglGetCurrentContext();
- struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dpy);
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
if (dri2_ctx && dri2_sync->base.SyncStatus == EGL_UNSIGNALED_KHR &&
(flags & EGL_SYNC_FLUSH_COMMANDS_BIT_KHR)) {
/* flush context if EGL_SYNC_FLUSH_COMMANDS_BIT_KHR is set */
- dri2_drv->glFlush();
+ dri2_gl_flush();
}
/* if timeout is EGL_FOREVER_KHR, it should wait without any timeout.*/
return dri2_dpy->interop->export_object(dri2_ctx->dri_context, in, out);
}
-static EGLBoolean
-dri2_load(_EGLDriver *drv)
-{
- struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
-
- dri2_drv->glFlush = (void (*)(void))
- _glapi_get_proc_address("glFlush");
-
- /* if glFlush is not available things are horribly broken */
- if (!dri2_drv->glFlush) {
- _eglLog(_EGL_WARNING, "DRI2: failed to find glFlush entry point");
- return EGL_FALSE;
- }
-
- return EGL_TRUE;
-}
-
/**
* This is the main entrypoint into the driver, called by libEGL.
* Create a new _EGLDriver object and init its dispatch table.
if (!dri2_drv)
return NULL;
- if (!dri2_load(&dri2_drv->base)) {
- free(dri2_drv);
- return NULL;
- }
_eglInitDriverFallbacks(&dri2_drv->base);
dri2_drv->base.API.Initialize = dri2_initialize;