<p dir="ltr"></p>
<p dir="ltr">On Aug 31, 2016 11:39 PM, "Michel Dänzer" <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>> wrote:<br>
><br>
> On 01/09/16 02:05 PM, Jason Ekstrand wrote:<br>
> ><br>
> ><br>
> > On Wed, Aug 31, 2016 at 7:00 PM, Michel Dänzer <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a><br>
> > <mailto:<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>>> wrote:<br>
> ><br>
> > On 31/08/16 11:21 PM, Jason Ekstrand wrote:<br>
> > > On Aug 19, 2016 12:07 AM, "Michel Dänzer" <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a> <mailto:<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>><br>
> > > <mailto:<a href="mailto:michel@daenzer.net">michel@daenzer.net</a> <mailto:<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>>>> wrote:<br>
> > >> From: Michel Dänzer <<a href="mailto:michel.daenzer@amd.com">michel.daenzer@amd.com</a> <mailto:<a href="mailto:michel.daenzer@amd.com">michel.daenzer@amd.com</a>><br>
> > > <mailto:<a href="mailto:michel.daenzer@amd.com">michel.daenzer@amd.com</a> <mailto:<a href="mailto:michel.daenzer@amd.com">michel.daenzer@amd.com</a>>>><br>
> > >><br>
> > >> Always use 3 buffers when flipping. With only 2 buffers, we have to wait<br>
> > >> for a flip to complete (which takes non-0 time even with asynchronous<br>
> > >> flips) before we can start working on the next frame. We were previously<br>
> > >> only using 2 buffers for flipping if the X server supports asynchronous<br>
> > >> flips, even when we're not using asynchronous flips. This could result<br>
> > >> in bad performance (the referenced bug report is an extreme case, where<br>
> > >> the inter-frame stalls were preventing the GPU from reaching its maximum<br>
> > >> clocks).<br>
> > ><br>
> > > Sorry for the post-push review but I don't usually pay much attention to<br>
> > > the window system code. In any case, I believe you're doing your<br>
> > > counting wrong. When flipping with swapinterval=0, you need 4 buffers:<br>
> > ><br>
> > > 1. The buffer currently being scanned out (will be released at next vblank)<br>
> > > 2. The buffer X has queued for scanout but is waiting on vblank<br>
> ><br>
> > s/vblank/flip/g, since async flips may not wait for vblank, but yeah.<br>
> ><br>
> > > 3. The buffer the application has just submitted which X will queue next<br>
> > > of it doesn't get another before the window closes.<br>
> > > 4. The buffer the application is using for rendering.<br>
> > ><br>
> > > With only 3, you get a stall during that window in which X has queued<br>
> > > another flip but we're waiting on vblank before the flip begins. An I<br>
> > > missing something?<br>
> ><br>
> > Nothing, except maybe the paragraph below stating that I couldn't<br>
> > measure any benefit from using 4 buffers. :) I'm not exactly sure why,<br>
> > but I suspect it might be because even with just 3 buffers, the GPU can<br>
> > always work on at least one frame ahead of time.<br>
> ><br>
> > Also note that even before my change, we were only using 3 buffers when<br>
> > the X driver supports async flips (with swap interval 0; only 2 buffers<br>
> > with swap interval > 0).<br>
> ><br>
> ><br>
> > Yes, because with async flips you don't have a buffer sitting queued in<br>
> > the kernel waiting to be flipped which you can't cancel.<br>
><br>
> Actually, there is. Even async flips take non-0 time to complete.<br>
><br>
><br>
> > that makes perfect sense.<br>
><br>
> What exactly does? My change may not be perfect, but the logic before it<br>
> was mostly backwards.</p>
<p dir="ltr">I think perhaps the problem here is that I don't know what you mean by "async flips". It's an X term that obviously does not mean what I thought it meant.</p>
<p dir="ltr">> > That said, I'd be interested in hearing about any test cases where 4<br>
> > buffers provide a significant boost over 3.<br>
> ><br>
> ><br>
> > A little history that may be useful: Quadbuffering was originally added<br>
> > for DRI3+present here:<br>
> ><br>
> > <a href="https://cgit.freedesktop.org/mesa/mesa/commit/?id=f7a355556ef5fe23056299a77414f9ad8b5e5a1d">https://cgit.freedesktop.org/mesa/mesa/commit/?id=f7a355556ef5fe23056299a77414f9ad8b5e5a1d</a><br>
><br>
> So the commit message claims. If you look at the code after that change<br>
> though, it's basically impossible to end up with 4 buffers (at least<br>
> permanently), since it would require all these conditions to be true at<br>
> the same:<br>
><br>
> 1. priv->flipping (the last Present request was completed as a flip)<br>
> 2. !(priv->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC) (the X<br>
> driver doesn't support async flips)<br>
> 3. priv->swap_interval == 0<br>
><br>
> Given 2, 1 & 3 are mutually exclusive.</p>
<p dir="ltr">I'm not seeing how 1 & 3 are mutually exclusive. priv->swap_interval doesn't seem to have anything to do with whether or not you're flipping.</p>
<p dir="ltr">> > Unfortunately, neither of those specify precise metrics. Eero's bug had<br>
> > some very concrete numbers. Hopefully he can provide you with the<br>
> > details you need for further analysis.<br>
><br>
> Indeed. FWIW, my feeling is that my change most likely just exposed<br>
> issues elsewhere.<br>
><br>
><br>
> --<br>
> Earthling Michel Dänzer | <a href="http://www.amd.com">http://www.amd.com</a><br>
> Libre software enthusiast | Mesa and X developer<br></p>