From 2da318d55d4bb6ad95ea66c8fcc8cb7db25c44f9 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 6 Sep 2018 13:27:07 +0900 Subject: [PATCH 01/16] tpl_wayland_egl_thread: Modified some bugs in in_use_buffers list. - For vulkan, get_buffers causes set_wl_buffer_info to be called once for all buffers. Therefore, vulkan does not have to push in_use_buffers when set_wl_buffer_info is called for each buffer first. Change-Id: Ic6fe472d675449906f3033f64807adc2821cec18 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 7f5808b..405648b 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1385,6 +1385,13 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->transform = wl_egl_window->transform; ++wl_egl_window->serial; buf_info->serial = wl_egl_window->serial; + + if (surf_source->in_use_buffers) { + g_mutex_lock(&surf_source->surf_mutex); + __tpl_list_push_back(surf_source->in_use_buffers, + (void *)tbm_surface); + g_mutex_unlock(&surf_source->surf_mutex); + } } else { buf_info->dx = 0; buf_info->dy = 0; @@ -1430,13 +1437,6 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, tbm_surface_internal_set_user_data(tbm_surface, KEY_BUFFER_INFO, buf_info); - if (surf_source->in_use_buffers) { - g_mutex_lock(&surf_source->surf_mutex); - __tpl_list_push_back(surf_source->in_use_buffers, - (void *)tbm_surface); - g_mutex_unlock(&surf_source->surf_mutex); - } - TRACE_MARK("[SET_BUFFER_INFO] BO(%d)", tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); TPL_LOG_T(BACKEND, -- 2.7.4 From 98827f085d65defeda0431bf3ee47edcd516193c Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 6 Sep 2018 13:53:16 +0900 Subject: [PATCH 02/16] tpl_wayland_egl_thread: Inserted the missing code to use sync fd. Change-Id: I4a8434e3c040b4abc9749d027fbcc4691f96d040 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 405648b..0e86b8c 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -3092,6 +3092,8 @@ twe_surface_create_sync_fd(tbm_surface_h tbm_surface) strerror_r(errno, buf, sizeof(buf)); TPL_ERR("Failed to create TBM sync fence: %d(%s)", errno, buf); } + + buf_info->sync_fd = sync_fd; } return sync_fd; -- 2.7.4 From 0df026578f27fdc24ebc3d6df9ede9a11d7f7a45 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 6 Sep 2018 14:16:31 +0900 Subject: [PATCH 03/16] tpl_wayland_egl_thread: Added log and trace mark Change-Id: I32a175d2c6e36c1ad9c068337c32a0db9e201f40 Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 0e86b8c..37e222e 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1767,6 +1767,11 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source, /* Presented buffer's sync operating dependent on tdm timeline fence. */ if (buf_info->sync_fd != -1) { + TPL_LOG_T(BACKEND, "[RELEASE_IMMEDIATELY] tbm_surface(%p) bo(%d) sync_fd(%d)", + tbm_surface, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0)), + buf_info->sync_fd); + TRACE_MARK("[RELEASE_IMMEDIATELY] 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) when vk_surface_commit.", -- 2.7.4 From 61adb6b18ae7f7a1e77d7f4d4ed34a49898758b1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 09:12:54 +0900 Subject: [PATCH 04/16] tpl_wayland_egl_thread: Enhanced thread safety for get_swapchain_buffers - If wayland events handled in the event thread during get_swapchain_buffers, unexpected problem can occur. Change-Id: I6c6955fd7bb5f9b03372de0c396c1b6e157b92c0 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 17ffa5c..2242975 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -522,12 +522,14 @@ __tpl_wl_vk_wsi_surface_get_swapchain_buffers(tpl_surface_t *surface, { tbm_surface_h *swapchain_buffers = NULL; tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL; int i; tpl_result_t ret = TPL_ERROR_NONE; TPL_ASSERT(surface); TPL_ASSERT(surface->backend.data); TPL_ASSERT(surface->display); + TPL_ASSERT(surface->display->backend.data); TPL_ASSERT(buffers); TPL_ASSERT(buffer_count); @@ -539,23 +541,29 @@ __tpl_wl_vk_wsi_surface_get_swapchain_buffers(tpl_surface_t *surface, return TPL_ERROR_OUT_OF_MEMORY; } - ret = twe_surface_get_swapchain_buffers(wayland_vk_wsi_surface->twe_surface, - swapchain_buffers, buffer_count); - if (ret != TPL_ERROR_NONE) { - TPL_ERR("Failed to get swapchain_buffers. wayland_vk_wsi_surface(%p) twe_surface(%p)", - wayland_vk_wsi_surface, wayland_vk_wsi_surface->twe_surface); - free(swapchain_buffers); - swapchain_buffers = NULL; - return ret; - } + wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *)surface->display->backend.data; - for (i = 0; i < *buffer_count; i++) { - TPL_DEBUG("swapchain_buffers[%d] = tbm_surface(%p) bo(%d)", - i, swapchain_buffers[i], - tbm_bo_export(tbm_surface_internal_get_bo(swapchain_buffers[i], 0))); - } + if (twe_display_lock(wayland_vk_wsi_display->twe_display) == TPL_ERROR_NONE) { + ret = twe_surface_get_swapchain_buffers(wayland_vk_wsi_surface->twe_surface, + swapchain_buffers, buffer_count); + if (ret != TPL_ERROR_NONE) { + TPL_ERR("Failed to get swapchain_buffers. wayland_vk_wsi_surface(%p) twe_surface(%p)", + wayland_vk_wsi_surface, wayland_vk_wsi_surface->twe_surface); + free(swapchain_buffers); + swapchain_buffers = NULL; + return ret; + } - *buffers = swapchain_buffers; + for (i = 0; i < *buffer_count; i++) { + TPL_DEBUG("swapchain_buffers[%d] = tbm_surface(%p) bo(%d)", + i, swapchain_buffers[i], + tbm_bo_export(tbm_surface_internal_get_bo(swapchain_buffers[i], 0))); + } + + *buffers = swapchain_buffers; + + twe_display_unlock(wayland_vk_wsi_display->twe_display); + } return TPL_ERROR_NONE; } -- 2.7.4 From 5e1cf71d1e954c496bfda1293f30f70e2cfca1e7 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 09:17:31 +0900 Subject: [PATCH 05/16] tpl_tbm: Modified to mutex_unlock during waiting for can_dequeue. Change-Id: I4279bc245e391a66cb80285b12ab6efd92df9965 Signed-off-by: Joonbum Ko --- src/tpl_tbm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index aeb8f14..df39918 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -655,8 +655,10 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_queue = (tbm_surface_queue_h)surface->native_handle; + TPL_OBJECT_UNLOCK(surface); if (tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface); + TPL_OBJECT_LOCK(surface); if (!tbm_surface) { TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", -- 2.7.4 From a4d54e761710fa7e5c3270d8ef7de3ac9a8f3e4f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 11:44:40 +0900 Subject: [PATCH 06/16] wayland-egl: Added new API to set window serial. - New wayland-egl-tizen API : void wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, unsigned int serial) - If client use this new API, increaing wl_egl_window->serial will not work at dequeue, and buffer's serial value will be set to the serial that the client passed to this API. '- The serial value client want to set must be incremented whenever there is a change related to the window. - This API should be called before the gl first draw call to ensure the correct one frame in the desired serial. Change-Id: I66266fc58867b331ab253ce5682df10d70176851 Signed-off-by: Joonbum Ko --- src/wayland-egl/wayland-egl-priv.h | 1 + src/wayland-egl/wayland-egl-tizen.c | 14 ++++++++++++++ src/wayland-egl/wayland-egl-tizen.h | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/src/wayland-egl/wayland-egl-priv.h b/src/wayland-egl/wayland-egl-priv.h index 0f87713..e729417 100644 --- a/src/wayland-egl/wayland-egl-priv.h +++ b/src/wayland-egl/wayland-egl-priv.h @@ -38,6 +38,7 @@ struct wl_egl_window { void (*rotate_callback)(struct wl_egl_window *, void *); int (*get_rotation_capability)(struct wl_egl_window *, void *); void (*set_frontbuffer_callback)(struct wl_egl_window *, void *, int); + void (*set_window_serial_callback)(struct wl_egl_window *, void *, unsigned int); }; #ifdef __cplusplus diff --git a/src/wayland-egl/wayland-egl-tizen.c b/src/wayland-egl/wayland-egl-tizen.c index d3af986..d697efd 100644 --- a/src/wayland-egl/wayland-egl-tizen.c +++ b/src/wayland-egl/wayland-egl-tizen.c @@ -149,4 +149,18 @@ wl_egl_window_tizen_get_window_serial(struct wl_egl_window *egl_window) } return egl_window->serial; +} + +void +wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, + unsigned int serial) +{ + if (egl_window == NULL) { + WL_EGL_ERR("egl_window is NULL"); + return; + } + + if (egl_window->set_window_serial_callback) + egl_window->set_window_serial_callback(egl_window, egl_window->private, + serial); } \ No newline at end of file diff --git a/src/wayland-egl/wayland-egl-tizen.h b/src/wayland-egl/wayland-egl-tizen.h index 6c76177..a1d0ee6 100644 --- a/src/wayland-egl/wayland-egl-tizen.h +++ b/src/wayland-egl/wayland-egl-tizen.h @@ -69,6 +69,10 @@ wl_egl_window_tizen_set_window_transform(struct wl_egl_window *egl_window, unsigned int wl_egl_window_tizen_get_window_serial(struct wl_egl_window *egl_window); +void +wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, + unsigned int serial); + #ifdef __cplusplus } #endif -- 2.7.4 From b4d7b13c7b421928235ad7ef010a3bd63d9647fb Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 12:03:56 +0900 Subject: [PATCH 07/16] tpl_wayland_egl(_thread): Implemented a few lines releated to set_window_serial. Change-Id: I01df22d47a6add48fcb97a2aa50b96bb87e269fd Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl.c | 37 +++++++++++++++++++++++++++++++++++-- src/tpl_wayland_egl_thread.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 01be90d..490518f 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -45,6 +45,8 @@ struct _tpl_wayland_egl_surface { tdm_client_vblank *tdm_vblank; /* vblank object for each wl_surface */ tpl_bool_t vblank_done; tpl_bool_t is_activated; + tpl_bool_t set_serial_is_used; /* Will be deprecated */ + unsigned int serial; int latest_transform; tpl_list_t *attached_buffers; /* list for tracking [ACQ]~[REL] buffers */ tpl_list_t *dequeued_buffers; /* list for tracking [DEQ]~[ENQ] buffers */ @@ -432,6 +434,10 @@ __cb_client_window_set_frontbuffer_mode(struct wl_egl_window *wl_egl_window, void *private, int set); static void +__cb_client_window_set_window_serial_callback(struct wl_egl_window *wl_egl_window, + void *private, unsigned int serial); + +static void __cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h surface_queue, void *data) { @@ -529,6 +535,8 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface->is_activated = TPL_FALSE; wayland_egl_surface->current_buffer = NULL; wayland_egl_surface->latest_transform = wl_egl_window->transform; + wayland_egl_surface->set_serial_is_used = TPL_FALSE; + wayland_egl_surface->serial = 0; wayland_egl_surface->attached_buffers = __tpl_list_alloc(); if (!wayland_egl_surface->attached_buffers) { @@ -592,6 +600,8 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) __cb_client_window_get_rotation_capability; wl_egl_window->set_frontbuffer_callback = (void *) __cb_client_window_set_frontbuffer_mode; + wl_egl_window->set_window_serial_callback = (void *) + __cb_client_window_set_window_serial_callback; /* tdm_vblank object decide to be maintained every tpl_wayland_egl_surface for the case where the several surfaces is created in one display connection. */ @@ -1314,8 +1324,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wl_display_flush(wayland_egl_display->wl_dpy); - ++wl_egl_window->serial; - wayland_egl_buffer->serial = wl_egl_window->serial; + if (wayland_egl_surface->set_serial_is_used) { + wayland_egl_buffer->serial = wayland_egl_surface->serial; + } else { + ++wl_egl_window->serial; + wayland_egl_buffer->serial = wl_egl_window->serial; + } wayland_egl_buffer->dx = wl_egl_window->dx; wayland_egl_buffer->dy = wl_egl_window->dy; @@ -1599,6 +1613,25 @@ __cb_client_window_set_frontbuffer_mode(struct wl_egl_window *wl_egl_window, surface->is_frontbuffer_mode = TPL_FALSE; } +static void +__cb_client_window_set_window_serial_callback(struct wl_egl_window *wl_egl_window, + void *private, unsigned int serial) +{ + TPL_ASSERT(private); + TPL_ASSERT(wl_egl_window); + + tpl_surface_t *surface = (tpl_surface_t *)private; + + TPL_ASSERT(surface->backend.data); + + tpl_wayland_egl_surface_t *wayland_egl_surface = + (tpl_wayland_egl_surface_t *)surface->backend.data; + + wayland_egl_surface->set_serial_is_used = TPL_TRUE; + wayland_egl_surface->serial = serial; +} + + #define IMPL_TIZEN_SURFACE_SHM_VERSION 2 void diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 37e222e..12b7315 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -111,6 +111,8 @@ struct _twe_wl_surf_source { tdm_client_vblank *vblank; tpl_bool_t vblank_done; tpl_bool_t is_destroying; + tpl_bool_t set_serial_is_used; /* Will be deprecated */ + unsigned int serial; struct tizen_surface_shm_flusher *tss_flusher; tbm_surface_queue_h tbm_queue; twe_wl_disp_source *disp_source; @@ -1150,6 +1152,19 @@ __cb_get_rotation_capability(struct wl_egl_window *wl_egl_window, return rotation_capability; } +static void +__cb_set_window_serial_callback(struct wl_egl_window *wl_egl_window, + void *private, unsigned int serial) +{ + TPL_ASSERT(private); + TPL_ASSERT(wl_egl_window); + + twe_wl_surf_source *source = (twe_wl_surf_source *)private; + + source->set_serial_is_used = TPL_TRUE; + source->serial = serial; +} + static void __cb_tss_flusher_flush_callback(void *data, struct tizen_surface_shm_flusher *tss_flusher) { @@ -1317,8 +1332,12 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, buf_info->transform = wl_egl_window->transform; buf_info->dx = wl_egl_window->dx; buf_info->dy = wl_egl_window->dy; - ++wl_egl_window->serial; - buf_info->serial = wl_egl_window->serial; + if (surf_source->set_serial_is_used) { + buf_info->serial = surf_source->serial; + } else { + ++wl_egl_window->serial; + buf_info->serial = wl_egl_window->serial; + } } if (buf_info->rects) { @@ -1383,8 +1402,13 @@ _twe_surface_set_wl_buffer_info(twe_wl_surf_source *surf_source, } buf_info->transform = wl_egl_window->transform; - ++wl_egl_window->serial; - buf_info->serial = wl_egl_window->serial; + + if (surf_source->set_serial_is_used) { + buf_info->serial = surf_source->serial; + } else { + ++wl_egl_window->serial; + buf_info->serial = wl_egl_window->serial; + } if (surf_source->in_use_buffers) { g_mutex_lock(&surf_source->surf_mutex); @@ -2421,6 +2445,9 @@ twe_surface_add(twe_thread* thread, source->vk_sub_thread = NULL; source->draw_done_count = 0; + source->set_serial_is_used = TPL_FALSE; + source->serial = 0; + if (!disp_source->is_vulkan_dpy) { struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle; @@ -2431,6 +2458,8 @@ twe_surface_add(twe_thread* thread, wl_egl_window->rotate_callback = (void *)__cb_rotate_callback; wl_egl_window->get_rotation_capability = (void *) __cb_get_rotation_capability; + wl_egl_window->set_window_serial_callback = (void *) + __cb_set_window_serial_callback; source->wl_egl_window = wl_egl_window; source->surf = wl_egl_window->surface; -- 2.7.4 From 96bb07819dd2d2b80a711a2a3092e882e9bd73eb Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 13:13:31 +0900 Subject: [PATCH 08/16] tpl_vk_wsi_thread: Enhanced thread safety for destroy swapchain. - If wayland events handled in the event thread during destroy_swapchain, unexpected problem can occur related wayland-tbm. Change-Id: I0b80e2784f8a51590ad238ffb63dcc783db2f969 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 2242975..73378d1 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -685,39 +685,45 @@ static tpl_result_t __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) { tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; + tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL; tpl_result_t res = TPL_ERROR_NONE; unsigned int ref; TPL_ASSERT(surface); TPL_ASSERT(surface->backend.data); TPL_ASSERT(surface->display); + TPL_ASSERT(surface->display->backend.data); wayland_vk_wsi_surface = (tpl_wayland_vk_wsi_surface_t *) surface->backend.data; - TPL_ASSERT(wayland_vk_wsi_surface); + wayland_vk_wsi_display = (tpl_wayland_vk_wsi_display_t *) surface->display->backend.data; - ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference); - if (ref > 0) { - TPL_LOG_T("WL_VK", - "This swapchain is still valid. | twe_surface(%p)", - wayland_vk_wsi_surface->twe_surface); - return TPL_ERROR_NONE; - } + if (twe_display_lock(wayland_vk_wsi_display->twe_display) == TPL_ERROR_NONE) { + ref = __tpl_util_atomic_dec(&wayland_vk_wsi_surface->swapchain_reference); + if (ref > 0) { + TPL_LOG_T("WL_VK", + "This swapchain is still valid. | twe_surface(%p)", + wayland_vk_wsi_surface->twe_surface); + return TPL_ERROR_NONE; + } - if (wayland_vk_wsi_surface->reset) { - TPL_LOG_T("WL_VK", - "Since reset is in the TRUE state, it will not be destroyed."); - return TPL_ERROR_NONE; - } + if (wayland_vk_wsi_surface->reset) { + TPL_LOG_T("WL_VK", + "Since reset is in the TRUE state, it will not be destroyed."); + return TPL_ERROR_NONE; + } - res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); - if (res != TPL_ERROR_NONE) { - TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", - wayland_vk_wsi_surface->twe_surface); - return res; - } + res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); + if (res != TPL_ERROR_NONE) { + TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", + wayland_vk_wsi_surface->twe_surface); + return res; + } - wayland_vk_wsi_surface->tbm_queue = NULL; + wayland_vk_wsi_surface->tbm_queue = NULL; + + twe_display_unlock(wayland_vk_wsi_display->twe_display); + } return TPL_ERROR_NONE; } -- 2.7.4 From 8a3e5472f7f8faf63921676331bd375ad1326d65 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 12 Sep 2018 13:15:07 +0900 Subject: [PATCH 09/16] Package version up to 1.5.16 Change-Id: I686392475ada3218c2301f86ab0f715daed038ef 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 32d62e8..3a510b5 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 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 a48ece85aa890f9a678dd41b94d2cc6c0fc46627 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Sep 2018 11:07:13 +0900 Subject: [PATCH 10/16] wayland-egl-tizen: Fixed a build warning. Change-Id: Icab11757adc178357488559cc8dc4ef5a724276f Signed-off-by: Joonbum Ko --- src/wayland-egl/wayland-egl-tizen.c | 2 +- src/wayland-egl/wayland-egl-tizen.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wayland-egl/wayland-egl-tizen.c b/src/wayland-egl/wayland-egl-tizen.c index d697efd..b44004a 100644 --- a/src/wayland-egl/wayland-egl-tizen.c +++ b/src/wayland-egl/wayland-egl-tizen.c @@ -50,7 +50,7 @@ unsigned int wl_egl_log_level; void wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, - wl_egl_window_tizen_rotation rotation) + int rotation) { if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); diff --git a/src/wayland-egl/wayland-egl-tizen.h b/src/wayland-egl/wayland-egl-tizen.h index a1d0ee6..b305e27 100644 --- a/src/wayland-egl/wayland-egl-tizen.h +++ b/src/wayland-egl/wayland-egl-tizen.h @@ -49,7 +49,7 @@ typedef enum { void wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, - wl_egl_window_tizen_rotation rotation); + int rotation); int wl_egl_window_tizen_get_capabilities(struct wl_egl_window *egl_window); -- 2.7.4 From fa54d91ae792f0079539039639a7eb650e9e0dc6 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Sep 2018 15:22:22 +0900 Subject: [PATCH 11/16] wl_vk_wsi_thread: Fixed missing unlocking at destroy swapchain. Change-Id: I174859edee77a17df09424f12bf15153391afd67 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 73378d1..5db9ec7 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -703,6 +703,7 @@ __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) TPL_LOG_T("WL_VK", "This swapchain is still valid. | twe_surface(%p)", wayland_vk_wsi_surface->twe_surface); + twe_display_unlock(wayland_vk_wsi_display->twe_display); return TPL_ERROR_NONE; } @@ -710,6 +711,7 @@ __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) if (wayland_vk_wsi_surface->reset) { TPL_LOG_T("WL_VK", "Since reset is in the TRUE state, it will not be destroyed."); + twe_display_unlock(wayland_vk_wsi_display->twe_display); return TPL_ERROR_NONE; } @@ -717,6 +719,7 @@ __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) if (res != TPL_ERROR_NONE) { TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", wayland_vk_wsi_surface->twe_surface); + twe_display_unlock(wayland_vk_wsi_display->twe_display); return res; } -- 2.7.4 From 534d18b352d930c5dea62cda349d2e4b7e6a399d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Sep 2018 15:40:59 +0900 Subject: [PATCH 12/16] Package version up to 1.5.17 Change-Id: Ifca8d8586dfbf9f11c1e45bf9cbae52b25e3ef7f 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 3a510b5..67f33bb 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 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 e142edc633335129f6d00b452a7cd3730c331d44 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 13 Sep 2018 18:47:35 +0900 Subject: [PATCH 13/16] tpl_vk_wsi_thread: Increased the ref_cnt of swapchain_buffers. - vulkan-wsi-tizen creates vkImage(s) from the swapchain_buffers obtained from the tpl_surface_get_swapchain_buffers() API. - If the queue_reset occurs in the event thread, then swapchain_buffers that have already been acquired by wsi will be destroyed, which can cause problems. - Therefore, even if queue_reset occurs in event_thread, TPL must increase ref_cnt of swapchain_buffers so that it is valid until swapchain is destroyed. Change-Id: Ibe41f212a64da89dbc30ea3f137f44dab187eb50 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 57 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 5db9ec7..96ac5da 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -23,6 +23,7 @@ struct _tpl_wayland_vk_wsi_display { struct _tpl_wayland_vk_wsi_surface { twe_surface_h twe_surface; tbm_surface_queue_h tbm_queue; + tbm_surface_h *swapchain_buffers; int buffer_count; tpl_bool_t is_activated; tpl_bool_t reset; @@ -287,6 +288,7 @@ __tpl_wl_vk_wsi_surface_init(tpl_surface_t *surface) wayland_vk_wsi_surface->twe_surface = twe_surface; wayland_vk_wsi_surface->is_activated = TPL_FALSE; + wayland_vk_wsi_surface->swapchain_buffers = NULL; TPL_LOG_T("WL_VK", "[INIT]tpl_surface(%p) tpl_wayland_vk_wsi_surface(%p) twe_surface(%p)", @@ -314,6 +316,11 @@ __tpl_wl_vk_wsi_surface_fini(tpl_surface_t *surface) if (wayland_vk_wsi_surface->tbm_queue) __tpl_wl_vk_wsi_surface_destroy_swapchain(surface); + if (wayland_vk_wsi_surface->swapchain_buffers) { + free(wayland_vk_wsi_surface->swapchain_buffers); + wayland_vk_wsi_surface->swapchain_buffers = NULL; + } + TPL_LOG_T("WL_VK", "[FINI] wayland_vk_wsi_surface(%p) native_surface(%p) twe_surface(%p)", wayland_vk_wsi_surface, surface->native_handle, @@ -520,7 +527,6 @@ __tpl_wl_vk_wsi_surface_get_swapchain_buffers(tpl_surface_t *surface, tbm_surface_h **buffers, int *buffer_count) { - tbm_surface_h *swapchain_buffers = NULL; tpl_wayland_vk_wsi_surface_t *wayland_vk_wsi_surface = NULL; tpl_wayland_vk_wsi_display_t *wayland_vk_wsi_display = NULL; int i; @@ -534,9 +540,10 @@ __tpl_wl_vk_wsi_surface_get_swapchain_buffers(tpl_surface_t *surface, TPL_ASSERT(buffer_count); wayland_vk_wsi_surface = (tpl_wayland_vk_wsi_surface_t *)surface->backend.data; - swapchain_buffers = (tbm_surface_h *)calloc( - wayland_vk_wsi_surface->buffer_count, sizeof(tbm_surface_h)); - if (!swapchain_buffers) { + wayland_vk_wsi_surface->swapchain_buffers = (tbm_surface_h *)calloc( + wayland_vk_wsi_surface->buffer_count, + sizeof(tbm_surface_h)); + if (!wayland_vk_wsi_surface->swapchain_buffers) { TPL_ERR("Failed to allocate memory for buffers."); return TPL_ERROR_OUT_OF_MEMORY; } @@ -545,22 +552,27 @@ __tpl_wl_vk_wsi_surface_get_swapchain_buffers(tpl_surface_t *surface, if (twe_display_lock(wayland_vk_wsi_display->twe_display) == TPL_ERROR_NONE) { ret = twe_surface_get_swapchain_buffers(wayland_vk_wsi_surface->twe_surface, - swapchain_buffers, buffer_count); + wayland_vk_wsi_surface->swapchain_buffers, + buffer_count); if (ret != TPL_ERROR_NONE) { TPL_ERR("Failed to get swapchain_buffers. wayland_vk_wsi_surface(%p) twe_surface(%p)", wayland_vk_wsi_surface, wayland_vk_wsi_surface->twe_surface); - free(swapchain_buffers); - swapchain_buffers = NULL; + free(wayland_vk_wsi_surface->swapchain_buffers); + wayland_vk_wsi_surface->swapchain_buffers = NULL; + twe_display_unlock(wayland_vk_wsi_display->twe_display); return ret; } for (i = 0; i < *buffer_count; i++) { TPL_DEBUG("swapchain_buffers[%d] = tbm_surface(%p) bo(%d)", - i, swapchain_buffers[i], - tbm_bo_export(tbm_surface_internal_get_bo(swapchain_buffers[i], 0))); + i, wayland_vk_wsi_surface->swapchain_buffers[i], + tbm_bo_export(tbm_surface_internal_get_bo( + wayland_vk_wsi_surface->swapchain_buffers[i], 0))); + tbm_surface_internal_ref(wayland_vk_wsi_surface->swapchain_buffers[i]); } - *buffers = swapchain_buffers; + + *buffers = wayland_vk_wsi_surface->swapchain_buffers; twe_display_unlock(wayland_vk_wsi_display->twe_display); } @@ -645,6 +657,18 @@ __tpl_wl_vk_wsi_surface_create_swapchain(tpl_surface_t *surface, __tpl_util_atomic_inc(&wayland_vk_wsi_surface->swapchain_reference); + if (wayland_vk_wsi_surface->swapchain_buffers) { + int i; + for (i = 0; i < wayland_vk_wsi_surface->buffer_count; i++) { + TPL_DEBUG("unref tbm_surface(%p)", wayland_vk_wsi_surface->swapchain_buffers[i]); + tbm_surface_internal_unref(wayland_vk_wsi_surface->swapchain_buffers[i]); + wayland_vk_wsi_surface->swapchain_buffers[i] = NULL; + } + + free(wayland_vk_wsi_surface->swapchain_buffers); + wayland_vk_wsi_surface->swapchain_buffers = NULL; + } + TPL_LOG_T("WL_VK", "[REUSE] wayland_vk_wsi_surface(%p) tbm_queue(%p) size(%d)", wayland_vk_wsi_surface, wayland_vk_wsi_surface->tbm_queue, wayland_vk_wsi_surface->buffer_count); @@ -715,6 +739,19 @@ __tpl_wl_vk_wsi_surface_destroy_swapchain(tpl_surface_t *surface) return TPL_ERROR_NONE; } + if (wayland_vk_wsi_surface->swapchain_buffers) { + int i; + for (i = 0; i < wayland_vk_wsi_surface->buffer_count; i++) { + TPL_DEBUG("Stop tracking tbm_surface(%p)", + wayland_vk_wsi_surface->swapchain_buffers[i]); + tbm_surface_internal_unref(wayland_vk_wsi_surface->swapchain_buffers[i]); + wayland_vk_wsi_surface->swapchain_buffers[i] = NULL; + } + + free(wayland_vk_wsi_surface->swapchain_buffers); + wayland_vk_wsi_surface->swapchain_buffers = NULL; + } + res = twe_surface_destroy_swapchain(wayland_vk_wsi_surface->twe_surface); if (res != TPL_ERROR_NONE) { TPL_ERR("Failed to destroy swapchain. twe_surface(%p)", -- 2.7.4 From 6b0a749c498be3408e987b1039e9606d99d3c374 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 14 Sep 2018 11:00:06 +0900 Subject: [PATCH 14/16] Package version up to 1.5.18 Change-Id: I3d315a58c125dce96d061f245dbd93a8ad00fd72 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 67f33bb..fb772ee 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 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 2362cc838a6548e10eeb5a3bf0a62673a2d315a3 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 19 Sep 2018 14:45:48 +0900 Subject: [PATCH 15/16] tpl_wayland_egl_thread: Modified wait_vblank handling of PRESENT_MODE_FIFO. - PRESENT_MODE_FIFO has been modified to be dependent on the behavior of the display server which can use HW vblank. (Therefore, PRESENT_MODE_IMMEDIATE and PRESENT_MODE_FIFO_RELAXED are not meaningful because client can not control HW vblank.) - If the client sends a commit only once per one vblank, the display server will perform pageflip on the HW vsync, so the latency of PRESENT_MODE_FIFO can be reduced. Change-Id: Ie3802e0a7b93515827e93c6712bb8cf3160640ce Signed-off-by: Joonbum Ko --- src/tpl_wayland_egl_thread.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/src/tpl_wayland_egl_thread.c b/src/tpl_wayland_egl_thread.c index 12b7315..62061b4 100644 --- a/src/tpl_wayland_egl_thread.c +++ b/src/tpl_wayland_egl_thread.c @@ -1644,24 +1644,6 @@ __cb_tdm_client_wait_vblank(tdm_client_vblank *vblank, tdm_error error, break; case TPL_DISPLAY_PRESENT_MODE_FIFO: - if (surf_source->vblank_waiting_buffers) { - tbm_surface_h tbm_surface = NULL; - tbm_surface = (tbm_surface_h)__tpl_list_pop_front( - surf_source->vblank_waiting_buffers, - NULL); - if (tbm_surface) - _twe_thread_wl_vk_surface_commit(surf_source, tbm_surface); - } - - if (!__tpl_list_is_empty(surf_source->vblank_waiting_buffers)) { - tpl_result_t res = TPL_ERROR_NONE; - res = _twe_surface_wait_vblank(surf_source); - if (res != TPL_ERROR_NONE) - TPL_ERR("Failed to set wait vblank. surf_source(%p)", - surf_source); - } - break; - case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED: if (surf_source->vblank_waiting_buffers) { tbm_surface_h tbm_surface = NULL; @@ -1780,7 +1762,9 @@ _twe_thread_wl_vk_surface_commit(twe_wl_surf_source *surf_source, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); if (surf_source->swapchain_properties.present_mode - == TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED) { + == TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED || + surf_source->swapchain_properties.present_mode + == TPL_DISPLAY_PRESENT_MODE_FIFO) { if (_twe_surface_wait_vblank(surf_source) != TPL_ERROR_NONE) TPL_ERR("Failed to set wait vblank"); } @@ -2002,21 +1986,6 @@ _twe_thread_wl_surface_acquire_and_commit(twe_wl_surf_source *surf_source) break; case TPL_DISPLAY_PRESENT_MODE_FIFO: - if (surf_source->vblank_done) { - if (_twe_surface_wait_vblank(surf_source) != TPL_ERROR_NONE) { - TPL_WARN("Failed to set wait vblank. Falling back to IMMEDIATE_MODE."); - _twe_thread_wl_vk_surface_commit(surf_source, tbm_surface); - } - } - if (surf_source->vblank_waiting_buffers) { - __tpl_list_push_back(surf_source->vblank_waiting_buffers, - (void *)tbm_surface); - - } else { - TPL_ERR("Invalid list. vblank_waiting_buffers is NULL."); - } - break; - case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED: if (surf_source->vblank_done) { _twe_thread_wl_vk_surface_commit(surf_source, tbm_surface); -- 2.7.4 From f9d222f05c060c5a33f41a8238edbb9c7727e7f1 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 19 Sep 2018 15:09:19 +0900 Subject: [PATCH 16/16] Package version up to 1.5.19 Change-Id: I9478b93838f55a6df38aa8ea1b84a6b5767c925f 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 fb772ee..c158978 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 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