lavapipe: allow timeline progress in GetSemaphoreCounterValue
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 18 Mar 2022 12:48:39 +0000 (08:48 -0400)
committerMarge Bot <emma+marge@anholt.net>
Wed, 30 Mar 2022 02:47:45 +0000 (02:47 +0000)
the vulkan spec doesn't explicitly state whether this function progresses
a given semaphore's timeline, and apparently there are some cases where
it's assumed that progress occurs if this function is called in a loop
instead of WaitSemaphores, so check the current fence for completion

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15453>

src/gallium/frontends/lavapipe/lvp_device.c

index 2b6ffdb..fb37b45 100644 (file)
@@ -2577,7 +2577,16 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_GetSemaphoreCounterValue(
    LVP_FROM_HANDLE(lvp_semaphore, sema, _semaphore);
    simple_mtx_lock(&sema->lock);
    prune_semaphore_links(device, sema, device->queue.last_finished);
-   *pValue = sema->current;
+   struct lvp_semaphore_timeline *tl = find_semaphore_timeline(sema, sema->current);
+   if (tl && fence_finish(device, tl->fence, 0)) {
+      simple_mtx_lock(&device->queue.last_lock);
+      if (tl->timeline > device->queue.last_finished)
+         device->queue.last_finished = tl->timeline;
+      simple_mtx_unlock(&device->queue.last_lock);
+      *pValue = tl->signal;
+   } else {
+      *pValue = sema->current;
+   }
    simple_mtx_unlock(&sema->lock);
    return VK_SUCCESS;
 }