swapchain: Signal fence and semaphore in vkAcquireNextImageKHR() 61/69261/1
authorTaekyun Kim <tkq.kim@samsung.com>
Thu, 12 May 2016 09:44:29 +0000 (18:44 +0900)
committerTaekyun Kim <tkq.kim@samsung.com>
Thu, 12 May 2016 09:44:29 +0000 (18:44 +0900)
Users should wait for fence or semaphore to be signaled in order to
use the acquired VkImage. We signal them immediately because the
dequeued buffer is already ready to be used. Later, we can do some
kinda lazy signaling by returning buffer index immediately and signal
fence or semaphore when wl_buffer.release actually arrives.

Change-Id: I59c555f939834448ce4251552452c4a1bc54f26f

src/wsi/swapchain.c

index 961e649..40b1433 100644 (file)
@@ -200,6 +200,17 @@ vk_AcquireNextImageKHR(VkDevice                     device,
                if (next == chain->buffers[i].tbm) {
                        VK_DEBUG("%s, tbm_surface: %p, index: %d\n", __func__, next, i);
                        *image_index = i;
+
+                       /* TODO: We can do optimization here by returning buffer index immediatly despite the
+                        * buffer is not released yet. The fence or semaphore will be signaled when
+                        * wl_buffer.release actually arrives. */
+
+                       if (fence != VK_NULL_HANDLE)
+                               vk_icd_signal_fence(fence);
+
+                       if (semaphore != VK_NULL_HANDLE)
+                               vk_icd_signal_semaphore(semaphore);
+
                        return VK_SUCCESS;
                }
        }