diff options
author | Keith Packard <[email protected]> | 2017-06-15 21:00:56 -0700 |
---|---|---|
committer | Keith Packard <[email protected]> | 2018-06-23 07:59:00 -0700 |
commit | 1df586be12e53917cd71b996f1d6ed2de02e4fc3 (patch) | |
tree | a3ad99a7c549a86cf50f0744b7ec7c64ccafcd1a /src/amd/vulkan/radv_device.c | |
parent | 16eb390834daaa153522e63bb17df9526eb9123c (diff) |
radv: add VK_EXT_display_control to radv driver [v5]
This extension provides fences and frame count information to direct
display contexts. It uses new kernel ioctls to provide 64-bits of
vblank sequence and nanosecond resolution.
v2:
Rework fence integration into the driver so that waiting for
any of a mixture of fence types (wsi, driver or syncobjs)
causes the driver to poll, while a list of just syncobjs or
just driver fences will block. When we get syncobjs for wsi
fences, we'll adapt to use them.
v3: Adopt Jason Ekstrand's coding conventions
Declare variables at first use, eliminate extra whitespace between
types and names. Wrap lines to 80 columns.
Suggested-by: Jason Ekstrand <[email protected]>
v4: Adapt to WSI fence API change. It now returns VkResult and
no longer has an option for relative timeouts.
v5: wsi_register_display_event and wsi_register_device_event now
use the default allocator when NULL is provided, so remove the
computation of 'alloc' here.
Signed-off-by: Keith Packard <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_device.c')
-rw-r--r-- | src/amd/vulkan/radv_device.c | 70 |
1 files changed, 55 insertions, 15 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index b72b5d969df..62e1b9dba66 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3251,6 +3251,7 @@ VkResult radv_CreateFence( if (!fence) return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); + fence->fence_wsi = NULL; fence->submitted = false; fence->signalled = !!(pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT); fence->temp_syncobj = 0; @@ -3295,6 +3296,8 @@ void radv_DestroyFence( device->ws->destroy_syncobj(device->ws, fence->syncobj); if (fence->fence) device->ws->destroy_fence(fence->fence); + if (fence->fence_wsi) + fence->fence_wsi->destroy(fence->fence_wsi); vk_free2(&device->alloc, pAllocator, fence); } @@ -3320,7 +3323,19 @@ static bool radv_all_fences_plain_and_submitted(uint32_t fenceCount, const VkFen { for (uint32_t i = 0; i < fenceCount; ++i) { RADV_FROM_HANDLE(radv_fence, fence, pFences[i]); - if (fence->syncobj || fence->temp_syncobj || (!fence->signalled && !fence->submitted)) + if (fence->fence == NULL || fence->syncobj || + fence->temp_syncobj || + (!fence->signalled && !fence->submitted)) + return false; + } + return true; +} + +static bool radv_all_fences_syncobj(uint32_t fenceCount, const VkFence *pFences) +{ + for (uint32_t i = 0; i < fenceCount; ++i) { + RADV_FROM_HANDLE(radv_fence, fence, pFences[i]); + if (fence->syncobj == 0 && fence->temp_syncobj == 0) return false; } return true; @@ -3336,7 +3351,9 @@ VkResult radv_WaitForFences( RADV_FROM_HANDLE(radv_device, device, _device); timeout = radv_get_absolute_timeout(timeout); - if (device->always_use_syncobj) { + if (device->always_use_syncobj && + radv_all_fences_syncobj(fenceCount, pFences)) + { uint32_t *handles = malloc(sizeof(uint32_t) * fenceCount); if (!handles) return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY); @@ -3406,21 +3423,34 @@ VkResult radv_WaitForFences( if (fence->signalled) continue; - if (!fence->submitted) { - while(radv_get_current_time() <= timeout && !fence->submitted) - /* Do nothing */; + if (fence->fence) { + if (!fence->submitted) { + while(radv_get_current_time() <= timeout && + !fence->submitted) + /* Do nothing */; - if (!fence->submitted) - return VK_TIMEOUT; + if (!fence->submitted) + return VK_TIMEOUT; + + /* Recheck as it may have been set by + * submitting operations. */ - /* Recheck as it may have been set by submitting operations. */ - if (fence->signalled) - continue; + if (fence->signalled) + continue; + } + + expired = device->ws->fence_wait(device->ws, + fence->fence, + true, timeout); + if (!expired) + return VK_TIMEOUT; } - expired = device->ws->fence_wait(device->ws, fence->fence, true, timeout); - if (!expired) - return VK_TIMEOUT; + if (fence->fence_wsi) { + VkResult result = fence->fence_wsi->wait(fence->fence_wsi, timeout); + if (result != VK_SUCCESS) + return result; + } fence->signalled = true; } @@ -3472,9 +3502,19 @@ VkResult radv_GetFenceStatus(VkDevice _device, VkFence _fence) return VK_SUCCESS; if (!fence->submitted) return VK_NOT_READY; - if (!device->ws->fence_wait(device->ws, fence->fence, false, 0)) - return VK_NOT_READY; + if (fence->fence) { + if (!device->ws->fence_wait(device->ws, fence->fence, false, 0)) + return VK_NOT_READY; + } + if (fence->fence_wsi) { + VkResult result = fence->fence_wsi->wait(fence->fence_wsi, 0); + if (result != VK_SUCCESS) { + if (result == VK_TIMEOUT) + return VK_NOT_READY; + return result; + } + } return VK_SUCCESS; } |