From e01283ccca6284d062490168db3eefb438e8e956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Wed, 2 May 2018 13:35:53 +0300 Subject: [PATCH] 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." Signed-off-by: Tapani Pälli Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106337 --- include/GL/internal/dri_interface.h | 5 +++-- src/egl/drivers/dri2/egl_dri2.c | 12 ++++++++++-- src/mesa/drivers/dri/i965/intel_screen.c | 5 +++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 319a1fe4f9..9e8dfeccbd 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -272,7 +272,7 @@ struct __DRItexBufferExtensionRec { * Used by drivers that implement DRI2 */ #define __DRI2_FLUSH "DRI2_Flush" -#define __DRI2_FLUSH_VERSION 4 +#define __DRI2_FLUSH_VERSION 5 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */ #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */ @@ -281,7 +281,8 @@ struct __DRItexBufferExtensionRec { enum __DRI2throttleReason { __DRI2_THROTTLE_SWAPBUFFER, __DRI2_THROTTLE_COPYSUBBUFFER, - __DRI2_THROTTLE_FLUSHFRONT + __DRI2_THROTTLE_FLUSHFRONT, + __DRI2_THROTTLE_FINISH }; struct __DRI2flushExtensionRec { diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 45d0c7275c..c427137bd9 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1730,8 +1730,16 @@ dri2_wait_client(_EGLDriver *drv, _EGLDisplay *disp, _EGLContext *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); + if (dri2_dpy->flush != NULL) { + if (dri2_dpy->flush->base.version >= 5) { + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); + dri2_dpy->flush->flush_with_flags(dri2_ctx->dri_context, dri_drawable, + __DRI2_FLUSH_DRAWABLE, + __DRI2_THROTTLE_FINISH); + } else { + dri2_dpy->flush->flush(dri_drawable); + } + } return EGL_TRUE; } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 409f763b64..f8706c952d 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -159,6 +159,11 @@ intel_dri2_flush_with_flags(__DRIcontext *cPriv, brw->need_flush_throttle = true; intel_batchbuffer_flush(brw); + + if (reason == __DRI2_THROTTLE_FINISH) { + if (brw->batch.last_bo) + brw_bo_wait_rendering(brw->batch.last_bo); + } } /** -- 2.14.3