tpl_wayland_egl_thread: Added an internal API to create sync_fd. 73/161973/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Fri, 20 Oct 2017 06:51:24 +0000 (15:51 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Tue, 28 Nov 2017 10:49:36 +0000 (19:49 +0900)
Change-Id: I96cdca8101a578b001e1bb5e85448091e6d39060
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c
src/tpl_wayland_egl_thread.h

index 9acfe83..ad49932 100644 (file)
@@ -1656,6 +1656,8 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source,
                                          surf_source->swapchain_properties.height);
        wl_surface_commit(wl_surface);
 
+       buf_info->sync_timestamp++;
+
        if (surf_source->swapchain_properties.present_mode
                        == TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED) {
                if (_twe_surface_wait_vblank(surf_source) != TPL_ERROR_NONE)
@@ -2602,7 +2604,6 @@ twe_surface_set_sync_fd(tbm_surface_h tbm_surface, tbm_fd sync_fd)
        }
 
        buf_info->draw_done_fence = sync_fd;
-
        buf_info->fence_waiting_thread = g_thread_new("fence_waiting_thread",
                                                                                                  _twe_sync_fence_waiting,
                                                                                                  buf_info);
@@ -2610,6 +2611,35 @@ twe_surface_set_sync_fd(tbm_surface_h tbm_surface, tbm_fd sync_fd)
        return TPL_ERROR_NONE;
 }
 
+tbm_fd
+twe_surface_create_sync_fd(tbm_surface_h tbm_surface)
+{
+       twe_wl_buffer_info *buf_info = NULL;
+       tbm_fd sync_fd = -1;
+
+       tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO,
+                                                                          (void **)&buf_info);
+
+       if (buf_info) {
+               if (buf_info->sync_timestamp) {
+                       /* first return -1 */
+                       char name[32];
+                       snprintf(name, 32, "%d",
+                                        tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)));
+                       sync_fd = tbm_sync_fence_create(buf_info->sync_timeline,
+                                                                                       name,
+                                                                                       buf_info->sync_timestamp);
+                       if (sync_fd == -1) {
+                               char buf[1024];
+                               strerror_r(errno, buf, sizeof(buf));
+                               TPL_ERR("Failed to create TBM sync fence: %d(%s)", errno, buf);
+                       }
+               }
+       }
+
+       return sync_fd;
+}
+
 tpl_result_t
 twe_surface_wait_dequeueable(twe_surface_h twe_surface, uint64_t timeout_ns)
 {
index e21e6bd..4c2fd4f 100644 (file)
@@ -86,6 +86,9 @@ twe_surface_set_damage_region(tbm_surface_h tbm_surface,
 tpl_result_t
 twe_surface_set_sync_fd(tbm_surface_h tbm_surface, tbm_fd wait_fd);
 
+tbm_fd
+twe_surface_create_sync_fd(tbm_surface_h tbm_surface);
+
 tpl_result_t
 twe_surface_wait_dequeueable(twe_surface_h twe_surface, uint64_t timeout_ns);