diff options
author | Dave Airlie <[email protected]> | 2017-02-27 19:14:00 +0000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2017-07-21 21:31:54 +0100 |
commit | eaa56eab6da565c7bc84419c025c7c9bc90cf87a (patch) | |
tree | 09e2adf2a642a3879a4992157ba6293d677214c9 /src/amd/vulkan/radv_wsi.c | |
parent | b5670beb31d3e6cfb8fff6f14e5fd5ec03ec16e9 (diff) |
radv: initial support for shared semaphores (v2)
This adds support for sharing semaphores using kernel syncobjects.
Syncobj backed semaphores are used for any semaphore which is
created with external flags, and when a semaphore is imported,
otherwise we use the current non-kernel semaphores.
Temporary imports from syncobj fd are also available, these
just override the current user until the next wait, when the
temp syncobj is dropped.
v2: allocate more chunks upfront, fix off by one after
previous refactor of syncobj setup, remove unnecessary null
check.
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_wsi.c')
-rw-r--r-- | src/amd/vulkan/radv_wsi.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/amd/vulkan/radv_wsi.c b/src/amd/vulkan/radv_wsi.c index ab3dcd67d5f..adc43111122 100644 --- a/src/amd/vulkan/radv_wsi.c +++ b/src/amd/vulkan/radv_wsi.c @@ -442,7 +442,6 @@ VkResult radv_AcquireNextImageKHR( fence->submitted = true; fence->signalled = true; } - return result; } @@ -452,7 +451,6 @@ VkResult radv_QueuePresentKHR( { RADV_FROM_HANDLE(radv_queue, queue, _queue); VkResult result = VK_SUCCESS; - const VkPresentRegionsKHR *regions = vk_find_struct_const(pPresentInfo->pNext, PRESENT_REGIONS_KHR); @@ -461,6 +459,20 @@ VkResult radv_QueuePresentKHR( struct radeon_winsys_cs *cs; const VkPresentRegionKHR *region = NULL; VkResult item_result; + struct radv_winsys_sem_info sem_info; + + item_result = radv_alloc_sem_info(&sem_info, + pPresentInfo->waitSemaphoreCount, + pPresentInfo->pWaitSemaphores, + 0, + NULL); + if (pPresentInfo->pResults != NULL) + pPresentInfo->pResults[i] = item_result; + result = result == VK_SUCCESS ? item_result : result; + if (item_result != VK_SUCCESS) { + radv_free_sem_info(&sem_info); + continue; + } assert(radv_device_from_handle(swapchain->device) == queue->device); if (swapchain->fences[0] == VK_NULL_HANDLE) { @@ -472,8 +484,10 @@ VkResult radv_QueuePresentKHR( if (pPresentInfo->pResults != NULL) pPresentInfo->pResults[i] = item_result; result = result == VK_SUCCESS ? item_result : result; - if (item_result != VK_SUCCESS) + if (item_result != VK_SUCCESS) { + radv_free_sem_info(&sem_info); continue; + } } else { radv_ResetFences(radv_device_to_handle(queue->device), 1, &swapchain->fences[0]); @@ -487,11 +501,12 @@ VkResult radv_QueuePresentKHR( RADV_FROM_HANDLE(radv_fence, fence, swapchain->fences[0]); struct radeon_winsys_fence *base_fence = fence->fence; struct radeon_winsys_ctx *ctx = queue->hw_ctx; + queue->device->ws->cs_submit(ctx, queue->queue_idx, &cs, 1, NULL, NULL, - (struct radeon_winsys_sem **)pPresentInfo->pWaitSemaphores, - pPresentInfo->waitSemaphoreCount, NULL, 0, false, base_fence); + &sem_info, + false, base_fence); fence->submitted = true; if (regions && regions->pRegions) @@ -504,8 +519,10 @@ VkResult radv_QueuePresentKHR( if (pPresentInfo->pResults != NULL) pPresentInfo->pResults[i] = item_result; result = result == VK_SUCCESS ? item_result : result; - if (item_result != VK_SUCCESS) + if (item_result != VK_SUCCESS) { + radv_free_sem_info(&sem_info); continue; + } VkFence last = swapchain->fences[2]; swapchain->fences[2] = swapchain->fences[1]; @@ -517,6 +534,7 @@ VkResult radv_QueuePresentKHR( 1, &last, true, 1); } + radv_free_sem_info(&sem_info); } return VK_SUCCESS; |