From 9e46d48933effaba8f93c82166d9f6a098a461af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Thu, 3 May 2018 08:38:18 +0300 Subject: [PATCH v2] egl: make eglWaitClient behave like glFinish MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As defined by the spec: "All rendering calls for the currently bound context, for the current rendering API, made prior to eglWaitClient, are guaranteed to be executed before native rendering calls made after eglWaitClient which affect the read or draw surfaces associated with that context. The same result can be achieved using client API-specific calls such as glFinish or vgFinish." v2: call glFinish() to ensure identical behaviour Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106337 --- src/egl/drivers/dri2/egl_dri2.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 45d0c7275c..698a48a598 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -124,6 +124,26 @@ dri2_gl_flush() glFlush(); } +static void +dri2_gl_finish() +{ + static void (*glFinish)(void); + static mtx_t glFinishMutex = _MTX_INITIALIZER_NP; + + mtx_lock(&glFinishMutex); + if (!glFinish) + glFinish = _glapi_get_proc_address("glFinish"); + mtx_unlock(&glFinishMutex); + + /* if glFinish is not available things are horribly broken */ + if (!glFinish) { + _eglLog(_EGL_WARNING, "DRI2: failed to find glFlush entry point"); + return; + } + + glFinish(); +} + static GLboolean dri_is_thread_safe(void *loaderPrivate) { @@ -1721,17 +1741,11 @@ dri2_query_buffer_age(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) static EGLBoolean dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *ctx) { - struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); - _EGLSurface *surf = ctx->DrawSurface; - __DRIdrawable *dri_drawable = dri2_dpy->vtbl->get_dri_drawable(surf); - (void) drv; + (void) disp; + (void) ctx; - /* FIXME: If EGL allows frontbuffer rendering for window surfaces, - * we need to copy fake to real here.*/ - - if (dri2_dpy->flush != NULL) - dri2_dpy->flush->flush(dri_drawable); + dri2_gl_finish(); return EGL_TRUE; } -- 2.13.6