[Mesa-stable] [PATCH] egl: Flush the Wayland display queue after calling attach/damage/commit

Giulio Camuffo giuliocamuffo at gmail.com
Thu Aug 22 06:14:02 PDT 2013


eglSwapBuffers() should result in a call to wl_display_flush since it
may be called by a rendering thread, and it cannot rely on the main
loop to call it. The main loop may indeed be stuck on a
wl_display_dispatch() call which blocks until there are events, and
if the redraw is triggered by an application internal event
(timer, ...) the attach/damage/commit calls done by egl will not be
followed by a wl_display_flush call, resulting in the frame not
reaching the compositor.
Thanks to Daniel Stone for the initial direction.

Cc: mesa-stable at lists.freedesktop.org
---

Please Cc me, I'm not subscribed to the list

 src/egl/drivers/dri2/egl_dri2.h         | 1 +
 src/egl/drivers/dri2/platform_wayland.c | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index fba5f81..caaee02 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -176,6 +176,7 @@ struct dri2_egl_surface
    int                    dy;
    struct wl_callback    *frame_callback;
    int			  format;
+   struct wl_display     *wl_display;
 #endif
 
 #ifdef HAVE_DRM_PLATFORM
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 1d417bb..1b10f71 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -146,6 +146,8 @@ dri2_create_surface(_EGLDriver *drv, _EGLDisplay *disp, EGLint type,
 
       dri2_surf->base.Width =  -1;
       dri2_surf->base.Height = -1;
+
+      dri2_surf->wl_display = dri2_dpy->wl_dpy;
       break;
    default: 
       goto cleanup_surf;
@@ -532,6 +534,8 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv,
    dri2_surf->current = dri2_surf->back;
    dri2_surf->back = NULL;
 
+   (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
+
    create_wl_buffer(dri2_surf);
 
    wl_surface_attach(dri2_surf->wl_win->surface,
@@ -558,8 +562,8 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv,
    }
 
    wl_surface_commit(dri2_surf->wl_win->surface);
+   wl_display_flush(dri2_surf->wl_display);
 
-   (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
    (*dri2_dpy->flush->invalidate)(dri2_surf->dri_drawable);
 
    return EGL_TRUE;
-- 
1.8.3.4



More information about the mesa-stable mailing list