[Mesa-dev] [PATCH 0/2] First attempt at asynchronous SwapBuffers

Michel Dänzer michel at daenzer.net
Thu Nov 15 10:15:09 PST 2012


On Don, 2012-11-15 at 18:48 +0100, Marek Olšák wrote: 
> On Thu, Nov 15, 2012 at 3:30 PM, Michel Dänzer <michel at daenzer.net> wrote:
> > On Don, 2012-11-15 at 04:43 +0100, Marek Olšák wrote:
> >>
> >> For the asynchronous SwapBuffers to work, there must be a separate X
> >> connection, because Xlib isn't thread-safe at all.
> >>
> >> Now the bad news. The DRI invalidate events may be received too late.
> >> We can't wait for the events in glXSwapBuffers, because that would
> >> defeat the whole purpose of thread offloading.
> >
> > [...]
> 
> [...]
> 
> >> For normal apps, that only happens when the window is resized, so only
> >> the next rendered frame is likely to contain garbage.
> >
> > DRI2SwapBuffers also generates invalidate events, and those can be
> > crucial e.g. with page flipping.
> 
> DRI2SwapBuffers is gone, see:
> http://www.mail-archive.com/mesa-dev@lists.freedesktop.org/msg27459.html

I'm referring to the DRI2 extension request, which is still called via
xcb_dri2_swap_buffers_unchecked. Basically, after calling this request,
you cannot know which buffers to use for the next frame without:

      * Waiting for the invalidate events triggered by the request. 
      * Calling the DRI2GetBuffers(WithFormat) request.

That's ignoring the xserver bug making even this sequence unreliable
between different clients, which applies to the separate display
connections between the offload thread and the main thread.


> >> Compositors don't work very well with this. I think it's because of
> >> the invalidate events not being received in time. As a temporary
> >> solution, I turn off asynchronous SwapBuffers if dri2_bind_tex_image
> >> is called, which should cover all compositors that either directly or
> >> indirectly use GLX.
> >
> > I fail to see the connection. Maybe the compositors break because they
> > use page flipping, per above?
> 
> I have SwapBuffersWait turned off, which also turns off page flipping AFAIK.

No, it doesn't. It merely disables hardware scanline waits for blit
swaps. To disable page flipping, use

Option "EnablePageFlip" "off"


> I guess I could try to invalidate all drawables before SwapBuffers if
> that's even possible.

Not sure what you mean. The X server tries to do what I think you might,
but doesn't get it quite right in all cases yet.


-- 
Earthling Michel Dänzer           |                   http://www.amd.com
Libre software enthusiast         |          Debian, X and DRI developer


More information about the mesa-dev mailing list