anv,radv: Implement vkAcquireNextImage2
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 20 Sep 2018 10:30:03 +0000 (05:30 -0500)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 21 Sep 2018 12:02:35 +0000 (07:02 -0500)
This was added as part of 1.1 but it's very hard to track exactly what
extension added it.  In any case, we should implement it.

Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Dave Airlie <Airlied@redhat.com>
src/amd/vulkan/radv_wsi.c
src/intel/vulkan/anv_wsi.c
src/vulkan/wsi/wsi_common.c
src/vulkan/wsi/wsi_common.h
src/vulkan/wsi/wsi_common_display.c
src/vulkan/wsi/wsi_common_private.h
src/vulkan/wsi/wsi_common_wayland.c
src/vulkan/wsi/wsi_common_x11.c

index 204841771354fddc3e75ad6064cd182abd4484ea..6479bea070b096a9510073044eec69263af14d61 100644 (file)
@@ -206,23 +206,38 @@ VkResult radv_GetSwapchainImagesKHR(
 }
 
 VkResult radv_AcquireNextImageKHR(
-       VkDevice                                     _device,
+       VkDevice                                     device,
        VkSwapchainKHR                               swapchain,
        uint64_t                                     timeout,
        VkSemaphore                                  semaphore,
-       VkFence                                      _fence,
+       VkFence                                      fence,
+       uint32_t*                                    pImageIndex)
+{
+       VkAcquireNextImageInfoKHR acquire_info = {
+               .sType = VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR,
+               .swapchain = swapchain,
+               .timeout = timeout,
+               .semaphore = semaphore,
+               .fence = fence,
+               .deviceMask = 0,
+       };
+
+       return radv_AcquireNextImage2KHR(device, &acquire_info, pImageIndex);
+}
+
+VkResult radv_AcquireNextImage2KHR(
+       VkDevice                                     _device,
+       const VkAcquireNextImageInfoKHR*             pAcquireInfo,
        uint32_t*                                    pImageIndex)
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_physical_device *pdevice = device->physical_device;
-       RADV_FROM_HANDLE(radv_fence, fence, _fence);
-
-       VkResult result = wsi_common_acquire_next_image(&pdevice->wsi_device,
-                                                       _device,
-                                                       swapchain,
-                                                       timeout,
-                                                       semaphore,
-                                                       pImageIndex);
+       RADV_FROM_HANDLE(radv_fence, fence, pAcquireInfo->fence);
+
+       VkResult result = wsi_common_acquire_next_image2(&pdevice->wsi_device,
+                                                        _device,
+                                                         pAcquireInfo,
+                                                        pImageIndex);
 
        if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
                fence->submitted = true;
index 1403601e9c0720f96b354156569ff5cb9e71ec48..5ed1d711689b4e152738492b4017e8c0b5ff018a 100644 (file)
@@ -216,28 +216,45 @@ VkResult anv_GetSwapchainImagesKHR(
 }
 
 VkResult anv_AcquireNextImageKHR(
-    VkDevice                                     _device,
+    VkDevice                                     device,
     VkSwapchainKHR                               swapchain,
     uint64_t                                     timeout,
     VkSemaphore                                  semaphore,
     VkFence                                      fence,
     uint32_t*                                    pImageIndex)
+{
+   VkAcquireNextImageInfoKHR acquire_info = {
+      .sType = VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR,
+      .swapchain = swapchain,
+      .timeout = timeout,
+      .semaphore = semaphore,
+      .fence = fence,
+      .deviceMask = 0,
+   };
+
+   return anv_AcquireNextImage2KHR(device, &acquire_info, pImageIndex);
+}
+
+VkResult anv_AcquireNextImage2KHR(
+    VkDevice                                     _device,
+    const VkAcquireNextImageInfoKHR*             pAcquireInfo,
+    uint32_t*                                    pImageIndex)
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
    struct anv_physical_device *pdevice = &device->instance->physicalDevice;
 
-   VkResult result = wsi_common_acquire_next_image(&pdevice->wsi_device,
-                                                   _device,
-                                                   swapchain,
-                                                   timeout,
-                                                   semaphore,
-                                                   pImageIndex);
+   VkResult result = wsi_common_acquire_next_image2(&pdevice->wsi_device,
+                                                    _device,
+                                                    pAcquireInfo,
+                                                    pImageIndex);
 
    /* Thanks to implicit sync, the image is ready immediately.  However, we
     * should wait for the current GPU state to finish.
     */
-   if (fence != VK_NULL_HANDLE)
-      anv_QueueSubmit(anv_queue_to_handle(&device->queue), 0, NULL, fence);
+   if (pAcquireInfo->fence != VK_NULL_HANDLE) {
+      anv_QueueSubmit(anv_queue_to_handle(&device->queue), 0, NULL,
+                      pAcquireInfo->fence);
+   }
 
    return result;
 }
index f2d90a6bba2d17d485e9aa193c5f65f40f18c7b8..3416fef3076abae93692172886c36f2b9e9276d7 100644 (file)
@@ -856,17 +856,14 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
 }
 
 VkResult
