From: Jason Ekstrand Date: Thu, 20 Sep 2018 10:30:03 +0000 (-0500) Subject: anv,radv: Implement vkAcquireNextImage2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab80889e92e2a3c2884e5da925424f9f6a88979b;p=mesa.git anv,radv: Implement vkAcquireNextImage2 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 --- diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index 20484177135..6479bea070b 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -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; diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c index 1403601e9c0..5ed1d711689 100644 --- a/src/intel/vulkan/anv_wsi.c +++ b/src/intel/vulkan/anv_wsi.c @@ -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; } diff --git a/src/vulkan/wsi/wsi_common.c b/src/vulkan/wsi/wsi_common.c index f2d90a6bba2..3416fef3076 100644 --- a/src/vulkan/wsi/wsi_common.c +++ b/src/vulkan/wsi/wsi_common.c @@ -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 diff --git a/src/vulkan/wsi/wsi_common.h b/src/vulkan/wsi/wsi_common.h index 33e4f849ac9..14f65097bb3 100644 --- a/src/vulkan/wsi/wsi_common.h +++ b/src/vulkan/wsi/wsi_common.h @@ -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, diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index 1e90bba460c..e99b0465ec9 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -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); diff --git a/src/vulkan/wsi/wsi_common_private.h b/src/vulkan/wsi/wsi_common_private.h index 9f2aacd6560..ee7ae75b8f7 100644 --- a/src/vulkan/wsi/wsi_common_private.h +++ b/src/vulkan/wsi/wsi_common_private.h @@ -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, diff --git a/src/vulkan/wsi/wsi_common_wayland.c b/src/vulkan/wsi/wsi_common_wayland.c index 4a6a4a29b93..6b34e21bd98 100644 --- a/src/vulkan/wsi/wsi_common_wayland.c +++ b/src/vulkan/wsi/wsi_common_wayland.c @@ -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; diff --git a/src/vulkan/wsi/wsi_common_x11.c b/src/vulkan/wsi/wsi_common_x11.c index d4c1790575f..5f99b2ee473 100644 --- a/src/vulkan/wsi/wsi_common_x11.c +++ b/src/vulkan/wsi/wsi_common_x11.c @@ -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);