zink: keep a count of async presents occuring for a given swapchain
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 9 Jun 2022 13:19:18 +0000 (09:19 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 13 Jun 2022 17:44:27 +0000 (17:44 +0000)
this provides info about whether a swapchain is in use in another thread

Fixes: 8ade5588e39 ("zink: add kopper api")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16932>

src/gallium/drivers/zink/zink_kopper.c
src/gallium/drivers/zink/zink_kopper.h

index 3cdff02..cfce107 100644 (file)
@@ -634,6 +634,8 @@ kopper_present(void *data, void *gdata, int thread_idx)
       _mesa_hash_table_insert(swapchain->presents, (void*)(uintptr_t)next, arr);
    }
    util_dynarray_append(arr, VkSemaphore, cpi->sem);
+   if (thread_idx != -1)
+      p_atomic_dec(&swapchain->async_presents);
    free(cpi);
 }
 
@@ -660,10 +662,11 @@ zink_kopper_present_queue(struct zink_screen *screen, struct zink_resource *res)
    cpi->info.pResults = NULL;
    res->obj->present = VK_NULL_HANDLE;
    if (util_queue_is_initialized(&screen->flush_queue)) {
+      p_atomic_inc(&cpi->swapchain->async_presents);
       util_queue_add_job(&screen->flush_queue, cpi, &cdt->present_fence,
                          kopper_present, NULL, 0);
    } else {
-      kopper_present(cpi, screen, 0);
+      kopper_present(cpi, screen, -1);
    }
    res->obj->acquire = VK_NULL_HANDLE;
    res->obj->indefinite_acquire = res->obj->acquired = false;
index 01a3cca..836dac0 100644 (file)
@@ -41,6 +41,7 @@ struct kopper_swapchain {
    VkSwapchainCreateInfoKHR scci;
    unsigned num_acquires;
    unsigned max_acquires;
+   unsigned async_presents;
 };
 
 enum kopper_type {