-wsi_common_acquire_next_image(const struct wsi_device *wsi,
-                              VkDevice device,
-                              VkSwapchainKHR _swapchain,
-                              uint64_t timeout,
-                              VkSemaphore semaphore,
-                              uint32_t *pImageIndex)
+wsi_common_acquire_next_image2(const struct wsi_device *wsi,
+                               VkDevice device,
+                               const VkAcquireNextImageInfoKHR *pAcquireInfo,
+                               uint32_t *pImageIndex)
 {
-   WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
+   WSI_FROM_HANDLE(wsi_swapchain, swapchain, pAcquireInfo->swapchain);
 
-   return swapchain->acquire_next_image(swapchain, timeout,
-                                        semaphore, pImageIndex);
+   return swapchain->acquire_next_image(swapchain, pAcquireInfo, pImageIndex);
 }
 
 VkResult
index 33e4f849ac99c45a300f6b9b97ae81327512913a..14f65097bb38087897c6a095d98418a037b77963 100644 (file)
@@ -209,12 +209,10 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
                       VkImage *pSwapchainImages);
 
 VkResult
-wsi_common_acquire_next_image(const struct wsi_device *wsi,
-                              VkDevice device,
-                              VkSwapchainKHR swapchain,
-                              uint64_t timeout,
-                              VkSemaphore semaphore,
-                              uint32_t *pImageIndex);
+wsi_common_acquire_next_image2(const struct wsi_device *wsi,
+                               VkDevice device,
+                               const VkAcquireNextImageInfoKHR *pAcquireInfo,
+                               uint32_t *pImageIndex);
 
 VkResult
 wsi_common_create_swapchain(struct wsi_device *wsi,
index 1e90bba460cba190c5ab04709a7feacc45558bb2..e99b0465ec9b6757d5d2cc3e633e7a1a6db84e24 100644 (file)
@@ -1197,8 +1197,7 @@ wsi_display_wait_for_event(struct wsi_display *wsi,
 
 static VkResult
 wsi_display_acquire_next_image(struct wsi_swapchain *drv_chain,
-                               uint64_t timeout,
-                               VkSemaphore semaphore,
+                               const VkAcquireNextImageInfoKHR *info,
                                uint32_t *image_index)
 {
    struct wsi_display_swapchain *chain =
@@ -1211,6 +1210,7 @@ wsi_display_acquire_next_image(struct wsi_swapchain *drv_chain,
    if (chain->status != VK_SUCCESS)
       return chain->status;
 
+   uint64_t timeout = info->timeout;
    if (timeout != 0 && timeout != UINT64_MAX)
       timeout = wsi_rel_to_abs_time(timeout);
 
index 9f2aacd6560a43b90d3b10935f68799b54d36cd0..ee7ae75b8f7a645c28fc397980bac112839bf86a 100644 (file)
@@ -62,7 +62,7 @@ struct wsi_swapchain {
    struct wsi_image *(*get_wsi_image)(struct wsi_swapchain *swapchain,
                                       uint32_t image_index);
    VkResult (*acquire_next_image)(struct wsi_swapchain *swap_chain,
-                                  uint64_t timeout, VkSemaphore semaphore,
+                                  const VkAcquireNextImageInfoKHR *info,
                                   uint32_t *image_index);
    VkResult (*queue_present)(struct wsi_swapchain *swap_chain,
                              uint32_t image_index,
index 4a6a4a29b93ff56a59a69d5831c56932d91c03f9..6b34e21bd982b5b81c7668f61bafbf7c719de826 100644 (file)
@@ -658,8 +658,7 @@ wsi_wl_swapchain_get_wsi_image(struct wsi_swapchain *wsi_chain,
 
 static VkResult
 wsi_wl_swapchain_acquire_next_image(struct wsi_swapchain *wsi_chain,
-                                    uint64_t timeout,
-                                    VkSemaphore semaphore,
+                                    const VkAcquireNextImageInfoKHR *info,
                                     uint32_t *image_index)
 {
    struct wsi_wl_swapchain *chain = (struct wsi_wl_swapchain *)wsi_chain;
index d4c1790575f9f1780e40a7454642ca9ad8512d58..5f99b2ee473028c799782fc80933a174e7d7e406 100644 (file)
@@ -948,11 +948,11 @@ x11_present_to_x11(struct x11_swapchain *chain, uint32_t image_index,
 
 static VkResult
 x11_acquire_next_image(struct wsi_swapchain *anv_chain,
-                       uint64_t timeout,
-                       VkSemaphore semaphore,
+                       const VkAcquireNextImageInfoKHR *info,
                        uint32_t *image_index)
 {
    struct x11_swapchain *chain = (struct x11_swapchain *)anv_chain;
+   uint64_t timeout = info->timeout;
 
    if (chain->threaded) {
       return x11_acquire_next_image_from_queue(chain, image_index, timeout);