mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
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 <Airlied@redhat.com>
This commit is contained in:
parent
24bacaddef
commit
ab80889e92
8 changed files with 66 additions and 40 deletions
|
|
@ -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);
|
||||
RADV_FROM_HANDLE(radv_fence, fence, pAcquireInfo->fence);
|
||||
|
||||
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);
|
||||
|
||||
if (fence && (result == VK_SUCCESS || result == VK_SUBOPTIMAL_KHR)) {
|
||||
fence->submitted = true;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue