diff options
author | Bas Nieuwenhuizen <[email protected]> | 2018-02-26 23:48:27 +0100 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2018-03-01 01:07:18 +0100 |
commit | 34bd5e2e2e8d9c213b051152f7a8b731151d9be5 (patch) | |
tree | 02635b72eebcb6d1417c4bd8332358196142f709 /src/amd/vulkan/radv_device.c | |
parent | 6968d782d3063c639e80dbcf6df944902d72692f (diff) |
radv: Implement more efficient !waitAll fence waiting.
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/amd/vulkan/radv_device.c')
-rw-r--r-- | src/amd/vulkan/radv_device.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 8eadd8f2037..21ccfa679f8 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -2907,6 +2907,17 @@ static uint64_t radv_get_absolute_timeout(uint64_t timeout) return current_time + timeout; } + +static bool radv_all_fences_plain_and_submitted(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 || fence->temp_syncobj || (!fence->signalled && !fence->submitted)) + return false; + } + return true; +} + VkResult radv_WaitForFences( VkDevice _device, uint32_t fenceCount, @@ -2918,6 +2929,31 @@ VkResult radv_WaitForFences( timeout = radv_get_absolute_timeout(timeout); if (!waitAll && fenceCount > 1) { + /* Not doing this by default for waitAll, due to needing to allocate twice. */ + if (device->physical_device->rad_info.drm_minor >= 10 && radv_all_fences_plain_and_submitted(fenceCount, pFences)) { + uint32_t wait_count = 0; + struct radeon_winsys_fence **fences = malloc(sizeof(struct radeon_winsys_fence *) * fenceCount); + if (!fences) + return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); + + for (uint32_t i = 0; i < fenceCount; ++i) { + RADV_FROM_HANDLE(radv_fence, fence, pFences[i]); + + if (fence->signalled) { + free(fences); + return VK_SUCCESS; + } + + fences[wait_count++] = fence->fence; + } + + bool success = device->ws->fences_wait(device->ws, fences, wait_count, + waitAll, timeout - radv_get_current_time()); + + free(fences); + return success ? VK_SUCCESS : VK_TIMEOUT; + } + while(radv_get_current_time() <= timeout) { for (uint32_t i = 0; i < fenceCount; ++i) { if (radv_GetFenceStatus(_device, pFences[i]) == VK_SUCCESS) |