wayland-egl-tizen: Changed API name render_sync_fd to commit_sync_fd. 52/227452/2
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 12 Mar 2020 05:04:16 +0000 (14:04 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 17 Mar 2020 05:27:40 +0000 (14:27 +0900)
 - If the user wants to know the render done using EGLSyncKHR,
  tpl_surface_dequeue_buffer, tpl_surface_enqueue_buffer and
  wl_surface_commit occur at similar moments.
   Therefore, it only tells when wl_surface_commit is done,
  but does not guarantee render done.
 - If EGLSyncKHR or dma_buf implicit fence is not used,
  render done can be guaranteed.

Change-Id: I43d7bdd10a33d0b559ecd1d219261bbb5415b574
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c
src/wayland-egl-tizen/wayland-egl-tizen-priv.h
src/wayland-egl-tizen/wayland-egl-tizen.c
src/wayland-egl-tizen/wayland-egl-tizen.h

index 6368d912259db1d9b8f4b34125274de302556717..01763833496e40ee2d9eecbc5af30ee8cc051780 100755 (executable)
@@ -123,9 +123,9 @@ struct _twe_wl_surf_source {
        twe_wl_disp_source *disp_source;
        twe_del_source *surf_del_source;
 
-       tbm_fd render_sync_timeline;
-       int render_sync_timestamp;
-       unsigned int render_sync_fence_number;
+       tbm_fd commit_sync_timeline;
+       int commit_sync_timestamp;
+       unsigned int commit_sync_fence_number;
 
        tbm_fd presentation_sync_timeline;
        int presentation_sync_timestamp;
@@ -1248,7 +1248,7 @@ __cb_set_window_serial_callback(struct wl_egl_window *wl_egl_window,
 }
 
 static int
-__cb_create_render_sync_fd(struct wl_egl_window *wl_egl_window, void *private)
+__cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private)
 {
        TPL_ASSERT(private);
        TPL_ASSERT(wl_egl_window);
@@ -1256,7 +1256,7 @@ __cb_create_render_sync_fd(struct wl_egl_window *wl_egl_window, void *private)
        struct tizen_private *tizen_private = (struct tizen_private *)private;
        twe_wl_surf_source *surf_source = NULL;
 
-       tbm_fd render_sync_fd = -1;
+       tbm_fd commit_sync_fd = -1;
 
        surf_source = (twe_wl_surf_source *)tizen_private->data;
        if (!surf_source) {
@@ -1264,19 +1264,19 @@ __cb_create_render_sync_fd(struct wl_egl_window *wl_egl_window, void *private)
                return -1;
        }
 
-       if (surf_source->render_sync_timeline != -1) {
+       if (surf_source->commit_sync_timeline != -1) {
                char name[32];
-               snprintf(name, 32, "%u", surf_source->render_sync_fence_number++);
-               render_sync_fd = tbm_sync_fence_create(surf_source->render_sync_timeline,
+               snprintf(name, 32, "%u", surf_source->commit_sync_fence_number++);
+               commit_sync_fd = tbm_sync_fence_create(surf_source->commit_sync_timeline,
                                                                                           name,
-                                                                                          surf_source->render_sync_timestamp + 1);
-               TPL_DEBUG("[RENDER_SYNC] surf_source(%p) timeline(%d) timestamp(%d) name(%s) sync_fence(%d)",
-                                 surf_source, surf_source->render_sync_timeline, surf_source->render_sync_timestamp,
-                                 name, render_sync_fd);
+                                                                                          surf_source->commit_sync_timestamp + 1);
+               TPL_DEBUG("[COMMIT_SYNC] surf_source(%p) timeline(%d) timestamp(%d) name(%s) sync_fence(%d)",
+                                 surf_source, surf_source->commit_sync_timeline, surf_source->commit_sync_timestamp,
+                                 name, commit_sync_fd);
 
-               TRACE_ASYNC_BEGIN(surf_source->render_sync_timestamp + 1, "[SYNC_FENCE]");
+               TRACE_ASYNC_BEGIN(surf_source->commit_sync_timestamp + 1, "[SYNC_FENCE]");
 
-               return render_sync_fd;
+               return commit_sync_fd;
        }
 
        return -1;
@@ -1335,7 +1335,7 @@ __cb_merge_sync_fds(void *private, int sync_fd1, int sync_fd2)
                return -1;
        }
 
-       if (surf_source->render_sync_timeline == -1 &&
+       if (surf_source->commit_sync_timeline == -1 &&
                surf_source->presentation_sync_timeline == -1) {
                TPL_ERR("There is no timeline for any sync fd in surf_source(%p)", surf_source);
                return -1;
@@ -1682,18 +1682,6 @@ _twe_surface_trace_enqueue_buffer(twe_wl_surf_source *surf_source,
                return;
        }
 
-       if (surf_source->render_sync_timeline != -1) {
-
-               surf_source->render_sync_timestamp++;
-               TRACE_ASYNC_END(surf_source->render_sync_timestamp, "[SYNC_FENCE]");
-
-               TPL_DEBUG("[RENDER_SYNC][INC] surf_source(%p) timeline(%d) timestamp(%d)",
-                                 surf_source, surf_source->render_sync_timeline, surf_source->render_sync_timestamp);
-               if (!tbm_sync_timeline_inc(surf_source->render_sync_timeline, 1)) {
-                       TPL_ERR("Failed to increase timeline(%d)", surf_source->render_sync_timeline);
-               }
-       }
-
        if (surf_source->in_use_buffers) {
                g_mutex_lock(&surf_source->surf_mutex);
                /* Stop tracking of this canceled tbm_surface */
@@ -2193,6 +2181,17 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source,
        if (surf_source->committed_buffers) {
                __tpl_list_push_back(surf_source->committed_buffers, tbm_surface);
        }
+
+       if (surf_source->commit_sync_timeline != -1) {
+               surf_source->commit_sync_timestamp++;
+               TRACE_ASYNC_END(surf_source->commit_sync_timestamp, "[SYNC_FENCE]");
+
+               TPL_DEBUG("[COMMIT_SYNC][INC] surf_source(%p) timeline(%d) timestamp(%d)",
+                                 surf_source, surf_source->commit_sync_timeline, surf_source->commit_sync_timestamp);
+               if (!tbm_sync_timeline_inc(surf_source->commit_sync_timeline, 1)) {
+                       TPL_ERR("Failed to increase timeline(%d)", surf_source->commit_sync_timeline);
+               }
+       }
 }
 
 /* The following function _twe_thread_wl_surface_acquire_and_commit can be
@@ -2751,9 +2750,9 @@ twe_surface_add(twe_thread* thread,
 
        source->post_interval = 1;
 
-       source->render_sync_timeline = tbm_sync_timeline_create();
-       source->render_sync_timestamp = 0;
-       source->render_sync_fence_number = 0;
+       source->commit_sync_timeline = tbm_sync_timeline_create();
+       source->commit_sync_timestamp = 0;
+       source->commit_sync_fence_number = 0;
 
        source->presentation_sync_timeline = tbm_sync_timeline_create();
        source->presentation_sync_timestamp = 0;
@@ -2779,7 +2778,7 @@ twe_surface_add(twe_thread* thread,
                                __cb_get_rotation_capability;
                        private->set_window_serial_callback = (void *)
                                __cb_set_window_serial_callback;
-                       private->create_render_sync_fd = (void *)__cb_create_render_sync_fd;
+                       private->create_commit_sync_fd = (void *)__cb_create_commit_sync_fd;
                        private->create_presentation_sync_fd = (void *)__cb_create_presentation_sync_fd;
                        private->merge_sync_fds = (void *)__cb_merge_sync_fds;
 
index 9a6b8123fde3af28b4d91505383bff2768758d7a..caeb5b0eb15df156d31bf2397db7659f507275af 100644 (file)
@@ -22,7 +22,7 @@ struct tizen_private {
        int (*get_rotation_capability)(struct wl_egl_window *, void *);
        void (*set_frontbuffer_callback)(struct wl_egl_window *, void *, int);
        void (*set_window_serial_callback)(struct wl_egl_window *, void *, unsigned int);
-       int (*create_render_sync_fd)(struct wl_egl_window *, void *);
+       int (*create_commit_sync_fd)(struct wl_egl_window *, void *);
        int (*create_presentation_sync_fd)(struct wl_egl_window *, void *);
        int (*merge_sync_fds)(void *, int, int);
 };
@@ -43,7 +43,7 @@ static struct tizen_private* tizen_private_create()
                private->get_rotation_capability = NULL;
                private->set_window_serial_callback = NULL;
                private->set_frontbuffer_callback = NULL;
-               private->create_render_sync_fd = NULL;
+               private->create_commit_sync_fd = NULL;
                private->create_presentation_sync_fd = NULL;
                private->merge_sync_fds = NULL;
        }
index 70e66a37f7fb8a99fa1850bb97bdf1228593a375..b4e679c1a27fbf1462afecf6e38fb4a13c6d0764 100644 (file)
@@ -253,7 +253,7 @@ wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window,
 }
 
 int
-wl_egl_window_tizen_create_render_sync_fd(struct wl_egl_window *egl_window)
+wl_egl_window_tizen_create_commit_sync_fd(struct wl_egl_window *egl_window)
 {
        struct tizen_private *private = NULL;
 
@@ -268,8 +268,8 @@ wl_egl_window_tizen_create_render_sync_fd(struct wl_egl_window *egl_window)
                return -1;
        }
 
-       if (private->create_render_sync_fd)
-               return private->create_render_sync_fd(egl_window, egl_window->driver_private);
+       if (private->create_commit_sync_fd)
+               return private->create_commit_sync_fd(egl_window, egl_window->driver_private);
 
        return -1;
 }
index 041488cbf7371a18c7289889be1ef44e0a0fd71b..921b193e69cc6e82e05a8ce87eeccf372715bbeb 100644 (file)
@@ -75,20 +75,21 @@ wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window,
 
 /* temporary APIs for testing sync feature */
 /**
- * Create a sync fence fd that can tell render done.
+ * Create a sync fence fd that can tell wl_surface_commit done.
  *
  * If eglSwapBuffers works async, it returns fd which tells
- * when the render job is finished.
+ * when wl_surface_commit called.
  * This fd can wait asynchronously via poll or select.
  *
  * Important *
  * This requires the following premise:
- *  - After ddk calls libplpl-egl's tpl_surface_dequeue_buffer to get the buffer,
- *   and until it calls tpl_surface_enqueue_buffer,
- *      it is called the gpu rendering job interval.
- *  - Therefore, when using the dma_buf implicit fence,
- *   there is no guarantee that the rendering job is finished
- *   with the fence obtained through this API.
+ *  - If the user wants to know the render done using EGLSyncKHR,
+ *   tpl_surface_dequeue_buffer, tpl_surface_enqueue_buffer and
+ *   wl_surface_commit occur at similar moments.
+ *    Therefore, it only tells when wl_surface_commit is done,
+ *   but does not guarantee render done.
+ *  - If EGLSyncKHR or dma_buf implicit fence is not used,
+ *   render done can be guaranteed.
  *
  * The fence_fd obtained through this function is one-time available,
  * can not be reused, so caller must close it when finished using it.
@@ -97,7 +98,7 @@ wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window,
  * @return sync fd on success, -1 on failure.
  */
 int
-wl_egl_window_tizen_create_render_sync_fd(struct wl_egl_window *egl_window);
+wl_egl_window_tizen_create_commit_sync_fd(struct wl_egl_window *egl_window);
 
 /**
  * Create a sync fence fd that can tell presentation done.