From a59d74fb5048cbbfa2fbd16a093fb63d877c13e7 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 19 Aug 2020 19:41:16 +0900 Subject: [PATCH 01/16] Fixed a bug related to render sync fd. - Very occasionally, when twe_thread is pushed down by scheduling, a sync_fd cannot be attached to twe_thread. - In this case, queue_can_acquire and render_done_cnt are different and the commit is delayed by one frame. - This problem may cause can_dequeue_timeout depending on the hwc situation. - Even if queue_flush is performed after can_dequeue_timeout, the commit latency cannot be restored until another interrupt occurs. Change-Id: I32bc48d523e815a944cbfb935277adc1bcc2bf44 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 82 +++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 2fe051d..bb75442 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -97,6 +97,12 @@ struct _twe_del_source { void (*destroy_target_source_func)(void *); }; + +struct sync_info { + tbm_surface_h tbm_surface; + int sync_fd; +}; + struct _twe_wl_surf_source { GSource gsource; gpointer tag; @@ -118,6 +124,7 @@ struct _twe_wl_surf_source { tpl_list_t *in_use_buffers; /* Trace tbm_surface from DEQUEUE to ENQUEUE */ 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 */ tbm_surface_h draw_done_buffer; /* for MAILBOX mode */ int render_done_cnt; @@ -154,11 +161,6 @@ struct _twe_wl_surf_source { int post_interval; - struct { - tbm_surface_h tbm_surface; - int sync_fd; - } sync_info; - struct zwp_linux_surface_synchronization_v1 *surface_sync; }; @@ -2654,28 +2656,27 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer data) } if (surf_source->use_sync_fence && - surf_source->sync_info.sync_fd > 0 && - surf_source->sync_info.tbm_surface) { - - int sync_fd = surf_source->sync_info.sync_fd; - tbm_surface_h tbm_surface = surf_source->sync_info.tbm_surface; - - if (!surf_source->use_surface_sync) { - res = _twe_thread_fence_wait_source_attach(surf_source, tbm_surface, sync_fd); - if (res != TPL_ERROR_NONE) { - TPL_ERR("Failed to attach source with fence_fd(%d) result(%d)", - sync_fd, res); - surf_source->use_sync_fence = TPL_FALSE; - } else { - surf_source->use_sync_fence = TPL_TRUE; + surf_source->render_done_fences) { + + while (__tpl_list_get_count(surf_source->render_done_fences)) { + struct sync_info *sync = __tpl_list_pop_front(surf_source->render_done_fences, + NULL); + if (sync) { + res = _twe_thread_fence_wait_source_attach(surf_source, + sync->tbm_surface, + sync->sync_fd); + if (res != TPL_ERROR_NONE) { + TPL_ERR("Failed to attach source with fence_fd(%d) result(%d)", + sync->sync_fd, res); + surf_source->use_sync_fence = TPL_FALSE; + } + + sync->sync_fd = -1; + sync->tbm_surface = NULL; + free(sync); } } - - surf_source->sync_info.sync_fd = -1; - surf_source->sync_info.tbm_surface = NULL; - } - - if (!surf_source->use_sync_fence){ + } else { _twe_thread_wl_surface_acquire_and_commit(surf_source); } } @@ -3112,6 +3113,7 @@ twe_surface_add(twe_thread* thread, source->committed_buffers = __tpl_list_alloc(); source->in_use_buffers = __tpl_list_alloc(); source->fence_waiting_sources = __tpl_list_alloc(); + source->render_done_fences = __tpl_list_alloc(); source->render_done_cnt = 0; source->cb_data = NULL; @@ -3138,9 +3140,6 @@ twe_surface_add(twe_thread* thread, source->presentation_sync_ts_backup = 0; source->presentation_sync_req_cnt = 0; - source->sync_info.tbm_surface = NULL; - source->sync_info.sync_fd = -1; - if (!disp_source->is_vulkan_dpy) { struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle; @@ -3718,13 +3717,26 @@ twe_surface_set_sync_fd(twe_surface_h twe_surface, close(buf_info->acquire_fence_fd); buf_info->acquire_fence_fd = sync_fd; } else { - g_mutex_lock(&surf_source->surf_mutex); - surf_source->sync_info.sync_fd = sync_fd; - surf_source->sync_info.tbm_surface = tbm_surface; - surf_source->use_sync_fence = TPL_TRUE; - TPL_DEBUG("[SET_SYNC_FD] surf_source(%p) tbm_surface(%p) sync_fd(%d)", - surf_source, tbm_surface, sync_fd); - g_mutex_unlock(&surf_source->surf_mutex); + /* The sync_info being pushed will be popped when surface_dispatch + * is called and attached to the twe_thread. */ + struct sync_info *sync = (struct sync_info *)calloc(1, sizeof(struct sync_info)); + if (sync) { + sync->sync_fd = sync_fd; + sync->tbm_surface = tbm_surface; + + if (surf_source->render_done_fences) { + g_mutex_lock(&surf_source->surf_mutex); + __tpl_list_push_back(surf_source->render_done_fences, + (void *)sync); + surf_source->use_sync_fence = TPL_TRUE; + TPL_DEBUG("[SET_SYNC_FD] surf_source(%p) tbm_surface(%p) sync_fd(%d)", + surf_source, tbm_surface, sync_fd); + g_mutex_unlock(&surf_source->surf_mutex); + } else { + surf_source->use_sync_fence = TPL_FALSE; + free(sync); + } + } } return ret; -- 2.7.4 From eea8387527bcf50ff4fd2ad7821b79642369e6f1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 19 Aug 2020 19:46:51 +0900 Subject: [PATCH 02/16] Package version up to 1.7.11 Change-Id: Iaf37706b20fb16539c3cb4511574f1f1e7dd18be 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 7fdd493..16495d3 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 10 +%define TPL_VERSION_PATCH 11 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From fca3077daabf68f1dfe116fe9691a75d85a54cc9 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 3 Sep 2020 15:33:36 +0900 Subject: [PATCH 03/16] wayland-egl-tizen: changed to use dlog to print logs. Change-Id: Ia248ca9b2ca3c6877a5e0844efa357be7f39ecba Signed-off-by: Joonbum Ko --- configure.ac | 4 ++- packaging/libtpl-egl.spec | 1 + src/wayland-egl-tizen/wayland-egl-tizen.c | 58 ++++++++----------------------- 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/configure.ac b/configure.ac index 71e4070..e59d587 100644 --- a/configure.ac +++ b/configure.ac @@ -102,7 +102,9 @@ AS_IF([test "${enable_dlog}" = "yes" || test "${enable_dlog}" = "1"], [PKG_CHECK_MODULES([DLOG], [dlog]) TPL_CFLAGS+="$DLOG_CFLAGS" TPL_CFLAGS+=" -DDLOG_DEFAULT_ENABLE " - TPL_LIBS+="$DLOG_LIBS"], + TPL_LIBS+="$DLOG_LIBS" + WL_EGL_TIZEN_CFLAGS+="$DLOG_CFLAGS" + WL_EGL_TIZEN_LIBS+="$DLOG_LIBS"], []) AM_CONDITIONAL([ENABLE_DLOG], [test "${enable_dlog}" = "yes" || test "${enable_dlog}" = "1"]) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 16495d3..f360f7d 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -112,6 +112,7 @@ the GPU Vendor DDK's EGL. Version: %{WL_EGL_TIZEN_VERSION} Release: 0 Summary: Wayland EGL TIZEN backend +BuildRequires: pkgconfig(dlog) %description -n libwayland-egl-tizen This package provides tizen specific extension of wayland-egl. diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.c b/src/wayland-egl-tizen/wayland-egl-tizen.c index b4e679c..2fb876c 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.c +++ b/src/wayland-egl-tizen/wayland-egl-tizen.c @@ -3,9 +3,6 @@ #include "wayland-egl-tizen.h" #include "wayland-egl-tizen-priv.h" -#define WL_EGL_DEBUG 1 -#if WL_EGL_DEBUG - #include #include #include @@ -13,41 +10,16 @@ #include #include -unsigned int wl_egl_log_level; - -/* WL-EGL Log Level - 0:unintialized, 1:initialized(no logging), 2:min log, 3:more log */ -#define WL_EGL_LOG(lvl, f, x...) { \ - if (wl_egl_log_level == 1) { \ - } \ - else if (wl_egl_log_level > 1) { \ - if (wl_egl_log_level <= lvl) \ - WL_EGL_LOG_PRINT(f, ##x) \ - } \ - else { \ - char *env = getenv("WL_EGL_LOG_LEVEL"); \ - if (env == NULL) \ - wl_egl_log_level = 1; \ - else \ - wl_egl_log_level = atoi(env); \ - \ - if (wl_egl_log_level > 1 && wl_egl_log_level <= lvl)\ - WL_EGL_LOG_PRINT(f, ##x) \ - } \ - } +#define LOG_TAG "WL_EGL" +#include -#define WL_EGL_LOG_PRINT(fmt, args...) { \ - printf("[\x1b[32mWL-EGL\x1b[0m %d:%d|\x1b[32m%s\x1b[0m|%d] " fmt "\n", \ - getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } - -#define WL_EGL_ERR(f, x...) { \ - printf("[\x1b[31mWL-EGL_ERR\x1b[0m %d:%d|\x1b[31m%s\x1b[0m|%d] " f "\n",\ - getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##x); \ - } +#define FONT_DEFAULT "\033[0m" /* for reset to default color */ +#define FONT_RED "\033[31m" /* for error logs */ +#define FONT_YELLOW "\033[33m" /* for warning logs */ -#else -#define WL_EGL_LOG(lvl, f, x...) -#endif +#define WL_EGL_LOG(f, x...) LOGI(f, ##x) +#define WL_EGL_ERR(f, x...) LOGE(FONT_RED f FONT_DEFAULT, ##x) +#define WL_EGL_WARN(f, x...) LOGW(FONT_YELLOW f FONT_DEFAULT, ##x) void wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, @@ -72,8 +44,8 @@ wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, } if (private->rotation == rotation) { - WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated", - rotation, private->rotation); + WL_EGL_WARN("wl_egl_window(%p) rotation(%d) already rotated", + egl_window, rotation); return; } @@ -137,9 +109,8 @@ wl_egl_window_tizen_set_buffer_transform(struct wl_egl_window *egl_window, } if (private->transform == wl_output_transform) { - WL_EGL_LOG(2, - "wl_output_transform(%d) private->transform(%d) already rotated", - wl_output_transform, private->transform); + WL_EGL_WARN("wl_egl_window(%p) wl_output_transform(%d) already rotated", + egl_window, wl_output_transform); return; } @@ -198,9 +169,8 @@ wl_egl_window_tizen_set_window_transform(struct wl_egl_window *egl_window, } if (private->window_transform == window_transform) { - WL_EGL_LOG(2, - "window_transform(%d) already rotated", - window_transform); + WL_EGL_WARN("wl_egl_window(%p) window_transform(%d) already rotated", + egl_window, window_transform); return; } -- 2.7.4 From 35c4a2c948c999f0c1ee39702bfdd40667b85e4b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 11 Sep 2020 16:23:59 +0900 Subject: [PATCH 04/16] set resize/destroy callback to null when wl_egl_window destroy. Change-Id: Icba12cf793918944567466465ae04720c16d062b Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index bb75442..d817dd1 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1299,6 +1299,8 @@ __cb_destroy_callback(void *private) TPL_LOG_T(BACKEND, "[DESTROY_CB] wl_egl_window(%p) surf_source(%p)", surf_source->wl_egl_window, surf_source); g_mutex_lock(&surf_source->surf_mutex); + surf_source->wl_egl_window->destroy_window_callback = NULL; + surf_source->wl_egl_window->resize_callback = NULL; surf_source->wl_egl_window->driver_private = NULL; surf_source->wl_egl_window = NULL; surf_source->surf = NULL; -- 2.7.4 From 84eb6445fd4e1c041d940329f3c378ee459d69ec Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 11 Sep 2020 16:23:59 +0900 Subject: [PATCH 05/16] Replaced assert used in wl_egl_window callback functions. Change-Id: I25f4aa5263d11656d2f40999a69f539f3c27c27c Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 45 +++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index d817dd1..27adc14 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1332,11 +1332,14 @@ __cb_resize_callback(struct wl_egl_window *wl_egl_window, void *private) TPL_ASSERT(wl_egl_window); struct tizen_private *tizen_private = (struct tizen_private *)private; + twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; int cur_w, cur_h, req_w, req_h, format; - TPL_ASSERT(tizen_private->data); - - twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; + if (!source) { + TPL_ERR("Invalid wl_egl_window(%p) tizen_private->data is null.", + wl_egl_window); + return; + } format = tbm_surface_queue_get_format(source->tbm_queue); cur_w = tbm_surface_queue_get_width(source->tbm_queue); @@ -1364,7 +1367,11 @@ __cb_rotate_callback(struct wl_egl_window *wl_egl_window, void *private) twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; int rotation = tizen_private->rotation; - TPL_ASSERT(source); + if (!source) { + TPL_ERR("Invalid wl_egl_window(%p) tizen_private->data is null.", + wl_egl_window); + return; + } TPL_LOG_T(BACKEND, "[ROTATE_CB] wl_egl_window(%p) (%d) -> (%d)", wl_egl_window, source->rotation, rotation); @@ -1384,15 +1391,20 @@ __cb_get_rotation_capability(struct wl_egl_window *wl_egl_window, int rotation_capability = WL_EGL_WINDOW_TIZEN_CAPABILITY_NONE; struct tizen_private *tizen_private = (struct tizen_private *)private; + twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; - if (tizen_private->data) { - twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; - if (source->rotation_capability == TPL_TRUE) - rotation_capability = WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED; - else - rotation_capability = WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_UNSUPPORTED; + if (!source) { + TPL_ERR("Invalid wl_egl_window(%p) tizen_private->data is null.", + wl_egl_window); + return rotation_capability; } + if (source->rotation_capability == TPL_TRUE) + rotation_capability = WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_SUPPORTED; + else + rotation_capability = WL_EGL_WINDOW_TIZEN_CAPABILITY_ROTATION_UNSUPPORTED; + + return rotation_capability; } @@ -1404,13 +1416,16 @@ __cb_set_window_serial_callback(struct wl_egl_window *wl_egl_window, TPL_ASSERT(wl_egl_window); struct tizen_private *tizen_private = (struct tizen_private *)private; + twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; - if (tizen_private->data) { - twe_wl_surf_source *source = (twe_wl_surf_source *)tizen_private->data; - - source->set_serial_is_used = TPL_TRUE; - source->serial = serial; + if (!source) { + TPL_ERR("Invalid wl_egl_window(%p) tizen_private->data is null.", + wl_egl_window); + return; } + + source->set_serial_is_used = TPL_TRUE; + source->serial = serial; } static int -- 2.7.4 From 758ae697356c4ff50c4c973ea87810038d9543bb Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 11 Sep 2020 16:40:52 +0900 Subject: [PATCH 06/16] Package version up to 1.7.12 Change-Id: If3b4764fb09fb25f073fe6f418c77c6d7a49f413 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 f360f7d..86c3b5b 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 11 +%define TPL_VERSION_PATCH 12 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From b24582664132f52cd64e483cdee5881a74866894 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 25 Sep 2020 11:16:26 +0900 Subject: [PATCH 07/16] Set initial latest_transform to 0. - When the initial transform of wl_egl_window is passed to tpl_surface without being 0, the transform value may not be notified to the server. - Therefore, in tpl_surface, latest_transform must be set to 0. Change-Id: I3f586f64ded24dd570837bcff5bb4f938f384865 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl.c | 2 +- src/tpl_wayland_egl_thread.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 19611a7..1a57fef 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -640,7 +640,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) surface->rotation = tizen_private->rotation; surface->rotation_capability = TPL_FALSE; - wayland_egl_surface->latest_transform = tizen_private->transform; + wayland_egl_surface->latest_transform = 0; wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback; wl_egl_window->destroy_window_callback = (void *)__cb_client_window_destroy_callback; diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 27adc14..416ab35 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3180,8 +3180,6 @@ twe_surface_add(twe_thread* thread, private->create_presentation_sync_fd = (void *)__cb_create_presentation_sync_fd; private->merge_sync_fds = (void *)__cb_merge_sync_fds; - source->latest_transform = private->transform; - wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback; wl_egl_window->resize_callback = (void *)__cb_resize_callback; } -- 2.7.4 From f3585065e1568bb11eca0b0daed78cbe81d4e115 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 25 Sep 2020 11:21:15 +0900 Subject: [PATCH 08/16] Package version up to 1.7.13 Change-Id: I9e9085c36326507ef717a177df161ddefd6febac 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 86c3b5b..98e0c89 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 12 +%define TPL_VERSION_PATCH 13 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 3f8a69b4a912f0d7bf292bfa0b16f3bcf92e5c4e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 9 Nov 2020 16:07:56 +0900 Subject: [PATCH 09/16] Trace the presentation feedback and destroy it properly. Change-Id: I6d7656a20c47f9cd8047cec97610d28ec71b2902 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 56 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 416ab35..cb62f4f 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -63,6 +63,11 @@ struct _twe_tdm_source { int tdm_fd; }; +struct feedback_info { + struct wp_presentation_feedback *feedback; + twe_wl_surf_source *surf_source; +}; + struct _twe_wl_disp_source { GSource gsource; GPollFD gfd; @@ -71,6 +76,7 @@ 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 { @@ -1093,6 +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); + wl_event_queue_destroy(disp_source->ev_queue); g_mutex_unlock(&disp_source->wl_event_mutex); @@ -1165,6 +1173,9 @@ twe_display_add(twe_thread* thread, TPL_DISPLAY_PRESENT_MODE_FIFO; _twe_display_wayland_init(source); + 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; @@ -2319,7 +2330,9 @@ __cb_presentation_feedback_presented(void *data, TPL_IGNORE(seq_lo); TPL_IGNORE(flags); - twe_wl_surf_source *surf_source = (twe_wl_surf_source *)data; + 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); @@ -2346,6 +2359,9 @@ __cb_presentation_feedback_presented(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); + g_mutex_unlock(&surf_source->pst_mutex); } @@ -2353,7 +2369,9 @@ static void __cb_presentation_feedback_discarded(void *data, struct wp_presentation_feedback *presentation_feedback) { - twe_wl_surf_source *surf_source = (twe_wl_surf_source *)data; + 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); @@ -2380,6 +2398,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); + g_mutex_unlock(&surf_source->pst_mutex); } @@ -2413,9 +2434,16 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, g_mutex_lock(&surf_source->pst_mutex); if (disp_source->presentation && surf_source->presentation_sync_req_cnt > 0) { - p_feedback = wp_presentation_feedback(disp_source->presentation, - wl_surface); - wp_presentation_feedback_add_listener(p_feedback, &feedback_listener, surf_source); + 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); + __tpl_list_push_back(disp_source->presentation_feedbacks, (void *)feedback_info); + } } g_mutex_unlock(&surf_source->pst_mutex); @@ -2945,6 +2973,24 @@ _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); + } + + num_feedbacks--; + } + } + if (surf_source->in_use_buffers) { __tpl_list_free(surf_source->in_use_buffers, (tpl_free_func_t)__cb_buffer_remove_from_list); -- 2.7.4 From 73ffe63a2aea71b17faae0312d89755beaac5797 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 9 Nov 2020 16:09:06 +0900 Subject: [PATCH 10/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 11/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 12/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 13/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 14/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 15/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 16/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