From c362b0b2860d1ebab098956e2567aeef8313952c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 15 Jun 2023 16:02:37 +0900 Subject: [PATCH 01/16] wl_egl: remove checking activated when dequeue buffer - Actual buffer will be attached when calling tbm_surface_queue_can_dequeue(). So calling wayland_tbm_client_queue_check_activate() at dequeue_buffer is not appropriate. Change-Id: Ie5500aa50f396e4a76160c703932d6c805e93d3d Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 7a57437..d305ec0 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2541,7 +2541,6 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tpl_wl_egl_buffer_t *wl_egl_buffer = NULL; tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_NONE; - tpl_bool_t is_activated = 0; int bo_name = 0; tbm_surface_h tbm_surface = NULL; @@ -2626,22 +2625,6 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, * during below dequeue procedure. */ tpl_gmutex_lock(&wl_egl_display->wl_event_mutex); - /* 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() - * in order to know what state the buffer will be dequeued next. - * - * ACTIVATED state means non-composite mode. Client can get buffers which - can be displayed directly(without compositing). - * DEACTIVATED state means composite mode. Client's buffer will be displayed - by compositor(E20) with compositing. - */ - is_activated = wayland_tbm_client_queue_check_activate( - wl_egl_display->wl_tbm_client, - wl_egl_surface->tbm_queue); - - wl_egl_surface->is_activated = is_activated; - surface->width = tbm_surface_queue_get_width(wl_egl_surface->tbm_queue); surface->height = tbm_surface_queue_get_height(wl_egl_surface->tbm_queue); wl_egl_surface->width = surface->width; @@ -2664,7 +2647,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, * */ if (surface->frontbuffer) { if (!surface->is_frontbuffer_mode || - !is_activated || + !wl_egl_surface->is_activated || wl_egl_surface->reset) { surface->frontbuffer = NULL; wl_egl_surface->need_to_enqueue = TPL_TRUE; @@ -2721,7 +2704,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, } } - if (surface->is_frontbuffer_mode && is_activated) { + if (surface->is_frontbuffer_mode && wl_egl_surface->is_activated) { if (surface->frontbuffer == NULL) { TPL_INFO("[FRONTBUFFER RENDERING START]", "wl_egl_surface(%p) wl_egl_window(%p) bo(%d)", -- 2.7.4 From be51392311d4a004ed5484ee64a3d88e7bbd4b36 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 7 Jul 2023 13:09:29 +0900 Subject: [PATCH 02/16] log: add & apply TPL_LOG_D instead of TPL_DEBUG - TPL_LOG_D can print the tag manually. - The prefix of almost all logs is modified to print wl_egl_surface to distinguish each wl_egl_surface. Change-Id: I68a5b450693ed0d9422a9ba72e119f56235d7a32 Signed-off-by: Joonbum Ko --- src/tpl.c | 3 +- src/tpl_utils.h | 7 ++-- src/tpl_utils_gthread.c | 12 ++++--- src/tpl_wayland_egl.c | 2 +- src/tpl_wl_egl_thread.c | 95 +++++++++++++++++++++++++------------------------ src/tpl_wl_vk_thread.c | 54 +++++++++++++++------------- 6 files changed, 93 insertions(+), 80 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index 1f2bd4e..90e5807 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -41,7 +41,7 @@ __tpl_init(void) tpl_getenv_initialized = 1; } - TPL_DEBUG("[libtpl-egl] loaded"); + TPL_LOG_D("[libtpl-egl][constructor]", "loaded"); #ifdef OBJECT_HASH_CHECK __tpl_object_hash_init(); #endif @@ -67,6 +67,7 @@ __tpl_runtime_fini(void) pthread_mutex_unlock(&runtime_mutex); } + TPL_LOG_D("[libtpl-egl][destructor]", "finished"); #ifdef OBJECT_HASH_CHECK __tpl_object_hash_shutdown(); #endif diff --git a/src/tpl_utils.h b/src/tpl_utils.h index b7dfa1c..08d7ab6 100644 --- a/src/tpl_utils.h +++ b/src/tpl_utils.h @@ -119,6 +119,7 @@ inline char *tpl_getenv(const char *name) #ifdef LOG_DEFAULT_ENABLE #define TPL_LOG_F(f, x...) tpl_log_f("[TPL_F]", f, ##x) #define TPL_LOG_B(b, f, x...) tpl_log_b("[TPL_" b "]", f, ##x) +#define TPL_LOG_D(t, f, x...) tpl_log_d(t, f, ##x) #define TPL_DEBUG(f, x...) tpl_log_d("[TPL_DEBUG]", f, ##x) #define TPL_LOG_T(b, f, x...) \ { \ @@ -176,16 +177,18 @@ inline char *tpl_getenv(const char *name) } \ } -#define TPL_DEBUG(f, x...) \ +#define TPL_LOG_D(t, f, x...) \ { \ LOG_INIT(); \ if (tpl_log_lvl > 2) \ - tpl_log_d("[TPL_DEBUG]", f, ##x); \ + tpl_log_d(t, f, ##x); \ } + #endif /* LOG_DEFAULT_ENABLE */ #else /* NDEBUG */ #define TPL_LOG_F(f, x...) #define TPL_LOG_B(b, f, x...) +#define TPL_LOG_D(t, f, x...) #define TPL_DEBUG(f, x...) #define TPL_ERR(f, x...) #define TPL_WARN(f, x...) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 68c2faf..4b17598 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -308,7 +308,7 @@ tpl_gsource_create(tpl_gthread *thread, void *data, int fd, g_source_attach(&new_gsource->gsource, g_main_loop_get_context(thread->loop)); - TPL_DEBUG("[GSOURCE_CREATE] tpl_gsource(%p) thread(%p) data(%p) fd(%d) type(%d)", + TPL_LOG_D("[GSOURCE][CREATE]", "tpl_gsource(%p) thread(%p) data(%p) fd(%d) type(%d)", new_gsource, thread, data, new_gsource->fd, type); return new_gsource; @@ -320,7 +320,7 @@ __gsource_remove_and_destroy(tpl_gsource *source) if (g_source_is_destroyed(&source->gsource)) return; - TPL_DEBUG("[GSOURCE_DESTROY] tpl_gsource(%p) type(%d)", + TPL_LOG_D("[GSOURCE][DESTROY]", "tpl_gsource(%p) type(%d)", source, source->type); g_source_remove_unix_fd(&source->gsource, source->tag); @@ -471,7 +471,7 @@ _thread_idle_cb(gpointer data) { tpl_gthread *gthread = (tpl_gthread *)data; - TPL_DEBUG("THREAD IDLE CALLBACK"); + TPL_LOG_D("[WAIT_IDLE]", "THREAD IDLE CALLBACK"); g_mutex_lock(>hread->idle_mutex); gthread->is_idle = TPL_TRUE; @@ -480,9 +480,11 @@ _thread_idle_cb(gpointer data) /* If the caller thread of tpl_gthread_wait_idle locked the pause_mutex, * thread will be paused here until unlock */ + TPL_LOG_D("[THREAD_PAUSE]", "try to lock pause_mutex"); g_mutex_lock(>hread->pause_mutex); gthread->paused = TPL_FALSE; g_mutex_unlock(>hread->pause_mutex); + TPL_LOG_D("[THREAD_RESUME]", "thread resumes"); return G_SOURCE_REMOVE; } @@ -495,7 +497,7 @@ tpl_gthread_wait_idle(tpl_gthread *gthread) gboolean ret = TRUE; tpl_result_t res = TPL_ERROR_NONE; - TPL_DEBUG("[WAIT IDLE] BEGIN"); + TPL_LOG_D("[WAIT_IDLE]", "BEGIN"); g_mutex_lock(>hread->idle_mutex); @@ -532,7 +534,7 @@ tpl_gthread_wait_idle(tpl_gthread *gthread) g_mutex_unlock(>hread->idle_mutex); - TPL_DEBUG("[WAIT IDLE] END"); + TPL_LOG_D("[WAIT_IDLE]", "END"); return res; } diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index b8b24da..38c2f39 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -1068,7 +1068,7 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, * the buffer is already displayed. */ if (wayland_egl_buffer->is_new) { - TPL_DEBUG("[FRONTBUFFER RENDERING MODE] tbm_surface(%p) bo(%d)", + TPL_LOG_D("[FRONTBUFFER RENDERING MODE]", "tbm_surface(%p) bo(%d)", tbm_surface, tbm_bo_export(wayland_egl_buffer->bo)); } else { TPL_LOG_B("WL_EGL", diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index d305ec0..84e8d08 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -467,7 +467,9 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, wl_egl_display->presentation = wl_registry_bind(wl_registry, name, &wp_presentation_interface, 1); - TPL_DEBUG("bind wp_presentation_interface"); + TPL_LOG_D("[REGISTRY_BIND]", + "wl_egl_display(%p) bind wp_presentation_interface", + wl_egl_display); } else if (strcmp(interface, "zwp_linux_explicit_synchronization_v1") == 0) { char *env = tpl_getenv("TPL_EFS"); if (env && !atoi(env)) { @@ -477,7 +479,9 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, wl_registry_bind(wl_registry, name, &zwp_linux_explicit_synchronization_v1_interface, 1); wl_egl_display->use_explicit_sync = TPL_TRUE; - TPL_DEBUG("bind zwp_linux_explicit_synchronization_v1_interface"); + TPL_LOG_D("[REGISTRY_BIND]", + "wl_egl_display(%p) bind zwp_linux_explicit_synchronization_v1_interface", + wl_egl_display); } } #endif @@ -829,7 +833,7 @@ __thread_func_disp_finalize(tpl_gsource *gsource) (tpl_wl_egl_display_t *)tpl_gsource_get_data(gsource); tpl_gmutex_lock(&wl_egl_display->disp_mutex); - TPL_DEBUG("[FINALIZE] wl_egl_display(%p) tpl_gsource(%p)", + TPL_LOG_D("[D_FINALIZE]", "wl_egl_display(%p) tpl_gsource(%p)", wl_egl_display, gsource); if (wl_egl_display->wl_initialized) @@ -1216,7 +1220,7 @@ __cb_destroy_callback(void *private) tpl_wl_egl_surface_t *wl_egl_surface = NULL; if (!tizen_private) { - TPL_LOG_B("WL_EGL", "[DESTROY_CB] Already destroyed surface"); + TPL_LOG_D("[WL_EGL_WINDOW_DESTROY_CALLBACK]", "Already destroyed surface"); return; } @@ -1377,7 +1381,7 @@ __cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private) commit_sync_fd = dup(wl_egl_surface->commit_sync.fd); TRACE_MARK("[ONLY_DUP] commit_sync_fd(%d) dup(%d)", wl_egl_surface->commit_sync.fd, commit_sync_fd); - TPL_DEBUG("[DUP_COMMIT_SYNC] wl_egl_surface(%p) commit_sync_fd(%d) dup(%d)", + TPL_LOG_D("[COMMIT_SYNC][DUP]", "wl_egl_surface(%p) commit_sync_fd(%d) dup(%d)", wl_egl_surface, wl_egl_surface->commit_sync.fd, commit_sync_fd); tpl_gmutex_unlock(&wl_egl_surface->commit_sync.mutex); return commit_sync_fd; @@ -1395,7 +1399,7 @@ __cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private) TRACE_MARK("[CREATE] commit_sync_fd(%d) dup(%d)", wl_egl_surface->commit_sync.fd, commit_sync_fd); - TPL_DEBUG("[CREATE_COMMIT_SYNC] wl_egl_surface(%p) commit_sync_fd(%d)", + TPL_LOG_D("[COMMIT_SYNC][CREATE]", "wl_egl_surface(%p) commit_sync_fd(%d)", wl_egl_surface, commit_sync_fd); tpl_gmutex_unlock(&wl_egl_surface->commit_sync.mutex); @@ -1456,7 +1460,7 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv presentation_sync_fd = dup(wl_egl_surface->presentation_sync.fd); TRACE_MARK("[ONLY_DUP] presentation_sync_fd(%d) dup(%d)", wl_egl_surface->presentation_sync.fd, presentation_sync_fd); - TPL_DEBUG("[DUP_PRESENTATION_SYNC] wl_egl_surface(%p) presentation_sync_fd(%d) dup(%d)", + TPL_LOG_D("[PRESENTATION_SYNC][DUP]", "wl_egl_surface(%p) presentation_sync_fd(%d) dup(%d)", wl_egl_surface, wl_egl_surface->presentation_sync.fd, presentation_sync_fd); tpl_gmutex_unlock(&wl_egl_surface->presentation_sync.mutex); return presentation_sync_fd; @@ -1473,7 +1477,7 @@ __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *priv presentation_sync_fd = dup(wl_egl_surface->presentation_sync.fd); TRACE_MARK("[CREATE] presentation_sync_fd(%d) dup(%d)", wl_egl_surface->presentation_sync.fd, presentation_sync_fd); - TPL_DEBUG("[CREATE_PRESENTATION_SYNC] wl_egl_surface(%p) presentation_sync_fd(%d) dup(%d)", + TPL_LOG_D("[PRESENTATION_SYNC][CREATE]", "wl_egl_surface(%p) presentation_sync_fd(%d) dup(%d)", wl_egl_surface, wl_egl_surface->presentation_sync.fd, presentation_sync_fd); tpl_gmutex_unlock(&wl_egl_surface->presentation_sync.mutex); @@ -1569,9 +1573,9 @@ __cb_tbm_queue_reset_callback(tbm_surface_queue_h tbm_queue, "wl_egl_surface(%p) wl_surface(%p) tbm_queue(%p)", wl_egl_surface, wl_egl_surface->wl_surface, tbm_queue); } else { - TPL_LOG_T("[DEACTIVATED]", - " wl_egl_surface(%p) wl_surface(%p) tbm_queue(%p)", - wl_egl_surface, wl_egl_surface->wl_surface, tbm_queue); + TPL_INFO("[DEACTIVATED]", + " wl_egl_surface(%p) wl_surface(%p) tbm_queue(%p)", + wl_egl_surface, wl_egl_surface->wl_surface, tbm_queue); } } @@ -1691,13 +1695,13 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) tpl_gmutex_lock(&wl_egl_surface->surf_mutex); if (message == INIT_SURFACE) { /* Initialize surface */ - TPL_DEBUG("wl_egl_surface(%p) initialize message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_egl_surface(%p) initialize message received!", wl_egl_surface); _thread_wl_egl_surface_init(wl_egl_surface); wl_egl_surface->initialized_in_thread = TPL_TRUE; tpl_gcond_signal(&wl_egl_surface->surf_cond); } else if (message == ACQUIRABLE) { /* Acquirable */ - TPL_DEBUG("wl_egl_surface(%p) acquirable message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_egl_surface(%p) acquirable message received!", wl_egl_surface); _thread_surface_queue_acquire(wl_egl_surface); } @@ -1718,7 +1722,7 @@ __thread_func_surf_finalize(tpl_gsource *gsource) TPL_CHECK_ON_NULL_RETURN(wl_egl_surface); tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - TPL_DEBUG("[FINALIZE] wl_egl_surface(%p) tpl_gsource(%p)", + TPL_LOG_D("[S_FINALIZE]", "wl_egl_surface(%p) tpl_gsource(%p)", wl_egl_surface, gsource); _thread_wl_egl_surface_fini(wl_egl_surface); @@ -2037,12 +2041,13 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) return; } - TPL_INFO("[QUEUE_CREATION]", + TPL_INFO("[QUEUE_CREATION][1/2]", "wl_egl_surface(%p) wl_surface(%p) wl_tbm_client(%p)", wl_egl_surface, wl_egl_surface->wl_surface, wl_egl_display->wl_tbm_client); - TPL_INFO("[QUEUE_CREATION]", - "tbm_queue(%p) size(%d x %d) X %d format(%d)", + TPL_INFO("[QUEUE_CREATION][2/2]", + "wl_egl_surface(%p) tbm_queue(%p) size(%d x %d) X %d format(%d)", + wl_egl_surface, wl_egl_surface->tbm_queue, wl_egl_surface->width, wl_egl_surface->height, @@ -2125,8 +2130,6 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) tpl_gthread_pause_in_idle(wl_egl_display->thread); buffer_cnt = __tpl_list_get_count(wl_egl_surface->buffers); - TPL_INFO("[BUFFER_CLEAR]", "BEGIN | wl_egl_surface(%p) buffer_cnt(%d)", - wl_egl_surface, buffer_cnt); while (!__tpl_list_is_empty(wl_egl_surface->buffers)) { wl_egl_buffer = (tpl_wl_egl_buffer_t *)__tpl_list_pop_front(wl_egl_surface->buffers, @@ -2136,8 +2139,9 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) status = wl_egl_buffer->status; - TPL_INFO("[BUFFER]","[%d/%d]| wl_egl_buffer(%p) tbm_surface(%p) status(%s)", - ++idx, buffer_cnt, wl_egl_buffer, + TPL_INFO("[BUFFER_CLEAR]", + "[%d/%d] wl_egl_surface(%p) wl_egl_buffer(%p) tbm_surface(%p) status(%s)", + ++idx, buffer_cnt, wl_egl_surface, wl_egl_buffer, wl_egl_buffer->tbm_surface, status_to_string[status]); @@ -2191,7 +2195,6 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) if (need_to_release || need_to_cancel) tbm_surface_internal_unref(wl_egl_buffer->tbm_surface); } - TPL_INFO("[BUFFER_CLEAR]", "END | wl_egl_surface(%p)", wl_egl_surface); tpl_gthread_continue(wl_egl_display->thread); } @@ -2561,8 +2564,8 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, enqueued_buffer->status < COMMITTED) { tpl_result_t wait_result; TPL_INFO("[DEQ_AFTER_RESET]", - "waiting for previous wl_egl_buffer(%p) commit", - enqueued_buffer); + "wl_egl_surface(%p) waiting for previous wl_egl_buffer(%p) commit", + wl_egl_surface, enqueued_buffer); wait_result = tpl_gcond_timed_wait(&enqueued_buffer->cond, &enqueued_buffer->mutex, @@ -2652,7 +2655,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, surface->frontbuffer = NULL; wl_egl_surface->need_to_enqueue = TPL_TRUE; wl_egl_surface->frontbuffer_activated = TPL_FALSE; - TPL_INFO("[FRONTBUFFER RENDERING STOP]", + TPL_INFO("[FRONTBUFFER_RENDERING_STOP]", "wl_egl_surface(%p) wl_egl_window(%p)", wl_egl_surface, wl_egl_surface->wl_egl_window); } else { @@ -2693,7 +2696,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, #if TIZEN_FEATURE_ENABLE if (wl_egl_display->use_explicit_sync) { *release_fence = wl_egl_buffer->release_fence_fd; - TPL_DEBUG("wl_egl_surface(%p) wl_egl_buffer(%p) release_fence_fd(%d)", + TPL_LOG_D("[EXPLICIT_FENCE]", "wl_egl_surface(%p) wl_egl_buffer(%p) release_fence_fd(%d)", wl_egl_surface, wl_egl_buffer, *release_fence); wl_egl_buffer->release_fence_fd = -1; @@ -2706,7 +2709,7 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, if (surface->is_frontbuffer_mode && wl_egl_surface->is_activated) { if (surface->frontbuffer == NULL) { - TPL_INFO("[FRONTBUFFER RENDERING START]", + TPL_INFO("[FRONTBUFFER_RENDERING_START]", "wl_egl_surface(%p) wl_egl_window(%p) bo(%d)", wl_egl_surface, wl_egl_surface->wl_egl_window, _get_tbm_surface_bo_name(tbm_surface)); @@ -2914,14 +2917,14 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) TRACE_ASYNC_END(wl_egl_buffer->acquire_fence_fd, "FENCE WAIT fd(%d)", wl_egl_buffer->acquire_fence_fd); - TPL_DEBUG("[RENDER DONE] wl_egl_buffer(%p) tbm_surface(%p)", - wl_egl_buffer, tbm_surface); + TPL_LOG_D("[RENDER DONE]", "wl_egl_surface(%p) wl_egl_buffer(%p) tbm_surface(%p)", + wl_egl_surface, wl_egl_buffer, tbm_surface); 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, + TPL_LOG_D("[FINALIZE]", "wl_egl_surface(%p) wl_egl_buffer(%p) wait_source(%p) fence_fd(%d)", + wl_egl_surface, wl_egl_buffer, wl_egl_buffer->waiting_source, wl_egl_buffer->acquire_fence_fd); close(wl_egl_buffer->acquire_fence_fd); @@ -3049,7 +3052,7 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error, tpl_wl_egl_buffer_t *wl_egl_buffer = NULL; TRACE_ASYNC_END((intptr_t)wl_egl_surface, "WAIT_VBLANK"); - TPL_DEBUG("[VBLANK] wl_egl_surface(%p)", wl_egl_surface); + TPL_LOG_D("[VBLANK_DONE]", "wl_egl_surface(%p)", wl_egl_surface); if (error == TDM_ERROR_TIMEOUT) TPL_WARN("[TDM_ERROR_TIMEOUT] It will keep going. wl_egl_surface(%p)", @@ -3274,7 +3277,7 @@ __cb_presentation_feedback_presented(void *data, tpl_gmutex_lock(&wl_egl_surface->presentation_sync.mutex); - TPL_DEBUG("[FEEDBACK][PRESENTED] pst_feedback(%p) presentation_feedback(%p) bo(%d)", + TPL_LOG_D("[PRESENTED]", "pst_feedback(%p) presentation_feedback(%p) bo(%d)", pst_feedback, presentation_feedback, pst_feedback->bo_name); if (pst_feedback->pst_sync_fd != -1) { @@ -3315,7 +3318,7 @@ __cb_presentation_feedback_discarded(void *data, tpl_gmutex_lock(&wl_egl_surface->presentation_sync.mutex); - TPL_DEBUG("[FEEDBACK][DISCARDED] pst_feedback(%p) presentation_feedback(%p) bo(%d)", + TPL_LOG_D("[DISCARDED]", "pst_feedback(%p) presentation_feedback(%p) bo(%d)", pst_feedback, presentation_feedback, pst_feedback->bo_name); if (pst_feedback->pst_sync_fd != -1) { @@ -3398,8 +3401,8 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, "[FATAL] Failed to create wl_buffer"); TPL_INFO("[WL_BUFFER_CREATE]", - "wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p)", - wl_egl_buffer, wl_egl_buffer->wl_buffer, + "wl_egl_surface(%p) wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p)", + wl_egl_surface, wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface); #if TIZEN_FEATURE_ENABLE @@ -3523,7 +3526,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, zwp_linux_surface_synchronization_v1_set_acquire_fence(wl_egl_surface->surface_sync, wl_egl_buffer->acquire_fence_fd); - TPL_DEBUG("[SET_ACQUIRE_FENCE] wl_egl_surface(%p) tbm_surface(%p) acquire_fence(%d)", + TPL_LOG_D("[SET_ACQUIRE_FENCE][1/2]", "wl_egl_surface(%p) tbm_surface(%p) acquire_fence(%d)", wl_egl_surface, wl_egl_buffer->tbm_surface, wl_egl_buffer->acquire_fence_fd); close(wl_egl_buffer->acquire_fence_fd); wl_egl_buffer->acquire_fence_fd = -1; @@ -3535,7 +3538,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, } else { zwp_linux_buffer_release_v1_add_listener( wl_egl_buffer->buffer_release, &zwp_release_listner, wl_egl_buffer); - TPL_DEBUG("add explicit_sync_release_listener."); + TPL_LOG_D("[SET_ACQUIRE_FENCE][2/2]", "add explicit_sync_release_listener."); } } #endif @@ -3577,7 +3580,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, TRACE_ASYNC_END(wl_egl_buffer->commit_sync_fd, "[COMMIT_SYNC] bo(%d)", wl_egl_buffer->bo_name); - TPL_DEBUG("[COMMIT_SYNC][SEND] wl_egl_surface(%p) commit_sync_fd(%d)", + TPL_LOG_D("[COMMIT_SYNC][SEND]", "wl_egl_surface(%p) commit_sync_fd(%d)", wl_egl_surface, wl_egl_buffer->commit_sync_fd); close(wl_egl_buffer->commit_sync_fd); @@ -3656,8 +3659,8 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) tpl_wl_egl_surface_t *wl_egl_surface = wl_egl_buffer->wl_egl_surface; tpl_wl_egl_display_t *wl_egl_display = wl_egl_surface->wl_egl_display; - TPL_INFO("[BUFFER_FREE]", "wl_egl_buffer(%p) wl_buffer(%p) tbm_surface(%p)", - wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface); + TPL_INFO("[BUFFER_FREE]", "wl_egl_surface(%p) wl_egl_buffer(%p) tbm_surface(%p) bo(%d)", + wl_egl_surface, wl_egl_buffer, wl_egl_buffer->tbm_surface, wl_egl_buffer->bo_name); tpl_gmutex_lock(&wl_egl_surface->buffers_mutex); if (wl_egl_surface->buffers) { @@ -3752,17 +3755,15 @@ _print_buffer_lists(tpl_wl_egl_surface_t *wl_egl_surface) tpl_gmutex_lock(&wl_egl_surface->buffers_mutex); buffer_cnt = __tpl_list_get_count(wl_egl_surface->buffers); - TPL_INFO("[BUFFERS_INFO]", "wl_egl_surface(%p) buffer_cnt(%d)", - wl_egl_surface, buffer_cnt); node = __tpl_list_get_front_node(wl_egl_surface->buffers); do { if (!node) break; wl_egl_buffer = (tpl_wl_egl_buffer_t *)__tpl_list_node_get_data(node); - TPL_INFO("[INFO]", - "[%d/%d] | wl_egl_buffer(%p) tbm_surface(%p) bo(%d) | status(%s)", - ++idx, buffer_cnt, wl_egl_buffer, wl_egl_buffer->tbm_surface, - wl_egl_buffer->bo_name, + TPL_INFO("[BUFFERS_INFO]", + "[%d/%d] wl_egl_surface(%p), wl_egl_buffer(%p) tbm_surface(%p) bo(%d) | status(%s)", + ++idx, buffer_cnt, wl_egl_surface, wl_egl_buffer, + wl_egl_buffer->tbm_surface, wl_egl_buffer->bo_name, status_to_string[wl_egl_buffer->status]); } while ((node = __tpl_list_node_next(node))); tpl_gmutex_unlock(&wl_egl_surface->buffers_mutex); diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 317d005..a339349 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -372,7 +372,9 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, wl_registry_bind(wl_registry, name, &zwp_linux_explicit_synchronization_v1_interface, 1); wl_vk_display->use_explicit_sync = TPL_TRUE; - TPL_DEBUG("bind zwp_linux_explicit_synchronization_v1_interface"); + TPL_LOG_D("[REGISTRY_BIND]", + "wl_vk_display(%p) bind zwp_linux_explicit_synchronization_v1_interface", + wl_vk_display); } } #endif @@ -693,7 +695,7 @@ __thread_func_disp_finalize(tpl_gsource *gsource) (tpl_wl_vk_display_t *)tpl_gsource_get_data(gsource); tpl_gmutex_lock(&wl_vk_display->disp_mutex); - TPL_DEBUG("[FINALIZE] wl_vk_display(%p) tpl_gsource(%p)", + TPL_LOG_D("[D_FINALIZE]", "wl_vk_display(%p) tpl_gsource(%p)", wl_vk_display, gsource); if (wl_vk_display->wl_initialized) @@ -1029,10 +1031,11 @@ _tpl_wl_vk_surface_buffer_clear(tpl_wl_vk_surface_t *wl_vk_surface) status = wl_vk_buffer->status; - TPL_DEBUG("[idx:%d] wl_vk_buffer(%p) tbm_surface(%p) status(%s)", - idx, wl_vk_buffer, - wl_vk_buffer->tbm_surface, - status_to_string[status]); + TPL_INFO("[BUFFER_CLEAR]", + "[%d] wl_vk_surface(%p) wl_vk_buffer(%p) tbm_surface(%p) status(%s)", + idx, wl_vk_surface, wl_vk_buffer, + wl_vk_buffer->tbm_surface, + status_to_string[status]); if (status >= ENQUEUED) { tpl_bool_t need_to_wait = TPL_FALSE; @@ -1211,13 +1214,13 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) tpl_gmutex_lock(&wl_vk_surface->surf_mutex); if (message == INIT_SURFACE) { /* Initialize surface */ - TPL_DEBUG("wl_vk_surface(%p) initialize message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) initialize message received!", wl_vk_surface); _thread_wl_vk_surface_init(wl_vk_surface); wl_vk_surface->initialized_in_thread = TPL_TRUE; tpl_gcond_signal(&wl_vk_surface->surf_cond); } else if (message == CREATE_QUEUE) { /* Create tbm_surface_queue */ - TPL_DEBUG("wl_vk_surface(%p) queue creation message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) queue creation message received!", wl_vk_surface); if (_thread_swapchain_create_tbm_queue(wl_vk_surface) != TPL_ERROR_NONE) { @@ -1226,12 +1229,12 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) } tpl_gcond_signal(&wl_vk_surface->surf_cond); } else if (message == DESTROY_QUEUE) { /* swapchain destroy */ - TPL_DEBUG("wl_vk_surface(%p) swapchain destroy message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) swapchain destroy message received!", wl_vk_surface); _thread_swapchain_destroy_tbm_queue(wl_vk_surface); tpl_gcond_signal(&wl_vk_surface->surf_cond); } else if (message == ACQUIRABLE) { /* Acquirable message */ - TPL_DEBUG("wl_vk_surface(%p) acquirable message received!", + TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) acquirable message received!", wl_vk_surface); if (_thread_surface_queue_acquire(wl_vk_surface) != TPL_ERROR_NONE) { @@ -1257,7 +1260,7 @@ __thread_func_surf_finalize(tpl_gsource *gsource) TPL_CHECK_ON_NULL_RETURN(wl_vk_surface); tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - TPL_DEBUG("[FINALIZE] wl_vk_surface(%p) tpl_gsource(%p)", + TPL_LOG_D("[S_FINALIZE]", "wl_vk_surface(%p) tpl_gsource(%p)", wl_vk_surface, gsource); _thread_wl_vk_surface_fini(wl_vk_surface); @@ -1498,9 +1501,9 @@ __cb_tbm_queue_reset_callback(tbm_surface_queue_h tbm_queue, "wl_vk_surface(%p) wl_surface(%p) tbm_queue(%p)", wl_vk_surface, wl_vk_surface->wl_surface, tbm_queue); } else { - TPL_LOG_T("[DEACTIVATED]", - " wl_vk_surface(%p) wl_surface(%p) tbm_queue(%p)", - wl_vk_surface, wl_vk_surface->wl_surface, tbm_queue); + TPL_INFO("[DEACTIVATED]", + " wl_vk_surface(%p) wl_surface(%p) tbm_queue(%p)", + wl_vk_surface, wl_vk_surface->wl_surface, tbm_queue); } } @@ -1573,7 +1576,9 @@ _thread_swapchain_create_tbm_queue(tpl_wl_vk_surface_t *wl_vk_surface) int i; for (i = 0; i < swapchain->properties.buffer_count; i++) { if (swapchain->swapchain_buffers[i]) { - TPL_DEBUG("unref tbm_surface(%p)", swapchain->swapchain_buffers[i]); + TPL_INFO("[UNTRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", + i, wl_vk_surface, swapchain, swapchain->swapchain_buffers[i], + _get_tbm_surface_bo_name(swapchain->swapchain_buffers[i])); tbm_surface_internal_unref(swapchain->swapchain_buffers[i]); swapchain->swapchain_buffers[i] = NULL; } @@ -1678,7 +1683,7 @@ _thread_swapchain_create_tbm_queue(tpl_wl_vk_surface_t *wl_vk_surface) swapchain->create_done = TPL_TRUE; TPL_INFO("[TBM_QUEUE_CREATED]", - "wl_vk_surface(%p) wl_vk_swapchain(%p) tbm_queue(%p)", + "wl_vk_surface(%p) swapchain(%p) tbm_queue(%p)", wl_vk_surface, swapchain, tbm_queue); return TPL_ERROR_NONE; @@ -1805,8 +1810,9 @@ __tpl_wl_vk_surface_destroy_swapchain(tpl_surface_t *surface) if (swapchain->swapchain_buffers) { for (int i = 0; i < swapchain->properties.buffer_count; i++) { if (swapchain->swapchain_buffers[i]) { - TPL_DEBUG("Stop tracking tbm_surface(%p)", - swapchain->swapchain_buffers[i]); + TPL_INFO("[UNTRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", + i, wl_vk_surface, swapchain, swapchain->swapchain_buffers[i], + _get_tbm_surface_bo_name(swapchain->swapchain_buffers[i])); tbm_surface_internal_unref(swapchain->swapchain_buffers[i]); swapchain->swapchain_buffers[i] = NULL; } @@ -1888,8 +1894,8 @@ __tpl_wl_vk_surface_get_swapchain_buffers(tpl_surface_t *surface, for (i = 0; i < *buffer_count; i++) { if (swapchain->swapchain_buffers[i]) { - TPL_DEBUG("swapchain_buffers[%d] = tbm_surface(%p) bo(%d)", - i, swapchain->swapchain_buffers[i], + TPL_INFO("[TRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", + i, wl_vk_surface, swapchain, swapchain->swapchain_buffers[i], _get_tbm_surface_bo_name(swapchain->swapchain_buffers[i])); tbm_surface_internal_ref(swapchain->swapchain_buffers[i]); } @@ -2121,7 +2127,7 @@ __tpl_wl_vk_surface_dequeue_buffer(tpl_surface_t *surface, #if TIZEN_FEATURE_ENABLE if (wl_vk_surface->surface_sync) { *release_fence = wl_vk_buffer->release_fence_fd; - TPL_DEBUG("wl_vk_surface(%p) wl_vk_buffer(%p) release_fence_fd(%d)", + TPL_LOG_D("[EXPLICIT_FENCE]", "wl_vk_surface(%p) wl_vk_buffer(%p) release_fence_fd(%d)", wl_vk_surface, wl_vk_buffer, *release_fence); wl_vk_buffer->release_fence_fd = -1; } else @@ -2528,7 +2534,7 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error, tpl_wl_vk_buffer_t *wl_vk_buffer = NULL; TRACE_ASYNC_END((intptr_t)wl_vk_surface, "WAIT_VBLANK"); - TPL_DEBUG("[VBLANK] wl_vk_surface(%p)", wl_vk_surface); + TPL_LOG_D("[VBLANK_DONE]", "wl_vk_surface(%p)", wl_vk_surface); if (error == TDM_ERROR_TIMEOUT) TPL_WARN("[TDM_ERROR_TIMEOUT] It will keep going. wl_vk_surface(%p)", @@ -2646,7 +2652,7 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, zwp_linux_surface_synchronization_v1_set_acquire_fence(wl_vk_surface->surface_sync, wl_vk_buffer->acquire_fence_fd); - TPL_DEBUG("[SET_ACQUIRE_FENCE] wl_vk_surface(%p) tbm_surface(%p) acquire_fence(%d)", + TPL_LOG_D("[SET_ACQUIRE_FENCE][1/2]", "wl_vk_surface(%p) tbm_surface(%p) acquire_fence(%d)", wl_vk_surface, wl_vk_buffer->tbm_surface, wl_vk_buffer->acquire_fence_fd); close(wl_vk_buffer->acquire_fence_fd); wl_vk_buffer->acquire_fence_fd = -1; @@ -2658,7 +2664,7 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, } else { zwp_linux_buffer_release_v1_add_listener( wl_vk_buffer->buffer_release, &zwp_release_listner, wl_vk_buffer); - TPL_DEBUG("add explicit_sync_release_listener."); + TPL_LOG_D("[SET_ACQUIRE_FENCE][2/2]", "add explicit_sync_release_listener."); } } #endif -- 2.7.4 From 4e697e01bd3b3391aa75dcd1a353cdcb9e9fe5a1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 10 Jul 2023 17:24:02 +0900 Subject: [PATCH 03/16] wl_vk: change the event message processing Change-Id: I6d3b6c7aa7b5289fb1b91a9c3f9cb563499fabd4 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index a339349..0592063 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -104,10 +104,10 @@ struct _tpl_wl_vk_swapchain { typedef enum surf_message { NONE_MESSAGE = 0, - INIT_SURFACE, - CREATE_QUEUE, - DESTROY_QUEUE, - ACQUIRABLE, + INIT_SURFACE = 1, + ACQUIRABLE = 2, + CREATE_QUEUE = 4, + DESTROY_QUEUE = 8, } surf_message; struct _tpl_wl_vk_surface { @@ -1213,13 +1213,25 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) wl_vk_surface = (tpl_wl_vk_surface_t *)tpl_gsource_get_data(gsource); tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - if (message == INIT_SURFACE) { /* Initialize surface */ + if (message & INIT_SURFACE) { /* Initialize surface */ TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) initialize message received!", wl_vk_surface); _thread_wl_vk_surface_init(wl_vk_surface); wl_vk_surface->initialized_in_thread = TPL_TRUE; tpl_gcond_signal(&wl_vk_surface->surf_cond); - } else if (message == CREATE_QUEUE) { /* Create tbm_surface_queue */ + } + + if (message & ACQUIRABLE) { /* Acquirable message */ + TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) acquirable message received!", + wl_vk_surface); + if (_thread_surface_queue_acquire(wl_vk_surface) + != TPL_ERROR_NONE) { + TPL_ERR("Failed to acquire from tbm_queue. wl_vk_surface(%p)", + wl_vk_surface); + } + } + + if (message & CREATE_QUEUE) { /* Create tbm_surface_queue */ TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) queue creation message received!", wl_vk_surface); if (_thread_swapchain_create_tbm_queue(wl_vk_surface) @@ -1228,19 +1240,13 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) wl_vk_surface); } tpl_gcond_signal(&wl_vk_surface->surf_cond); - } else if (message == DESTROY_QUEUE) { /* swapchain destroy */ + } + + if (message & DESTROY_QUEUE) { /* swapchain destroy */ TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) swapchain destroy message received!", wl_vk_surface); _thread_swapchain_destroy_tbm_queue(wl_vk_surface); tpl_gcond_signal(&wl_vk_surface->surf_cond); - } else if (message == ACQUIRABLE) { /* Acquirable message */ - TPL_LOG_D("[MSG_RECEIVED]", "wl_vk_surface(%p) acquirable message received!", - wl_vk_surface); - if (_thread_surface_queue_acquire(wl_vk_surface) - != TPL_ERROR_NONE) { - TPL_ERR("Failed to acquire from tbm_queue. wl_vk_surface(%p)", - wl_vk_surface); - } } /* init to NONE_MESSAGE */ -- 2.7.4 From f1be039aedd0c47aa9afe71404237f3de58b3fe4 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 10 Jul 2023 20:06:47 +0900 Subject: [PATCH 04/16] utils_gthread: add enum type to distinguish the fd type Change-Id: Idca314bb4cb28cae973c56b9bc99a32195924e47 Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 16 ++++++++-------- src/tpl_utils_gthread.h | 10 +++++++++- src/tpl_wl_egl_thread.c | 7 +++++-- src/tpl_wl_vk_thread.c | 4 +++- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 4b17598..8406753 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -24,7 +24,7 @@ struct _tpl_gsource { tpl_gthread *thread; int fd; - tpl_bool_t is_eventfd; + fd_type_t fd_type; tpl_gsource_functions *gsource_funcs; tpl_gsource_type_t type; @@ -187,7 +187,7 @@ _thread_source_dispatch(GSource *source, GSourceFunc cb, gpointer data) ssize_t s; uint64_t message = 0; - if (gsource->is_eventfd) { + if (gsource->fd_type == FD_TYPE_EVENT) { s = read(gsource->fd, &message, sizeof(uint64_t)); if (s != sizeof(uint64_t)) { TPL_ERR("Failed to read from event_fd(%d)", @@ -245,7 +245,7 @@ _thread_source_finalize(GSource *source) if (gsource->gsource_funcs && gsource->gsource_funcs->finalize) gsource->gsource_funcs->finalize(gsource); - if (gsource->is_eventfd) + if (gsource->fd_type == FD_TYPE_EVENT) close(gsource->fd); gsource->fd = -1; @@ -263,7 +263,7 @@ static GSourceFuncs _thread_source_funcs = { }; tpl_gsource * -tpl_gsource_create(tpl_gthread *thread, void *data, int fd, +tpl_gsource_create(tpl_gthread *thread, void *data, int fd, fd_type_t fd_type, tpl_gsource_functions *funcs, tpl_gsource_type_t type) { tpl_gsource *new_gsource = NULL; @@ -283,10 +283,10 @@ tpl_gsource_create(tpl_gthread *thread, void *data, int fd, return NULL; } - new_gsource->is_eventfd = TPL_TRUE; + new_gsource->fd_type = FD_TYPE_EVENT; } else { new_gsource->fd = fd; - new_gsource->is_eventfd = TPL_FALSE; + new_gsource->fd_type = fd_type; } new_gsource->thread = thread; @@ -296,7 +296,7 @@ tpl_gsource_create(tpl_gthread *thread, void *data, int fd, new_gsource->intended_destroy = TPL_FALSE; if (new_gsource->type == SOURCE_TYPE_NORMAL) { - tpl_gsource *finalizer = tpl_gsource_create(thread, new_gsource, -1, + tpl_gsource *finalizer = tpl_gsource_create(thread, new_gsource, -1, FD_TYPE_NONE, NULL, SOURCE_TYPE_FINALIZER); new_gsource->finalizer = finalizer; } else @@ -365,7 +365,7 @@ tpl_gsource_send_message(tpl_gsource *source, uint64_t message) uint64_t value = message; int ret; - if (!source->is_eventfd) { + if (source->fd_type != FD_TYPE_EVENT) { TPL_ERR("source is not using eventfd. source(%p) fd(%d)", source, source->fd); return; diff --git a/src/tpl_utils_gthread.h b/src/tpl_utils_gthread.h index c6ae5a4..b5f0eb5 100644 --- a/src/tpl_utils_gthread.h +++ b/src/tpl_utils_gthread.h @@ -17,6 +17,14 @@ typedef GMutex tpl_gmutex; typedef GCond tpl_gcond; typedef enum { + FD_TYPE_NONE = -1, /* not specified */ + FD_TYPE_EVENT, /* event fd. should close it when finalize */ + FD_TYPE_FENCE, /* fence fd. should close after waiting until it signaled */ + FD_TYPE_SOCKET, /* socket fd. cannot close this passed fd */ + FD_TYPE_MAX +} fd_type_t; + +typedef enum { SOURCE_TYPE_UNKNOWN = -1, /* not specified. it will be classified to NORMAL */ SOURCE_TYPE_NORMAL, /* normal source */ SOURCE_TYPE_DISPOSABLE, /* disposable source */ @@ -83,7 +91,7 @@ tpl_gthread_destroy(tpl_gthread *thread); * @see tpl_gsource_destroy */ tpl_gsource * -tpl_gsource_create(tpl_gthread *thread, void *data, int fd, +tpl_gsource_create(tpl_gthread *thread, void *data, int fd, fd_type_t fd_type, tpl_gsource_functions *funcs, tpl_gsource_type_t type); /** diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 84e8d08..6debf26 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -931,6 +931,7 @@ __tpl_wl_egl_display_init(tpl_display_t *display) wl_egl_display->disp_source = tpl_gsource_create(wl_egl_display->thread, (void *)wl_egl_display, wl_display_get_fd(wl_egl_display->wl_display), + FD_TYPE_SOCKET, &disp_funcs, SOURCE_TYPE_NORMAL); if (!wl_egl_display->disp_source) { TPL_ERR("Failed to add native_display(%p) to thread(%p)", @@ -946,6 +947,7 @@ __tpl_wl_egl_display_init(tpl_display_t *display) wl_egl_display->tdm.tdm_source = tpl_gsource_create(wl_egl_display->thread, (void *)wl_egl_display, wl_egl_display->tdm.tdm_display_fd, + FD_TYPE_SOCKET, &tdm_funcs, SOURCE_TYPE_NORMAL); wl_egl_display->tdm.gsource_finalized = TPL_FALSE; if (!wl_egl_display->tdm.tdm_source) { @@ -1771,7 +1773,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) } surf_source = tpl_gsource_create(wl_egl_display->thread, (void *)wl_egl_surface, - -1, &surf_funcs, SOURCE_TYPE_NORMAL); + -1, FD_TYPE_NONE, &surf_funcs, SOURCE_TYPE_NORMAL); if (!surf_source) { TPL_ERR("Failed to create surf_source with wl_egl_surface(%p)", wl_egl_surface); @@ -3008,7 +3010,8 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_buffer->waiting_source = tpl_gsource_create(wl_egl_display->thread, wl_egl_buffer, - wl_egl_buffer->acquire_fence_fd, &buffer_funcs, + wl_egl_buffer->acquire_fence_fd, + FD_TYPE_FENCE, &buffer_funcs, SOURCE_TYPE_DISPOSABLE); wl_egl_buffer->status = WAITING_SIGNALED; diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 0592063..a40b4f0 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -789,6 +789,7 @@ __tpl_wl_vk_display_init(tpl_display_t *display) wl_vk_display->disp_source = tpl_gsource_create(wl_vk_display->thread, (void *)wl_vk_display, + FD_TYPE_SOCKET, wl_display_get_fd(wl_vk_display->wl_display), &disp_funcs, SOURCE_TYPE_NORMAL); if (!wl_vk_display->disp_source) { @@ -804,6 +805,7 @@ __tpl_wl_vk_display_init(tpl_display_t *display) wl_vk_display->tdm.tdm_source = tpl_gsource_create(wl_vk_display->thread, (void *)wl_vk_display, wl_vk_display->tdm.tdm_display_fd, + FD_TYPE_SOCKET, &tdm_funcs, SOURCE_TYPE_NORMAL); if (!wl_vk_display->tdm.tdm_source) { TPL_ERR("Failed to create tdm_gsource\n"); @@ -1308,7 +1310,7 @@ __tpl_wl_vk_surface_init(tpl_surface_t *surface) } surf_source = tpl_gsource_create(wl_vk_display->thread, (void *)wl_vk_surface, - -1, &surf_funcs, SOURCE_TYPE_NORMAL); + -1, FD_TYPE_NONE, &surf_funcs, SOURCE_TYPE_NORMAL); if (!surf_source) { TPL_ERR("Failed to create surf_source with wl_vk_surface(%p)", wl_vk_surface); -- 2.7.4 From 8cac0af52e889a70a8ea2c4f0c08a13ca140d387 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 11 Jul 2023 15:33:48 +0900 Subject: [PATCH 05/16] wl_egl: close fence_fd when gsource finalized - Even though when main thread have called tpl_gsource_destroy for fence_waiting_source, which has not yet signaled, gsource may not be completely destroyed because it might be in dispatch queue in g_main_context. - In this case, if the fence_waiting_source is dispatched, it can try to commit with the invalid wl_egl_buffer that has already been freed. - This commit makes to prevent operating with an invalid wl_egl_buffer and to close fence_fd properly. Change-Id: Ibce274b062bf8a6354a76464fca8f1e10b77c7b8 Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 7 ++++++- src/tpl_wl_egl_thread.c | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 8406753..6020a67 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -245,7 +245,8 @@ _thread_source_finalize(GSource *source) if (gsource->gsource_funcs && gsource->gsource_funcs->finalize) gsource->gsource_funcs->finalize(gsource); - if (gsource->fd_type == FD_TYPE_EVENT) + if (gsource->fd_type == FD_TYPE_EVENT || + gsource->fd_type == FD_TYPE_FENCE) close(gsource->fd); gsource->fd = -1; @@ -326,6 +327,8 @@ __gsource_remove_and_destroy(tpl_gsource *source) g_source_remove_unix_fd(&source->gsource, source->tag); g_source_destroy(&source->gsource); g_source_unref(&source->gsource); + + source->data = NULL; } void @@ -336,6 +339,7 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) if (g_source_is_destroyed(&source->gsource)) { TPL_WARN("gsource(%p) already has been destroyed.", source); + source->data = NULL; return; } @@ -356,6 +360,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); } diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 6debf26..365fead 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2911,8 +2911,14 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) { tpl_wl_egl_buffer_t *wl_egl_buffer = (tpl_wl_egl_buffer_t *)tpl_gsource_get_data(gsource); + TPL_CHECK_ON_NULL_RETURN_VAL(wl_egl_buffer, TPL_FALSE); + tpl_wl_egl_surface_t *wl_egl_surface = wl_egl_buffer->wl_egl_surface; + TPL_CHECK_ON_NULL_RETURN_VAL(wl_egl_surface, TPL_FALSE); + tbm_surface_h tbm_surface = wl_egl_buffer->tbm_surface; + TPL_CHECK_ON_NULL_RETURN_VAL(tbm_surface, TPL_FALSE); + TPL_CHECK_ON_FALSE_RETURN_VAL(tbm_surface_internal_is_valid(tbm_surface), TPL_FALSE); wl_egl_surface->render_done_cnt++; @@ -2929,7 +2935,6 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message) wl_egl_surface, 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; @@ -3732,6 +3737,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->num_rects = 0; } + wl_egl_buffer->wl_egl_surface = NULL; wl_egl_buffer->tbm_surface = NULL; wl_egl_buffer->bo_name = -1; wl_egl_buffer->status = RELEASED; -- 2.7.4 From 4ae1d9a7e5bed1845ca6fc20eaafa86e2ecc9d43 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 11 Jul 2023 15:47:59 +0900 Subject: [PATCH 06/16] Package version up to 1.10.4 Change-Id: I480c76e12c88d8e9d972e7903d1fbaae6b39a72c 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 ba39ffb..051fb0e 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 10 -%define TPL_VERSION_PATCH 3 +%define TPL_VERSION_PATCH 4 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 027671a01d9be088aa65759758ded4a5e210b106 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 17 Jul 2023 16:35:16 +0900 Subject: [PATCH 07/16] utils_gthread: do not make data into NULL before the source is destroyed - Even if thread call the g_source_destroy & unref it, it may not be destroyed immediately. (waiting for dispatch in g_main_context) - source->data will be changed to NULL only when it destroyed perfectly. Change-Id: Iecf8ce7599a0ad92346fe7dc802bfcebbb7cd25c Signed-off-by: Joonbum Ko --- src/tpl_utils_gthread.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index 6020a67..e9f506b 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -327,8 +327,6 @@ __gsource_remove_and_destroy(tpl_gsource *source) g_source_remove_unix_fd(&source->gsource, source->tag); g_source_destroy(&source->gsource); g_source_unref(&source->gsource); - - source->data = NULL; } void @@ -339,7 +337,6 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) if (g_source_is_destroyed(&source->gsource)) { TPL_WARN("gsource(%p) already has been destroyed.", source); - source->data = NULL; return; } @@ -358,6 +355,16 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) } if (!destroy_in_thread) { + if (source->fd_type == FD_TYPE_FENCE && + source->type == SOURCE_TYPE_DISPOSABLE) { + TPL_LOG_D("[GSOURCE][DESTROY]", "tpl_gsource(%p) type(%d)", + source, source->type); + + g_source_remove_unix_fd(&source->gsource, source->tag); + source->data = NULL; + g_source_destroy(&source->gsource); + g_source_unref(&source->gsource); + } __gsource_remove_and_destroy(source); } -- 2.7.4 From 7637587656b3af5c4e586c74839aac76a29e9b66 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 17 Jul 2023 16:37:55 +0900 Subject: [PATCH 08/16] Package version up to 1.10.5 Change-Id: I1a3e22b04d5b73a5ba2f4dceb80f8202e5e6af93 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 051fb0e..baf58d3 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 10 -%define TPL_VERSION_PATCH 4 +%define TPL_VERSION_PATCH 5 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 8547656ec1849d40cc1bcd527e2732359a1ed671 Mon Sep 17 00:00:00 2001 From: Xuelian Bai Date: Mon, 24 Jul 2023 11:15:17 +0800 Subject: [PATCH 09/16] Fix a typo This typo will cause frozen for all vulkan app, since display dispatch didn't work Change-Id: Ibd3d753e35c0825bb7a6bc008baa4ace2fb076ff Signed-off-by: Xuelian Bai --- src/tpl_wl_vk_thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index a40b4f0..bbe15aa 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -789,8 +789,8 @@ __tpl_wl_vk_display_init(tpl_display_t *display) wl_vk_display->disp_source = tpl_gsource_create(wl_vk_display->thread, (void *)wl_vk_display, - FD_TYPE_SOCKET, wl_display_get_fd(wl_vk_display->wl_display), + FD_TYPE_SOCKET, &disp_funcs, SOURCE_TYPE_NORMAL); if (!wl_vk_display->disp_source) { TPL_ERR("Failed to add native_display(%p) to thread(%p)", -- 2.7.4 From 648550b901c2f7f8743aeb2f3277e9907b6cb5fe Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 18 Jul 2023 19:40:25 +0900 Subject: [PATCH 10/16] wl_vk: untrack the swapchain_buffers when destroy_swapchain called Change-Id: I72ed5fdf2fec9f00fa25e5bc87ea26501d1042f9 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 56 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index bbe15aa..3ad9b00 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -99,6 +99,10 @@ struct _tpl_wl_vk_swapchain { tbm_surface_h *swapchain_buffers; + /* [TEMP] To fix dEQP-VK.wsi.wayland.swapchain.modify.resize crash issue + * It will be fixed properly using old_swapchain handle */ + tbm_surface_h *old_swapchain_buffers; + tpl_util_atomic_uint ref_cnt; }; @@ -1576,23 +1580,18 @@ _thread_swapchain_create_tbm_queue(tpl_wl_vk_surface_t *wl_vk_surface) return TPL_ERROR_INVALID_PARAMETER; } + if (swapchain->old_swapchain_buffers) { + TPL_ERR("Should be destroy old_swapchain before create"); + swapchain->result = TPL_ERROR_INVALID_OPERATION; + return TPL_ERROR_INVALID_OPERATION; + } + if (swapchain->tbm_queue) { int old_width = tbm_surface_queue_get_width(swapchain->tbm_queue); int old_height = tbm_surface_queue_get_height(swapchain->tbm_queue); if (swapchain->swapchain_buffers) { - int i; - for (i = 0; i < swapchain->properties.buffer_count; i++) { - if (swapchain->swapchain_buffers[i]) { - TPL_INFO("[UNTRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", - i, wl_vk_surface, swapchain, swapchain->swapchain_buffers[i], - _get_tbm_surface_bo_name(swapchain->swapchain_buffers[i])); - tbm_surface_internal_unref(swapchain->swapchain_buffers[i]); - swapchain->swapchain_buffers[i] = NULL; - } - } - - free(swapchain->swapchain_buffers); + swapchain->old_swapchain_buffers = swapchain->swapchain_buffers; swapchain->swapchain_buffers = NULL; } @@ -1731,6 +1730,8 @@ __tpl_wl_vk_surface_create_swapchain(tpl_surface_t *surface, swapchain->properties.present_mode = present_mode; swapchain->wl_vk_surface = wl_vk_surface; swapchain->properties.format = format; + swapchain->swapchain_buffers = NULL; + swapchain->old_swapchain_buffers = NULL; swapchain->result = TPL_ERROR_NONE; swapchain->create_done = TPL_FALSE; @@ -1775,6 +1776,21 @@ _thread_swapchain_destroy_tbm_queue(tpl_wl_vk_surface_t *wl_vk_surface) } } +void __untrack_swapchain_buffers(tpl_wl_vk_surface_t *wl_vk_surface, tbm_surface_h *sc_buffers) +{ + tpl_wl_vk_swapchain_t *swapchain = wl_vk_surface->swapchain; + + for (int i = 0; i < swapchain->properties.buffer_count; i++) { + if (sc_buffers[i]) { + TPL_INFO("[UNTRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", + i, wl_vk_surface, swapchain, sc_buffers[i], + _get_tbm_surface_bo_name(sc_buffers[i])); + tbm_surface_internal_unref(sc_buffers[i]); + sc_buffers[i] = NULL; + } + } +} + static tpl_result_t __tpl_wl_vk_surface_destroy_swapchain(tpl_surface_t *surface) { @@ -1808,6 +1824,11 @@ __tpl_wl_vk_surface_destroy_swapchain(tpl_surface_t *surface) TPL_INFO("[DESTROY_SWAPCHAIN]", "wl_vk_surface(%p) swapchain(%p) still valid.", wl_vk_surface, swapchain); + if (swapchain->old_swapchain_buffers) { + __untrack_swapchain_buffers(wl_vk_surface, swapchain->old_swapchain_buffers); + free(swapchain->old_swapchain_buffers); + swapchain->old_swapchain_buffers = NULL; + } return TPL_ERROR_NONE; } @@ -1816,16 +1837,7 @@ __tpl_wl_vk_surface_destroy_swapchain(tpl_surface_t *surface) wl_vk_surface, wl_vk_surface->swapchain); if (swapchain->swapchain_buffers) { - for (int i = 0; i < swapchain->properties.buffer_count; i++) { - if (swapchain->swapchain_buffers[i]) { - TPL_INFO("[UNTRACK_BUFFERS]", "[%d] wl_vk_surface(%p) sc(%p) tbm_surface(%p) bo(%d)", - i, wl_vk_surface, swapchain, swapchain->swapchain_buffers[i], - _get_tbm_surface_bo_name(swapchain->swapchain_buffers[i])); - tbm_surface_internal_unref(swapchain->swapchain_buffers[i]); - swapchain->swapchain_buffers[i] = NULL; - } - } - + __untrack_swapchain_buffers(wl_vk_surface, swapchain->swapchain_buffers); free(swapchain->swapchain_buffers); swapchain->swapchain_buffers = NULL; } -- 2.7.4 From d93e0763029e5f444a94b9abdd17bd53e5832e82 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 24 Jul 2023 16:15:58 +0900 Subject: [PATCH 11/16] Package version up to 1.10.6 Change-Id: Ie0023ea5aaf82238fb8c50fec70e6c4bc676b642 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 baf58d3..7f8ca01 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 10 -%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 a3e34cc9dc656a82a430b7f93aeeb5f4058664e8 Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Tue, 29 Aug 2023 19:56:54 +0900 Subject: [PATCH 12/16] Remove double free situation - if (source->fd_type == FD_TYPE_FENCE && source->type == SOURCE_TYPE_DISPOSABLE) then g_source_remove_unix_fd, g_source_destroy, g_source_unref is called twice for source->gsource. - it can cause error like that free already freed memory or free with invalid pointer (garbage value) Change-Id: I44e3b1d50b0710d9cd2ddcf8e8c8f4215acff344 --- src/tpl_utils_gthread.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tpl_utils_gthread.c b/src/tpl_utils_gthread.c index e9f506b..b4b78cf 100644 --- a/src/tpl_utils_gthread.c +++ b/src/tpl_utils_gthread.c @@ -365,7 +365,8 @@ tpl_gsource_destroy(tpl_gsource *source, tpl_bool_t destroy_in_thread) g_source_destroy(&source->gsource); g_source_unref(&source->gsource); } - __gsource_remove_and_destroy(source); + else + __gsource_remove_and_destroy(source); } g_mutex_unlock(&thread->thread_mutex); -- 2.7.4 From 6f6890884ab6a8bfba8cfa92a92e04885b9a3eda Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Tue, 29 Aug 2023 20:06:33 +0900 Subject: [PATCH 13/16] Package version up to 1.10.7 Change-Id: I7fc5a01433d47123fca4a008bbfec74dbc9d9c01 --- 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 7f8ca01..0a9792d 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 10 -%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 dd301a71effb57c7828f8a10e6e10b30a3631cd8 Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Mon, 18 Sep 2023 15:13:55 +0900 Subject: [PATCH 14/16] protect wl_egl_buffer->wl_buffer with mutex_lock - wl_egl_buffer->wl_buffer is must protected when call wl_egl_display && wl_egl_display->wl_tbm_client Change-Id: I223f1521b1f412914194226ce69a996fc4ef91db --- src/tpl_wl_egl_thread.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 365fead..c927f6e 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -3685,17 +3685,20 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) tpl_gmutex_unlock(&wl_egl_surface->vblank->mutex); } - if (wl_egl_display) { + if (wl_egl_display) + wl_display_flush(wl_egl_display->wl_display); + + tpl_gmutex_lock(&wl_egl_buffer->mutex); + + if (wl_egl_display && wl_egl_display->wl_tbm_client) { if (wl_egl_buffer->wl_buffer) { wayland_tbm_client_destroy_buffer(wl_egl_display->wl_tbm_client, (void *)wl_egl_buffer->wl_buffer); wl_egl_buffer->wl_buffer = NULL; } - - 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); -- 2.7.4 From 24bd311a2e3e019d4797f27eac800630ee8026db Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Mon, 18 Sep 2023 15:19:41 +0900 Subject: [PATCH 15/16] Enqueued tbm_surface is needed to unref when surface's finalize is called - If main thread called __tpl_wl_egl_surface_fini(), then sometimes enqueued buffer can be remained before acquire. so in that case tbm_surface must be unreferenced. Change-Id: I3482feca808deec9c238d5ca32ee46c9ebeec401 --- 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 c927f6e..3a5fe4a 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2194,7 +2194,7 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) tpl_gmutex_unlock(&wl_egl_buffer->mutex); - if (need_to_release || need_to_cancel) + if (need_to_release || need_to_cancel || status == ENQUEUED) tbm_surface_internal_unref(wl_egl_buffer->tbm_surface); } -- 2.7.4 From 465c6f82870a29124ce3c016e5a24ccf42d88942 Mon Sep 17 00:00:00 2001 From: "jinbong, Lee" Date: Mon, 18 Sep 2023 15:37:32 +0900 Subject: [PATCH 16/16] Package version up to 1.10.8 Change-Id: Ibc178293f788b1a372ac9f4e7288d7d2aa7b7b5d --- 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 0a9792d..5f78a63 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 10 -%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