From f1f862a75c29afe40bd28ccb7bfa094a7a1a1778 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 5 Jul 2012 10:54:37 +0100 Subject: [PATCH] glx/dri2: Flush pending writes before retreiving new attachments Fixes fbo-sys-blit In fbo-sys-blit, we clear the back-buffer and do a local blit from back-to-front. We then attempt to read back from the front buffer, which instantiates a FakeFront on the server. The server copies across its stale front buffer to the intialise the FakeFront, which is then probed for the results of the local copy (which has now been overwritten by the remote copy). --- src/glx/dri2_glx.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index b6988c3..58da51e 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -571,15 +571,24 @@ dri2_wait_x(struct glx_context *gc) } static void +__dri2_wait_gl(struct dri2_drawable *pdraw) +{ + if (!pdraw->have_fake_front) + return; + + dri2_copy_drawable(pdraw, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); +} + +static void dri2_wait_gl(struct glx_context *gc) { - struct dri2_drawable *priv = (struct dri2_drawable *) + struct dri2_drawable *pdraw = (struct dri2_drawable *) GetGLXDRIDrawable(gc->currentDpy, gc->currentDrawable); - if (priv == NULL || !priv->have_fake_front) + if (pdraw == NULL) return; - dri2_copy_drawable(priv, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + __dri2_wait_gl(pdraw); } static void @@ -587,7 +596,6 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate) { struct glx_display *priv; struct dri2_display *pdp; - struct glx_context *gc; struct dri2_drawable *pdraw = loaderPrivate; struct dri2_screen *psc; @@ -601,7 +609,6 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate) priv = __glXInitialize(psc->base.dpy); pdp = (struct dri2_display *) priv->dri2Display; - gc = __glXGetCurrentContext(); dri2Throttle(psc, pdraw, __DRI2_THROTTLE_FLUSHFRONT); @@ -609,7 +616,7 @@ dri2FlushFrontBuffer(__DRIdrawable *driDrawable, void *loaderPrivate) if (!pdp->invalidateAvailable) dri2InvalidateBuffers(priv->dpy, pdraw->base.xDrawable); - dri2_wait_gl(gc); + __dri2_wait_gl(pdraw); } @@ -745,6 +752,8 @@ dri2GetBuffers(__DRIdrawable * driDrawable, struct dri2_drawable *pdraw = loaderPrivate; DRI2Buffer *buffers; + __dri2_wait_gl(pdraw); + buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable, width, height, attachments, count, out_count); if (buffers == NULL) @@ -768,6 +777,8 @@ dri2GetBuffersWithFormat(__DRIdrawable * driDrawable, struct dri2_drawable *pdraw = loaderPrivate; DRI2Buffer *buffers; + __dri2_wait_gl(pdraw); + buffers = DRI2GetBuffersWithFormat(pdraw->base.psc->dpy, pdraw->base.xDrawable, width, height, attachments, -- 1.7.10