From 728061b96891290c02297f3097d790221f624a8d Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Tue, 15 Sep 2020 19:46:24 -0400 Subject: [PATCH] turnip: signal fence and semaphore in AcquireNextImage2KHR As a result of doing semaphores correctly, this is needed for things to work correctly. Signed-off-by: Jonathan Marek Part-of: --- src/freedreno/vulkan/tu_drm.c | 19 +++++++++++++++++++ src/freedreno/vulkan/tu_kgsl.c | 7 +++++++ src/freedreno/vulkan/tu_private.h | 3 +++ src/freedreno/vulkan/tu_wsi.c | 6 +++++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c index c79d93a..28b887a 100644 --- a/src/freedreno/vulkan/tu_drm.c +++ b/src/freedreno/vulkan/tu_drm.c @@ -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 + }); +} diff --git a/src/freedreno/vulkan/tu_kgsl.c b/src/freedreno/vulkan/tu_kgsl.c index 155d7f7..cabdb28 100644 --- a/src/freedreno/vulkan/tu_kgsl.c +++ b/src/freedreno/vulkan/tu_kgsl.c @@ -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; +} diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 2e14f3f..1fcb09c 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -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) \ diff --git a/src/freedreno/vulkan/tu_wsi.c b/src/freedreno/vulkan/tu_wsi.c index d7c4bda..7a1f7dd 100644 --- a/src/freedreno/vulkan/tu_wsi.c +++ b/src/freedreno/vulkan/tu_wsi.c @@ -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; } -- 2.7.4