turnip: signal fence and semaphore in AcquireNextImage2KHR
authorJonathan Marek <jonathan@marek.ca>
Tue, 15 Sep 2020 23:46:24 +0000 (19:46 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 30 Sep 2020 00:32:40 +0000 (00:32 +0000)
As a result of doing semaphores correctly, this is needed for things to
work correctly.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6719>

src/freedreno/vulkan/tu_drm.c
src/freedreno/vulkan/tu_kgsl.c
src/freedreno/vulkan/tu_private.h
src/freedreno/vulkan/tu_wsi.c

index c79d93a..28b887a 100644 (file)
@@ -875,3 +875,22 @@ tu_GetFenceStatus(VkDevice _device, VkFence _fence)
       result = VK_NOT_READY;
    return result;
 }
+
+int
+tu_signal_fences(struct tu_device *device, struct tu_syncobj *fence1, struct tu_syncobj *fence2)
+{
+   uint32_t handles[2], count = 0;
+   if (fence1)
+      handles[count++] = fence1->temporary ?: fence1->permanent;
+
+   if (fence2)
+      handles[count++] = fence2->temporary ?: fence2->permanent;
+
+   if (!count)
+      return 0;
+
+   return ioctl(device->fd, DRM_IOCTL_SYNCOBJ_SIGNAL, &(struct drm_syncobj_array) {
+      .handles = (uintptr_t) handles,
+      .count_handles = count
+   });
+}
index 155d7f7..cabdb28 100644 (file)
@@ -402,3 +402,10 @@ tu_GetFenceStatus(VkDevice _device, VkFence _fence)
    tu_finishme("GetFenceStatus");
    return VK_SUCCESS;
 }
+
+int
+tu_signal_fences(struct tu_device *device, struct tu_syncobj *fence1, struct tu_syncobj *fence2)
+{
+   tu_finishme("tu_signal_fences");
+   return 0;
+}
index 2e14f3f..1fcb09c 100644 (file)
@@ -1512,6 +1512,9 @@ tu_drm_submitqueue_new(const struct tu_device *dev,
 void
 tu_drm_submitqueue_close(const struct tu_device *dev, uint32_t queue_id);
 
+int
+tu_signal_fences(struct tu_device *device, struct tu_syncobj *fence1, struct tu_syncobj *fence2);
+
 #define TU_DEFINE_HANDLE_CASTS(__tu_type, __VkType)                          \
                                                                              \
    static inline struct __tu_type *__tu_type##_from_handle(__VkType _handle) \
index d7c4bda..7a1f7dd 100644 (file)
@@ -228,12 +228,16 @@ tu_AcquireNextImage2KHR(VkDevice _device,
                         uint32_t *pImageIndex)
 {
    TU_FROM_HANDLE(tu_device, device, _device);
+   TU_FROM_HANDLE(tu_syncobj, fence, pAcquireInfo->fence);
+   TU_FROM_HANDLE(tu_syncobj, semaphore, pAcquireInfo->semaphore);
+
    struct tu_physical_device *pdevice = device->physical_device;
 
    VkResult result = wsi_common_acquire_next_image2(
       &pdevice->wsi_device, _device, pAcquireInfo, pImageIndex);
 
-   /* TODO signal fence and semaphore */
+   /* signal fence/semaphore - image is available immediately */
+   tu_signal_fences(device, fence, semaphore);
 
    return result;
 }