From c800f6666dd59664b01a67e6ae07703216709bdb Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 17 Nov 2021 13:32:44 +0900 Subject: [PATCH 01/16] Package version up to 1.8.16 Change-Id: I1275061fee1f08b925c5eaf1abf5ab0c12a21443 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 12d7ffd..5d0cdfe 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 8 -%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 202e2f2249d3d02b58cc6a123f7e517a79239e95 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 14 Dec 2021 13:35:06 +0900 Subject: [PATCH 02/16] Initialize wl_egl_buffer->waiting_source in mutex protection. - the buffer_clear() of the main thread could occur thread conflict. - the pointer wl_egl_buffer->waiting_source must be protected. Change-Id: I4af88b06ff104a39c1fc0aa890d1cab74f589eb7 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 6fcce36..1a96557 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2731,6 +2731,15 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) tpl_gmutex_lock(&wl_egl_buffer->mutex); wl_egl_buffer->status = WAITING_VBLANK; + + TPL_DEBUG("[FINALIZE] wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)", + wl_egl_buffer, wl_egl_buffer->waiting_source, + wl_egl_buffer->acquire_fence_fd); + + close(wl_egl_buffer->acquire_fence_fd); + wl_egl_buffer->acquire_fence_fd = -1; + wl_egl_buffer->waiting_source = NULL; + tpl_gmutex_unlock(&wl_egl_buffer->mutex); tpl_gmutex_lock(&wl_egl_surface->surf_mutex); @@ -2749,16 +2758,7 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) static void __thread_func_waiting_source_finalize(tpl_gsource *gsource) { - tpl_wl_egl_buffer_t *wl_egl_buffer = - (tpl_wl_egl_buffer_t *)tpl_gsource_get_data(gsource); - - TPL_DEBUG("[FINALIZE] wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)", - wl_egl_buffer, wl_egl_buffer->waiting_source, - wl_egl_buffer->acquire_fence_fd); - - close(wl_egl_buffer->acquire_fence_fd); - wl_egl_buffer->acquire_fence_fd = -1; - wl_egl_buffer->waiting_source = NULL; + TPL_IGNORE(gsource); } static tpl_gsource_functions buffer_funcs = { -- 2.7.4 From 43840c0d6d8f902c2672442d285c800af5707957 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Thu, 9 Dec 2021 19:54:34 +0900 Subject: [PATCH 03/16] Send transform of window and buffer to server after they are created. this patch is for fixing below case 1. create eglWidnowSurface(1) with wl_egl_window(1) 2. set window and buffer 90 transform with wl_egl_window(1) 3. destroy eglWindowSurface(1) of wl_egl_window(1) 4. set window and buffer 0 transform with wl_egl_window(1) 5. create eglWidnowSurface(2) with wl_egl_window(1) 7. set window transform 0 transform with wl_egl_window(1) 8. tpl does not send 0 transform to server Change-Id: I8d83750f4ecd5791accecf4fe51681fe55b05cf1 --- src/tpl_wayland_egl.c | 3 ++- src/tpl_wl_egl_thread.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 113159d..27509b1 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -681,7 +681,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 = 0; + wayland_egl_surface->latest_transform = -1; wl_egl_window->resize_callback = (void *)__cb_client_window_resize_callback; wl_egl_window->destroy_window_callback = (void *)__cb_client_window_destroy_callback; @@ -1446,6 +1446,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0); wayland_egl_buffer->wayland_egl_surface = wayland_egl_surface; wayland_egl_buffer->transform = tizen_private->transform; + wayland_egl_buffer->window_transform = -1; if (wayland_egl_buffer->window_transform != tizen_private->window_transform) { wayland_egl_buffer->window_transform = tizen_private->window_transform; diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 1a96557..4a53fd5 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -1677,7 +1677,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->use_render_done_fence = TPL_FALSE; wl_egl_surface->set_serial_is_used = TPL_FALSE; - wl_egl_surface->latest_transform = 0; + wl_egl_surface->latest_transform = -1; wl_egl_surface->render_done_cnt = 0; wl_egl_surface->serial = 0; @@ -2347,6 +2347,8 @@ _wl_egl_buffer_create(tpl_wl_egl_surface_t *wl_egl_surface, wl_egl_buffer->width = tbm_surface_get_width(tbm_surface); wl_egl_buffer->height = tbm_surface_get_height(tbm_surface); + wl_egl_buffer->w_transform = -1; + tpl_gmutex_init(&wl_egl_buffer->mutex); tpl_gcond_init(&wl_egl_buffer->cond); -- 2.7.4 From fdb7ec845fb18e6932e94bf084e8656f4e95ddcd Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Fri, 10 Dec 2021 15:48:48 +0900 Subject: [PATCH 04/16] Send transform of window and buffer since wl_surface version 2 wl_surface_set_buffer_transform request is supported since wl_surface version 2 Change-Id: Iaa9a996853b3e59fb2d325b615e1587d18e6c119 --- src/tpl_wayland_egl.c | 16 ++++++++++------ src/tpl_wl_egl_thread.c | 13 ++++++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 27509b1..16fc9f2 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -911,17 +911,21 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, version = wl_proxy_get_version((struct wl_proxy *)wl_egl_window->surface); if (wayland_egl_buffer->w_rotated == TPL_TRUE) { - wayland_tbm_client_set_buffer_transform( - wayland_egl_display->wl_tbm_client, - (void *)wayland_egl_buffer->wl_proxy, - wayland_egl_buffer->window_transform); + if (version > 1) { + wayland_tbm_client_set_buffer_transform( + wayland_egl_display->wl_tbm_client, + (void *)wayland_egl_buffer->wl_proxy, + wayland_egl_buffer->window_transform); + } wayland_egl_buffer->w_rotated = TPL_FALSE; } if (wayland_egl_surface->latest_transform != wayland_egl_buffer->transform) { wayland_egl_surface->latest_transform = wayland_egl_buffer->transform; - wl_surface_set_buffer_transform(wl_egl_window->surface, - wayland_egl_buffer->transform); + if (version > 1) { + wl_surface_set_buffer_transform(wl_egl_window->surface, + wayland_egl_buffer->transform); + } } wl_surface_attach(wl_egl_window->surface, (void *)wayland_egl_buffer->wl_proxy, diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 4a53fd5..f15040a 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -3252,16 +3252,19 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, #endif if (wl_egl_buffer->w_rotated == TPL_TRUE) { - wayland_tbm_client_set_buffer_transform( - wl_egl_display->wl_tbm_client, - (void *)wl_egl_buffer->wl_buffer, - wl_egl_buffer->w_transform); + if (version > 1) { + wayland_tbm_client_set_buffer_transform( + wl_egl_display->wl_tbm_client, + (void *)wl_egl_buffer->wl_buffer, + wl_egl_buffer->w_transform); + } wl_egl_buffer->w_rotated = TPL_FALSE; } if (wl_egl_surface->latest_transform != wl_egl_buffer->transform) { wl_egl_surface->latest_transform = wl_egl_buffer->transform; - wl_surface_set_buffer_transform(wl_surface, wl_egl_buffer->transform); + if (version > 1) + wl_surface_set_buffer_transform(wl_surface, wl_egl_buffer->transform); } if (wl_egl_window) { -- 2.7.4 From c1cdbcc95fba4b3520fb852a911011d3ce7eb439 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 14 Dec 2021 13:46:53 +0900 Subject: [PATCH 05/16] Package version up to 1.8.17 Change-Id: I94cb61d3c1600621d650b4b47ca41758ff8e3d4c 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 5d0cdfe..78c6858 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 8 -%define TPL_VERSION_PATCH 16 +%define TPL_VERSION_PATCH 17 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 3551e544287916a3763251a6051da72f88d7d5ee Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 22 Dec 2021 14:45:09 +0900 Subject: [PATCH 06/16] Modified the new buffer allocation in the RESET situation As-Is : - If the tbm_surface_queue_reset occurs more frequently than VBLANK (16ms), there is a problem that the new tbm_surface continues to be allocated. To-Be : - If there is a dequeue buffer before the RESET occurs, the new buffer will be allocated after waiting for dequeued buffer to be commit. Change-Id: Id256e15e1125e06b362d5b90e7ead7718b6343ad Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index f15040a..81f8253 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -116,6 +116,7 @@ struct _tpl_wl_egl_surface { tpl_wl_egl_buffer_t *buffers[BUFFER_ARRAY_SIZE]; int buffer_cnt; /* the number of using wl_egl_buffers */ tpl_gmutex buffers_mutex; + tpl_wl_egl_buffer_t *last_deq_buffer; tpl_list_t *presentation_feedbacks; /* for tracing presentation feedbacks */ @@ -1701,6 +1702,8 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->buffer_cnt = 0; } + wl_egl_surface->last_deq_buffer = NULL; + { struct tizen_private *tizen_private = NULL; @@ -2134,6 +2137,8 @@ __tpl_wl_egl_surface_fini(tpl_surface_t *surface) wl_egl_surface->wl_egl_window = NULL; } + wl_egl_surface->last_deq_buffer = NULL; + wl_egl_surface->wl_surface = NULL; wl_egl_surface->wl_egl_display = NULL; wl_egl_surface->tpl_surface = NULL; @@ -2419,6 +2424,25 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_surface_h tbm_surface = NULL; TPL_OBJECT_UNLOCK(surface); + if (wl_egl_surface->reset == TPL_TRUE && wl_egl_surface->last_deq_buffer) { + tpl_wl_egl_buffer_t *last_deq_buffer = wl_egl_surface->last_deq_buffer; + + tpl_gmutex_lock(&last_deq_buffer->mutex); + if (last_deq_buffer->status > RELEASED && + last_deq_buffer->status < COMMITTED) { + tpl_result_t wait_result; + wait_result = tpl_cond_timed_wait(&last_deq_buffer->cond, + &last_deq_buffer->mutex, + 200); /* 200ms */ + + if (wait_result == TPL_ERROR_TIME_OUT) + TPL_WARN("timeout occured waiting signaled. wl_egl_buffer(%p)", + last_deq_buffer); + } + tpl_gmutex_unlock(&last_deq_buffer->mutex); + + wl_egl_surface->last_deq_buffer = NULL; + } tsq_err = tbm_surface_queue_can_dequeue_wait_timeout( wl_egl_surface->tbm_queue, CAN_DEQUEUE_TIMEOUT_MS); TPL_OBJECT_LOCK(surface); @@ -2510,6 +2534,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tpl_gmutex_lock(&wl_egl_buffer->mutex); wl_egl_buffer->status = DEQUEUED; + wl_egl_surface->last_deq_buffer = wl_egl_buffer; /* If wl_egl_buffer->release_fence_fd is -1, * the tbm_surface can be used immediately. @@ -2571,6 +2596,9 @@ __tpl_wl_egl_surface_cancel_buffer(tpl_surface_t *surface, tpl_gmutex_unlock(&wl_egl_buffer->mutex); } + if (wl_egl_buffer == wl_egl_surface->last_deq_buffer) + wl_egl_surface->last_deq_buffer = NULL; + tbm_surface_internal_unref(tbm_surface); tsq_err = tbm_surface_queue_cancel_dequeue(wl_egl_surface->tbm_queue, @@ -3510,6 +3538,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->tbm_surface = NULL; wl_egl_buffer->bo_name = -1; + wl_egl_buffer->status = RELEASED; free(wl_egl_buffer); } -- 2.7.4 From 899e7a3170b1bb8e1aa76d356e28aaa3866062ee Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 22 Dec 2021 17:16:12 +0900 Subject: [PATCH 07/16] Remove wl_egl_buffer from vblank list when it freed. - If the wl_egl_buffer is forcibly free from the buffer_clear(), the invalid wl_egl_buffer remains in vblank->waiting_buffers. - This invalid pointer should be removed from the list when wl_egl_buffer free. Change-Id: If6b9f58f4160c4426f2b816a22afb9e23b61372a Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 81f8253..257de88 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -3485,6 +3485,13 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) } tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + __tpl_list_remove_data(wl_egl_surface->vblank->waiting_buffers, + (void *)wl_egl_buffer, + TPL_FIRST, + NULL); + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + if (wl_egl_display) { if (wl_egl_buffer->wl_buffer) { wayland_tbm_client_destroy_buffer(wl_egl_display->wl_tbm_client, -- 2.7.4 From 8dcb75d10e0506af4b9f6a6f642ea206dd84a2ed Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 22 Dec 2021 17:25:36 +0900 Subject: [PATCH 08/16] Changed to do roundtrip_queue before display_fini. Change-Id: I998141a3dc63ac944526dbb14876d8d6fa690c02 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 257de88..06abb41 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -632,10 +632,11 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display) wl_egl_display->prepared = TPL_FALSE; } - if (wl_display_dispatch_queue_pending(wl_egl_display->wl_display, - wl_egl_display->ev_queue) == -1) { - _wl_display_print_err(wl_egl_display, "dispatch_queue_pending"); + if (wl_display_roundtrip_queue(wl_egl_display->wl_display, + wl_egl_display->ev_queue) == -1) { + _wl_display_print_err(wl_egl_display, "roundtrip_queue"); } + #if TIZEN_FEATURE_ENABLE if (wl_egl_display->tss) { TPL_INFO("[TIZEN_SURFACE_SHM_DESTROY]", @@ -679,6 +680,7 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display) wl_event_queue_destroy(wl_egl_display->ev_queue); + wl_egl_display->ev_queue = NULL; wl_egl_display->wl_initialized = TPL_FALSE; TPL_INFO("[DISPLAY_FINI]", "wl_egl_display(%p) wl_display(%p)", -- 2.7.4 From 7adc2423fc5dd801d75f648d1445cd6060f7bb4c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 23 Dec 2021 10:41:04 +0900 Subject: [PATCH 09/16] Added mutex for protecting vblank resources. As-Is : - vblank resource was protected via surf_mutex. To-Be : - It will be protected via its own mutex. Change-Id: Iff4084a4f8271b8cbe4a7ece308b98915d9641af Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 59 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 06abb41..62fba27 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -149,6 +149,7 @@ struct _surface_vblank { tdm_client_vblank *tdm_vblank; tpl_wl_egl_surface_t *wl_egl_surface; tpl_list_t *waiting_buffers; /* for FIFO/FIFO_RELAXED modes */ + tpl_gmutex mutex; }; typedef enum buffer_status { @@ -1546,9 +1547,20 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_surface->tss_flusher = NULL; } #endif + + if (wl_egl_surface->tbm_queue) { + TPL_INFO("[TBM_QUEUE_DESTROY]", + "wl_egl_surface(%p) tbm_queue(%p)", + wl_egl_surface, wl_egl_surface->tbm_queue); + tbm_surface_queue_destroy(wl_egl_surface->tbm_queue); + wl_egl_surface->tbm_queue = NULL; + } + if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { + tpl_gmutex_lock(&wl_egl_surface->vblank->mutex); __tpl_list_free(wl_egl_surface->vblank->waiting_buffers, NULL); wl_egl_surface->vblank->waiting_buffers = NULL; + tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); } if (wl_egl_surface->vblank) { @@ -1559,14 +1571,6 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_surface->vblank = NULL; } - if (wl_egl_surface->tbm_queue) { - TPL_INFO("[TBM_QUEUE_DESTROY]", - "wl_egl_surface(%p) tbm_queue(%p)", - wl_egl_surface, wl_egl_surface->tbm_queue); - tbm_surface_queue_destroy(wl_egl_surface->tbm_queue); - wl_egl_surface->tbm_queue = NULL; - } - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); } @@ -1891,6 +1895,7 @@ __cb_surface_vblank_free(void *data) tdm_client_vblank_destroy(vblank->tdm_vblank); vblank->tdm_vblank = NULL; vblank->wl_egl_surface = NULL; + tpl_gmutex_clear(&vblank->mutex); free(vblank); @@ -1938,6 +1943,7 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) } else { vblank->waiting_buffers = __tpl_list_alloc(); vblank->wl_egl_surface = wl_egl_surface; + tpl_gmutex_init(&vblank->mutex); __tpl_list_push_back(wl_egl_display->tdm.surface_vblanks, (void *)vblank); @@ -2778,9 +2784,12 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) if (wl_egl_surface->vblank == NULL || wl_egl_surface->vblank_done) _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer); - else + else { + tpl_gmutex_lock(&wl_egl_surface->vblank->mutex); __tpl_list_push_back(wl_egl_surface->vblank->waiting_buffers, wl_egl_buffer); + tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); + } tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); @@ -2864,7 +2873,9 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface) ready_to_commit = TPL_TRUE; else { wl_egl_buffer->status = WAITING_VBLANK; + tpl_gmutex_lock(&wl_egl_surface->vblank->mutex); __tpl_list_push_back(wl_egl_surface->vblank->waiting_buffers, wl_egl_buffer); + tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); ready_to_commit = TPL_FALSE; } } @@ -2898,19 +2909,25 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error, tpl_gmutex_lock(&wl_egl_surface->surf_mutex); if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { - while (!__tpl_list_is_empty(wl_egl_surface->vblank->waiting_buffers)) { + tpl_bool_t is_empty = TPL_TRUE; + do { + tpl_gmutex_lock(&wl_egl_surface->vblank->mutex); wl_egl_buffer = (tpl_wl_egl_buffer_t *)__tpl_list_pop_front( wl_egl_surface->vblank->waiting_buffers, NULL); - if (wl_egl_buffer) - _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer); + is_empty = __tpl_list_is_empty(wl_egl_surface->vblank->waiting_buffers); + tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); + + if (!wl_egl_buffer) break; + + _thread_wl_surface_commit(wl_egl_surface, wl_egl_buffer); - /* If tdm error such as TIEMOUT occured, + /* If tdm error such as TIMEOUT occured, * flush all vblank waiting buffers of its wl_egl_surface. * Otherwise, only one wl_egl_buffer will be commited per one vblank event. */ if (error == TDM_ERROR_NONE) break; - } + } while (!is_empty); } tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); } @@ -3487,12 +3504,14 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) } tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - __tpl_list_remove_data(wl_egl_surface->vblank->waiting_buffers, - (void *)wl_egl_buffer, - TPL_FIRST, - NULL); - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { + tpl_gmutex_lock(&wl_egl_surface->vblank->mutex); + __tpl_list_remove_data(wl_egl_surface->vblank->waiting_buffers, + (void *)wl_egl_buffer, + TPL_FIRST, + NULL); + tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); + } if (wl_egl_display) { if (wl_egl_buffer->wl_buffer) { -- 2.7.4 From f1fe0c1a612f11063039e4881bd37505b521e7d6 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 23 Dec 2021 10:38:38 +0900 Subject: [PATCH 10/16] Package version up to 1.8.18 Change-Id: I61c16ae2ae8798af01bfcf383602f607dce88049 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 78c6858..fdd3bb6 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 8 -%define TPL_VERSION_PATCH 17 +%define TPL_VERSION_PATCH 18 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 1155aad24dff7c04ef6c98510117bdafea71900c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 24 Dec 2021 10:40:41 +0900 Subject: [PATCH 11/16] Initialize last_deq_buffer to NULL when it free. Problem : DEQ -> ENQ -> ACQ -> VBLANK -> COMMIT -> RELEASE -> QUEUE_RESET -> last_deq_buffer free -> try DEQ !!< will be blocked. Init wl_egl_surface->last_deq_buffer to NULL when it was free to prevent to access the wrong pointer of last_deq_buffer. Change-Id: Ic619b6a27a098b3de06c5733cec171538f921165 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 62fba27..59c0d4c 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2436,7 +2436,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tpl_wl_egl_buffer_t *last_deq_buffer = wl_egl_surface->last_deq_buffer; tpl_gmutex_lock(&last_deq_buffer->mutex); - if (last_deq_buffer->status > RELEASED && + if (last_deq_buffer->status > ENQUEUED && last_deq_buffer->status < COMMITTED) { tpl_result_t wait_result; wait_result = tpl_cond_timed_wait(&last_deq_buffer->cond, @@ -3502,6 +3502,10 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->idx = -1; } + + if (wl_egl_surface->last_deq_buffer == wl_egl_buffer) + wl_egl_surface->last_deq_buffer = NULL; + tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { -- 2.7.4 From 7047bf7ccfe5ecbfd52cd894114b7b21a12b6d7c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 24 Dec 2021 10:45:28 +0900 Subject: [PATCH 12/16] Package version up to 1.8.19 Change-Id: I5b0450b14c24e3f8152b46f9482f52a8fce19d71 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 fdd3bb6..54ce804 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 8 -%define TPL_VERSION_PATCH 18 +%define TPL_VERSION_PATCH 19 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 0daaf9e673202e340ccffe3f38e473f40e6cda28 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 15:19:24 +0900 Subject: [PATCH 13/16] Add log to check when the transform changed Change-Id: I069fc944356d25845655359cdb8654887b554e8f Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 59c0d4c..43342c0 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -3304,14 +3304,22 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, wl_egl_display->wl_tbm_client, (void *)wl_egl_buffer->wl_buffer, wl_egl_buffer->w_transform); + TPL_INFO("[W_TRANSFORM]", + "wl_egl_surface(%p) wl_egl_buffer(%p) w_transform(%d)", + wl_egl_surface, wl_egl_buffer, wl_egl_buffer->w_transform); } wl_egl_buffer->w_rotated = TPL_FALSE; } if (wl_egl_surface->latest_transform != wl_egl_buffer->transform) { - wl_egl_surface->latest_transform = wl_egl_buffer->transform; - if (version > 1) + if (version > 1) { wl_surface_set_buffer_transform(wl_surface, wl_egl_buffer->transform); + TPL_INFO("[TRANSFORM]", + "wl_egl_surface(%p) wl_egl_buffer(%p) transform(%d -> %d)", + wl_egl_surface, wl_egl_buffer, + wl_egl_surface->latest_transform, wl_egl_buffer->transform); + } + wl_egl_surface->latest_transform = wl_egl_buffer->transform; } if (wl_egl_window) { -- 2.7.4 From aab0e0bcf795d4efbf406b136093a5baa4c822c5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 13:56:12 +0900 Subject: [PATCH 14/16] Add mutex protection when gsource_destroy Change-Id: I50e841fa3895e6f145249396574e6a8267f1e663 Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 41c5101..51a6dc7 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -161,6 +161,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) tpl_gsource *gsource = (tpl_gsource *)source; gboolean ret = G_SOURCE_CONTINUE; GIOCondition cond = g_source_query_unix_fd(source, gsource->tag); + tpl_gthread *thread = gsource->thread; TPL_IGNORE(cb); @@ -183,7 +184,6 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) gsource->intended_destroy == TPL_TRUE) { tpl_gsource *del_source = (tpl_gsource *)gsource->data; if (!g_source_is_destroyed(&del_source->gsource)) { - tpl_gthread *thread = del_source->thread; g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(del_source); @@ -203,8 +203,10 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) if (gsource->type == SOURCE_TYPE_DISPOSABLE || gsource->type == SOURCE_TYPE_FINALIZER) { + g_mutex_lock(&thread->thread_mutex); __gsource_remove_and_destroy(gsource); ret = G_SOURCE_REMOVE; + g_mutex_unlock(&thread->thread_mutex); } return ret; @@ -290,6 +292,9 @@ tpl_gsource_create(tpl_gthread *thread, void *data, int fd, static void __gsource_remove_and_destroy(tpl_gsource *source) { + if (g_source_is_destroyed(&source->gsource)) + return; + TPL_DEBUG("[GSOURCE_DESTROY] tpl_gsource(%p) type(%d)", source, source->type); @@ -301,25 +306,24 @@ __gsource_remove_and_destroy(tpl_gsource *source) void tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) { + tpl_gthread *thread = source->thread; + if (g_source_is_destroyed(&source->gsource)) { TPL_WARN("gsource(%p) already has been destroyed.", source); return; } + g_mutex_lock(&thread->thread_mutex); if (source->type == SOURCE_TYPE_NORMAL && source->finalizer) { tpl_gsource *finalizer = source->finalizer; if (destroy_in_thread) { - tpl_gthread *thread = source->thread; - g_mutex_lock(&thread->thread_mutex); - finalizer->intended_destroy = TPL_TRUE; tpl_gsource_send_message(finalizer, 1); g_cond_wait(&thread->thread_cond, &thread->thread_mutex); - g_mutex_unlock(&thread->thread_mutex); } else { __gsource_remove_and_destroy(finalizer); source->finalizer = NULL; @@ -329,6 +333,7 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) if (!destroy_in_thread) { __gsource_remove_and_destroy(source); } + g_mutex_unlock(&thread->thread_mutex); } void -- 2.7.4 From 5b60b3b5509130d859f9448a37d7d516cf7444d7 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 15:37:10 +0900 Subject: [PATCH 15/16] Clear all cached buffer when queue_force_flush Change-Id: Ic232153cfbdea49aea1a9fd862ac81f673f7814c Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 43342c0..8e633d6 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2259,11 +2259,19 @@ _tbm_queue_force_flush(tpl_wl_egl_surface_t *wl_egl_surface) int i; tpl_wl_egl_buffer_t *wl_egl_buffer = NULL; for (i = 0; i < BUFFER_ARRAY_SIZE; i++) { + buffer_status_t status; tpl_gmutex_lock(&wl_egl_surface->buffers_mutex); wl_egl_buffer = wl_egl_surface->buffers[i]; tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); - if (wl_egl_buffer && wl_egl_buffer->status == COMMITTED) { - wl_egl_buffer->status = RELEASED; + if (wl_egl_buffer) { + tpl_gmutex_lock(&wl_egl_buffer->mutex); + status = wl_egl_buffer->status; + tpl_gmutex_unlock(&wl_egl_buffer->mutex); + } else { + continue; + } + + if (status > ENQUEUED && status <= COMMITTED) { tsq_err = tbm_surface_queue_release(wl_egl_surface->tbm_queue, wl_egl_buffer->tbm_surface); if (tsq_err != TBM_SURFACE_QUEUE_ERROR_NONE) @@ -2278,6 +2286,8 @@ _tbm_queue_force_flush(tpl_wl_egl_surface_t *wl_egl_surface) "wl_egl_surface(%p) tbm_queue(%p)", wl_egl_surface, wl_egl_surface->tbm_queue); + _print_buffer_lists(wl_egl_surface); + return TPL_ERROR_NONE; } @@ -3535,6 +3545,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_display_flush(wl_egl_display->wl_display); } + tpl_gmutex_lock(&wl_egl_buffer->mutex); #if TIZEN_FEATURE_ENABLE if (wl_egl_buffer->buffer_release) { zwp_linux_buffer_release_v1_destroy(wl_egl_buffer->buffer_release); @@ -3580,6 +3591,9 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->bo_name = -1; wl_egl_buffer->status = RELEASED; + tpl_gmutex_unlock(&wl_egl_buffer->mutex); + tpl_gmutex_clear(&wl_egl_buffer->mutex); + tpl_gcond_clear(&wl_egl_buffer->cond); free(wl_egl_buffer); } -- 2.7.4 From 9344c0e1889d02135ab6e73a271f9ad933df3039 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 30 Dec 2021 16:31:34 +0900 Subject: [PATCH 16/16] Package version up to 1.8.20 Change-Id: I27eb1758e92fcafa69fd5203fc85fd7cca1d6fac 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 54ce804..71334f1 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 8 -%define TPL_VERSION_PATCH 19 +%define TPL_VERSION_PATCH 20 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4