From 046bd77d08dfebd800bc1df1b5678ab88d74abb1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 28 Dec 2018 16:37:25 +0900 Subject: [PATCH 01/16] tpl_wl_egl_thread: Implemented force_flush to use can_dequeue_wait_timeout. - This is a patch to solve the problem of blocking in tbm_surface_queue_can_dequeue() if release_event is missing due to wayland socket or server logic problem. - If TBM_SURFACE_QUEUE_ERROR_TIMEOUT occurs, new buffers are allocated to escape blocking without waiting for buffer release events. Change-Id: I883c65b3af3cfa66336f4301628614ede0b421a7 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 35 +++++++++++++++++++++++++++++++++++ src/tpl_wayland_egl_thread.h | 3 +++ src/tpl_wl_egl_thread.c | 30 +++++++++++++++++++++++++----- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index ce5f854..3e9a913 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3169,6 +3169,41 @@ twe_surface_wait_dequeueable(twe_surface_h twe_surface, uint64_t timeout_ns) return TPL_ERROR_NONE; } +tpl_result_t +twe_surface_queue_force_flush(twe_surface_h twe_surface) +{ + twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface; + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_NONE; + + if ((tsq_err = tbm_surface_queue_flush(surf_source->tbm_queue)) + != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("[TIMEOUT_RESET] Failed to flush tbm_surface_queue(%p) tsq_err(%d)", + surf_source->tbm_queue, tsq_err); + return TPL_ERROR_INVALID_OPERATION; + } + + if (surf_source->committed_buffers) { + while (!__tpl_list_is_empty(surf_source->committed_buffers)) { + tbm_surface_h tbm_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))); + 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)", + tbm_surface, tsq_err); + } + } + + TPL_LOG_T(BACKEND, + "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)", + surf_source, surf_source->tbm_queue); + + return TPL_ERROR_NONE; +} + tpl_bool_t twe_check_native_handle_is_wl_display(tpl_handle_t display) diff --git a/src/tpl_wayland_egl_thread.h b/src/tpl_wayland_egl_thread.h index 4f7ba97..dfe6f6f 100644 --- a/src/tpl_wayland_egl_thread.h +++ b/src/tpl_wayland_egl_thread.h @@ -98,6 +98,9 @@ twe_surface_create_sync_fd(tbm_surface_h tbm_surface); tpl_result_t twe_surface_wait_dequeueable(twe_surface_h twe_surface, uint64_t timeout_ns); +tpl_result_t +twe_surface_queue_force_flush(twe_surface_h twe_surface); + tpl_bool_t twe_check_native_handle_is_wl_display(tpl_handle_t display); diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 6f7f4a4..f819b45 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -634,6 +634,8 @@ __tpl_wl_egl_surface_cancel_dequeued_buffer(tpl_surface_t *surface, return TPL_ERROR_NONE; } +#define CAN_DEQUEUE_TIMEOUT_MS 5000 + static tbm_surface_h __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_fd *sync_fence) @@ -658,11 +660,8 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, *sync_fence = -1; TPL_OBJECT_UNLOCK(surface); - if (!tbm_surface_queue_can_dequeue(wayland_egl_surface->tbm_queue, 1)) { - TPL_ERR("Failed to query can_dequeue. tbm_queue(%p)", wayland_egl_surface->tbm_queue); - TPL_OBJECT_LOCK(surface); - return NULL; - } + tsq_err = tbm_surface_queue_can_dequeue_wait_timeout( + wayland_egl_surface->tbm_queue, CAN_DEQUEUE_TIMEOUT_MS); TPL_OBJECT_LOCK(surface); /* After the can dequeue state, call twe_display_lock to prevent other @@ -670,6 +669,27 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, * during below dequeue procedure. */ 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); + 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); + if (lock_ret == TPL_ERROR_NONE) + twe_display_unlock(wayland_egl_display->twe_display); + return NULL; + } else { + tsq_err = TBM_SURFACE_QUEUE_ERROR_NONE; + } + } + + if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) { + TPL_ERR("Failed to query can_dequeue. tbm_queue(%p)", wayland_egl_surface->tbm_queue); + if (lock_ret == TPL_ERROR_NONE) + twe_display_unlock(wayland_egl_display->twe_display); + return NULL; + } + /* wayland client can check their states (ACTIVATED or DEACTIVATED) with * below function [wayland_tbm_client_queue_check_activate()]. * This function has to be called before tbm_surface_queue_dequeue() -- 2.7.4 From 017786d0c793ec882b9359cfd79d7b870752287b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 28 Dec 2018 18:06:47 +0900 Subject: [PATCH 02/16] Package version up to 1.5.27 - API dependency ( libtbm-3.0.9 ) tbm_surface_queue_can_dequeue_wait_timeout() Change-Id: I457145607f227118b5723653098f676d0b8a80e9 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 b94a34a..09dbab6 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 5 -%define TPL_VERSION_PATCH 26 +%define TPL_VERSION_PATCH 27 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 75ff4e2251d0fdf4c525b9d7e046d6ca1189a333 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 8 Jan 2019 16:20:10 +0900 Subject: [PATCH 03/16] tpl_wayland_egl(_thread): Initialized the callbacks of wl_egl_window to NULL when destroy. Change-Id: I288df9cb513fea71f615f66068b4109b4677fbb9 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl.c | 5 +++++ src/tpl_wayland_egl_thread.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 5b2431f..387882d 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -674,6 +674,11 @@ __tpl_wayland_egl_surface_fini(tpl_surface_t *surface) /* TPL_ASSERT(wl_egl_window->surface); */ /* to be enabled once evas/gl patch is in place */ wl_egl_window->private = NULL; + wl_egl_window->resize_callback = NULL; + wl_egl_window->rotate_callback = NULL; + wl_egl_window->get_rotation_capability = NULL; + wl_egl_window->set_frontbuffer_callback = NULL; + wl_egl_window->set_window_serial_callback = NULL; __tpl_wayland_egl_surface_buffer_flusher_fini(surface); diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 3e9a913..1b7cb84 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2318,9 +2318,11 @@ _twe_thread_wl_surf_source_destroy(void *source) if (surf_source->wl_egl_window) { TPL_LOG_T(BACKEND, "twe_surface(%p) wl_egl_window(%p) wl_surface(%p)", surf_source, surf_source->wl_egl_window, surf_source->surf); + surf_source->wl_egl_window->set_window_serial_callback = NULL; surf_source->wl_egl_window->destroy_window_callback = NULL; surf_source->wl_egl_window->resize_callback = NULL; surf_source->wl_egl_window->rotate_callback = NULL; + surf_source->wl_egl_window->get_rotation_capability = NULL; surf_source->wl_egl_window->private = NULL; surf_source->wl_egl_window = NULL; surf_source->surf = NULL; -- 2.7.4 From e52b73e2a2f6dac6be5e2675292ea333a1e84bbe Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 14 Jan 2019 13:28:47 +0900 Subject: [PATCH 04/16] Package version up to 1.5.28 Change-Id: I1c65cedf0c2c91ba411cd849b5525be8bf50744a 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 09dbab6..f12db99 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 5 -%define TPL_VERSION_PATCH 27 +%define TPL_VERSION_PATCH 28 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From d3320be930b9e8bcaadeb1cf3e811c641f3c55af Mon Sep 17 00:00:00 2001 From: Zhaowei Yuan Date: Mon, 28 Jan 2019 15:56:44 +0800 Subject: [PATCH 05/16] Fix a typo Change-Id: Id6a01bb111ff0ea00aa38a4f10fafc96d1203651 Signed-off-by: Zhaowei Yuan --- src/tpl_wl_egl_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index f819b45..faf8d13 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -542,7 +542,7 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", surface->frontbuffer); - /* The first buffer to be activated in frontbuffer mode muse be + /* The first buffer to be activated in frontbuffer mode must be * committed. Subsequence frames do not need to be committed because * the buffer is already displayed. */ -- 2.7.4 From 42820fad94344eed662b79053ac3aac0a2eb4111 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 29 Jan 2019 15:59:17 +0900 Subject: [PATCH 06/16] tpl_wl_egl_thread: Fixed a bug related to frontbuffer mode. Change-Id: I160d5c6002fef08d9e66e6b030dba87ab7d1016f Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index faf8d13..40f1f28 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -32,6 +32,7 @@ struct _tpl_wayland_egl_surface { tbm_surface_queue_h tbm_queue; tpl_bool_t is_activated; tpl_bool_t reset; /* TRUE if queue reseted by external */ + tpl_bool_t need_to_enqueue; }; static tpl_result_t @@ -374,6 +375,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface->twe_surface = twe_surface; wayland_egl_surface->tbm_queue = tbm_queue; wayland_egl_surface->is_activated = TPL_FALSE; + wayland_egl_surface->need_to_enqueue = TPL_TRUE; surface->width = tbm_surface_queue_get_width(tbm_queue); surface->height = tbm_surface_queue_get_height(tbm_queue); @@ -537,21 +539,26 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, * commit if surface->frontbuffer that is already set and the tbm_surface * client want to enqueue are the same. */ - if (surface->is_frontbuffer_mode && surface->frontbuffer == tbm_surface) { - TPL_LOG_T("WL_EGL", - "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", - surface->frontbuffer); - + if (surface->is_frontbuffer_mode) { /* The first buffer to be activated in frontbuffer mode must be * committed. Subsequence frames do not need to be committed because * the buffer is already displayed. */ - if (!twe_surface_check_commit_needed(wayland_egl_surface->twe_surface, - surface->frontbuffer)) { + + if (!wayland_egl_surface->need_to_enqueue || + (surface->frontbuffer == tbm_surface && + !twe_surface_check_commit_needed(wayland_egl_surface->twe_surface, + surface->frontbuffer))) { + TPL_LOG_T("WL_EGL", + "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", + surface->frontbuffer); TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); TPL_OBJECT_UNLOCK(wayland_egl_surface); return TPL_ERROR_NONE; } + + if (surface->frontbuffer == tbm_surface) + wayland_egl_surface->need_to_enqueue = TPL_FALSE; } if (sync_fence != -1) { @@ -724,8 +731,10 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, if (lock_ret == TPL_ERROR_NONE) twe_display_unlock(wayland_egl_display->twe_display); return surface->frontbuffer; - } else + } else { surface->frontbuffer = NULL; + wayland_egl_surface->need_to_enqueue = TPL_TRUE; + } } else { surface->frontbuffer = NULL; } -- 2.7.4 From 386547df5f2056ee255dd4a5b91792fcffbe596f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 31 Jan 2019 09:34:46 +0900 Subject: [PATCH 07/16] Package version up to 1.5.29 Change-Id: I6d35a800f2ea18fdaef343845f18da83d9132f51 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 f12db99..2a80187 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 5 -%define TPL_VERSION_PATCH 28 +%define TPL_VERSION_PATCH 29 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From cadfe7c72be7e2eb570e4c28b5ecee7e8d3a6a1e Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 15 Mar 2019 13:48:57 +0900 Subject: [PATCH 08/16] tpl_wayland_egl_thread:Added mutex lock to ensure thread safety - Previously it was unnecessary, but the vulnerability was discovered with the addition of can_dequeue_timeout and force_flush. Change-Id: I860df25b6949a5927a8c67596613e521d0f740ec Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 1b7cb84..7ae4966 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1633,6 +1633,7 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error, surf_source->vblank_done = TPL_TRUE; + g_mutex_lock(&surf_source->surf_mutex); if (!disp_source->is_vulkan_dpy) { if (surf_source->vblank_waiting_buffers) { tbm_surface_h tbm_surface = NULL; @@ -1643,7 +1644,6 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error, _twe_thread_wl_surface_commit(surf_source, tbm_surface); } } else { - g_mutex_lock(&surf_source->surf_mutex); switch (surf_source->swapchain_properties.present_mode) { case TPL_DISPLAY_PRESENT_MODE_MAILBOX: if (surf_source->draw_done_buffer) { @@ -1666,8 +1666,8 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error, break; } - g_mutex_unlock(&surf_source->surf_mutex); } + g_mutex_unlock(&surf_source->surf_mutex); } static tdm_client_vblank* @@ -3184,6 +3184,7 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface) return TPL_ERROR_INVALID_OPERATION; } + g_mutex_lock(&surf_source->surf_mutex); if (surf_source->committed_buffers) { while (!__tpl_list_is_empty(surf_source->committed_buffers)) { tbm_surface_h tbm_surface = @@ -3198,6 +3199,7 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface) tbm_surface, tsq_err); } } + g_mutex_unlock(&surf_source->surf_mutex); TPL_LOG_T(BACKEND, "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)", -- 2.7.4 From e8488665b2c7fda4e962eed5c4fe137738246a5f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 15 Mar 2019 13:56:35 +0900 Subject: [PATCH 09/16] tpl_wl_egl_thread: Changed can_dequeue time limit to 10000ms. Change-Id: Ib0adf59ea6daed5027587b864f16e2d64e08c600 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 40f1f28..685d8bb 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -641,7 +641,7 @@ __tpl_wl_egl_surface_cancel_dequeued_buffer(tpl_surface_t *surface, return TPL_ERROR_NONE; } -#define CAN_DEQUEUE_TIMEOUT_MS 5000 +#define CAN_DEQUEUE_TIMEOUT_MS 10000 static tbm_surface_h __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, -- 2.7.4 From d09c060ce6ae9de8fdbe6f598926c2029a01ffb3 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 18 Mar 2019 13:10:42 +0900 Subject: [PATCH 10/16] tpl_wl_egl_thread: Fixed a bug that attempted an incorrect enqueue for the frontbuffer. Change-Id: Ieb6149bfb0c2683ac663e30e6308266578fe71c9 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 1 + src/tpl_wl_egl_thread.c | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 7ae4966..ce438ff 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1354,6 +1354,7 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, } buf_info->draw_done = TPL_FALSE; + buf_info->need_to_commit = TPL_TRUE; buf_info->sync_fd = -1; if (surf_source->in_use_buffers) { diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 685d8bb..2452d88 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -535,6 +535,17 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, } } + if (!wayland_egl_surface->need_to_enqueue || + !twe_surface_check_commit_needed(wayland_egl_surface->twe_surface, + tbm_surface)) { + TPL_LOG_T("WL_EGL", + "[ENQ_SKIP][Frontbuffer:%s] tbm_surface(%p) need not to enqueue", + ((surface->frontbuffer == tbm_surface) ? "ON" : "OFF"), tbm_surface); + TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); + TPL_OBJECT_UNLOCK(wayland_egl_surface); + return TPL_ERROR_NONE; + } + /* In frontbuffer mode, will skip tbm_surface_queue_enqueue, acquire, and * commit if surface->frontbuffer that is already set and the tbm_surface * client want to enqueue are the same. @@ -544,19 +555,6 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, * committed. Subsequence frames do not need to be committed because * the buffer is already displayed. */ - - if (!wayland_egl_surface->need_to_enqueue || - (surface->frontbuffer == tbm_surface && - !twe_surface_check_commit_needed(wayland_egl_surface->twe_surface, - surface->frontbuffer))) { - TPL_LOG_T("WL_EGL", - "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", - surface->frontbuffer); - TRACE_ASYNC_END((int)tbm_surface, "[DEQ]~[ENQ] BO_NAME:%d", bo_name); - TPL_OBJECT_UNLOCK(wayland_egl_surface); - return TPL_ERROR_NONE; - } - if (surface->frontbuffer == tbm_surface) wayland_egl_surface->need_to_enqueue = TPL_FALSE; } -- 2.7.4 From ca70d927336e1e33d8f95fb20c2b27493f3080ed Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 15 Mar 2019 13:51:39 +0900 Subject: [PATCH 11/16] Package version up to 1.5.30 Change-Id: Id278d98c0576d6c1d47b9ccd222357ad6d3cceac 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 2a80187..1fc213c 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 5 -%define TPL_VERSION_PATCH 29 +%define TPL_VERSION_PATCH 30 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From ba16506e941077f35b09f06530b748c7888defd6 Mon Sep 17 00:00:00 2001 From: Xuelian Bai Date: Thu, 7 Mar 2019 19:57:49 +0800 Subject: [PATCH 12/16] Call wayland_tbm_client_create_surface_queue_tiled and set flags for tbm_surface_queue_sequence_create, if GPU support tiled memory. Change-Id: I64da5f16368589777b1d53444f00fa976c783202 --- src/tpl_wayland_egl.c | 44 +++++++++++++++++++++++--------- src/tpl_wayland_egl_thread.c | 61 +++++++++++++++++++++++++++++++++----------- 2 files changed, 78 insertions(+), 27 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 387882d..f358985 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -504,6 +504,9 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) tpl_wayland_egl_display_t *wayland_egl_display; tpl_wayland_egl_surface_t *wayland_egl_surface; struct wl_egl_window *wl_egl_window; + tbm_bufmgr bufmgr = NULL; + unsigned int capability; + int flags = TBM_BO_DEFAULT; TPL_ASSERT(surface); TPL_ASSERT(surface->display); @@ -550,22 +553,39 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) goto alloc_dequeue_buffers_fail; } + bufmgr = tbm_bufmgr_init(-1); + capability = tbm_bufmgr_get_capability(bufmgr); + tbm_bufmgr_deinit(bufmgr); + + if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY) + flags = TBM_BO_TILED; + if (wl_egl_window->surface) { - wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue( - wayland_egl_display->wl_tbm_client, - wl_egl_window->surface, - surface->num_buffers, - wl_egl_window->width, - wl_egl_window->height, - surface->format); + if (flags == TBM_BO_TILED) { + wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue_tiled( + wayland_egl_display->wl_tbm_client, + wl_egl_window->surface, + surface->num_buffers, + wl_egl_window->width, + wl_egl_window->height, + surface->format); + } else { + wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue( + wayland_egl_display->wl_tbm_client, + wl_egl_window->surface, + surface->num_buffers, + wl_egl_window->width, + wl_egl_window->height, + surface->format); + } } else /*Why wl_surface is NULL ?*/ wayland_egl_surface->tbm_queue = tbm_surface_queue_sequence_create( - surface->num_buffers, - wl_egl_window->width, - wl_egl_window->height, - surface->format, - 0); + surface->num_buffers, + wl_egl_window->width, + wl_egl_window->height, + surface->format, + flags); if (!wayland_egl_surface->tbm_queue) { TPL_ERR("TBM surface queue creation failed!"); diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index ce438ff..30227a0 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -2146,6 +2146,8 @@ _twe_surface_create_tbm_queue(twe_wl_surf_source *source, { tbm_surface_queue_h tbm_queue = NULL; struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle; + tbm_bufmgr bufmgr = NULL; + unsigned int capability; if (!wl_tbm_client || !wl_egl_window) { TPL_ERR("Invalid parameters. wl_tbm_client(%p) wl_egl_window(%p)", @@ -2153,13 +2155,27 @@ _twe_surface_create_tbm_queue(twe_wl_surf_source *source, return NULL; } - tbm_queue = wayland_tbm_client_create_surface_queue( - wl_tbm_client, - wl_egl_window->surface, - num_buffers, - wl_egl_window->width, - wl_egl_window->height, - format); + bufmgr = tbm_bufmgr_init(-1); + capability = tbm_bufmgr_get_capability(bufmgr); + tbm_bufmgr_deinit(bufmgr); + + if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY) { + tbm_queue = wayland_tbm_client_create_surface_queue_tiled( + wl_tbm_client, + wl_egl_window->surface, + num_buffers, + wl_egl_window->width, + wl_egl_window->height, + format); + } else { + tbm_queue = wayland_tbm_client_create_surface_queue( + wl_tbm_client, + wl_egl_window->surface, + num_buffers, + wl_egl_window->width, + wl_egl_window->height, + format); + } if (!tbm_queue) { TPL_ERR("Failed to create tbm_surface_queue."); @@ -2529,6 +2545,8 @@ twe_surface_create_swapchain(twe_surface_h twe_surface, twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface; twe_wl_disp_source *disp_source = NULL; GMainContext *context; + tbm_bufmgr bufmgr = NULL; + unsigned int capability; if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) { TPL_ERR("twe_surface(%p) is invalid.", twe_surface); @@ -2568,12 +2586,25 @@ twe_surface_create_swapchain(twe_surface_h twe_surface, } } - surf_source->tbm_queue = wayland_tbm_client_create_surface_queue( - disp_source->wl_tbm_client, - surf_source->surf, - buffer_count, - width, height, - TBM_FORMAT_ARGB8888); + bufmgr = tbm_bufmgr_init(-1); + capability = tbm_bufmgr_get_capability(bufmgr); + tbm_bufmgr_deinit(bufmgr); + + if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY) { + surf_source->tbm_queue = wayland_tbm_client_create_surface_queue_tiled( + disp_source->wl_tbm_client, + surf_source->surf, + buffer_count, + width, height, + TBM_FORMAT_ARGB8888); + } else { + surf_source->tbm_queue = wayland_tbm_client_create_surface_queue( + disp_source->wl_tbm_client, + surf_source->surf, + buffer_count, + width, height, + TBM_FORMAT_ARGB8888); + } if (!surf_source->tbm_queue) { TPL_ERR("TBM surface queue creation failed!"); @@ -3203,8 +3234,8 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface) g_mutex_unlock(&surf_source->surf_mutex); TPL_LOG_T(BACKEND, - "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)", - surf_source, surf_source->tbm_queue); + "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)", + surf_source, surf_source->tbm_queue); return TPL_ERROR_NONE; } -- 2.7.4 From 857e4ecbabd5ad67dc965c5e7ec31bc2594349b2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 1 Apr 2019 15:17:38 +0900 Subject: [PATCH 13/16] tpl_wayland_egl: Added checking reset flag to fix frontbuffer mode - If activate-> deactivate-> activate occurs between tpl_surface_dequeue <-> tpl_surface_dequeue, a new dequeue is needed. Change-Id: Ie76f8f0ccd3e7aac6b912f6e9bd4dd90eea9b121 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl.c | 2 +- src/tpl_wl_egl_thread.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index f358985..7185368 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -1231,7 +1231,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou * it will return that frontbuffer if it is still activated, * otherwise dequeue the new buffer after initializing * surface->frontbuffer to NULL. */ - if (is_activated) { + if (is_activated && !wayland_egl_surface->reset) { TPL_LOG_B("WL_EGL", "[DEQ][F] surface->frontbuffer(%p) BO_NAME(%d)", surface->frontbuffer, diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 2452d88..bd7ecbb 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -716,7 +716,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, * it will return that frontbuffer if it is still activated, * otherwise dequeue the new buffer after initializing * surface->frontbuffer to NULL. */ - if (is_activated) { + if (is_activated && !wayland_egl_surface->reset) { TPL_LOG_T("WL_EGL", "[DEQ][F] surface->frontbuffer(%p) BO_NAME(%d)", surface->frontbuffer, -- 2.7.4 From cb7d037bb3eba592acfee996234a1ddf20232723 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 8 Apr 2019 14:49:33 +0900 Subject: [PATCH 14/16] Package version up to 1.6.1 - Minor version up to 6 to separate tizen_5.5 feature. Change-Id: I84612ff2a48b23446502dcfbb47394ee0e23bb7b 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 1fc213c..9a1fc6f 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 5 -%define TPL_VERSION_PATCH 30 +%define TPL_VERSION_MINOR 6 +%define TPL_VERSION_PATCH 1 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From d1ada33513a9a4934f1f92882e6498e5a431724a Mon Sep 17 00:00:00 2001 From: Xuelian Bai Date: Mon, 15 Apr 2019 20:15:44 +0800 Subject: [PATCH 15/16] Fix a typo Change-Id: I3411edd175f7898dfe426bd398f29739cb39044a --- src/tpl_wayland_egl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 7185368..f9debe1 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -802,7 +802,7 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error, tpl_wayland_egl_surface_t *wayland_egl_surface = (tpl_wayland_egl_surface_t *)user_data; wayland_egl_surface->vblank_done = TPL_TRUE; - TRACE_MARK("TDM_CLIENT_VBLACK"); + TRACE_MARK("TDM_CLIENT_VBLANK"); } static void -- 2.7.4 From 20d3cbf66b6987f36dd72ad8240fdecd8ab4047d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 15 Apr 2019 14:55:41 +0900 Subject: [PATCH 16/16] tpl_wayland_egl_thread: Modified get_window_info internal function. - Modified the internal function so that the first format can be maintained to avoid problems when a_size is changed in a way different from the format at the time of surface creation. Change-Id: I8b65c5fb9a02f7b01286429735f703aad90adbfe Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 14 +++++++++++++- src/tpl_wayland_egl_thread.h | 2 +- src/tpl_wl_egl_thread.c | 9 +-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 30227a0..8e65783 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3265,7 +3265,8 @@ twe_check_native_handle_is_wl_display(tpl_handle_t display) } tpl_result_t -twe_get_native_window_info(tpl_handle_t window, int *width, int *height) +twe_get_native_window_info(tpl_handle_t window, int *width, int *height, + tbm_format *format, int a_size) { struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)window; if (!wl_egl_window) { @@ -3275,6 +3276,17 @@ twe_get_native_window_info(tpl_handle_t window, int *width, int *height) if (width) *width = wl_egl_window->width; if (height) *height = wl_egl_window->height; + if (format) { + if (wl_egl_window->private) { + twe_wl_surf_source *surf_source = (twe_wl_surf_source *)wl_egl_window->private; + *format = surf_source->format; + } else { + if (a_size == 8) + *format = TBM_FORMAT_ARGB8888; + else + *format = TBM_FORMAT_XRGB8888; + } + } return TPL_ERROR_NONE; } diff --git a/src/tpl_wayland_egl_thread.h b/src/tpl_wayland_egl_thread.h index dfe6f6f..6cb9116 100644 --- a/src/tpl_wayland_egl_thread.h +++ b/src/tpl_wayland_egl_thread.h @@ -105,7 +105,7 @@ tpl_bool_t twe_check_native_handle_is_wl_display(tpl_handle_t display); tpl_result_t -twe_get_native_window_info(tpl_handle_t window, int *width, int *height); +twe_get_native_window_info(tpl_handle_t window, int *width, int *height, tbm_format *format, int a_size); tbm_surface_h twe_get_native_buffer_from_pixmap(tpl_handle_t pixmap); diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index bd7ecbb..4ebe168 100644 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -189,14 +189,7 @@ __tpl_wl_egl_display_get_window_info(tpl_display_t *display, TPL_ASSERT(display); TPL_ASSERT(window); - if (format) { - if (a_size == 8) - *format = TBM_FORMAT_ARGB8888; - else - *format = TBM_FORMAT_XRGB8888; - } - - if ((ret = twe_get_native_window_info(window, width, height)) + if ((ret = twe_get_native_window_info(window, width, height, format, a_size)) != TPL_ERROR_NONE) { TPL_ERR("Failed to get size info of native_window(%p)", window); } -- 2.7.4