radv: Implement WaitForFences with !waitAll.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 26 Feb 2018 21:50:41 +0000 (22:50 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 1 Mar 2018 00:07:18 +0000 (01:07 +0100)
Nothing to do except using a busy wait loop. At least for old kernels.

A better implementation for newer kernels to come later.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105255
Fixes: f4e499ec79 "radv: add initial non-conformant radv vulkan driver"
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c

index 92865122ad541eb9604d1ac91fbf34bf2842fa10..24ea3b689ecb9ce08fc9e1b7da40e5f53f60689a 100644 (file)
@@ -2890,13 +2890,17 @@ void radv_DestroyFence(
        vk_free2(&device->alloc, pAllocator, fence);
 }
 
-static uint64_t radv_get_absolute_timeout(uint64_t timeout)
+
+static uint64_t radv_get_current_time()
 {
-       uint64_t current_time;
        struct timespec tv;
-
        clock_gettime(CLOCK_MONOTONIC, &tv);
-       current_time = tv.tv_nsec + tv.tv_sec*1000000000ull;
+       return tv.tv_nsec + tv.tv_sec*1000000000ull;
+}
+
+static uint64_t radv_get_absolute_timeout(uint64_t timeout)
+{
+       uint64_t current_time = radv_get_current_time();
 
        timeout = MIN2(UINT64_MAX - current_time, timeout);
 
@@ -2914,7 +2918,13 @@ VkResult radv_WaitForFences(
        timeout = radv_get_absolute_timeout(timeout);
 
        if (!waitAll && fenceCount > 1) {
-               fprintf(stderr, "radv: WaitForFences without waitAll not implemented yet\n");
+               while(radv_get_current_time() <= timeout) {
+                       for (uint32_t i = 0; i < fenceCount; ++i) {
+                               if (radv_GetFenceStatus(_device, pFences[i]) == VK_SUCCESS)
+                                       return VK_SUCCESS;
+                       }
+               }
+               return VK_TIMEOUT;
        }
 
        for (uint32_t i = 0; i < fenceCount; ++i) {