vulkan/wsi: Add a helper for AcquireNextImage
Unfortunately, due to the fact that AcquireNextImage does not take a queue, the ANV trick for triggering the fence won't work in general. We leave dealing with the fence up to the caller for now. Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Chad Versace <chadversary@chromium.org>
This commit is contained in:
@@ -206,18 +206,23 @@ VkResult radv_GetSwapchainImagesKHR(
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkResult radv_AcquireNextImageKHR(
|
VkResult radv_AcquireNextImageKHR(
|
||||||
VkDevice device,
|
VkDevice _device,
|
||||||
VkSwapchainKHR _swapchain,
|
VkSwapchainKHR swapchain,
|
||||||
uint64_t timeout,
|
uint64_t timeout,
|
||||||
VkSemaphore semaphore,
|
VkSemaphore semaphore,
|
||||||
VkFence _fence,
|
VkFence _fence,
|
||||||
uint32_t* pImageIndex)
|
uint32_t* pImageIndex)
|
||||||
{
|
{
|
||||||
RADV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
RADV_FROM_HANDLE(radv_device, device, _device);
|
||||||
|
struct radv_physical_device *pdevice = device->physical_device;
|
||||||
RADV_FROM_HANDLE(radv_fence, fence, _fence);
|
RADV_FROM_HANDLE(radv_fence, fence, _fence);
|
||||||
|
|
||||||
VkResult result = swapchain->acquire_next_image(swapchain, timeout, semaphore,
|
VkResult result = wsi_common_acquire_next_image(&pdevice->wsi_device,
|
||||||
pImageIndex);
|
_device,
|
||||||
|
swapchain,
|
||||||
|
timeout,
|
||||||
|
semaphore,
|
||||||
|
pImageIndex);
|
||||||
|
|
||||||
if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
|
if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
|
||||||
fence->submitted = true;
|
fence->submitted = true;
|
||||||
|
@@ -234,24 +234,27 @@ VkResult anv_GetSwapchainImagesKHR(
|
|||||||
|
|
||||||
VkResult anv_AcquireNextImageKHR(
|
VkResult anv_AcquireNextImageKHR(
|
||||||
VkDevice _device,
|
VkDevice _device,
|
||||||
VkSwapchainKHR _swapchain,
|
VkSwapchainKHR swapchain,
|
||||||
uint64_t timeout,
|
uint64_t timeout,
|
||||||
VkSemaphore semaphore,
|
VkSemaphore semaphore,
|
||||||
VkFence _fence,
|
VkFence fence,
|
||||||
uint32_t* pImageIndex)
|
uint32_t* pImageIndex)
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
ANV_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
struct anv_physical_device *pdevice = &device->instance->physicalDevice;
|
||||||
ANV_FROM_HANDLE(anv_fence, fence, _fence);
|
|
||||||
|
|
||||||
VkResult result = swapchain->acquire_next_image(swapchain, timeout,
|
VkResult result = wsi_common_acquire_next_image(&pdevice->wsi_device,
|
||||||
semaphore, pImageIndex);
|
_device,
|
||||||
|
swapchain,
|
||||||
|
timeout,
|
||||||
|
semaphore,
|
||||||
|
pImageIndex);
|
||||||
|
|
||||||
/* Thanks to implicit sync, the image is ready immediately. However, we
|
/* Thanks to implicit sync, the image is ready immediately. However, we
|
||||||
* should wait for the current GPU state to finish.
|
* should wait for the current GPU state to finish.
|
||||||
*/
|
*/
|
||||||
if (fence)
|
if (fence != VK_NULL_HANDLE)
|
||||||
anv_QueueSubmit(anv_queue_to_handle(&device->queue), 0, NULL, _fence);
|
anv_QueueSubmit(anv_queue_to_handle(&device->queue), 0, NULL, fence);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -539,6 +539,20 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
|
|||||||
return vk_outarray_status(&images);
|
return vk_outarray_status(&images);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VkResult
|
||||||
|
wsi_common_acquire_next_image(const struct wsi_device *wsi,
|
||||||
|
VkDevice device,
|
||||||
|
VkSwapchainKHR _swapchain,
|
||||||
|
uint64_t timeout,
|
||||||
|
VkSemaphore semaphore,
|
||||||
|
uint32_t *pImageIndex)
|
||||||
|
{
|
||||||
|
WSI_FROM_HANDLE(wsi_swapchain, swapchain, _swapchain);
|
||||||
|
|
||||||
|
return swapchain->acquire_next_image(swapchain, timeout,
|
||||||
|
semaphore, pImageIndex);
|
||||||
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_queue_present(const struct wsi_device *wsi,
|
wsi_common_queue_present(const struct wsi_device *wsi,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
|
@@ -220,6 +220,14 @@ wsi_common_get_images(VkSwapchainKHR _swapchain,
|
|||||||
uint32_t *pSwapchainImageCount,
|
uint32_t *pSwapchainImageCount,
|
||||||
VkImage *pSwapchainImages);
|
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);
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
wsi_common_create_swapchain(struct wsi_device *wsi,
|
wsi_common_create_swapchain(struct wsi_device *wsi,
|
||||||
VkDevice device,
|
VkDevice device,
|
||||||
|
Reference in New Issue
Block a user