From a4ff35ab481c0276f675c6ddbfa25067ca5d5b50 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 24 Apr 2020 13:21:27 +0900 Subject: [PATCH 01/16] Fixed to print fence fd passed by enqueue_buffer. Change-Id: Iaceb87b819e8fbad1539e5abc94bb3d5d525b8a3 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index fac6875..f3a0fc9 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -545,8 +545,8 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, TRACE_MARK("[ENQ] BO_NAME:%d", bo_name); TPL_LOG_T("WL_EGL", - "[ENQ] wayland_egl_surface(%p) tbm_surface(%p) bo(%d)", - wayland_egl_surface, tbm_surface, bo_name); + "[ENQ] wayland_egl_surface(%p) tbm_surface(%p) bo(%d) fence(%d)", + wayland_egl_surface, tbm_surface, bo_name, sync_fence); /* If there are received region information, * save it to buf_info in tbm_surface user_data using below API. */ -- 2.7.4 From 2aa72bf3285da6b14a918b8738fe7e42d65470c2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 27 Apr 2020 16:29:50 +0900 Subject: [PATCH 02/16] Fixed a bug that could cause deadlock. Change-Id: Idb231c020b08e60aa3e2368562551a7e06cfd61b Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index a5801ec..f815193 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2294,7 +2294,6 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) tbm_surface_internal_get_user_data(tbm_surface, KEY_BUFFER_INFO, (void **)&buf_info); - g_mutex_lock(&surf_source->surf_mutex); if (!disp_source->is_vulkan_dpy) { /* wayland_egl */ if (surf_source->vblank_done) { TPL_LOG_T(BACKEND, "[ACQ] tbm_surface(%p) bo(%d)", @@ -2363,7 +2362,6 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) break; } } - g_mutex_unlock(&surf_source->surf_mutex); } } @@ -3289,13 +3287,13 @@ _twe_thread_fence_wait_source_dispatch(GSource *source, GSourceFunc cb, gpointer TRACE_ASYNC_END((int)wait_source, "FENCE WAIT fd(%d)", wait_source->fence_fd); + g_mutex_lock(&surf_source->surf_mutex); /* Since this source is going to be removed, acquire_and_commit must be * executed even in a situation other than G_IO_IN. * Nevertheless, there may be room for improvement. */ _twe_thread_wl_surface_acquire_and_commit(surf_source); tbm_surface_internal_unref(tbm_surface); - g_mutex_lock(&surf_source->surf_mutex); __tpl_list_remove_data(surf_source->fence_waiting_sources, (void *)wait_source, TPL_FIRST, NULL); g_mutex_unlock(&surf_source->surf_mutex); -- 2.7.4 From aca218df76453a2484bd9e938e823063a04e1834 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 27 Apr 2020 18:45:03 +0900 Subject: [PATCH 03/16] Changed getenv() for TPL_WAIT_VBLANK to be called from main thread. Change-Id: I9e5143492d35ed7e6c1722af3c0b7888ff918aa8 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index f815193..79bcb91 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -42,6 +42,7 @@ struct _twe_thread_context { int ref_cnt; + tpl_bool_t use_wait_vblank; twe_tdm_source *tdm_source; twe_del_source *tdm_del_source; @@ -216,12 +217,9 @@ _twe_thread_loop(gpointer data) { twe_thread_context *ctx = data; - char *env = NULL; - g_mutex_lock(&ctx->thread_mutex); - env = getenv("TPL_WAIT_VBLANK"); - if (env == NULL || atoi(env)) { + if (ctx->use_wait_vblank) { twe_tdm_source *tdm_source = _twe_thread_tdm_source_create(); if (tdm_source) { @@ -506,6 +504,7 @@ twe_thread* twe_thread_create(void) { twe_thread *thread = NULL; + char *env = NULL; thread = calloc(1, sizeof(twe_thread)); if (!thread) { @@ -531,6 +530,13 @@ twe_thread_create(void) g_mutex_init(&_twe_ctx->thread_mutex); g_cond_init(&_twe_ctx->thread_cond); + _twe_ctx->use_wait_vblank = TPL_TRUE; + + env = getenv("TPL_WAIT_VBLANK"); + if (env && !atoi(env)) { + _twe_ctx->use_wait_vblank = TPL_FALSE; + } + g_mutex_lock(&_twe_ctx->thread_mutex); _twe_ctx->twe_thread = g_thread_new("twe_thread", _twe_thread_loop, _twe_ctx); -- 2.7.4 From 544f32c939a2ea99d7a33a96582cfa58ff5ff8d3 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 27 Apr 2020 19:07:02 +0900 Subject: [PATCH 04/16] Added inline function tpl_getenv() to replace getenv. Change-Id: I1018d6f7c11bba4aaaee3e29cc53dd1660f70593 Signed-off-by: Joonbum Ko --- src/tpl.c | 2 ++ src/tpl_utils.h | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/tpl.c b/src/tpl.c index 2a19d8d..8107b8f 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -2,6 +2,8 @@ unsigned int tpl_log_lvl = 0; unsigned int tpl_log_initialized = 0; +unsigned int tpl_getenv_initialized = 0; +unsigned int tpl_getenv_enabled = 0; unsigned int tpl_dump_lvl = 0; struct _tpl_runtime { diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 7f55fec..9e0369f 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -6,6 +6,7 @@ #include #include #include +#include #if defined(__GNUC__) && __GNUC__ >= 4 # define TPL_API __attribute__ ((visibility("default"))) @@ -53,8 +54,33 @@ /* 0:uninitialized, 1:initialized,no log, 2:user log */ extern unsigned int tpl_log_lvl; extern unsigned int tpl_log_initialized; +extern unsigned int tpl_getenv_initialized; +extern unsigned int tpl_getenv_enabled; extern unsigned int tpl_dump_lvl; +#define TPL_GETENV_INIT() \ + { \ + if (!tpl_getenv_initialized) \ + { \ + int ret = access("/opt/usr/tpl_env", F_OK); \ + if (ret == 0) \ + tpl_getenv_enabled = 1; \ + else \ + tpl_getenv_enabled = 0; \ + tpl_getenv_initialized = 1; \ + } \ + } + +inline char *tpl_getenv(const char *name) +{ + TPL_GETENV_INIT(); + if (tpl_getenv_enabled) + return getenv(name); + else + return NULL; +} + + #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 */ @@ -289,7 +315,6 @@ extern unsigned int tpl_dump_lvl; } #endif - typedef struct _tpl_list_node tpl_list_node_t; typedef struct _tpl_list tpl_list_t; typedef struct tpl_util_map_entry tpl_util_map_entry_t; -- 2.7.4 From 039117dfaac098322e6177e8bc0d3f8e5a707adc Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 27 Apr 2020 20:36:18 +0900 Subject: [PATCH 05/16] Replaced all getenv() by tpl_getenv() to reduce unnecessary calls. - In libtpl-egl, getenv() is using for debugging purposes only. - In most situations, it was frequently called getenv() which is not thread-safe, even though it is unnecessary. - It is difficult to make getenv() completely disabled, but replaced it with tpl_getenv() so that it can only be used in debugging situations. - tpl_getenv() returns the result of calling getenv() only if '/opt/usr/tpl_env' file exists, otherwise NULL. - example 1. $ export TPL_LOG_LEVEL=3 2. $ run gl app -> libtpl-egl will not get the env TPL_LOG_LEVEL 3. $ touch /opt/usr/tpl_env 4. $ run gl app -> TPL_LOG_LEVEL=3 will be accepted Change-Id: I4d40e1beb2f4c34e17b7694f96db5d237cb33bfe Signed-off-by: Joonbum Ko --- src/tpl.c | 4 ++-- src/tpl_object.c | 2 +- src/tpl_utils.h | 4 ++-- src/tpl_wayland_egl.c | 2 +- src/tpl_wayland_egl_thread.c | 2 +- src/tpl_x11_dri2.c | 4 ++-- src/tpl_x11_dri3.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index 8107b8f..e6d90f0 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -231,11 +231,11 @@ __tpl_display_choose_backend(tpl_handle_t native_dpy) int wl_egl_thread = 0; #endif - thread = getenv("TPL_WL_EGL_THREAD"); + thread = tpl_getenv("TPL_WL_EGL_THREAD"); if (thread) wl_egl_thread = atoi(thread); - plat_name = getenv("EGL_PLATFORM"); + plat_name = tpl_getenv("EGL_PLATFORM"); if (plat_name) { #ifdef TPL_WINSYS_DRI2 diff --git a/src/tpl_object.c b/src/tpl_object.c index cf66cb0..4eb48c6 100644 --- a/src/tpl_object.c +++ b/src/tpl_object.c @@ -11,7 +11,7 @@ __tpl_object_hash_init(void) char *val; tpl_obj_hash_check = TPL_FALSE; - val = getenv("TPL_OBJECT_HASH_CHECK"); + val = tpl_getenv("TPL_OBJECT_HASH_CHECK"); if ((val) && (!strcmp(val, "1")) && (!tpl_obj_hash)) { tpl_obj_hash_check = TPL_TRUE; tpl_obj_hash = __tpl_hashlist_create(); diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 9e0369f..92cb6a0 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -152,7 +152,7 @@ inline char *tpl_getenv(const char *name) { \ if (!tpl_log_initialized) \ { \ - char *env = getenv("TPL_LOG_LEVEL"); \ + char *env = tpl_getenv("TPL_LOG_LEVEL"); \ if (env == NULL) \ tpl_log_lvl = 0; \ else \ @@ -303,7 +303,7 @@ inline char *tpl_getenv(const char *name) } \ else \ { \ - char *env = getenv("TPL_DUMP_LEVEL"); \ + char *env = tpl_getenv("TPL_DUMP_LEVEL"); \ if (env == NULL) \ tpl_dump_lvl = 0; \ else \ diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index d3d4d38..19611a7 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -173,7 +173,7 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) (struct wl_display *)display->native_handle; wayland_egl_display->wl_tbm_client = wayland_tbm_client_init((struct wl_display *) wl_dpy); - char *env = getenv("TPL_WAIT_VBLANK"); + char *env = tpl_getenv("TPL_WAIT_VBLANK"); if (!wayland_egl_display->wl_tbm_client) { TPL_ERR("Wayland TBM initialization failed!"); diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 79bcb91..6722970 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -532,7 +532,7 @@ twe_thread_create(void) _twe_ctx->use_wait_vblank = TPL_TRUE; - env = getenv("TPL_WAIT_VBLANK"); + env = tpl_getenv("TPL_WAIT_VBLANK"); if (env && !atoi(env)) { _twe_ctx->use_wait_vblank = TPL_FALSE; } diff --git a/src/tpl_x11_dri2.c b/src/tpl_x11_dri2.c index c38f2c7..e5480a7 100644 --- a/src/tpl_x11_dri2.c +++ b/src/tpl_x11_dri2.c @@ -207,10 +207,10 @@ __tpl_x11_dri2_display_init(tpl_display_t *display) global.bufmgr = tbm_bufmgr_init(global.bufmgr_fd); /* Initialize swap type configuration. */ - __tpl_x11_swap_str_to_swap_type(getenv(EGL_X11_WINDOW_SWAP_TYPE_ENV_NAME), + __tpl_x11_swap_str_to_swap_type(tpl_getenv(EGL_X11_WINDOW_SWAP_TYPE_ENV_NAME), &global.win_swap_type); - __tpl_x11_swap_str_to_swap_type(getenv(EGL_X11_FB_SWAP_TYPE_ENV_NAME), + __tpl_x11_swap_str_to_swap_type(tpl_getenv(EGL_X11_FB_SWAP_TYPE_ENV_NAME), &global.fb_swap_type); } diff --git a/src/tpl_x11_dri3.c b/src/tpl_x11_dri3.c index 076446b..3f90de3 100644 --- a/src/tpl_x11_dri3.c +++ b/src/tpl_x11_dri3.c @@ -1237,7 +1237,7 @@ __tpl_x11_dri3_display_init(tpl_display_t *display) { const char *backend_env = NULL; int count = 0; - backend_env = getenv("MALI_EGL_DRI3_BUF_NUM"); + backend_env = tpl_getenv("MALI_EGL_DRI3_BUF_NUM"); /* 2015-05-13 joonbum.ko@samsung.com */ /* Change the value of dri3_max_back 5 to 3 */ if (!backend_env || strlen(backend_env) == 0) -- 2.7.4 From 9ed760f3c77d58726ba5921a64649cfa34c374a3 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 29 Apr 2020 15:04:23 +0900 Subject: [PATCH 06/16] Moved tpl_getenv init to tpl_init Change-Id: I825862911ca1fe4054908cc678d9e960aa5e75c7 Signed-off-by: Joonbum Ko --- src/tpl.c | 10 ++++++++++ src/tpl_utils.h | 15 --------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index e6d90f0..50e19af 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -31,6 +31,16 @@ __tpl_runtime_init() static void __attribute__((constructor)) __tpl_init(void) { + if (!tpl_getenv_initialized) + { + int ret = access("/opt/usr/tpl_env", F_OK); + if (ret == 0) + tpl_getenv_enabled = 1; + else + tpl_getenv_enabled = 0; + tpl_getenv_initialized = 1; + } + TPL_DEBUG("[libtpl-egl] loaded"); #ifdef OBJECT_HASH_CHECK __tpl_object_hash_init(); diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 92cb6a0..89854a1 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -54,26 +54,11 @@ /* 0:uninitialized, 1:initialized,no log, 2:user log */ extern unsigned int tpl_log_lvl; extern unsigned int tpl_log_initialized; -extern unsigned int tpl_getenv_initialized; extern unsigned int tpl_getenv_enabled; extern unsigned int tpl_dump_lvl; -#define TPL_GETENV_INIT() \ - { \ - if (!tpl_getenv_initialized) \ - { \ - int ret = access("/opt/usr/tpl_env", F_OK); \ - if (ret == 0) \ - tpl_getenv_enabled = 1; \ - else \ - tpl_getenv_enabled = 0; \ - tpl_getenv_initialized = 1; \ - } \ - } - inline char *tpl_getenv(const char *name) { - TPL_GETENV_INIT(); if (tpl_getenv_enabled) return getenv(name); else -- 2.7.4 From e61ae4b4270b0b5000b4f4238e6b916696474b48 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 6 May 2020 18:44:54 +0900 Subject: [PATCH 07/16] Package version up to 1.7.6 Change-Id: I4ad491a190a0b18521a272d623738cd17cd0fa83 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 98712ac..4c3c68b 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 5 +%define TPL_VERSION_PATCH 6 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From c3516d1de7e02d41852dd05ff441f796de0f9335 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 14 May 2020 19:07:14 +0900 Subject: [PATCH 08/16] Fixed to unref tbm_surface even when enqueue failed. Change-Id: I99a3e93833430a652cb653d8343a6dfd1a2d2342 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index f3a0fc9..5ca8691 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -598,16 +598,8 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, tsq_err = tbm_surface_queue_enqueue(wayland_egl_surface->tbm_queue, tbm_surface); - if (tsq_err == TBM_SURFACE_QUEUE_ERROR_NONE) { - /* - * If tbm_surface_queue has not been reset, tbm_surface_queue_enqueue - * will return ERROR_NONE. Otherwise, queue has been reset - * this tbm_surface may have only one ref_count. So we need to - * unreference this tbm_surface after getting ERROR_NONE result from - * tbm_surface_queue_enqueue in order to prevent destruction. - */ + if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { tbm_surface_internal_unref(tbm_surface); - } else { TPL_ERR("Failed to enqueue tbm_surface(%p). tsq_err=%d", tbm_surface, tsq_err); TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); @@ -615,6 +607,8 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, return TPL_ERROR_INVALID_OPERATION; } + tbm_surface_internal_unref(tbm_surface); + TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); TPL_OBJECT_UNLOCK(wayland_egl_surface); -- 2.7.4 From 85995920898b3bd0c86824383180c4d8f5aaf79c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 27 May 2020 16:13:11 +0900 Subject: [PATCH 09/16] Changed the default log output from LOGD to LOGI. Change-Id: I26d2328a119dfe23523f279f9b72eab7ba9ea552 Signed-off-by: Joonbum Ko --- src/tpl_utils.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tpl_utils.h b/src/tpl_utils.h index 89854a1..26b696e 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -80,10 +80,10 @@ inline char *tpl_getenv(const char *name) #endif #ifdef DLOG_DEFAULT_ENABLE -#define tpl_log_f(t, f, x...) LOGD(FONT_GREEN t FONT_DEFAULT " " f, ##x) -#define tpl_log_b(t, f, x...) LOGD(FONT_BLUE t FONT_DEFAULT " " f, ##x) -#define tpl_log_d(t, f, x...) LOGD(FONT_MAGENTA t FONT_DEFAULT " " f, ##x) -#define tpl_log_t(t, f, x...) LOGD(FONT_CYAN t FONT_DEFAULT " " f, ##x) +#define tpl_log_f(t, f, x...) LOGI(FONT_GREEN t FONT_DEFAULT " " f, ##x) +#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_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 */ -- 2.7.4 From b4dcff113ae780d2049053b3b067202401c0fe7a Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 28 May 2020 12:52:09 +0900 Subject: [PATCH 10/16] Enhanced the error logs. Change-Id: I0ec3e186f1318a050c75fe1596b60803191f8100 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 5ca8691..15697a4 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -448,7 +448,7 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface) static tpl_result_t __tpl_wl_egl_surface_set_rotation_capability(tpl_surface_t *surface, - tpl_bool_t set) + tpl_bool_t set) { tpl_wayland_egl_surface_t *wayland_egl_surface = NULL; @@ -459,8 +459,8 @@ __tpl_wl_egl_surface_set_rotation_capability(tpl_surface_t *surface, wayland_egl_surface = (tpl_wayland_egl_surface_t *)surface->backend.data; if (!wayland_egl_surface) { - TPL_ERR("Invalid parameter. wayland_egl_surface(%p)", - wayland_egl_surface); + TPL_ERR("Invalid parameter. surface(%p) wayland_egl_surface(%p)", + surface, wayland_egl_surface); return TPL_ERROR_INVALID_PARAMETER; } @@ -478,7 +478,7 @@ __tpl_wl_egl_surface_set_rotation_capability(tpl_surface_t *surface, static tpl_result_t __tpl_wl_egl_surface_set_post_interval(tpl_surface_t *surface, - int post_interval) + int post_interval) { tpl_wayland_egl_surface_t *wayland_egl_surface = NULL; @@ -489,8 +489,8 @@ __tpl_wl_egl_surface_set_post_interval(tpl_surface_t *surface, wayland_egl_surface = (tpl_wayland_egl_surface_t *)surface->backend.data; if (!wayland_egl_surface) { - TPL_ERR("Invalid parameter. wayland_egl_surface(%p)", - wayland_egl_surface); + TPL_ERR("Invalid parameter. surface(%p) wayland_egl_surface(%p)", + surface, wayland_egl_surface); return TPL_ERROR_INVALID_PARAMETER; } @@ -527,8 +527,8 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, bo_name = tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)); if (!wayland_egl_surface) { - TPL_ERR("Invalid parameter. wayland_egl_surface(%p)", - wayland_egl_surface); + TPL_ERR("Invalid parameter. surface(%p) wayland_egl_surface(%p)", + surface, wayland_egl_surface); TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); TPL_OBJECT_UNLOCK(wayland_egl_surface); return TPL_ERROR_INVALID_PARAMETER; @@ -600,8 +600,8 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { tbm_surface_internal_unref(tbm_surface); - TPL_ERR("Failed to enqueue tbm_surface(%p). tsq_err=%d", - tbm_surface, tsq_err); + TPL_ERR("Failed to enqueue tbm_surface(%p). tpl_surface(%p) tsq_err=%d", + tbm_surface, surface, tsq_err); TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); TPL_OBJECT_UNLOCK(wayland_egl_surface); return TPL_ERROR_INVALID_OPERATION; @@ -655,7 +655,8 @@ __tpl_wl_egl_surface_cancel_dequeued_buffer(tpl_surface_t *surface, tsq_err = tbm_surface_queue_cancel_dequeue(wayland_egl_surface->tbm_queue, tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { - TPL_ERR("Failed to release tbm_surface(%p)", tbm_surface); + TPL_ERR("Failed to release tbm_surface(%p) surface(%p)", + tbm_surface, surface); return TPL_ERROR_INVALID_OPERATION; } @@ -701,11 +702,12 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, lock_ret = twe_display_lock(wayland_egl_display->twe_display); if (tsq_err == TBM_SURFACE_QUEUE_ERROR_TIMEOUT) { - TPL_ERR("[CAN_DEQUEUE_TIMEOUT] queue(%p) will be reset", - wayland_egl_surface->tbm_queue); + TPL_ERR("[CAN_DEQUEUE_TIMEOUT] queue(%p) will be reset. surface(%p)", + wayland_egl_surface->tbm_queue, surface); if (twe_surface_queue_force_flush(wayland_egl_surface->twe_surface) != TPL_ERROR_NONE) { - TPL_ERR("Failed to timeout reset. tbm_queue(%p)", wayland_egl_surface->tbm_queue); + TPL_ERR("Failed to timeout reset. tbm_queue(%p) surface(%p)", + wayland_egl_surface->tbm_queue, surface); if (lock_ret == TPL_ERROR_NONE) twe_display_unlock(wayland_egl_display->twe_display); return NULL; @@ -715,7 +717,8 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, } if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { - TPL_ERR("Failed to query can_dequeue. tbm_queue(%p)", wayland_egl_surface->tbm_queue); + TPL_ERR("Failed to query can_dequeue. tbm_queue(%p) surface(%p)", + wayland_egl_surface->tbm_queue, surface); if (lock_ret == TPL_ERROR_NONE) twe_display_unlock(wayland_egl_display->twe_display); return NULL; @@ -766,8 +769,8 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue, &tbm_surface); if (!tbm_surface) { - TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", - tsq_err); + TPL_ERR("Failed to dequeue from tbm_queue(%p) surface(%p)| tsq_err = %d", + wayland_egl_surface->tbm_queue, surface, tsq_err); if (lock_ret == TPL_ERROR_NONE) twe_display_unlock(wayland_egl_display->twe_display); return NULL; -- 2.7.4 From 773e37bd4f9b80d116a75f2f664917f31165b61e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 28 May 2020 13:29:30 +0900 Subject: [PATCH 11/16] Package version up to 1.7.7 Change-Id: I059dad443fb17d301aaeb10aa870fb23be999c86 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 4c3c68b..3609994 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 6 +%define TPL_VERSION_PATCH 7 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 8d4dee8677e95eac9019a4e3e9b2c2e63fd5ddcd Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 15 Jun 2020 16:25:27 +0900 Subject: [PATCH 12/16] Fixed a bug related to presentation sync timestamp. Change-Id: I0fad572699eb008378b52f6abbd5c2edc3795e66 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 6722970..8012edc 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1346,11 +1346,17 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv } 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, - NULL, - surf_source->presentation_sync_timestamp++); + 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); -- 2.7.4 From 8bdba6676623af16aded1772ec538922fb6f2fda Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 16 Jun 2020 12:55:40 +0900 Subject: [PATCH 13/16] Fixed a bug related to commit sync. Change-Id: Ie104256039adcf193cd845b3727643fb97eae1f5 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 8012edc..56afe25 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -175,6 +175,8 @@ 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; @@ -1317,7 +1319,7 @@ __cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private) 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, + 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]"); @@ -1584,6 +1586,8 @@ _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->commit_sync_ts_backup = ++surf_source->commit_sync_timestamp; + if (surf_source->in_use_buffers) { g_mutex_lock(&surf_source->surf_mutex); __tpl_list_push_back(surf_source->in_use_buffers, @@ -1668,6 +1672,7 @@ _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; if (buf_info->is_vk_image) { buf_info->sync_timeline = tbm_sync_timeline_create(); @@ -2247,11 +2252,10 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, } if (surf_source->commit_sync_timeline != -1) { - surf_source->commit_sync_timestamp++; - TRACE_ASYNC_END(surf_source->commit_sync_timestamp, "[SYNC_FENCE]"); + TRACE_ASYNC_END(buf_info->commit_sync_ts_backup, "[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); + 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); } -- 2.7.4 From 5516e085447c3cf40def01e269fc377bd024d158 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 1 Jun 2020 19:22:52 +0900 Subject: [PATCH 14/16] Moved wl_display_flush to be called immediately after wl_surface_commit. Change-Id: I7ab8f9d99824d1a6548db4c82d619c35024b54cd Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 56afe25..f347d46 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1689,7 +1689,6 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, wl_buffer_add_listener((void *)buf_info->wl_buffer, &wl_buffer_release_listener, tbm_surface); - wl_display_flush(surf_source->disp_source->disp); tbm_surface_internal_add_user_data(tbm_surface, KEY_BUFFER_INFO, (tbm_data_free)__cb_twe_buffer_free_callback); @@ -2006,6 +2005,8 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source, wl_surface_commit(wl_surface); + 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_ASYNC_BEGIN((int)tbm_surface, "[COMMIT ~ RELEASE] BO(%d)", @@ -2233,6 +2234,8 @@ _twe_thread_wl_surface_commit(twe_wl_surf_source *surf_source, wl_surface_commit(wl_surface); + 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))); -- 2.7.4 From b79a476a4d7ace0849710bf4adc9fc9ce10799d0 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 17 Jun 2020 13:54:39 +0900 Subject: [PATCH 15/16] Fixed missing close for open timeline fd. Change-Id: Ib0f009a12fec57968ea5f220426cada2497a4c34 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index f347d46..1b12f4e 100755 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2754,6 +2754,16 @@ _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_unlock(&surf_source->surf_mutex); g_mutex_clear(&surf_source->surf_mutex); -- 2.7.4 From 1a3bffdccdc63a32682eef3e9f0481d6db141c2c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 17 Jun 2020 13:56:09 +0900 Subject: [PATCH 16/16] Package version up to 1.7.8 Change-Id: I566dad831a07e60cee55870081b183a1638895b4 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 3609994..58ba310 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 7 +%define TPL_VERSION_PATCH 8 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4