[Mesa-dev] [PATCH] dri2: Insert a synchronisation point for glXWaitX

Chris Wilson chris at chris-wilson.co.uk
Mon Aug 10 04:57:16 PDT 2015

"X rendering calls made prior to glXWaitX are guaranteed to be
executed before GL rendering calls made after glXWaitX."

The goal is to implement that without adding a round-trip to the
Xserver. Adding one using XSync() is easy, but we can piggy-back
another, the DRI2GetBuffers request made to update the render buffers
before the next rendering (thus satisfying the condition of flushing all
X operations before the next GL rendering). To this end we can just flag
the DRI2 buffers as invalid, and the driver will refresh them in due
course. If the DRI2 buffers are, or will be, invalid due to damage from
X or through a SwapBuffers call, we will not have to add another
roundtrip as the single DRI2GetBuffers will refresh over multiple

This should fix the historic issue that glXWaitX() has been unreliable,
but has recently found itself a new trigger will the removal of
unnecessary glViewport calls:

commit 95073a2dca03a48f4c77bc846a4a6d1f0eb81ae6
Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Fri Sep 26 15:13:30 2014 -0700

    mesa: Avoid flagging _NEW_VIEWPORT on redundant viewport updates.

since each Viewport typically ended up triggering an invalidate.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90264
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Michel Dänzer <michel at daenzer.net>
Cc: Kenneth Graunke <kenneth at whitecape.org>
Cc: Brian Paul <brianp at vmware.com>
Cc: Ian Romanick <ian.d.romanick at intel.com>
 src/glx/dri2_glx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 5767026..01b5c28 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -656,6 +656,8 @@ dri2_wait_x(struct glx_context *gc)
    struct dri2_drawable *priv = (struct dri2_drawable *)
       GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable);
+   dri2InvalidateBuffers(gc->currentDpy, gc->currentDrawable);
    if (priv == NULL || !priv->have_fake_front)

More information about the mesa-dev mailing list