From 73ffe63a2aea71b17faae0312d89755beaac5797 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 9 Nov 2020 16:09:06 +0900 Subject: [PATCH 01/16] Wait until all fences imported from outside are signaled. Change-Id: I209b76c5badfb5c4881e8afd850e8b1db401d2a2 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index cb62f4f..35305a7 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3298,6 +3298,14 @@ twe_surface_del(twe_surface_h twe_surface) return TPL_ERROR_INVALID_PARAMETER; } + if (surf_source->use_sync_fence && surf_source->fence_waiting_sources) { + TPL_DEBUG("twe_surface(%p) is waiting for all fences to be signaled.", + surf_source); + while (!__tpl_list_is_empty(surf_source->fence_waiting_sources)) { + __tpl_util_sys_yield(); + } + } + TPL_LOG_T(BACKEND, "twe_surface(%p) will be destroyed in thread", twe_surface); surf_del_source = surf_source->surf_del_source; -- 2.7.4 From 8341480a586d217c446f0f8a5e8215a5c6ed6757 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 9 Nov 2020 16:58:37 +0900 Subject: [PATCH 02/16] Package version up to 1.7.14 Change-Id: Id03c74ca31661b1a08a1b3062ac956091240a319 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 98e0c89..dd3f418 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 7 -%define TPL_VERSION_PATCH 13 +%define TPL_VERSION_PATCH 14 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From f55d4b7fdd9081e9772b19ac056a700f911a712b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Nov 2020 11:30:11 +0900 Subject: [PATCH 03/16] Added null checking to prevent assert checking failure. Change-Id: I8bb6b5c21d1ea6721eef717525f1a87e0e8bf412 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 35305a7..9d45f7b 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1099,7 +1099,8 @@ _twe_thread_wl_disp_source_destroy(void *source) _twe_display_print_err(disp_source, "dispatch_queue_pending"); } - __tpl_list_free(disp_source->presentation_feedbacks, (tpl_free_func_t)free); + if (disp_source->presentation_feedbacks) + __tpl_list_free(disp_source->presentation_feedbacks, (tpl_free_func_t)free); wl_event_queue_destroy(disp_source->ev_queue); g_mutex_unlock(&disp_source->wl_event_mutex); -- 2.7.4 From 311e4aacfc7b4b75eb31d34cad5e075f4a561c42 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Nov 2020 11:36:37 +0900 Subject: [PATCH 04/16] Delete unused variable. Change-Id: Id78516b6815c2fbadcf60c0a82830de5f2767cb6 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 9d45f7b..e9630cb 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2420,7 +2420,6 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, struct wl_surface *wl_surface = surf_source->surf; struct wl_egl_window *wl_egl_window = surf_source->wl_egl_window; uint32_t version; - struct wp_presentation_feedback *p_feedback; tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, (void **)&buf_info); -- 2.7.4 From 6d67777ed6ff087d41c7b12bce2c262dc036759b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Nov 2020 11:31:15 +0900 Subject: [PATCH 05/16] Package version up to 1.7.15 Change-Id: Ife7e7a36eb11974aa1b1ec570a9af87b708948a6 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index dd3f418..69369e8 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 7 -%define TPL_VERSION_PATCH 14 +%define TPL_VERSION_PATCH 15 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 901351750e27d9e439a24608a73b49f000b62578 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 19 Nov 2020 11:13:17 +0900 Subject: [PATCH 06/16] Initialize presentation_feedbacks list to NULL when created. Change-Id: Id969409745c1c6a5bef01c49b80e6c37535e5409 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index e9630cb..84b6d86 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1099,7 +1099,7 @@ _twe_thread_wl_disp_source_destroy(void *source) _twe_display_print_err(disp_source, "dispatch_queue_pending"); } - if (disp_source->presentation_feedbacks) + if (disp_source->presentation && disp_source->presentation_feedbacks) __tpl_list_free(disp_source->presentation_feedbacks, (tpl_free_func_t)free); wl_event_queue_destroy(disp_source->ev_queue); @@ -1174,6 +1174,8 @@ twe_display_add(twe_thread* thread, TPL_DISPLAY_PRESENT_MODE_FIFO; _twe_display_wayland_init(source); + source->presentation_feedbacks = NULL; + if (source->presentation) source->presentation_feedbacks = __tpl_list_alloc(); @@ -2399,8 +2401,9 @@ __cb_presentation_feedback_discarded(void *data, if (presentation_feedback) wp_presentation_feedback_destroy(presentation_feedback); - __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, - TPL_FIRST, (tpl_free_func_t)free); + if (disp_source->presentation_feedbacks) + __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, + TPL_FIRST, (tpl_free_func_t)free); g_mutex_unlock(&surf_source->pst_mutex); } @@ -2442,7 +2445,9 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, feedback_info->surf_source = surf_source; wp_presentation_feedback_add_listener(feedback_info->feedback, &feedback_listener, feedback_info); - __tpl_list_push_back(disp_source->presentation_feedbacks, (void *)feedback_info); + if (disp_source->presentation_feedbacks) + __tpl_list_push_back(disp_source->presentation_feedbacks, + (void *)feedback_info); } } g_mutex_unlock(&surf_source->pst_mutex); -- 2.7.4 From 1c8bdbd73cecd710491dbc118f63fb7470acd5e6 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 19 Nov 2020 11:14:07 +0900 Subject: [PATCH 07/16] Package version up to 1.7.16 Change-Id: If7650b7bffa78d10dd1960b6f341ebfb8e5f84b3 Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 69369e8..8564405 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -4,7 +4,7 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 %define TPL_VERSION_MINOR 7 -%define TPL_VERSION_PATCH 15 +%define TPL_VERSION_PATCH 16 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From e57f44eaa847f9797dfec5c2deaec33339533de9 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 25 Nov 2020 13:43:42 +0900 Subject: [PATCH 08/16] Fix damage rectangle of buffer when it needs to add full damage The damage rectangle is specified in buffer coordinates, where x and y specify the upper left corner of the damage rectangle. geometry of window should not be considered. Change-Id: I68153ec6106f80d6537683276bc1634189ad96e2 --- src/tpl_wayland_egl.c | 4 ++-- src/tpl_wayland_egl_thread.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 1a57fef..1491898 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -898,8 +898,8 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, wayland_egl_buffer->height); } else { wl_surface_damage_buffer(wl_egl_window->surface, - wayland_egl_buffer->dx, - wayland_egl_buffer->dy, + 0, + 0, wayland_egl_buffer->width, wayland_egl_buffer->height); } diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 84b6d86..941a9eb 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2480,7 +2480,7 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, buf_info->width, buf_info->height); } else { wl_surface_damage_buffer(wl_surface, - buf_info->dx, buf_info->dy, + 0, 0, buf_info->width, buf_info->height); } } else { -- 2.7.4 From 2658bfbd8b1c25b93ac60ae11591f92ac1f8f948 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 4 Dec 2020 13:05:43 +0900 Subject: [PATCH 09/16] re-implement commit_sync without using sync_timeline Change-Id: Ic5f06eb4da1a37a82e251be5d0d9b5bb3c313a56 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 134 +++++++++++++++++++++++++++++++------------ 1 file changed, 97 insertions(+), 37 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 941a9eb..fa92a87 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -144,9 +144,10 @@ struct _twe_wl_surf_source { twe_wl_disp_source *disp_source; twe_del_source *surf_del_source; - tbm_fd commit_sync_timeline; - int commit_sync_timestamp; - unsigned int commit_sync_fence_number; + struct { + GMutex mutex; + int fd; + } commit_sync; tbm_fd presentation_sync_timeline; int presentation_sync_timestamp; @@ -197,8 +198,6 @@ struct _twe_wl_buffer_info { tbm_fd sync_fd; tpl_bool_t is_vk_image; - unsigned int commit_sync_ts_backup; - tbm_surface_h tbm_surface; twe_wl_surf_source *surf_source; @@ -216,6 +215,8 @@ struct _twe_wl_buffer_info { /* each buffers own its acquire_fence_fd. until it passes ownership * to it to SERVER */ int acquire_fence_fd; + + int commit_sync_fd; }; struct _twe_fence_wait_source { @@ -539,6 +540,26 @@ _twe_thread_tdm_source_destroy(void *source) g_source_unref(&tdm_source->gsource); } +static int +_write_to_eventfd(int eventfd) +{ + uint64_t value = 1; + int ret; + + if (eventfd == -1) { + TPL_ERR("Invalid fd(-1)"); + return -1; + } + + ret = write(eventfd, &value, sizeof(uint64_t)); + if (ret == -1) { + TPL_ERR("failed to write to fd(%d)", eventfd); + return ret; + } + + return ret; +} + twe_thread* twe_thread_create(void) { @@ -1451,7 +1472,7 @@ __cb_create_commit_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 commit_sync_fd = -1; + int commit_sync_fd = -1; surf_source = (twe_wl_surf_source *)tizen_private->data; if (!surf_source) { @@ -1459,22 +1480,35 @@ __cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private) return -1; } - if (surf_source->commit_sync_timeline != -1) { - char name[32]; - 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->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 + 1, - name, commit_sync_fd); - - TRACE_ASYNC_BEGIN(surf_source->commit_sync_timestamp + 1, "[SYNC_FENCE]"); + g_mutex_lock(&surf_source->commit_sync.mutex); + if (surf_source->commit_sync.fd != -1) { + commit_sync_fd = dup(surf_source->commit_sync.fd); + TRACE_MARK("[ONLY_DUP] commit_sync_fd(%d) dup(%d)", + surf_source->commit_sync.fd, commit_sync_fd); + TPL_DEBUG("[DUP_COMMIT_SYNC] surf_source(%p) commit_sync_fd(%d) dup(%d)", + surf_source, surf_source->commit_sync.fd, commit_sync_fd); + g_mutex_unlock(&surf_source->commit_sync.mutex); return commit_sync_fd; } - return -1; + surf_source->commit_sync.fd = eventfd(0, EFD_CLOEXEC); + if (surf_source->commit_sync.fd == -1) { + TPL_ERR("Failed to create commit_sync_fd. twe_surface(%p)", surf_source); + g_mutex_unlock(&surf_source->commit_sync.mutex); + return -1; + } + + commit_sync_fd = dup(surf_source->commit_sync.fd); + + TRACE_MARK("[CREATE] commit_sync_fd(%d) dup(%d)", + surf_source->commit_sync.fd, commit_sync_fd); + TPL_DEBUG("[CREATE_COMMIT_SYNC] surf_source(%p) commit_sync_fd(%d)", + surf_source, commit_sync_fd); + + g_mutex_unlock(&surf_source->commit_sync.mutex); + + return commit_sync_fd; } static int @@ -1536,8 +1570,7 @@ __cb_merge_sync_fds(void *private, int sync_fd1, int sync_fd2) return -1; } - if (surf_source->commit_sync_timeline == -1 && - surf_source->presentation_sync_timeline == -1) { + if (surf_source->presentation_sync_timeline == -1) { TPL_ERR("There is no timeline for any sync fd in surf_source(%p)", surf_source); return -1; } @@ -1613,6 +1646,14 @@ __cb_twe_buffer_free_callback(twe_wl_buffer_info *buf_info) wayland_tbm_client_destroy_buffer(disp_source->wl_tbm_client, (void *)buf_info->wl_buffer); + if (buf_info->commit_sync_fd != -1) { + int ret = _write_to_eventfd(buf_info->commit_sync_fd); + if (ret == -1) + TPL_ERR("Failed to send commit_sync signal to fd(%d)", buf_info->commit_sync_fd); + close(buf_info->commit_sync_fd); + buf_info->commit_sync_fd = -1; + } + if (buf_info->sync_timeline != -1) { close(buf_info->sync_timeline); buf_info->sync_timeline = -1; @@ -1844,8 +1885,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->need_to_commit = TPL_TRUE; buf_info->sync_fd = -1; buf_info->acquire_fence_fd = -1; - - buf_info->commit_sync_ts_backup = ++surf_source->commit_sync_timestamp; + buf_info->commit_sync_fd = -1; if (surf_source->in_use_buffers) { g_mutex_lock(&surf_source->surf_mutex); @@ -1931,9 +1971,9 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->sync_fd = -1; buf_info->sync_timeline = -1; buf_info->is_vk_image = surf_source->disp_source->is_vulkan_dpy; - buf_info->commit_sync_ts_backup = ++surf_source->commit_sync_timestamp; buf_info->release_fence_fd = -1; buf_info->acquire_fence_fd = -1; + buf_info->commit_sync_fd = -1; wl_buffer_add_listener((void *)buf_info->wl_buffer, &wl_buffer_release_listener, tbm_surface); @@ -1993,11 +2033,24 @@ static void _twe_surface_trace_enqueue_buffer(twe_wl_surf_source *surf_source, tbm_surface_h tbm_surface) { + twe_wl_buffer_info *buf_info = NULL; + if (!surf_source) { TPL_ERR("Invalid parameter. twe_surface(%p)", surf_source); return; } + tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, + (void **)&buf_info); + if (buf_info) { + g_mutex_lock(&surf_source->commit_sync.mutex); + buf_info->commit_sync_fd = surf_source->commit_sync.fd; + surf_source->commit_sync.fd = -1; + TRACE_ASYNC_BEGIN(buf_info->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + g_mutex_unlock(&surf_source->commit_sync.mutex); + } + if (surf_source->in_use_buffers) { g_mutex_lock(&surf_source->surf_mutex); /* Stop tracking of this canceled tbm_surface */ @@ -2553,15 +2606,24 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, __tpl_list_push_back(surf_source->committed_buffers, tbm_surface); } - if (surf_source->commit_sync_timeline != -1) { - TRACE_ASYNC_END(buf_info->commit_sync_ts_backup, "[SYNC_FENCE]"); + g_mutex_lock(&surf_source->commit_sync.mutex); - TPL_DEBUG("[COMMIT_SYNC][INC] surf_source(%p) timeline(%d) timestamp(%d)", - surf_source, surf_source->commit_sync_timeline, buf_info->commit_sync_ts_backup); - if (!tbm_sync_timeline_inc(surf_source->commit_sync_timeline, 1)) { - TPL_ERR("Failed to increase timeline(%d)", surf_source->commit_sync_timeline); + if (buf_info->commit_sync_fd != -1) { + int ret = _write_to_eventfd(buf_info->commit_sync_fd); + if (ret == -1) { + TPL_ERR("Failed to send commit_sync signal to fd(%d)", buf_info->commit_sync_fd); } + + TRACE_ASYNC_END(buf_info->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + TPL_DEBUG("[COMMIT_SYNC][SEND] surf_source(%p) commit_sync_fd(%d)", + surf_source, buf_info->commit_sync_fd); + + close(buf_info->commit_sync_fd); + buf_info->commit_sync_fd = -1; } + + g_mutex_unlock(&surf_source->commit_sync.mutex); } /* The following function _twe_thread_wl_surface_acquire_and_commit can be @@ -3101,16 +3163,15 @@ _twe_thread_wl_surf_source_destroy(void *source) surf_source->surf = NULL; } - if (surf_source->commit_sync_timeline >= 0) { - close(surf_source->commit_sync_timeline); - surf_source->commit_sync_timeline = -1; - } - if (surf_source->presentation_sync_timeline >= 0) { close(surf_source->presentation_sync_timeline); surf_source->presentation_sync_timeline = -1; } + g_mutex_lock(&surf_source->commit_sync.mutex); + g_mutex_unlock(&surf_source->commit_sync.mutex); + g_mutex_clear(&surf_source->commit_sync.mutex); + g_mutex_unlock(&surf_source->surf_mutex); g_mutex_clear(&surf_source->surf_mutex); @@ -3199,9 +3260,8 @@ twe_surface_add(twe_thread* thread, source->post_interval = 1; - source->commit_sync_timeline = tbm_sync_timeline_create(); - source->commit_sync_timestamp = 0; - source->commit_sync_fence_number = 0; + source->commit_sync.fd = -1; + g_mutex_init(&source->commit_sync.mutex); source->presentation_sync_timeline = tbm_sync_timeline_create(); source->presentation_sync_timestamp = 0; -- 2.7.4 From 84e482f0b22a39418f2571e56923c3f514ff3cd5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 15 Dec 2020 19:53:09 +0900 Subject: [PATCH 10/16] re-implement presentation sync without using sync_timeline. Change-Id: I999a56996081ac7b1706ca6ba9226b36e9b6f3d5 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 301 ++++++++++++++++++++++++------------------- 1 file changed, 172 insertions(+), 129 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index fa92a87..4c7f2f9 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -76,7 +76,6 @@ struct _twe_wl_disp_source { struct wayland_tbm_client *wl_tbm_client; struct tizen_surface_shm *tss; /* used for surface buffer_flush */ struct wp_presentation *presentation; - tpl_list_t *presentation_feedbacks; struct zwp_linux_explicit_synchronization_v1 *explicit_sync; tpl_bool_t use_explicit_sync; struct { @@ -131,6 +130,7 @@ struct _twe_wl_surf_source { tpl_list_t *fence_waiting_sources; /* Trace fence_wait_source from ENQUEUE to fence signaled */ tpl_list_t *vblank_waiting_buffers; /* for FIFO/FIFO_RELAXED modes */ tpl_list_t *render_done_fences; /* for attaching to twe_thread with fences passed by enqueue */ + tpl_list_t *presentation_feedbacks; /* for tracing presentation feedbacks */ tbm_surface_h draw_done_buffer; /* for MAILBOX mode */ int render_done_cnt; @@ -149,11 +149,10 @@ struct _twe_wl_surf_source { int fd; } commit_sync; - tbm_fd presentation_sync_timeline; - int presentation_sync_timestamp; - int presentation_sync_ts_backup; - int presentation_sync_req_cnt; - GMutex pst_mutex; + struct { + GMutex mutex; + int fd; + } presentation_sync; GMutex surf_mutex; @@ -217,6 +216,10 @@ struct _twe_wl_buffer_info { int acquire_fence_fd; int commit_sync_fd; + + struct wp_presentation_feedback *presentation_feedback; + int presentation_sync_fd; + }; struct _twe_fence_wait_source { @@ -1120,9 +1123,6 @@ _twe_thread_wl_disp_source_destroy(void *source) _twe_display_print_err(disp_source, "dispatch_queue_pending"); } - if (disp_source->presentation && disp_source->presentation_feedbacks) - __tpl_list_free(disp_source->presentation_feedbacks, (tpl_free_func_t)free); - wl_event_queue_destroy(disp_source->ev_queue); g_mutex_unlock(&disp_source->wl_event_mutex); @@ -1195,11 +1195,6 @@ twe_display_add(twe_thread* thread, TPL_DISPLAY_PRESENT_MODE_FIFO; _twe_display_wayland_init(source); - source->presentation_feedbacks = NULL; - - if (source->presentation) - source->presentation_feedbacks = __tpl_list_alloc(); - source->disp_del_source = _twe_del_source_init(ctx, source); source->disp_del_source->destroy_target_source_func = _twe_thread_wl_disp_source_destroy; @@ -1520,7 +1515,7 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv struct tizen_private *tizen_private = (struct tizen_private *)private; twe_wl_surf_source *surf_source = NULL; - tbm_fd presentation_sync_fd = -1; + int presentation_sync_fd = -1; surf_source = (twe_wl_surf_source *)tizen_private->data; if (!surf_source) { @@ -1528,31 +1523,33 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv return -1; } - if (surf_source->presentation_sync_timeline != -1) { - char name[32]; - snprintf(name, 32, "p_sync_timeline:%d", - surf_source->presentation_sync_timeline); - - g_mutex_lock(&surf_source->pst_mutex); - - surf_source->presentation_sync_timestamp++; - - presentation_sync_fd = tbm_sync_fence_create(surf_source->presentation_sync_timeline, - name, - surf_source->presentation_sync_timestamp); - TPL_DEBUG("[PRESENTATION_SYNC] surf_source(%p) timeline(%d) timestamp(%d) sync_fence(%d)", - surf_source, surf_source->presentation_sync_timeline, surf_source->presentation_sync_timestamp, - presentation_sync_fd); + g_mutex_lock(&surf_source->presentation_sync.mutex); + if (surf_source->presentation_sync.fd != -1) { + presentation_sync_fd = dup(surf_source->presentation_sync.fd); + TRACE_MARK("[ONLY_DUP] presentation_sync_fd(%d) dup(%d)", + surf_source->presentation_sync.fd, presentation_sync_fd); + TPL_DEBUG("[DUP_PRESENTATION_SYNC] surf_source(%p) presentation_sync_fd(%d) dup(%d)", + surf_source, surf_source->presentation_sync.fd, presentation_sync_fd); + g_mutex_unlock(&surf_source->presentation_sync.mutex); + return presentation_sync_fd; + } - TRACE_ASYNC_BEGIN(surf_source->presentation_sync_timestamp, "[PRESENTATION]"); + surf_source->presentation_sync.fd = eventfd(0, EFD_CLOEXEC); + if (surf_source->presentation_sync.fd == -1) { + TPL_ERR("Failed to create presentation_sync_fd. twe_surface(%p)", surf_source); + g_mutex_unlock(&surf_source->presentation_sync.mutex); + return -1; + } - surf_source->presentation_sync_req_cnt++; + presentation_sync_fd = dup(surf_source->presentation_sync.fd); + TRACE_MARK("[CREATE] presentation_sync_fd(%d) dup(%d)", + surf_source->presentation_sync.fd, presentation_sync_fd); + TPL_DEBUG("[CREATE_PRESENTATION_SYNC] surf_source(%p) presentation_sync_fd(%d) dup(%d)", + surf_source, surf_source->presentation_sync.fd, presentation_sync_fd); - g_mutex_unlock(&surf_source->pst_mutex); - return presentation_sync_fd; - } + g_mutex_unlock(&surf_source->presentation_sync.mutex); - return -1; + return presentation_sync_fd; } static int @@ -1570,11 +1567,6 @@ __cb_merge_sync_fds(void *private, int sync_fd1, int sync_fd2) return -1; } - if (surf_source->presentation_sync_timeline == -1) { - TPL_ERR("There is no timeline for any sync fd in surf_source(%p)", surf_source); - return -1; - } - merged_fd = tbm_sync_fence_merge(NULL, sync_fd1, sync_fd2); TPL_DEBUG("[FENCE_MERGE] surf_source(%p) fence1(%d) + fence2(%d) = merged(%d)", @@ -1649,11 +1641,25 @@ __cb_twe_buffer_free_callback(twe_wl_buffer_info *buf_info) if (buf_info->commit_sync_fd != -1) { int ret = _write_to_eventfd(buf_info->commit_sync_fd); if (ret == -1) - TPL_ERR("Failed to send commit_sync signal to fd(%d)", buf_info->commit_sync_fd); + TPL_ERR("Failed to send commit_sync signal to fd(%d)", + buf_info->commit_sync_fd); close(buf_info->commit_sync_fd); buf_info->commit_sync_fd = -1; } + if (buf_info->presentation_sync_fd != -1) { + int ret = _write_to_eventfd(buf_info->presentation_sync_fd); + if (ret == -1) + TPL_ERR("Failed to send presentation_sync signal to fd(%d)", + buf_info->presentation_sync_fd); + close(buf_info->presentation_sync_fd); + buf_info->presentation_sync_fd = -1; + + if (buf_info->presentation_feedback) + wp_presentation_feedback_destroy(buf_info->presentation_feedback); + buf_info->presentation_feedback = NULL; + } + if (buf_info->sync_timeline != -1) { close(buf_info->sync_timeline); buf_info->sync_timeline = -1; @@ -1887,6 +1893,9 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->acquire_fence_fd = -1; buf_info->commit_sync_fd = -1; + buf_info->presentation_sync_fd = -1; + buf_info->presentation_feedback = NULL; + if (surf_source->in_use_buffers) { g_mutex_lock(&surf_source->surf_mutex); __tpl_list_push_back(surf_source->in_use_buffers, @@ -1974,6 +1983,9 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->release_fence_fd = -1; buf_info->acquire_fence_fd = -1; buf_info->commit_sync_fd = -1; + buf_info->presentation_sync_fd = -1; + buf_info->presentation_feedback = NULL; + wl_buffer_add_listener((void *)buf_info->wl_buffer, &wl_buffer_release_listener, tbm_surface); @@ -2049,6 +2061,11 @@ _twe_surface_trace_enqueue_buffer(twe_wl_surf_source *surf_source, TRACE_ASYNC_BEGIN(buf_info->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); g_mutex_unlock(&surf_source->commit_sync.mutex); + + g_mutex_lock(&surf_source->presentation_sync.mutex); + buf_info->presentation_sync_fd = surf_source->presentation_sync.fd; + surf_source->presentation_sync.fd = -1; + g_mutex_unlock(&surf_source->presentation_sync.mutex); } if (surf_source->in_use_buffers) { @@ -2386,79 +2403,100 @@ __cb_presentation_feedback_presented(void *data, TPL_IGNORE(seq_lo); TPL_IGNORE(flags); - struct feedback_info *feedback_info = (struct feedback_info *)data; - twe_wl_surf_source *surf_source = feedback_info->surf_source; - twe_wl_disp_source *disp_source = surf_source->disp_source; - - g_mutex_lock(&surf_source->pst_mutex); + tbm_surface_h tbm_surface = (tbm_surface_h)data; + twe_wl_buffer_info *buf_info = NULL; + twe_wl_surf_source *surf_source = NULL; - TPL_DEBUG("[FEEDBACK][PRESENTED] surf_source(%p) wl_surface(%p)", - surf_source, surf_source->surf); + tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, + (void **)&buf_info); + if (!buf_info) { + TPL_ERR("Failed to get twe_wl_buffer_info from tbm_surface(%p)", + tbm_surface); + return; + } - if (surf_source->presentation_sync_timeline != -1 && - surf_source->presentation_sync_req_cnt > 0) { + surf_source = buf_info->surf_source; - surf_source->presentation_sync_ts_backup++; - surf_source->presentation_sync_req_cnt--; + g_mutex_lock(&surf_source->presentation_sync.mutex); - TRACE_ASYNC_END(surf_source->presentation_sync_ts_backup, "[PRESENTATION]"); + TPL_DEBUG("[FEEDBACK][PRESENTED] surf_source(%p) tbm_surface(%p) bo(%d)", + surf_source, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); - TPL_DEBUG("[PRESENTATION][INC] surf_source(%p) timeline(%d) timestamp(%d)", - surf_source, surf_source->presentation_sync_timeline, - surf_source->presentation_sync_ts_backup); - if (!tbm_sync_timeline_inc(surf_source->presentation_sync_timeline, 1)) { - TPL_ERR("Failed to increase timeline(%d)", - surf_source->presentation_sync_timeline); + if (buf_info->presentation_sync_fd != -1) { + int ret = _write_to_eventfd(buf_info->presentation_sync_fd); + if (ret == -1) { + TPL_ERR("Failed to send presentation_sync signal to fd(%d)", + buf_info->presentation_sync_fd); } + + TRACE_ASYNC_END(buf_info->presentation_sync_fd, + "[PRESENTATION_SYNC] bo(%d)", + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + + close(buf_info->presentation_sync_fd); + buf_info->presentation_sync_fd = -1; } - if (presentation_feedback) - wp_presentation_feedback_destroy(presentation_feedback); + if (buf_info->presentation_feedback) + wp_presentation_feedback_destroy(buf_info->presentation_feedback); + + buf_info->presentation_feedback = NULL; - __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, - TPL_FIRST, (tpl_free_func_t)free); + __tpl_list_remove_data(surf_source->presentation_feedbacks, tbm_surface, + TPL_FIRST, NULL); - g_mutex_unlock(&surf_source->pst_mutex); + g_mutex_unlock(&surf_source->presentation_sync.mutex); } static void __cb_presentation_feedback_discarded(void *data, struct wp_presentation_feedback *presentation_feedback) { - struct feedback_info *feedback_info = (struct feedback_info *)data; - twe_wl_surf_source *surf_source = feedback_info->surf_source; - twe_wl_disp_source *disp_source = surf_source->disp_source; - - g_mutex_lock(&surf_source->pst_mutex); + tbm_surface_h tbm_surface = (tbm_surface_h)data; + twe_wl_buffer_info *buf_info = NULL; + twe_wl_surf_source *surf_source = NULL; - TPL_DEBUG("[FEEDBACK][DISCARDED] surf_source(%p) wl_surface(%p)", - surf_source, surf_source->surf); + tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, + (void **)&buf_info); + if (!buf_info) { + TPL_ERR("Failed to get twe_wl_buffer_info from tbm_surface(%p)", + tbm_surface); + return; + } - if (surf_source->presentation_sync_timeline != -1 && - surf_source->presentation_sync_req_cnt > 0) { + surf_source = buf_info->surf_source; - surf_source->presentation_sync_ts_backup++; - surf_source->presentation_sync_req_cnt--; + g_mutex_lock(&surf_source->presentation_sync.mutex); - TRACE_ASYNC_END(surf_source->presentation_sync_ts_backup, "[PRESENTATION]"); + TPL_DEBUG("[FEEDBACK][DISCARDED] surf_source(%p) tbm_surface(%p) bo(%d)", + surf_source, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); - TPL_DEBUG("[PRESENTATION][INC] surf_source(%p) timeline(%d) timestamp(%d)", - surf_source, surf_source->presentation_sync_timeline, - surf_source->presentation_sync_ts_backup); - if (!tbm_sync_timeline_inc(surf_source->presentation_sync_timeline, 1)) { - TPL_ERR("Failed to increase timeline(%d)", - surf_source->presentation_sync_timeline); + if (buf_info->presentation_sync_fd != -1) { + int ret = _write_to_eventfd(buf_info->presentation_sync_fd); + if (ret == -1) { + TPL_ERR("Failed to send presentation_sync signal to fd(%d)", + buf_info->presentation_sync_fd); } + + TRACE_ASYNC_END(buf_info->presentation_sync_fd, + "[PRESENTATION_SYNC] bo(%d)", + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + + close(buf_info->presentation_sync_fd); + buf_info->presentation_sync_fd = -1; } - if (presentation_feedback) - wp_presentation_feedback_destroy(presentation_feedback); + if (buf_info->presentation_feedback) + wp_presentation_feedback_destroy(buf_info->presentation_feedback); - if (disp_source->presentation_feedbacks) - __tpl_list_remove_data(disp_source->presentation_feedbacks, feedback_info, - TPL_FIRST, (tpl_free_func_t)free); + buf_info->presentation_feedback = NULL; - g_mutex_unlock(&surf_source->pst_mutex); + __tpl_list_remove_data(surf_source->presentation_feedbacks, tbm_surface, + TPL_FIRST, NULL); + + g_mutex_unlock(&surf_source->presentation_sync.mutex); } static const struct wp_presentation_feedback_listener feedback_listener = { @@ -2487,23 +2525,19 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, version = wl_proxy_get_version((struct wl_proxy *)wl_surface); - g_mutex_lock(&surf_source->pst_mutex); - if (disp_source->presentation && - surf_source->presentation_sync_req_cnt > 0) { - struct feedback_info *feedback_info = - (struct feedback_info *)calloc(1, sizeof(struct feedback_info)); - if (feedback_info) { - feedback_info->feedback = wp_presentation_feedback(disp_source->presentation, - wl_surface); - feedback_info->surf_source = surf_source; - wp_presentation_feedback_add_listener(feedback_info->feedback, - &feedback_listener, feedback_info); - if (disp_source->presentation_feedbacks) - __tpl_list_push_back(disp_source->presentation_feedbacks, - (void *)feedback_info); - } + g_mutex_lock(&surf_source->presentation_sync.mutex); + if (disp_source->presentation && buf_info->presentation_sync_fd != -1) { + buf_info->presentation_feedback = + wp_presentation_feedback(disp_source->presentation, + wl_surface); + wp_presentation_feedback_add_listener(buf_info->presentation_feedback, + &feedback_listener, tbm_surface); + __tpl_list_push_back(surf_source->presentation_feedbacks, tbm_surface); + TRACE_ASYNC_BEGIN(buf_info->presentation_sync_fd, + "[PRESENTATION_SYNC] bo(%d)", + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); } - g_mutex_unlock(&surf_source->pst_mutex); + g_mutex_unlock(&surf_source->presentation_sync.mutex); if (buf_info->w_rotated == TPL_TRUE) { wayland_tbm_client_set_buffer_transform( @@ -3040,24 +3074,37 @@ _twe_thread_wl_surf_source_destroy(void *source) g_mutex_lock(&surf_source->surf_mutex); - if (disp_source->presentation && disp_source->presentation_feedbacks) { - int num_feedbacks = __tpl_list_get_count(disp_source->presentation_feedbacks); - while (num_feedbacks) { - struct feedback_info *feedback_info = __tpl_list_pop_front(disp_source->presentation_feedbacks, NULL); - if (feedback_info && surf_source == feedback_info->surf_source) { - wp_presentation_feedback_destroy(feedback_info->feedback); - feedback_info->feedback = NULL; - feedback_info->surf_source = NULL; - - free(feedback_info); - } else { - __tpl_list_push_back(disp_source->presentation_feedbacks, feedback_info); + g_mutex_lock(&surf_source->presentation_sync.mutex); + if (disp_source->presentation && surf_source->presentation_feedbacks) { + while (!__tpl_list_is_empty(surf_source->presentation_feedbacks)) { + tbm_surface_h tbm_surface = + __tpl_list_pop_front(surf_source->presentation_feedbacks, NULL); + if (tbm_surface_internal_is_valid(tbm_surface)) { + twe_wl_buffer_info *buf_info = NULL; + tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, + (void **)&buf_info); + if (buf_info && buf_info->presentation_sync_fd != -1 && + buf_info->presentation_feedback) { + + _write_to_eventfd(buf_info->presentation_sync_fd); + close(buf_info->presentation_sync_fd); + buf_info->presentation_sync_fd = -1; + + wp_presentation_feedback_destroy(buf_info->presentation_feedback); + buf_info->presentation_feedback = NULL; + } } - - num_feedbacks--; } } + if (surf_source->presentation_sync.fd != -1) { + _write_to_eventfd(surf_source->presentation_sync.fd); + close(surf_source->presentation_sync.fd); + surf_source->presentation_sync.fd = -1; + } + g_mutex_unlock(&surf_source->presentation_sync.mutex); + g_mutex_clear(&surf_source->presentation_sync.mutex); + if (surf_source->in_use_buffers) { __tpl_list_free(surf_source->in_use_buffers, (tpl_free_func_t)__cb_buffer_remove_from_list); @@ -3163,11 +3210,6 @@ _twe_thread_wl_surf_source_destroy(void *source) surf_source->surf = NULL; } - if (surf_source->presentation_sync_timeline >= 0) { - close(surf_source->presentation_sync_timeline); - surf_source->presentation_sync_timeline = -1; - } - g_mutex_lock(&surf_source->commit_sync.mutex); g_mutex_unlock(&surf_source->commit_sync.mutex); g_mutex_clear(&surf_source->commit_sync.mutex); @@ -3263,10 +3305,12 @@ twe_surface_add(twe_thread* thread, source->commit_sync.fd = -1; g_mutex_init(&source->commit_sync.mutex); - source->presentation_sync_timeline = tbm_sync_timeline_create(); - source->presentation_sync_timestamp = 0; - source->presentation_sync_ts_backup = 0; - source->presentation_sync_req_cnt = 0; + source->presentation_sync.fd = -1; + g_mutex_init(&source->presentation_sync.mutex); + if (disp_source->presentation) + source->presentation_feedbacks = __tpl_list_alloc(); + else + source->presentation_feedbacks = NULL; if (!disp_source->is_vulkan_dpy) { struct wl_egl_window *wl_egl_window = @@ -3328,7 +3372,6 @@ twe_surface_add(twe_thread* thread, g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); g_mutex_init(&source->surf_mutex); - g_mutex_init(&source->pst_mutex); g_mutex_init(&source->free_queue_mutex); g_cond_init(&source->free_queue_cond); -- 2.7.4 From bcb469a8fee8c38dd22d91a38ff2f8cfd50b23e2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 17 Dec 2020 16:04:18 +0900 Subject: [PATCH 11/16] wl_egl_window_tizen_merge_sync_fds will be deprecated. Change-Id: Idc4898f83829fe482d23fc8e862cd0d26b992e8c Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 25 ------------------------- src/wayland-egl-tizen/wayland-egl-tizen.h | 5 +++++ 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 4c7f2f9..070273c 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1552,30 +1552,6 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv return presentation_sync_fd; } -static int -__cb_merge_sync_fds(void *private, int sync_fd1, int sync_fd2) -{ - TPL_ASSERT(private); - - struct tizen_private *tizen_private = (struct tizen_private *)private; - twe_wl_surf_source *surf_source = NULL; - tbm_fd merged_fd; - - surf_source = (twe_wl_surf_source *)tizen_private->data; - if (!surf_source) { - TPL_ERR("Invalid parameter. twe_surface(%p)", surf_source); - return -1; - } - - merged_fd = tbm_sync_fence_merge(NULL, sync_fd1, sync_fd2); - - TPL_DEBUG("[FENCE_MERGE] surf_source(%p) fence1(%d) + fence2(%d) = merged(%d)", - surf_source, sync_fd1, sync_fd2, merged_fd); - - return merged_fd; -} - - static void __cb_tss_flusher_flush_callback(void *data, struct tizen_surface_shm_flusher *tss_flusher) { @@ -3333,7 +3309,6 @@ twe_surface_add(twe_thread* thread, __cb_set_window_serial_callback; 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; wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback; wl_egl_window->resize_callback = (void *)__cb_resize_callback; diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.h b/src/wayland-egl-tizen/wayland-egl-tizen.h index 921b193..206f632 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen.h @@ -120,6 +120,11 @@ int wl_egl_window_tizen_create_presentation_sync_fd(struct wl_egl_window *egl_window); /** + * [DEPRECATED] + * The commit_sync_fd and presentation_sync_fd have been modified + * to do not use sync_timeline. + * Therefore, this merge function cannot be used. + * * Get a new fence fd with fence1 and fence2 merged * * It returns a new fence fd waiting for both fences to be signaled. -- 2.7.4 From 7789a667e24f79bff7798376aa2b4c40705a63ef Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 17 Dec 2020 16:43:40 +0900 Subject: [PATCH 12/16] Add internal function to get bo name from tbm_surface Change-Id: I467f724d531d0a3c3b6de1d8568f4632bc8960b9 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 91 +++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 070273c..4e978d5 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -255,6 +255,12 @@ tpl_result_t _twe_thread_fence_wait_source_attach(twe_wl_surf_source *surf_source, tbm_surface_h tbm_surface, tbm_fd sync_fd); +static int +_get_tbm_surface_bo_name(tbm_surface_h tbm_surface) +{ + return tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)); +} + static gpointer _twe_thread_loop(gpointer data) { @@ -714,7 +720,7 @@ _twe_print_buffer_list(twe_wl_surf_source *surf_source) tbm_surface = (tbm_surface_h)__tpl_list_node_get_data(node); TPL_DEBUG("VBLANK WAITING BUFFERS | %d | tbm_surface(%p) bo(%d)", idx, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); idx++; } @@ -732,7 +738,7 @@ _twe_print_buffer_list(twe_wl_surf_source *surf_source) tbm_surface = (tbm_surface_h)__tpl_list_node_get_data(node); TPL_DEBUG("DEQUEUED BUFFERS | %d | tbm_surface(%p) bo(%d)", idx, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); idx++; } @@ -750,7 +756,7 @@ _twe_print_buffer_list(twe_wl_surf_source *surf_source) tbm_surface = (tbm_surface_h)__tpl_list_node_get_data(node); TPL_DEBUG("COMMITTED BUFFERS | %d | tbm_surface(%p) bo(%d)", idx, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); idx++; } } @@ -1683,15 +1689,13 @@ __cb_buffer_release_callback(void *data, struct wl_proxy *wl_buffer) buf_info->need_to_release = TPL_FALSE; - TRACE_MARK("[RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + TRACE_MARK("[RELEASE] BO(%d)", _get_tbm_surface_bo_name(tbm_surface)); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_LOG_T(BACKEND, "[REL] wl_buffer(%p) tbm_surface(%p) bo(%d)", buf_info->wl_buffer, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tbm_surface_internal_unref(tbm_surface); } @@ -1734,16 +1738,15 @@ __cb_buffer_fenced_release(void *data, buf_info->release_fence_fd = fence; TRACE_MARK("[FENCED_RELEASE] BO(%d) fence(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + _get_tbm_surface_bo_name(tbm_surface), fence); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_LOG_T(BACKEND, "[FENCED_RELEASE] wl_buffer(%p) tbm_surface(%p) bo(%d) fence(%d)", buf_info->wl_buffer, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + _get_tbm_surface_bo_name(tbm_surface), fence); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, @@ -1788,15 +1791,14 @@ __cb_buffer_immediate_release(void *data, buf_info->release_fence_fd = -1; TRACE_MARK("[IMMEDIATE_RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_LOG_T(BACKEND, "[IMMEDIATE_RELEASE] wl_buffer(%p) tbm_surface(%p) bo(%d)", buf_info->wl_buffer, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, tbm_surface); @@ -1880,13 +1882,13 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, } TRACE_MARK("[SET_BUFFER_INFO] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_LOG_T(BACKEND, "[REUSE_BUF] buf_info(%p) tbm_surface(%p) bo(%d) (%dx%d) " "transform(%d) w_transform(%d)", buf_info, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + _get_tbm_surface_bo_name(tbm_surface), buf_info->width, buf_info->height, buf_info->transform, buf_info->w_transform); return; @@ -1985,12 +1987,12 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info); TRACE_MARK("[SET_BUFFER_INFO] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_LOG_T(BACKEND, "[NEW_BUF] buf_info(%p) tbm_surface(%p) bo(%d) (%dx%d) " "transform(%d) w_transform(%d)", buf_info, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + _get_tbm_surface_bo_name(tbm_surface), buf_info->width, buf_info->height, buf_info->transform, buf_info->w_transform); } @@ -2035,7 +2037,7 @@ _twe_surface_trace_enqueue_buffer(twe_wl_surf_source *surf_source, buf_info->commit_sync_fd = surf_source->commit_sync.fd; surf_source->commit_sync.fd = -1; TRACE_ASYNC_BEGIN(buf_info->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); g_mutex_unlock(&surf_source->commit_sync.mutex); g_mutex_lock(&surf_source->presentation_sync.mutex); @@ -2312,16 +2314,15 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source, wl_display_flush(surf_source->disp_source->disp); - TRACE_MARK("[COMMIT] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + TRACE_MARK("[COMMIT] BO(%d)", _get_tbm_surface_bo_name(tbm_surface)); TRACE_ASYNC_BEGIN((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); buf_info->sync_timestamp++; TPL_LOG_T(BACKEND, "[COMMIT] wl_buffer(%p) tbm_surface(%p) bo(%d)", buf_info->wl_buffer, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); if (surf_source->swapchain_properties.present_mode == TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED || @@ -2339,10 +2340,10 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source, /* Presented buffer's sync operating dependent on tdm timeline fence. */ if (buf_info->sync_fd != -1) { TPL_LOG_T(BACKEND, "[RELEASE_IMMEDIATELY] tbm_surface(%p) bo(%d) sync_fd(%d)", - tbm_surface, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + tbm_surface, _get_tbm_surface_bo_name(tbm_surface), buf_info->sync_fd); TRACE_MARK("[RELEASE_IMMEDIATELY] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("Failed to release tbm_surface(%p) when vk_surface_commit.", @@ -2397,7 +2398,7 @@ __cb_presentation_feedback_presented(void *data, TPL_DEBUG("[FEEDBACK][PRESENTED] surf_source(%p) tbm_surface(%p) bo(%d)", surf_source, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); if (buf_info->presentation_sync_fd != -1) { int ret = _write_to_eventfd(buf_info->presentation_sync_fd); @@ -2408,7 +2409,7 @@ __cb_presentation_feedback_presented(void *data, TRACE_ASYNC_END(buf_info->presentation_sync_fd, "[PRESENTATION_SYNC] bo(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); close(buf_info->presentation_sync_fd); buf_info->presentation_sync_fd = -1; @@ -2447,7 +2448,7 @@ __cb_presentation_feedback_discarded(void *data, TPL_DEBUG("[FEEDBACK][DISCARDED] surf_source(%p) tbm_surface(%p) bo(%d)", surf_source, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); if (buf_info->presentation_sync_fd != -1) { int ret = _write_to_eventfd(buf_info->presentation_sync_fd); @@ -2458,7 +2459,7 @@ __cb_presentation_feedback_discarded(void *data, TRACE_ASYNC_END(buf_info->presentation_sync_fd, "[PRESENTATION_SYNC] bo(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); close(buf_info->presentation_sync_fd); buf_info->presentation_sync_fd = -1; @@ -2511,7 +2512,7 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, __tpl_list_push_back(surf_source->presentation_feedbacks, tbm_surface); TRACE_ASYNC_BEGIN(buf_info->presentation_sync_fd, "[PRESENTATION_SYNC] bo(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); } g_mutex_unlock(&surf_source->presentation_sync.mutex); @@ -2599,13 +2600,13 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, wl_display_flush(surf_source->disp_source->disp); TRACE_ASYNC_BEGIN((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); buf_info->need_to_commit = TPL_FALSE; TPL_LOG_T(BACKEND, "[COMMIT] wl_buffer(%p) tbm_surface(%p) bo(%d)", buf_info->wl_buffer, tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); if ((_twe_ctx->tdm_source || surf_source->vblank) && _twe_surface_wait_vblank(surf_source) != TPL_ERROR_NONE) @@ -2625,7 +2626,7 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, } TRACE_ASYNC_END(buf_info->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); TPL_DEBUG("[COMMIT_SYNC][SEND] surf_source(%p) commit_sync_fd(%d)", surf_source, buf_info->commit_sync_fd); @@ -2688,7 +2689,7 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) if (surf_source->vblank_done) { TPL_LOG_T(BACKEND, "[ACQ] tbm_surface(%p) bo(%d)", tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); _twe_thread_wl_surface_commit(surf_source, tbm_surface); } else { @@ -2701,7 +2702,7 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) TPL_LOG_T(BACKEND, "[ACQ][COMMIT_PENDING] tbm_surface(%p) bo(%d)", tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); } else { _twe_thread_wl_surface_commit(surf_source, tbm_surface); } @@ -2710,7 +2711,7 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) } else { /* wayland_vulkan */ TPL_LOG_T(BACKEND, "[ACQ] tbm_surface(%p) bo(%d)", tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); switch (surf_source->swapchain_properties.present_mode) { case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE: @@ -2721,8 +2722,7 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) if (surf_source->draw_done_buffer) { TPL_LOG_T(BACKEND, "[SKIP] tbm_surface(%p) bo(%d)", tbm_surface, - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tbm_surface_internal_unref(surf_source->draw_done_buffer); tbm_surface_queue_release(surf_source->tbm_queue, surf_source->draw_done_buffer); @@ -3103,8 +3103,7 @@ _twe_thread_wl_surf_source_destroy(void *source) (tpl_free_func_t)__cb_buffer_remove_from_list); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("Failed to release. tbm_surface(%p) tsq_err(%d)", @@ -3561,8 +3560,7 @@ twe_surface_destroy_swapchain(twe_surface_h twe_surface) (tpl_free_func_t)__cb_buffer_remove_from_list); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("Failed to release. tbm_surface(%p) tsq_err(%d)", @@ -3906,7 +3904,7 @@ twe_surface_create_sync_fd(tbm_surface_h tbm_surface) if (buf_info) { char name[32]; snprintf(name, 32, "%d", - tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); sync_fd = tbm_sync_fence_create(buf_info->sync_timeline, name, buf_info->sync_timestamp); @@ -4006,8 +4004,7 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface) __tpl_list_pop_front(surf_source->committed_buffers, (tpl_free_func_t)__cb_buffer_remove_from_list); TRACE_ASYNC_END((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", - tbm_bo_export(tbm_surface_internal_get_bo( - tbm_surface, 0))); + _get_tbm_surface_bo_name(tbm_surface)); tsq_err = tbm_surface_queue_release(surf_source->tbm_queue, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) TPL_ERR("Failed to release. tbm_surface(%p) tsq_err(%d)", -- 2.7.4 From 8f720f2c9cfc5dbbb59ebb8acd3d1f7cef2a9092 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 17 Dec 2020 19:50:24 +0900 Subject: [PATCH 13/16] Add a new log TPL_INFO. Change-Id: I549db8c4b447c6bcc3c35fe52a8782e4b470aa9e Signed-off-by: Joonbum Ko --- src/tpl_utils.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 26b696e..21f2580 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -73,6 +73,7 @@ inline char *tpl_getenv(const char *name) #define FONT_BLUE "\033[34m" /* for backend logs */ #define FONT_MAGENTA "\033[35m" /* for debug logs */ #define FONT_CYAN "\033[36m" /* for thread logs */ +#define BG_COLOR_GREEN "\033[0;42m" #ifdef DLOG_DEFAULT_ENABLE #define LOG_TAG "TPL" @@ -84,6 +85,7 @@ inline char *tpl_getenv(const char *name) #define tpl_log_b(t, f, x...) LOGI(FONT_BLUE t FONT_DEFAULT " " f, ##x) #define tpl_log_d(t, f, x...) LOGI(FONT_MAGENTA t FONT_DEFAULT " " f, ##x) #define tpl_log_t(t, f, x...) LOGI(FONT_CYAN t FONT_DEFAULT " " f, ##x) +#define tpl_log_i(t, f, x...) LOGI(BG_COLOR_GREEN t FONT_DEFAULT " " f, ##x) #define tpl_log_e(t, f, x...) LOGE(FONT_RED t " " f FONT_DEFAULT, ##x) #define tpl_log_w(t, f, x...) LOGW(FONT_YELLOW t " " f FONT_DEFAULT, ##x) #else /* DLOG_DEFAULT_ENABLE */ @@ -99,6 +101,9 @@ inline char *tpl_getenv(const char *name) #define tpl_log_t(t, f, x...) \ fprintf(stderr, FONT_CYAN t FONT_DEFAULT "[(tid:%li)(%s)]" f "\n", \ syscall(SYS_gettid), __func__, ##x) +#define tpl_log_i(t, f, x...) \ + fprintf(stderr, BG_COLOR_GREEN t FONT_DEFAULT "[(tid:%li)(%s)]" f "\n", \ + syscall(SYS_gettid), __func__, ##x) #define tpl_log_e(t, f, x...) \ fprintf(stderr, FONT_RED t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n", \ syscall(SYS_gettid), __func__, ##x) @@ -107,7 +112,7 @@ inline char *tpl_getenv(const char *name) syscall(SYS_gettid), __func__, ##x) #endif /* DLOG_DEFAULT_ENABLE */ - +#define TPL_INFO(tag, f, x...) tpl_log_i(tag, f, ##x) #define TPL_ERR(f, x...) tpl_log_e("[TPL_ERROR]", f, ##x) #define TPL_WARN(f, x...) tpl_log_w("[TPL_WARNING]", f, ##x) -- 2.7.4 From 233abd89ea9bf13551f7e0650bfd768a5ffeb6ea Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 17 Dec 2020 19:52:14 +0900 Subject: [PATCH 14/16] Change log tag for basic info to always be displayed to TPL_INFO Change-Id: Ifedf01d5459b848715c7e8664a57c5308ed22080 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 53 ++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 4e978d5..c2712ff 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1132,8 +1132,8 @@ _twe_thread_wl_disp_source_destroy(void *source) wl_event_queue_destroy(disp_source->ev_queue); g_mutex_unlock(&disp_source->wl_event_mutex); - TPL_LOG_T(BACKEND, "[DEL] twe_display(%p) wl_display(%p)", - disp_source, disp_source->disp); + TPL_INFO("[DISPLAY_DEL]", "twe_display(%p) wl_display(%p)", + disp_source, disp_source->disp); g_mutex_clear(&disp_source->wl_event_mutex); @@ -1209,8 +1209,8 @@ twe_display_add(twe_thread* thread, g_source_add_poll(&source->gsource, &source->gfd); g_source_attach(&source->gsource, g_main_loop_get_context(ctx->twe_loop)); - TPL_LOG_T(BACKEND, "add| gsource(%p) ev_queue(%p) wl_display(%p)", - source, source->ev_queue, display); + TPL_INFO("[DISPLAY_ADD]", "gsource(%p) ev_queue(%p) wl_display(%p)", + source, source->ev_queue, display); return (twe_display_h)source; } @@ -1238,6 +1238,8 @@ twe_display_del(twe_display_h twe_display) g_mutex_lock(&_twe_ctx->thread_mutex); + TPL_INFO("[DISPLAY_DEL]", "twe_display(%p) will be destroyed in thread", + twe_display); _twe_thread_del_source_trigger(disp_del_source); g_cond_wait(&_twe_ctx->thread_cond, &_twe_ctx->thread_mutex); g_mutex_unlock(&_twe_ctx->thread_mutex); @@ -1611,8 +1613,8 @@ __cb_twe_buffer_free_callback(twe_wl_buffer_info *buf_info) twe_wl_surf_source *surf_source = buf_info->surf_source; twe_wl_disp_source *disp_source = surf_source->disp_source; - TPL_LOG_T(BACKEND, "[FREE] twe_buffer(%p) wl_buffer(%p)", - buf_info, buf_info->wl_buffer); + TPL_INFO("[BUFFER_FREE]", "buf_info(%p) wl_buffer(%p) tbm_surface(%p)", + buf_info, buf_info->wl_buffer, buf_info->tbm_surface); wl_display_flush(disp_source->disp); @@ -1988,13 +1990,12 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, TRACE_MARK("[SET_BUFFER_INFO] BO(%d)", _get_tbm_surface_bo_name(tbm_surface)); - TPL_LOG_T(BACKEND, - "[NEW_BUF] buf_info(%p) tbm_surface(%p) bo(%d) (%dx%d) " - "transform(%d) w_transform(%d)", - buf_info, tbm_surface, - _get_tbm_surface_bo_name(tbm_surface), - buf_info->width, buf_info->height, - buf_info->transform, buf_info->w_transform); + TPL_INFO("[NEW_BUFFER_CREATED]", + "buf_info(%p) tbm_surface(%p) bo(%d) (%dx%d) transform(%d) w_transform(%d)", + buf_info, tbm_surface, + _get_tbm_surface_bo_name(tbm_surface), + buf_info->width, buf_info->height, + buf_info->transform, buf_info->w_transform); } static void @@ -3051,6 +3052,11 @@ _twe_thread_wl_surf_source_destroy(void *source) g_mutex_lock(&surf_source->surf_mutex); g_mutex_lock(&surf_source->presentation_sync.mutex); + + TPL_INFO("[TWE_SURFACE_DESTROY]", + "surf_source(%p) wl_egl_window(%p) wl_surface(%p)", + surf_source, surf_source->wl_egl_window, surf_source->surf); + if (disp_source->presentation && surf_source->presentation_feedbacks) { while (!__tpl_list_is_empty(surf_source->presentation_feedbacks)) { tbm_surface_h tbm_surface = @@ -3088,8 +3094,7 @@ _twe_thread_wl_surf_source_destroy(void *source) } if (surf_source->surface_sync) { - TPL_LOG_T(BACKEND, - "[SURFACE_SYNC FINI] twe_wl_surf_source(%p) surface_sync(%p)", + TPL_INFO("[SURFACE_SYNC FINI]", "twe_wl_surf_source(%p) surface_sync(%p)", surf_source, surf_source->surface_sync); zwp_linux_surface_synchronization_v1_destroy(surf_source->surface_sync); surf_source->surface_sync = NULL; @@ -3156,8 +3161,9 @@ _twe_thread_wl_surf_source_destroy(void *source) } if (surf_source->vblank) { - TPL_LOG_T(BACKEND, "[VBLANK FINI] twe_wl_surf_source(%p) vblank(%p)", - surf_source, surf_source->vblank); + TPL_INFO("[VBLANK FINI]", + "twe_wl_surf_source(%p) vblank(%p)", + surf_source, surf_source->vblank); tdm_client_vblank_destroy(surf_source->vblank); surf_source->vblank = NULL; } @@ -3167,8 +3173,8 @@ _twe_thread_wl_surf_source_destroy(void *source) if (surf_source->wl_egl_window) { struct tizen_private *tizen_private = NULL; - TPL_LOG_T(BACKEND, "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", - surf_source, surf_source->wl_egl_window, surf_source->surf); + TPL_INFO("[WINDOW_FINI]", "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", + surf_source, surf_source->wl_egl_window, surf_source->surf); tizen_private = _get_tizen_private(surf_source->wl_egl_window); if (tizen_private) { tizen_private->set_window_serial_callback = NULL; @@ -3350,9 +3356,8 @@ twe_surface_add(twe_thread* thread, g_mutex_init(&source->free_queue_mutex); g_cond_init(&source->free_queue_cond); - TPL_LOG_T(BACKEND, - "gsource(%p) native_handle(%p) wl_surface(%p) event_fd(%d)", - source, native_handle, source->surf, source->event_fd); + TPL_INFO("[SURFACE_ADD]", "gsource(%p) wl_surface(%p) event_fd(%d)", + source, source->surf, source->event_fd); return (twe_surface_h)source; } @@ -3388,8 +3393,8 @@ twe_surface_del(twe_surface_h twe_surface) } } - TPL_LOG_T(BACKEND, "twe_surface(%p) will be destroyed in thread", - twe_surface); + TPL_INFO("[SURFACE_DEL]", "twe_surface(%p) will be destroyed in thread", + twe_surface); surf_del_source = surf_source->surf_del_source; g_mutex_lock(&_twe_ctx->thread_mutex); -- 2.7.4 From 4f3ec2023186cdf4e2627154e0d38f8576079f18 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 22 Dec 2020 13:25:37 +0900 Subject: [PATCH 15/16] Add null checking to resolve dereference problem. Change-Id: I847db94a26f97573489c39793401861d014e81c9 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index c2712ff..0ea5cc4 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3139,7 +3139,7 @@ _twe_thread_wl_surf_source_destroy(void *source) twe_fence_wait_source *wait_source = __tpl_list_pop_front(surf_source->fence_waiting_sources, NULL); - if (!g_source_is_destroyed(&wait_source->gsource)) { + if (wait_source && !g_source_is_destroyed(&wait_source->gsource)) { tbm_surface_internal_unref(wait_source->tbm_surface); wait_source->tbm_surface = NULL; -- 2.7.4 From fa9dfd331294fd01fdb3ee7b2d6970774bcc4f8e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 2 Dec 2020 18:24:36 +0900 Subject: [PATCH 16/16] Package version up to 1.8.0 Change-Id: I35749e4d35e17444aa5bc23d87567dd619f2272b Signed-off-by: Joonbum Ko --- packaging/libtpl-egl.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 8564405..a0e2e65 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -3,8 +3,8 @@ #TPL VERSION MACROS %define TPL_VERSION_MAJOR 1 -%define TPL_VERSION_MINOR 7 -%define TPL_VERSION_PATCH 16 +%define TPL_VERSION_MINOR 8 +%define TPL_VERSION_PATCH 0 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4