On Tue, 2009-03-24 at 17:53 +0100, Michel Dänzer wrote:
> Eric,
> 
> 
> your mesa commit dd1c68f15123a889a3ce9d2afe724e272d163e32 ('dri2: Avoid
> round-tripping on DRI2GetBuffers for the same set of buffers.') breaks
> when the display connection doesn't receive ConfigureNotify events. This
> can be reproduced by running a 3D application in a guest operating
> system in VMware Workstation, which calls
> 
>         XSelectInput(..., ExposureMask);
> 
> on the child window used for GL rendering. The GL driver ends up using
> stale buffers / window size, so the output is cropped and misplaced.
> 
> I wrote up the attached patch to fix this by adding StructureNotifyMask
> to the event mask of the DRI2 display connection; this fixes the problem
> above, but on second thought I'm concerned about potential side effects
> of this approach on display connections which are otherwise not
> interested in ConfigureNotify events. If I'm reading the libX11 event
> queue management code correctly, this could result in an unlimited
> number of ConfigureNotify events queueing up on the client side. In
> practice the number may usually be low, but there could be more subtle
> side effects, e.g. because the queue would not empty up anymore.
> 
> So for Mesa 7.4, I suspect the safest course of action is to revert
> dd1c68f15123a889a3ce9d2afe724e272d163e32. Something like the change
> below could be used to at least limit the number of additional X server
> round-trips to one per frame.
> 
> What do you think?

While I actually did the typing, the plan there (in particular the
understanding of the event code) came mostly from Keith.  I've added him
to the Cc.  Keith -- does this match your understanding of the event
code?

Ack on reverting the patch for 7.4, though if it's really not going to
work out I'd rather revert it from master as well.  We can work around
the cost by suppressing the getbuffers for internal glViewport calls (it
was the plan before he came up with the clever hack).

> commit 31cc890207e18f7f538502cca0b9492b4938b7e7
> Author: Michel Dänzer <[email protected]>
> Date:   Tue Mar 24 17:35:29 2009 +0100
> 
>     DRI2: Avoid changing buffers in the middle of a frame.
> 
> diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
> index 9c8f110..de187f9 100644
> --- a/src/glx/x11/dri2_glx.c
> +++ b/src/glx/x11/dri2_glx.c
> @@ -76,6 +76,7 @@ struct __GLXDRIdrawablePrivateRec {
>      int have_back;
>      int have_front;
>      int have_fake_front;
> +    GLboolean buffers_cached;
>  };
>  
>  static void dri2DestroyContext(__GLXDRIcontext *context,
> @@ -170,6 +171,7 @@ static __GLXDRIdrawable 
> *dri2CreateDrawable(__GLXscreenConfigs *psc,
>      pdraw->base.drawable = drawable;
>      pdraw->base.psc = psc;
>      pdraw->bufferCount = 0;
> +    pdraw->buffers_cached = GL_FALSE;
>  
>      DRI2CreateDrawable(psc->dpy, xDrawable);
>  
> @@ -194,6 +196,8 @@ static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw,
>      XRectangle xrect;
>      XserverRegion region;
>  
> +    priv->buffers_cached = GL_FALSE;
> +
>      /* Check we have the right attachments */
>      if (!(priv->have_front && priv->have_back))
>       return;
> @@ -228,6 +232,8 @@ static void dri2WaitX(__GLXDRIdrawable *pdraw)
>      XRectangle xrect;
>      XserverRegion region;
>  
> +    priv->buffers_cached = GL_FALSE;
> +
>      /* Check we have the right attachments */
>      if (!(priv->have_fake_front && priv->have_front))
>       return;
> @@ -254,6 +260,8 @@ static void dri2WaitGL(__GLXDRIdrawable *pdraw)
>      XRectangle xrect;
>      XserverRegion region;
>  
> +    priv->buffers_cached = GL_FALSE;
> +
>      if (!(priv->have_fake_front && priv->have_front))
>       return;
>  
> @@ -291,6 +299,22 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
>      DRI2Buffer *buffers;
>      int i;
>  
> +    /**
> +     * We want to avoid changing the buffers in the middle of a frame.
> +     */
> +    if (pdraw->buffers_cached && count == pdraw->bufferCount) {
> +     for (i = 0; i < count; i++) {
> +         if (pdraw->buffers[i].attachment != attachments[i])
> +             break;
> +     }
> +     if (i == count) {
> +         *width = pdraw->width;
> +         *height = pdraw->height;
> +         *out_count = pdraw->bufferCount;
> +         return pdraw->buffers;
> +     }
> +    }
> +
>      buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
>                            width, height, attachments, count, out_count);
>      if (buffers == NULL)
> @@ -321,6 +345,8 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
>  
>      Xfree(buffers);
>  
> +    pdraw->buffers_cached = GL_TRUE;
> +
>      return pdraw->buffers;
>  }
>  
> 
> 
-- 
Eric Anholt
[email protected]                         [email protected]


Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to