<p dir="ltr">On Aug 19, 2016 12:07 AM, "Michel Dänzer" <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>> wrote:<br>
><br>
> From: Michel Dänzer <<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).</p>
<p dir="ltr">Sorry for the post-push review but I don't usually pay much attention to the window system code. In any case, I believe you're doing your counting wrong. When flipping with swapinterval=0, you need 4 buffers:</p>
<p dir="ltr">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>
3. The buffer the application has just submitted which X will queue next of it doesn't get another before the window closes.<br>
4. The buffer the application is using for rendering.</p>
<p dir="ltr">With only 3, you get a stall during that window in which X has queued another flip but we're waiting on vblank before the flip begins. An I missing something?</p>
<p dir="ltr">--Jason</p>
<p dir="ltr">> I couldn't measure any performance boost using 4 buffers with flipping.<br>
> Performance actually seemed to go down slightly, but that might have<br>
> been just noise.<br>
><br>
> Without flipping, a single back buffer is enough for swap interval 0,<br>
> but we need to use 2 back buffers when the swap interval is non-0,<br>
> otherwise we have to wait for the swap interval to pass before we can<br>
> start working on the next frame. This condition was previously reversed.<br>
><br>
> Cc: "12.0 11.2" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a>><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=97260">https://bugs.freedesktop.org/show_bug.cgi?id=97260</a><br>
> Signed-off-by: Michel Dänzer <<a href="mailto:michel.daenzer@amd.com">michel.daenzer@amd.com</a>><br>
> ---<br>
> src/loader/loader_dri3_helper.c | 15 ++++++---------<br>
> 1 file changed, 6 insertions(+), 9 deletions(-)<br>
><br>
> diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c<br>
> index e9fb97b..86ae5ae 100644<br>
> --- a/src/loader/loader_dri3_helper.c<br>
> +++ b/src/loader/loader_dri3_helper.c<br>
> @@ -68,15 +68,12 @@ dri3_fence_await(xcb_connection_t *c, struct loader_dri3_buffer *buffer)<br>
> static void<br>
> dri3_update_num_back(struct loader_dri3_drawable *draw)<br>
> {<br>
> - draw->num_back = 1;<br>
> - if (draw->flipping) {<br>
> - if (!draw->is_pixmap &&<br>
> - !(draw->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC))<br>
> - draw->num_back++;<br>
> - draw->num_back++;<br>
> - }<br>
> - if (draw->vtable->get_swap_interval(draw) == 0)<br>
> - draw->num_back++;<br>
> + if (draw->flipping)<br>
> + draw->num_back = 3;<br>
> + else if (draw->vtable->get_swap_interval(draw) != 0)<br>
> + draw->num_back = 2;<br>
> + else<br>
> + draw->num_back = 1;<br>
> }<br>
><br>
> void<br>
> --<br>
> 2.9.3<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br></p>