vulkan/wsi/x11: Wait for GPU work before present with mailbox.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 20 May 2019 01:10:46 +0000 (03:10 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 26 Jul 2019 14:37:28 +0000 (16:37 +0200)
Otherwise the wait only happens at flip time, which messes with
keeping idle buffers around if the GPU work makes the image miss
the next flip.

I decided not to use the wait fences as those are still xshm fences,
so that means we'd still have to wait in the application. Just doing
it before presenting makes things simpler.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/vulkan/wsi/wsi_common_x11.c

index e233c0625f30067d95a6809747e78a65ccd91bfe..40bdd4106059f592868b78a5c1378722eccd6a35 100644 (file)
@@ -1091,6 +1091,16 @@ x11_manage_fifo_queues(void *state)
          return NULL;
       }
 
          return NULL;
       }
 
+      if (chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) {
+         result = chain->base.wsi->WaitForFences(chain->base.device, 1,
+                                        &chain->base.fences[image_index],
+                                        true, UINT64_MAX);
+         if (result != VK_SUCCESS) {
+            result = VK_ERROR_OUT_OF_DATE_KHR;
+            goto fail;
+         }
+      }
+
       uint64_t target_msc = 0;
       if (chain->has_acquire_queue)
          target_msc = chain->last_present_msc + 1;
       uint64_t target_msc = 0;
       if (chain->has_acquire_queue)
          target_msc = chain->last_present_msc + 1;
@@ -1503,7 +1513,8 @@ x11_surface_create_swapchain(VkIcdSurfaceBase *icd_surface,
          goto fail_init_images;
    }
 
          goto fail_init_images;
    }
 
-   if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR) {
+   if (chain->base.present_mode == VK_PRESENT_MODE_FIFO_KHR ||
+       chain->base.present_mode == VK_PRESENT_MODE_MAILBOX_KHR) {
       chain->has_present_queue = true;
 
       /* Initialize our queues.  We make them base.image_count + 1 because we will
       chain->has_present_queue = true;
 
       /* Initialize our queues.  We make them base.image_count + 1 because we will