loader/dri3: Overhaul dri3_update_num_back
authorMichel Dänzer <michel.daenzer@amd.com>
Wed, 17 Aug 2016 08:02:04 +0000 (17:02 +0900)
committerMichel Dänzer <michel@daenzer.net>
Thu, 25 Aug 2016 08:40:24 +0000 (17:40 +0900)
Always use 3 buffers when flipping. With only 2 buffers, we have to wait
for a flip to complete (which takes non-0 time even with asynchronous
flips) before we can start working on the next frame. We were previously
only using 2 buffers for flipping if the X server supports asynchronous
flips, even when we're not using asynchronous flips. This could result
in bad performance (the referenced bug report is an extreme case, where
the inter-frame stalls were preventing the GPU from reaching its maximum
clocks).

I couldn't measure any performance boost using 4 buffers with flipping.
Performance actually seemed to go down slightly, but that might have
been just noise.

Without flipping, a single back buffer is enough for swap interval 0,
but we need to use 2 back buffers when the swap interval is non-0,
otherwise we have to wait for the swap interval to pass before we can
start working on the next frame. This condition was previously reversed.

Cc: "12.0 11.2" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97260
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/loader/loader_dri3_helper.c

index e9fb97bfaf7b13cac98635190a5a422c1e31cfa9..86ae5aecd5fe1d4de47479d3b70d222bbdd557c4 100644 (file)
@@ -68,15 +68,12 @@ dri3_fence_await(xcb_connection_t *c, struct loader_dri3_buffer *buffer)
 static void
 dri3_update_num_back(struct loader_dri3_drawable *draw)
 {
-   draw->num_back = 1;
-   if (draw->flipping) {
-      if (!draw->is_pixmap &&
-          !(draw->present_capabilities & XCB_PRESENT_CAPABILITY_ASYNC))
-         draw->num_back++;
-      draw->num_back++;
-   }
-   if (draw->vtable->get_swap_interval(draw) == 0)
-      draw->num_back++;
+   if (draw->flipping)
+      draw->num_back = 3;
+   else if (draw->vtable->get_swap_interval(draw) != 0)
+      draw->num_back = 2;
+   else
+      draw->num_back = 1;
 }
 
 void