From 709d66fc80e2a8f2146df23f10e52cee3cc324aa Mon Sep 17 00:00:00 2001 From: Tianhao Ni Date: Fri, 4 Jun 2021 13:42:48 +0800 Subject: [PATCH 01/16] Fix ws-testcase build issue: - Issue: undefined reference to '__tpl_display_choose_backend_wl_egl_thread' undefined refetence to '__tpl_display_choose_backend_wayland_vk_wsi' - Fix: Replace __tpl_display_choose_backend_wl_egl_thread() with __tpl_display_choose_backend_wl_egl_thread2() Replace __tpl_display_choose_backend_wayland_vk_wsi() with __tpl_display_choose_backend_wayland_vk_wsi_thread() Change-Id: I1d562bbaf37c4c45b238e221b125bdb42cc6db1a Signed-off-by: Tianhao Ni --- src/tpl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index f40889d..5482bc1 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -274,14 +274,14 @@ __tpl_display_choose_backend(tpl_handle_t native_dpy) if (__tpl_display_choose_backend_tbm(native_dpy) == TPL_TRUE) return TPL_BACKEND_TBM; if (wl_egl_thread) { - if (__tpl_display_choose_backend_wl_egl_thread(native_dpy)) + if (__tpl_display_choose_backend_wl_egl_thread2(native_dpy)) return TPL_BACKEND_WAYLAND_THREAD; } else { if (__tpl_display_choose_backend_wayland_egl(native_dpy)) return TPL_BACKEND_WAYLAND; } - if (__tpl_display_choose_backend_wayland_vk_wsi(native_dpy) == TPL_TRUE) - return TPL_BACKEND_WAYLAND_VULKAN_WSI; + if (__tpl_display_choose_backend_wayland_vk_wsi_thread(native_dpy) == TPL_TRUE) + return TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD; #endif #ifdef TPL_WINSYS_DRI2 if (__tpl_display_choose_backend_x11_dri2(native_dpy) == TPL_TRUE) -- 2.7.4 From 80dd92be4a4af352449a0a13870fcd61ff4537c5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 27 May 2021 20:14:47 +0900 Subject: [PATCH 02/16] Clarified thread message and corrected some bugs. Change-Id: I63fec57eb66104c87757cf5f665e8160859bddc8 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 36 +++++++++++++++++++--------- src/tpl_wl_vk_thread.c | 64 +++++++++++++++++++++++++++++++------------------ 2 files changed, 66 insertions(+), 34 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index d6f37f2..c564ae1 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -68,6 +68,12 @@ struct _tpl_wl_egl_display { struct zwp_linux_explicit_synchronization_v1 *explicit_sync; /* for explicit fence sync */ }; +typedef enum surf_message { + NONE_MESSAGE = 0, + INIT_SURFACE, + ACQUIRABLE, +} surf_message; + struct _tpl_wl_egl_surface { tpl_gsource *surf_source; @@ -114,6 +120,8 @@ struct _tpl_wl_egl_surface { tpl_gmutex surf_mutex; tpl_gcond surf_cond; + surf_message sent_message; + /* for waiting draw done */ tpl_bool_t use_render_done_fence; tpl_bool_t is_activated; @@ -1415,9 +1423,11 @@ __cb_tbm_queue_acquirable_callback(tbm_surface_queue_h tbm_queue, TPL_CHECK_ON_NULL_RETURN(wl_egl_surface); tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - - tpl_gsource_send_message(wl_egl_surface->surf_source, 2); - + if (wl_egl_surface->sent_message == NONE_MESSAGE) { + wl_egl_surface->sent_message = ACQUIRABLE; + tpl_gsource_send_message(wl_egl_surface->surf_source, + wl_egl_surface->sent_message); + } tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); } /* -- END -- tbm_surface_queue callback funstions */ @@ -1512,22 +1522,22 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) wl_egl_surface = (tpl_wl_egl_surface_t *)tpl_gsource_get_data(gsource); - /* Initialize surface */ - if (message == 1) { - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + if (message == INIT_SURFACE) { /* Initialize surface */ TPL_DEBUG("wl_egl_surface(%p) initialize message received!", wl_egl_surface); _thread_wl_egl_surface_init(wl_egl_surface); tpl_gcond_signal(&wl_egl_surface->surf_cond); - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); - } else if (message == 2) { - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); + } else if (message == ACQUIRABLE) { /* Acquirable */ TPL_DEBUG("wl_egl_surface(%p) acquirable message received!", wl_egl_surface); _thread_surface_queue_acquire(wl_egl_surface); - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); } + wl_egl_surface->sent_message = NONE_MESSAGE; + + tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); + return TPL_TRUE; } @@ -1627,6 +1637,8 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->commit_sync.fd = -1; wl_egl_surface->presentation_sync.fd = -1; + wl_egl_surface->sent_message = NONE_MESSAGE; + { int i = 0; for (i = 0; i < BUFFER_ARRAY_SIZE; i++) @@ -1669,7 +1681,9 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) /* Initialize in thread */ tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - tpl_gsource_send_message(wl_egl_surface->surf_source, 1); + wl_egl_surface->sent_message = INIT_SURFACE; + tpl_gsource_send_message(wl_egl_surface->surf_source, + wl_egl_surface->sent_message); tpl_gcond_wait(&wl_egl_surface->surf_cond, &wl_egl_surface->surf_mutex); tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 20baea3..4ae5b55 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -82,6 +82,14 @@ struct _tpl_wl_vk_swapchain { tpl_util_atomic_uint ref_cnt; }; +typedef enum surf_message { + NONE_MESSAGE = 0, + INIT_SURFACE, + CREATE_QUEUE, + DESTROY_QUEUE, + ACQUIRABLE, +} surf_message; + struct _tpl_wl_vk_surface { tpl_gsource *surf_source; @@ -113,6 +121,8 @@ struct _tpl_wl_vk_surface { tpl_bool_t reset; /* TRUE if queue reseted by external */ tpl_bool_t vblank_done; + surf_message sent_message; + int post_interval; }; @@ -1101,15 +1111,13 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) wl_vk_surface = (tpl_wl_vk_surface_t *)tpl_gsource_get_data(gsource); - if (message == 1) { /* Initialize surface */ - tpl_gmutex_lock(&wl_vk_surface->surf_mutex); + tpl_gmutex_lock(&wl_vk_surface->surf_mutex); + if (message == INIT_SURFACE) { /* Initialize surface */ TPL_DEBUG("wl_vk_surface(%p) initialize message received!", wl_vk_surface); _thread_wl_vk_surface_init(wl_vk_surface); - tpl_gcond_signal(&wl_vk_surface->surf_cond); - tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); - } else if (message == 2) { /* Create tbm_surface_queue */ - tpl_gmutex_lock(&wl_vk_surface->surf_mutex); + 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!", wl_vk_surface); if (_thread_swapchain_create_tbm_queue(wl_vk_surface) @@ -1118,9 +1126,12 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) wl_vk_surface); } tpl_gcond_signal(&wl_vk_surface->surf_cond); - tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); - } else if (message == 3) { /* Acquirable message */ - tpl_gmutex_lock(&wl_vk_surface->surf_mutex); + } else if (message == DESTROY_QUEUE) { /* swapchain destroy */ + TPL_DEBUG("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!", wl_vk_surface); if (_thread_surface_queue_acquire(wl_vk_surface) @@ -1128,16 +1139,13 @@ __thread_func_surf_dispatch(tpl_gsource *gsource, uint64_t message) TPL_ERR("Failed to acquire from tbm_queue. wl_vk_surface(%p)", wl_vk_surface); } - tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); - } else if (message == 4) { /* swapchain destroy */ - tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - TPL_DEBUG("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); - tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); } + /* init to NONE_MESSAGE */ + wl_vk_surface->sent_message = NONE_MESSAGE; + + tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); + return TPL_TRUE; } @@ -1214,6 +1222,8 @@ __tpl_wl_vk_surface_init(tpl_surface_t *surface) wl_vk_surface->vblank = NULL; wl_vk_surface->surface_sync = NULL; + wl_vk_surface->sent_message = NONE_MESSAGE; + wl_vk_surface->post_interval = surface->post_interval; { @@ -1230,7 +1240,9 @@ __tpl_wl_vk_surface_init(tpl_surface_t *surface) /* Initialize in thread */ tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - tpl_gsource_send_message(wl_vk_surface->surf_source, 1); + wl_vk_surface->sent_message = INIT_SURFACE; + tpl_gsource_send_message(wl_vk_surface->surf_source, + wl_vk_surface->sent_message); tpl_gcond_wait(&wl_vk_surface->surf_cond, &wl_vk_surface->surf_mutex); tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); @@ -1389,9 +1401,11 @@ __cb_tbm_queue_acquirable_callback(tbm_surface_queue_h tbm_queue, TPL_CHECK_ON_NULL_RETURN(wl_vk_surface); tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - - tpl_gsource_send_message(wl_vk_surface->surf_source, 3); - + if (wl_vk_surface->sent_message == NONE_MESSAGE) { + wl_vk_surface->sent_message = ACQUIRABLE; + tpl_gsource_send_message(wl_vk_surface->surf_source, + wl_vk_surface->sent_message); + } tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); } @@ -1580,7 +1594,9 @@ __tpl_wl_vk_surface_create_swapchain(tpl_surface_t *surface, tpl_gmutex_lock(&wl_vk_surface->surf_mutex); /* send swapchain create tbm_queue message */ - tpl_gsource_send_message(wl_vk_surface->surf_source, 2); + wl_vk_surface->sent_message = CREATE_QUEUE; + tpl_gsource_send_message(wl_vk_surface->surf_source, + wl_vk_surface->sent_message); tpl_gcond_wait(&wl_vk_surface->surf_cond, &wl_vk_surface->surf_mutex); tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); @@ -1664,7 +1680,9 @@ __tpl_wl_vk_surface_destroy_swapchain(tpl_surface_t *surface) _tpl_wl_vk_surface_buffer_clear(wl_vk_surface); tpl_gmutex_lock(&wl_vk_surface->surf_mutex); - tpl_gsource_send_message(wl_vk_surface->surf_source, 4); + wl_vk_surface->sent_message = DESTROY_QUEUE; + tpl_gsource_send_message(wl_vk_surface->surf_source, + wl_vk_surface->sent_message); tpl_gcond_wait(&wl_vk_surface->surf_cond, &wl_vk_surface->surf_mutex); tpl_gmutex_unlock(&wl_vk_surface->surf_mutex); -- 2.7.4 From 93ba663e8f4b9ca339de5ec5bb4e3d9d4dd6e4be Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 25 May 2021 18:22:55 +0900 Subject: [PATCH 03/16] Add null checking to prevent problem. Change-Id: Icd94a00b015b5100e6beaa59d435731836a2d376 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 8 ++++++-- src/tpl_wl_vk_thread.c | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index c564ae1..7813981 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -2548,12 +2548,16 @@ __tpl_wl_egl_surface_enqueue_buffer(tpl_surface_t *surface, return TPL_ERROR_INVALID_PARAMETER; } + wl_egl_buffer = _get_wl_egl_buffer(tbm_surface); + if (!wl_egl_buffer) { + TPL_ERR("Failed to get wl_egl_buffer from tbm_surface(%p)", tbm_surface); + return TPL_ERROR_INVALID_PARAMETER; + } + bo_name = _get_tbm_surface_bo_name(tbm_surface); TRACE_MARK("[ENQ] BO_NAME:%d", bo_name); - wl_egl_buffer = _get_wl_egl_buffer(tbm_surface); - tpl_gmutex_lock(&wl_egl_buffer->mutex); /* If there are received region information, save it to wl_egl_buffer */ diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 4ae5b55..4ea1a68 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -2067,6 +2067,11 @@ __tpl_wl_vk_surface_enqueue_buffer(tpl_surface_t *surface, TPL_ERROR_INVALID_PARAMETER); wl_vk_buffer = _get_wl_vk_buffer(tbm_surface); + if (!wl_vk_buffer) { + TPL_ERR("Failed to get wl_vk_buffer from tbm_surface(%p)", tbm_surface); + return TPL_ERROR_INVALID_PARAMETER; + } + bo_name = wl_vk_buffer->bo_name; tpl_gmutex_lock(&wl_vk_buffer->mutex); -- 2.7.4 From 49497c55dbce81af89175d8b1b3fe7a61abd6d8d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 27 May 2021 19:56:35 +0900 Subject: [PATCH 04/16] Remove duplicate initialize. Change-Id: Iebcb9c25dd42fe487dec172327f5161ff56ea0f1 Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 4ea1a68..12ecfca 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -1854,6 +1854,9 @@ _wl_vk_buffer_create(tpl_wl_vk_surface_t *wl_vk_surface, wl_vk_buffer->rects = NULL; wl_vk_buffer->num_rects = 0; + wl_vk_buffer->need_to_commit = TPL_FALSE; + wl_vk_buffer->buffer_release = NULL; + tpl_gmutex_init(&wl_vk_buffer->mutex); tpl_gcond_init(&wl_vk_buffer->cond); @@ -1897,9 +1900,6 @@ _wl_vk_buffer_create(tpl_wl_vk_surface_t *wl_vk_surface, wl_vk_buffer->bo_name); } - wl_vk_buffer->need_to_commit = TPL_FALSE; - wl_vk_buffer->buffer_release = NULL; - return wl_vk_buffer; } -- 2.7.4 From 498cfcf676a285d387de27171c155ca013a5b69d Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 4 Jun 2021 15:55:36 +0900 Subject: [PATCH 05/16] Package version up to 1.8.9 Change-Id: I68bc650bfe937a7e80c0ea73fa4b5a013cf020fd 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 0698e6f..fad9c16 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 8 +%define TPL_VERSION_PATCH 9 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 47717e62e7f81dfb292a7f2050dc618d25f0c78b Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Tue, 8 Jun 2021 18:35:18 +0900 Subject: [PATCH 06/16] Add magic check to confirm WL_EGL_TIZEN private. Change-Id: I0f3663c027c4c3e2d14843296b94d81345b3580e Signed-off-by: Joonbum Ko --- src/wayland-egl-tizen/wayland-egl-tizen-priv.h | 9 +++- src/wayland-egl-tizen/wayland-egl-tizen.c | 63 ++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h index caeb5b0..af307da 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h @@ -9,7 +9,12 @@ extern "C" { #include #include +#ifndef WL_EGL_TIZEN_MAGIC +#define WL_EGL_TIZEN_MAGIC 0xDEF00123 +#endif + struct tizen_private { + unsigned int magic; int rotation; int frontbuffer_mode; int transform; @@ -27,11 +32,13 @@ struct tizen_private { int (*merge_sync_fds)(void *, int, int); }; -static struct tizen_private* tizen_private_create() +static struct tizen_private* +tizen_private_create() { struct tizen_private *private = NULL; private = (struct tizen_private *)calloc(1, sizeof(struct tizen_private)); if (private) { + private->magic = WL_EGL_TIZEN_MAGIC; private->rotation = 0; private->frontbuffer_mode = 0; private->transform = 0; diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.c b/src/wayland-egl-tizen/wayland-egl-tizen.c index 2fb876c..ff16603 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.c +++ b/src/wayland-egl-tizen/wayland-egl-tizen.c @@ -21,6 +21,15 @@ #define WL_EGL_ERR(f, x...) LOGE(FONT_RED f FONT_DEFAULT, ##x) #define WL_EGL_WARN(f, x...) LOGW(FONT_YELLOW f FONT_DEFAULT, ##x) +static int +_wl_egl_tizen_magic_check(struct tizen_private *private) +{ + if (private->magic != WL_EGL_TIZEN_MAGIC) + return 0; + + return 1; +} + void wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, int rotation) @@ -41,6 +50,11 @@ wl_egl_window_tizen_set_rotation(struct wl_egl_window *egl_window, egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return; + } } if (private->rotation == rotation) { @@ -76,6 +90,11 @@ wl_egl_window_tizen_get_capabilities(struct wl_egl_window *egl_window) egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return -1; + } } if (private->get_rotation_capability) @@ -106,6 +125,11 @@ wl_egl_window_tizen_set_buffer_transform(struct wl_egl_window *egl_window, egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return; + } } if (private->transform == wl_output_transform) { @@ -137,6 +161,11 @@ wl_egl_window_tizen_set_frontbuffer_mode(struct wl_egl_window *egl_window, egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return; + } } private->frontbuffer_mode = set; @@ -166,6 +195,11 @@ wl_egl_window_tizen_set_window_transform(struct wl_egl_window *egl_window, egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return; + } } if (private->window_transform == window_transform) { @@ -196,6 +230,11 @@ wl_egl_window_tizen_get_window_serial(struct wl_egl_window *egl_window) egl_window->driver_private = (void *)private; } else { private = (struct tizen_private *)egl_window->driver_private; + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return 0; + } } return private->serial; @@ -217,6 +256,12 @@ wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, return; } + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return; + } + if (private->set_window_serial_callback) private->set_window_serial_callback(egl_window, egl_window->driver_private, serial); @@ -238,6 +283,12 @@ wl_egl_window_tizen_create_commit_sync_fd(struct wl_egl_window *egl_window) return -1; } + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return -1; + } + if (private->create_commit_sync_fd) return private->create_commit_sync_fd(egl_window, egl_window->driver_private); @@ -260,6 +311,12 @@ wl_egl_window_tizen_create_presentation_sync_fd(struct wl_egl_window *egl_window return -1; } + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return -1; + } + if (private->create_presentation_sync_fd) return private->create_presentation_sync_fd(egl_window, egl_window->driver_private); @@ -283,6 +340,12 @@ wl_egl_window_tizen_merge_sync_fds(struct wl_egl_window *egl_window, return -1; } + if (!_wl_egl_tizen_magic_check(private)) { + WL_EGL_WARN("driver_private of wl_egl_window(%p) is not tizen_private", + egl_window); + return -1; + } + if (private->merge_sync_fds) return private->merge_sync_fds(egl_window->driver_private, sync_fd1, sync_fd2); -- 2.7.4 From 25a167d511b9f02e8ae2e7462f7f631ae3393b14 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 9 Jun 2021 12:20:44 +0900 Subject: [PATCH 07/16] Resolve build warning related to backend init functions. Change-Id: I08419d24c1411051029d4db6406682be0628db15 Signed-off-by: Joonbum Ko --- src/tpl.c | 2 +- src/tpl_internal.h | 3 ++- src/tpl_wl_egl_thread.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tpl.c b/src/tpl.c index 5482bc1..1f2bd4e 100644 --- a/src/tpl.c +++ b/src/tpl.c @@ -274,7 +274,7 @@ __tpl_display_choose_backend(tpl_handle_t native_dpy) if (__tpl_display_choose_backend_tbm(native_dpy) == TPL_TRUE) return TPL_BACKEND_TBM; if (wl_egl_thread) { - if (__tpl_display_choose_backend_wl_egl_thread2(native_dpy)) + if (__tpl_display_choose_backend_wl_egl_thread(native_dpy)) return TPL_BACKEND_WAYLAND_THREAD; } else { if (__tpl_display_choose_backend_wayland_egl(native_dpy)) diff --git a/src/tpl_internal.h b/src/tpl_internal.h index 97a07ef..0fa3988 100755 --- a/src/tpl_internal.h +++ b/src/tpl_internal.h @@ -219,7 +219,8 @@ tpl_backend_type_t __tpl_display_choose_backend(tpl_handle_t native_dpy); tpl_bool_t __tpl_display_choose_backend_tbm(tpl_handle_t native_dpy); tpl_bool_t __tpl_display_choose_backend_wayland_egl(tpl_handle_t native_dpy); tpl_bool_t __tpl_display_choose_backend_wl_egl_thread(tpl_handle_t native_dpy); -tpl_bool_t __tpl_display_choose_backend_wayland_vk_wsi(tpl_handle_t native_dpy); +tpl_bool_t __tpl_display_choose_backend_wayland_vk_wsi_thread(tpl_handle_t native_dpy); +//tpl_bool_t __tpl_display_choose_backend_wayland_vk_wsi(tpl_handle_t native_dpy); //tpl_bool_t __tpl_display_choose_backend_x11_dri2(tpl_handle_t native_dpy); //unused //tpl_bool_t __tpl_display_choose_backend_x11_dri3(tpl_handle_t native_dpy); //unused void __tpl_display_init_backend(tpl_display_t *display, diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 7813981..32d5f22 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -1053,7 +1053,7 @@ __tpl_wl_egl_display_get_buffer_from_native_pixmap(tpl_handle_t pixmap) } tpl_bool_t -__tpl_display_choose_backend_wl_egl_thread2(tpl_handle_t native_dpy) +__tpl_display_choose_backend_wl_egl_thread(tpl_handle_t native_dpy) { struct wl_interface *wl_egl_native_dpy = *(void **) native_dpy; -- 2.7.4 From 72ff58eedf23fdacd5676da22b6aa9baf3a06e47 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 10 Jun 2021 14:36:02 +0900 Subject: [PATCH 08/16] Fix incorrect use of can_dequeue return value. Change-Id: Iac9ca1b9cd0a8d4749f10ee4dfd97f45a7f1a39a Signed-off-by: Joonbum Ko --- src/tpl_wl_vk_thread.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 12ecfca..f883334 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -1933,8 +1933,7 @@ __tpl_wl_vk_surface_dequeue_buffer(tpl_surface_t *surface, tsq_err = tbm_surface_queue_can_dequeue_wait_timeout( swapchain->tbm_queue, timeout_ns/1000); } else { - tsq_err = tbm_surface_queue_can_dequeue( - swapchain->tbm_queue, 1); + tbm_surface_queue_can_dequeue(swapchain->tbm_queue, 1); } TRACE_END(); TPL_OBJECT_LOCK(surface); -- 2.7.4 From 44143afa080d4f4e0b79655e677300a0e4cc2530 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 21 Jun 2021 11:11:34 +0900 Subject: [PATCH 09/16] Fix missing use of num_buffers when create tbm_queue. Change-Id: If02ac0b00d87c3a1da860eb69b3b361666ff90a6 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 32d5f22..05f5789 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -31,8 +31,7 @@ static int wl_egl_buffer_key; #define KEY_WL_EGL_BUFFER (unsigned long)(&wl_egl_buffer_key) /* In wayland, application and compositor create its own drawing buffers. Recommend size is more than 2. */ -#define CLIENT_QUEUE_SIZE 3 -#define BUFFER_ARRAY_SIZE (CLIENT_QUEUE_SIZE * 2) +#define BUFFER_ARRAY_SIZE 9 typedef struct _tpl_wl_egl_display tpl_wl_egl_display_t; typedef struct _tpl_wl_egl_surface tpl_wl_egl_surface_t; @@ -78,6 +77,7 @@ struct _tpl_wl_egl_surface { tpl_gsource *surf_source; tbm_surface_queue_h tbm_queue; + int num_buffers; struct wl_egl_window *wl_egl_window; struct wl_surface *wl_surface; @@ -1609,6 +1609,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->width = wl_egl_window->width; wl_egl_surface->height = wl_egl_window->height; wl_egl_surface->format = surface->format; + wl_egl_surface->num_buffers = surface->num_buffers; wl_egl_surface->surf_source = surf_source; wl_egl_surface->wl_egl_window = wl_egl_window; @@ -1842,7 +1843,7 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_surface->tbm_queue = _thread_create_tbm_queue( wl_egl_surface, wl_egl_display->wl_tbm_client, - CLIENT_QUEUE_SIZE); + wl_egl_surface->num_buffers); if (!wl_egl_surface->tbm_queue) { TPL_ERR("Failed to create tbm_queue. wl_egl_surface(%p) wl_tbm_client(%p)", wl_egl_surface, wl_egl_display->wl_tbm_client); @@ -1858,7 +1859,7 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_surface->tbm_queue, wl_egl_surface->width, wl_egl_surface->height, - CLIENT_QUEUE_SIZE, + wl_egl_surface->num_buffers, wl_egl_surface->format); if (wl_egl_display->use_wait_vblank) { -- 2.7.4 From 988f0718e50097c10fd16065317fb9345f2cfad5 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 21 Jun 2021 11:12:06 +0900 Subject: [PATCH 10/16] Package version up to 1.8.10 Change-Id: Ife001513e981d8ae2dae6dfedc5d7e210c0e873b 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 fad9c16..69771e5 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 9 +%define TPL_VERSION_PATCH 10 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From a1b9e95acdb4f419c2f9fd7c064f4782754fb5ae Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Wed, 21 Jul 2021 16:53:14 +0900 Subject: [PATCH 11/16] Remove unnecessary surf_mutex locking - This surf_mutex locking in buffer_clear can occur deadlock problem. Change-Id: Ibd4fc7ff312c4ab96aa0db6c69d217979cac9622 Signed-off-by: Joonbum Ko --- src/tpl_wl_egl_thread.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 05f5789..819fe1a 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -1978,8 +1978,6 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) } } - tpl_gmutex_lock(&wl_egl_surface->surf_mutex); - status = wl_egl_buffer->status; /* update status */ /* ACQUIRED, WAITING_SIGNALED, WAITING_VBLANK, COMMITTED */ @@ -2007,8 +2005,6 @@ _tpl_wl_egl_surface_buffer_clear(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_buffer->tbm_surface, tsq_err); } - tpl_gmutex_unlock(&wl_egl_surface->surf_mutex); - wl_egl_buffer->status = RELEASED; tpl_gmutex_unlock(&wl_egl_buffer->mutex); -- 2.7.4 From 10d4517b8dceddbb49f6930fbc998ec93933fc6f Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 26 Jul 2021 13:16:14 +0900 Subject: [PATCH 12/16] Package version up to 1.8.11 Change-Id: I19b4eabb56d6563d1c7a4bd1886a25d376d3f010 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 69771e5..ba8dab7 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 10 +%define TPL_VERSION_PATCH 11 %define TPL_VERSION %{TPL_VERSION_MAJOR}.%{TPL_VERSION_MINOR}.%{TPL_VERSION_PATCH} #TPL WINDOW SYSTEM DEFINITION -- 2.7.4 From 9ab32cbeae0e1a8cf0a7907686f6091b8a980256 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Aug 2021 10:53:02 +0900 Subject: [PATCH 13/16] wayland-egl-tizen: Add a log output option. Change-Id: I732410110ece931eb036b4398a45b8be143e36e4 Signed-off-by: Joonbum Ko --- src/wayland-egl-tizen/wayland-egl-tizen.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.c b/src/wayland-egl-tizen/wayland-egl-tizen.c index ff16603..bec3e92 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.c +++ b/src/wayland-egl-tizen/wayland-egl-tizen.c @@ -10,16 +10,34 @@ #include #include -#define LOG_TAG "WL_EGL" -#include - #define FONT_DEFAULT "\033[0m" /* for reset to default color */ #define FONT_RED "\033[31m" /* for error logs */ #define FONT_YELLOW "\033[33m" /* for warning logs */ +#define BG_COLOR_GREEN "\033[0;42m" + +#ifdef DLOG_DEFAULT_ENABLE +#define LOG_TAG "WL_EGL" +#include + +#define wl_egl_log_i(t, f, x...) LOGI(BG_COLOR_GREEN t FONT_DEFAULT " " f, ##x) +#define wl_egl_log_e(t, f, x...) LOGE(FONT_RED t " " f FONT_DEFAULT, ##x) +#define wl_egl_log_w(t, f, x...) LOGW(FONT_YELLOW t " " f FONT_DEFAULT, ##x) +#else /* DLOG_DEFAULT_ENABLE */ +#define wl_egl_log_i(t, f, x...) \ + fprintf(stderr, BG_COLOR_GREEN t FONT_DEFAULT "[(tid:%li)(%s)]" f "\n", \ + syscall(SYS_gettid), __func__, ##x) +#define wl_egl_log_e(t, f, x...) \ + fprintf(stderr, FONT_RED t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n", \ + syscall(SYS_gettid), __func__, ##x) +#define wl_egl_log_w(t, f, x...) \ + fprintf(stderr, FONT_YELLOW t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n",\ + syscall(SYS_gettid), __func__, ##x) +#endif /* DLOG_DEFAULT_ENABLE */ + +#define WL_EGL_LOG(f, x...) wl_egl_log_i("[INFO]", f, ##x) +#define WL_EGL_ERR(f, x...) wl_egl_log_e("[ERROR]", f, ##x) +#define WL_EGL_WARN(f, x...) wl_egl_log_w("[WARN]", f, ##x) -#define WL_EGL_LOG(f, x...) LOGI(f, ##x) -#define WL_EGL_ERR(f, x...) LOGE(FONT_RED f FONT_DEFAULT, ##x) -#define WL_EGL_WARN(f, x...) LOGW(FONT_YELLOW f FONT_DEFAULT, ##x) static int _wl_egl_tizen_magic_check(struct tizen_private *private) -- 2.7.4 From e806539702881132dcf6e449bc63f99ade2167d7 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Aug 2021 11:02:40 +0900 Subject: [PATCH 14/16] Move unusing files to unused and remove from makefile. Change-Id: Ic24027a9e907cb064325a1c2690e820da17cd03a Signed-off-by: Joonbum Ko --- src/Makefile.am | 3 +-- src/{ => unused}/tpl_wayland_egl_thread.c | 0 src/{ => unused}/tpl_wayland_egl_thread.h | 0 src/{ => unused}/tpl_wl_egl_thread_legacy.c | 0 4 files changed, 1 insertion(+), 2 deletions(-) rename src/{ => unused}/tpl_wayland_egl_thread.c (100%) rename src/{ => unused}/tpl_wayland_egl_thread.h (100%) rename src/{ => unused}/tpl_wl_egl_thread_legacy.c (100%) diff --git a/src/Makefile.am b/src/Makefile.am index 62240c6..3255de3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,13 +21,12 @@ libtpl_egl_la_SOURCES = tpl.c \ tpl_surface.c \ tpl_utils_hlist.c \ tpl_utils_map.c \ - tpl_utils_gthread.c + tpl_utils_gthread.c # Wayland if WITH_WAYLAND libtpl_egl_la_SOURCES += tpl_wayland_egl.c \ tpl_wl_egl_thread.c \ - tpl_wayland_egl_thread.c \ tpl_wl_vk_thread.c \ wayland-vulkan/wayland-vulkan-protocol.c endif diff --git a/src/tpl_wayland_egl_thread.c b/src/unused/tpl_wayland_egl_thread.c similarity index 100% rename from src/tpl_wayland_egl_thread.c rename to src/unused/tpl_wayland_egl_thread.c diff --git a/src/tpl_wayland_egl_thread.h b/src/unused/tpl_wayland_egl_thread.h similarity index 100% rename from src/tpl_wayland_egl_thread.h rename to src/unused/tpl_wayland_egl_thread.h diff --git a/src/tpl_wl_egl_thread_legacy.c b/src/unused/tpl_wl_egl_thread_legacy.c similarity index 100% rename from src/tpl_wl_egl_thread_legacy.c rename to src/unused/tpl_wl_egl_thread_legacy.c -- 2.7.4 From de4443b12e3ee8bcf905d003cc3f65a24ea89bdb Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Aug 2021 12:17:00 +0900 Subject: [PATCH 15/16] Remove dependency releated wayland-vulkan-protocol Change-Id: Id33821ae95d98e84c1af38b429804ccf3e92850e Signed-off-by: Joonbum Ko --- configure.ac | 5 +---- src/Makefile.am | 21 +-------------------- .../wayland-vulkan/wayland-vulkan-protocol.xml | 0 3 files changed, 2 insertions(+), 24 deletions(-) rename src/{ => unused}/wayland-vulkan/wayland-vulkan-protocol.xml (100%) diff --git a/configure.ac b/configure.ac index e59d587..0e38fb8 100644 --- a/configure.ac +++ b/configure.ac @@ -24,10 +24,7 @@ AC_SUBST(WL_EGL_TIZEN_VERSION_PATCH) # Checks for programs. AC_PROG_CXX AC_PROG_CC -AC_PATH_PROG([WL_SCANNER], [wayland-scanner]) -if test -z "$WL_SCANNER"; then - AC_MSG_ERROR([wayland-scanner is not found]) -fi + # Checks for libraries. AC_CHECK_LIB([dl], [dlopen]) diff --git a/src/Makefile.am b/src/Makefile.am index 3255de3..cd9ccc4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,8 +27,7 @@ libtpl_egl_la_SOURCES = tpl.c \ if WITH_WAYLAND libtpl_egl_la_SOURCES += tpl_wayland_egl.c \ tpl_wl_egl_thread.c \ - tpl_wl_vk_thread.c \ - wayland-vulkan/wayland-vulkan-protocol.c + tpl_wl_vk_thread.c endif # TBM @@ -36,21 +35,3 @@ if WITH_TBM libtpl_egl_la_SOURCES += tpl_tbm.c endif -nodist_libtpl_egl_la_SOURCES = wayland-vulkan/wayland-vulkan-server-protocol.h \ - wayland-vulkan/wayland-vulkan-client-protocol.h - -BUILT_SOURCES = wayland-vulkan/wayland-vulkan-server-protocol.h \ - wayland-vulkan/wayland-vulkan-client-protocol.h \ - wayland-vulkan/wayland-vulkan-protocol.c - -WAYLAND_VULKAN_PROTOCOLS = wayland-vulkan/wayland-vulkan-protocol.xml - -wayland-vulkan/wayland-vulkan-protocol.c : $(WAYLAND_VULKAN_PROTOCOLS) - wayland-scanner code < $< > $@ - -wayland-vulkan/wayland-vulkan-server-protocol.h : $(WAYLAND_VULKAN_PROTOCOLS) - wayland-scanner server-header < $< > $@ - -wayland-vulkan/wayland-vulkan-client-protocol.h : $(WAYLAND_VULKAN_PROTOCOLS) - wayland-scanner client-header < $< > $@ - diff --git a/src/wayland-vulkan/wayland-vulkan-protocol.xml b/src/unused/wayland-vulkan/wayland-vulkan-protocol.xml similarity index 100% rename from src/wayland-vulkan/wayland-vulkan-protocol.xml rename to src/unused/wayland-vulkan/wayland-vulkan-protocol.xml -- 2.7.4 From bb924dcfaed6df181b6509ea5b6adf838e9f79a2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Aug 2021 11:04:56 +0900 Subject: [PATCH 16/16] Add build flags to separate tizen specific feature. Change-Id: I4615c5a9ca6a82d116fdd0662c2ce8f271490c62 Signed-off-by: Joonbum Ko --- configure.ac | 22 +++++++++++-- packaging/libtpl-egl.spec | 14 ++++++-- src/tpl_wayland_egl.c | 29 +++++++++++++---- src/tpl_wl_egl_thread.c | 82 +++++++++++++++++++++++++++++++++++++---------- src/tpl_wl_vk_thread.c | 48 ++++++++++++++++++++++----- 5 files changed, 158 insertions(+), 37 deletions(-) diff --git a/configure.ac b/configure.ac index 0e38fb8..6d9e688 100644 --- a/configure.ac +++ b/configure.ac @@ -59,11 +59,10 @@ AC_ARG_WITH([wayland], AS_IF([test "${with_wayland}" = "yes" || test "${with_wayland}" = "1"], [PKG_CHECK_MODULES([TPL_WL], [libtdm-client wayland-tbm-client wayland-tbm-server - tizen-surface-client glib-2.0 wayland-egl presentation-time-client wayland-egl-backend - linux-explicit-synchronization-unstable-v1-client]) + glib-2.0 wayland-egl wayland-egl-backend]) TPL_CFLAGS+="$TPL_WL_CFLAGS" TPL_CFLAGS+=" -DTPL_WINSYS_WL=1 " - TPL_LIBS+="$TPL_WL_LIBS"], + TPL_LIBS+="$TPL_WL_LIBS "], []) AM_CONDITIONAL([WITH_WAYLAND], [test "${with_wayland}" = "yes" || test "${with_wayland}" = "1"]) @@ -153,6 +152,23 @@ AS_IF([test "${enable_ttrace}" = "yes" || test "${enable_ttrace}" = "1"], AM_CONDITIONAL([ENABLE_TTRACE], [test "${enable_ttrace}" = "yes" || test "${enable_ttrace}" = "1"]) +AC_ARG_ENABLE([tizen-feature], + [AS_HELP_STRING([--enable-tizen-feature=yes|no],[Enable tizen specific feature. @<:@default=enabled@:>@])], + [], + []) + +AS_IF([test "${enable_tizen_feature}" = "yes" || test "${enable_tizen_feature}" = "1"], + [PKG_CHECK_MODULES([TIZEN_FEATURE], + [tizen-surface-client presentation-time-client + linux-explicit-synchronization-unstable-v1-client]) + TPL_CFLAGS+="$TIZEN_FEATURE_CFLAGS" + TPL_CFLAGS+=" -DTIZEN_FEATURE_ENABLE=1 " + TPL_LIBS+="$TIZEN_FEATURE_LIBS"], + [TPL_CFLAGS+=" -DTIZEN_FEATURE_ENABLE=0 "]) + +AM_CONDITIONAL([ENABLE_TIZEN_FEATURE], [test "${enable_tizen_feature}" = "yes" || test "${enable_tizen_feature}" = "1"]) + + AC_ARG_WITH([utest], [AS_HELP_STRING([--with-utest=yes|no],[Build tpl unit test. @<:@default=disabled@:>@])], [], diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index ba8dab7..d15d8a9 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -18,6 +18,7 @@ %define ENABLE_OBJECT_HASH_CHECK 1 %define ENABLE_WORKER_TEST_ONLY 0 %define ENABLE_DEFAULT_WL_THREAD 0 +%define ENABLE_TIZEN_FEATURE 1 #TPL INSTALL OPTION %define ENABLE_TPL_TEST 0 @@ -53,7 +54,6 @@ Source: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkg-config BuildRequires: pkgconfig(libtbm) -BuildRequires: pkgconfig(dlog) %if "%{TPL_WINSYS}" == "DRI2" || "%{TPL_WINSYS}" == "DRI3" BuildRequires: pkgconfig(libdri2) @@ -78,16 +78,23 @@ BuildRequires: pkgconfig(wayland-egl) BuildRequires: pkgconfig(wayland-egl-backend) BuildRequires: pkgconfig(wayland-tbm-client) BuildRequires: pkgconfig(wayland-tbm-server) +BuildRequires: pkgconfig(glib-2.0) +%if "%{ENABLE_TIZEN_FEATURE}" == "1" BuildRequires: pkgconfig(tizen-surface-client) BuildRequires: pkgconfig(presentation-time-client) BuildRequires: pkgconfig(linux-explicit-synchronization-unstable-v1-client) -BuildRequires: pkgconfig(glib-2.0) +%endif + %endif %if "%{ENABLE_TTRACE}" == "1" BuildRequires: pkgconfig(ttrace) %endif +%if "%{ENABLE_DLOG}" == "1" +BuildRequires: pkgconfig(dlog) +%endif + %global TZ_SYS_RO_SHARE %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share} %description @@ -166,7 +173,8 @@ export WL_EGL_TIZEN_VERSION_PATCH=%{WL_EGL_TIZEN_VERSION_PATCH} --enable-dlog-default=%{ENABLE_DEFAULT_LOG} \ --enable-dump=%{ENABLE_DEFAULT_DUMP} \ --enable-object-hash-check=%{ENABLE_OBJECT_HASH_CHECK} \ - --enable-ttrace=%{ENABLE_TTRACE} + --enable-ttrace=%{ENABLE_TTRACE} \ + --enable-tizen-feature=%{ENABLE_TIZEN_FEATURE} make %{?_smp_mflags} diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 1491898..3ff1817 100755 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -20,7 +20,14 @@ #include #include #include + +#ifndef TIZEN_FEATURE_ENABLE +#define TIZEN_FEATURE_ENABLE 1 +#endif + +#if TIZEN_FEATURE_ENABLE #include +#endif typedef struct _tpl_wayland_egl_display tpl_wayland_egl_display_t; typedef struct _tpl_wayland_egl_surface tpl_wayland_egl_surface_t; @@ -32,7 +39,9 @@ struct _tpl_wayland_egl_display { tdm_client *tdm_client; struct wl_display *wl_dpy; struct wl_event_queue *wl_tbm_event_queue; +#if TIZEN_FEATURE_ENABLE struct tizen_surface_shm *tizen_surface_shm; /* used for surface buffer_flush */ +#endif pthread_mutex_t wl_event_mutex; pthread_mutex_t tdm_mutex; }; @@ -51,7 +60,9 @@ struct _tpl_wayland_egl_surface { 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 */ +#if TIZEN_FEATURE_ENABLE struct tizen_surface_shm_flusher *tizen_surface_shm_flusher; /* wl_proxy for buffer flush */ +#endif }; struct _tpl_wayland_egl_buffer { @@ -77,6 +88,7 @@ static const struct wl_buffer_listener buffer_release_listener; static int tpl_wayland_egl_buffer_key; #define KEY_tpl_wayland_egl_buffer (unsigned long)(&tpl_wayland_egl_buffer_key) +#if TIZEN_FEATURE_ENABLE static void __tpl_wayland_egl_display_buffer_flusher_init( tpl_wayland_egl_display_t *wayland_egl_display); @@ -87,6 +99,7 @@ static void __tpl_wayland_egl_surface_buffer_flusher_init(tpl_surface_t *surface); static void __tpl_wayland_egl_surface_buffer_flusher_fini(tpl_surface_t *surface); +#endif static void __tpl_wayland_egl_buffer_free(tpl_wayland_egl_buffer_t *wayland_egl_buffer); @@ -225,7 +238,9 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) } wayland_egl_display->wl_dpy = wl_dpy; +#if TIZEN_FEATURE_ENABLE __tpl_wayland_egl_display_buffer_flusher_init(wayland_egl_display); +#endif } else { TPL_ERR("Invalid native handle for display."); @@ -275,9 +290,9 @@ __tpl_wayland_egl_display_fini(tpl_display_t *display) wayland_egl_display, wayland_egl_display->wl_tbm_client); lock_res = pthread_mutex_lock(&wayland_egl_display->wl_event_mutex); - +#if TIZEN_FEATURE_ENABLE __tpl_wayland_egl_display_buffer_flusher_fini(wayland_egl_display); - +#endif tdm_lock_res = pthread_mutex_lock(&wayland_egl_display->tdm_mutex); if (wayland_egl_display->tdm_client) tdm_client_destroy(wayland_egl_display->tdm_client); @@ -666,9 +681,9 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) } if (tdm_lock_res == 0) pthread_mutex_unlock(&wayland_egl_display->tdm_mutex); } - +#if TIZEN_FEATURE_ENABLE __tpl_wayland_egl_surface_buffer_flusher_init(surface); - +#endif TPL_LOG_B("WL_EGL", "[INIT] tpl_surface_t(%p) tpl_wayland_egl_surface_t(%p) tbm_queue(%p)", surface, wayland_egl_surface, @@ -738,9 +753,9 @@ __tpl_wayland_egl_surface_fini(tpl_surface_t *surface) wl_egl_window->driver_private = NULL; wl_egl_window->resize_callback = NULL; wl_egl_window->destroy_window_callback = NULL; - +#if TIZEN_FEATURE_ENABLE __tpl_wayland_egl_surface_buffer_flusher_fini(surface); - +#endif if (wayland_egl_surface->tdm_vblank) { int tdm_lock_res = pthread_mutex_lock(&wayland_egl_display->tdm_mutex); TPL_LOG_B("WL_EGL", @@ -1730,6 +1745,7 @@ __cb_client_window_set_window_serial_callback(struct wl_egl_window *wl_egl_windo #define IMPL_TIZEN_SURFACE_SHM_VERSION 2 +#if TIZEN_FEATURE_ENABLE void __cb_resistry_global_callback(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, @@ -1936,3 +1952,4 @@ __tpl_wayland_egl_surface_buffer_flusher_fini(tpl_surface_t *surface) wayland_egl_surface->tizen_surface_shm_flusher = NULL; } } +#endif diff --git a/src/tpl_wl_egl_thread.c b/src/tpl_wl_egl_thread.c index 819fe1a..5360eb7 100755 --- a/src/tpl_wl_egl_thread.c +++ b/src/tpl_wl_egl_thread.c @@ -21,9 +21,15 @@ #include "wayland-egl-tizen/wayland-egl-tizen.h" #include "wayland-egl-tizen/wayland-egl-tizen-priv.h" +#ifndef TIZEN_FEATURE_ENABLE +#define TIZEN_FEATURE_ENABLE 1 +#endif + +#if TIZEN_FEATURE_ENABLE #include #include #include +#endif #include "tpl_utils_gthread.h" @@ -52,6 +58,7 @@ struct _tpl_wl_egl_display { tpl_bool_t use_wait_vblank; tpl_bool_t use_explicit_sync; + tpl_bool_t use_tss; tpl_bool_t prepared; struct { @@ -62,9 +69,11 @@ struct _tpl_wl_egl_display { tpl_list_t *surface_vblanks; } tdm; +#if TIZEN_FEATURE_ENABLE struct tizen_surface_shm *tss; /* used for surface buffer_flush */ struct wp_presentation *presentation; /* for presentation feedback */ struct zwp_linux_explicit_synchronization_v1 *explicit_sync; /* for explicit fence sync */ +#endif }; typedef enum surf_message { @@ -81,8 +90,11 @@ struct _tpl_wl_egl_surface { struct wl_egl_window *wl_egl_window; struct wl_surface *wl_surface; + +#if TIZEN_FEATURE_ENABLE struct zwp_linux_surface_synchronization_v1 *surface_sync; /* for explicit fence sync */ struct tizen_surface_shm_flusher *tss_flusher; /* used for surface buffer_flush */ +#endif tpl_surface_vblank_t *vblank; @@ -189,10 +201,10 @@ struct _tpl_wl_egl_buffer { /* for checking draw done */ tpl_bool_t draw_done; - +#if TIZEN_FEATURE_ENABLE /* to get release event via zwp_linux_buffer_release_v1 */ struct zwp_linux_buffer_release_v1 *buffer_release; - +#endif /* each buffers own its release_fence_fd, until it passes ownership * to it to EGL */ int32_t release_fence_fd; @@ -219,6 +231,7 @@ struct _tpl_wl_egl_buffer { tpl_wl_egl_surface_t *wl_egl_surface; }; +#if TIZEN_FEATURE_ENABLE struct pst_feedback { /* to get presentation feedback from display server */ struct wp_presentation_feedback *presentation_feedback; @@ -229,6 +242,7 @@ struct pst_feedback { tpl_wl_egl_surface_t *wl_egl_surface; }; +#endif static int _get_tbm_surface_bo_name(tbm_surface_h tbm_surface); @@ -381,11 +395,13 @@ _thread_tdm_init(tpl_wl_egl_display_t *wl_egl_display) #define IMPL_TIZEN_SURFACE_SHM_VERSION 2 + static void __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version) { +#if TIZEN_FEATURE_ENABLE tpl_wl_egl_display_t *wl_egl_display = (tpl_wl_egl_display_t *)data; if (!strcmp(interface, "tizen_surface_shm")) { @@ -395,6 +411,7 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, &tizen_surface_shm_interface, ((version < IMPL_TIZEN_SURFACE_SHM_VERSION) ? version : IMPL_TIZEN_SURFACE_SHM_VERSION)); + wl_egl_display->use_tss = TPL_TRUE; } else if (!strcmp(interface, wp_presentation_interface.name)) { wl_egl_display->presentation = wl_registry_bind(wl_registry, @@ -412,6 +429,7 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, TPL_DEBUG("bind zwp_linux_explicit_synchronization_v1_interface"); } } +#endif } static void @@ -531,6 +549,7 @@ _thread_wl_display_init(tpl_wl_egl_display_t *wl_egl_display) goto fini; } +#if TIZEN_FEATURE_ENABLE /* set tizen_surface_shm's queue as client's private queue */ if (wl_egl_display->tss) { wl_proxy_set_queue((struct wl_proxy *)wl_egl_display->tss, @@ -551,18 +570,19 @@ _thread_wl_display_init(tpl_wl_egl_display_t *wl_egl_display) TPL_LOG_T("WL_EGL", "zwp_linux_explicit_synchronization_v1(%p) init.", wl_egl_display->explicit_sync); } - +#endif wl_egl_display->wl_initialized = TPL_TRUE; TPL_INFO("[WAYLAND_INIT]", "wl_egl_display(%p) wl_display(%p) wl_tbm_client(%p) event_queue(%p)", wl_egl_display, wl_egl_display->wl_display, wl_egl_display->wl_tbm_client, wl_egl_display->ev_queue); +#if TIZEN_FEATURE_ENABLE TPL_INFO("[WAYLAND_INIT]", "tizen_surface_shm(%p) wp_presentation(%p) explicit_sync(%p)", wl_egl_display->tss, wl_egl_display->presentation, wl_egl_display->explicit_sync); - +#endif fini: if (display_wrapper) wl_proxy_wrapper_destroy(display_wrapper); @@ -587,7 +607,7 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display) wl_egl_display->ev_queue) == -1) { _wl_display_print_err(wl_egl_display, "dispatch_queue_pending"); } - +#if TIZEN_FEATURE_ENABLE if (wl_egl_display->tss) { TPL_INFO("[TIZEN_SURFACE_SHM_DESTROY]", "wl_egl_display(%p) tizen_surface_shm(%p) fini.", @@ -611,7 +631,7 @@ _thread_wl_display_fini(tpl_wl_egl_display_t *wl_egl_display) zwp_linux_explicit_synchronization_v1_destroy(wl_egl_display->explicit_sync); wl_egl_display->explicit_sync = NULL; } - +#endif if (wl_egl_display->wl_tbm_client) { struct wl_proxy *wl_tbm = NULL; @@ -810,13 +830,16 @@ __tpl_wl_egl_display_init(tpl_display_t *display) wl_egl_display->ev_queue = NULL; wl_egl_display->wl_display = (struct wl_display *)display->native_handle; wl_egl_display->last_error = 0; + wl_egl_display->use_tss = TPL_FALSE; wl_egl_display->use_explicit_sync = TPL_FALSE; // default disabled wl_egl_display->prepared = TPL_FALSE; +#if TIZEN_FEATURE_ENABLE /* Wayland Interfaces */ wl_egl_display->tss = NULL; wl_egl_display->presentation = NULL; wl_egl_display->explicit_sync = NULL; +#endif wl_egl_display->wl_tbm_client = NULL; wl_egl_display->use_wait_vblank = TPL_TRUE; // default enabled @@ -873,7 +896,7 @@ __tpl_wl_egl_display_init(tpl_display_t *display) TPL_INFO("[DISPLAY_INIT]", "USE_WAIT_VBLANK(%s) TIZEN_SURFACE_SHM(%s) USE_EXPLICIT_SYNC(%s)", wl_egl_display->use_wait_vblank ? "TRUE" : "FALSE", - wl_egl_display->tss ? "TRUE" : "FALSE", + wl_egl_display->use_tss ? "TRUE" : "FALSE", wl_egl_display->use_explicit_sync ? "TRUE" : "FALSE"); return TPL_ERROR_NONE; @@ -1267,6 +1290,7 @@ __cb_create_commit_sync_fd(struct wl_egl_window *wl_egl_window, void *private) return commit_sync_fd; } +#if TIZEN_FEATURE_ENABLE static int __cb_create_presentation_sync_fd(struct wl_egl_window *wl_egl_window, void *private) { @@ -1357,7 +1381,7 @@ tss_flusher_listener = { __cb_tss_flusher_free_flush_callback }; /* -- END -- tizen_surface_shm_flusher_listener */ - +#endif /* -- BEGIN -- tbm_surface_queue callback funstions */ static void @@ -1443,7 +1467,7 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface) "wl_egl_surface(%p) wl_egl_window(%p) wl_surface(%p)", wl_egl_surface, wl_egl_surface->wl_egl_window, wl_egl_surface->wl_surface); - +#if TIZEN_FEATURE_ENABLE tpl_gmutex_lock(&wl_egl_surface->presentation_sync.mutex); if (wl_egl_display->presentation && wl_egl_surface->presentation_feedbacks) { @@ -1490,7 +1514,7 @@ _thread_wl_egl_surface_fini(tpl_wl_egl_surface_t *wl_egl_surface) tizen_surface_shm_flusher_destroy(wl_egl_surface->tss_flusher); wl_egl_surface->tss_flusher = NULL; } - +#endif if (wl_egl_surface->vblank && wl_egl_surface->vblank->waiting_buffers) { __tpl_list_free(wl_egl_surface->vblank->waiting_buffers, NULL); wl_egl_surface->vblank->waiting_buffers = NULL; @@ -1630,8 +1654,10 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) wl_egl_surface->serial = 0; wl_egl_surface->vblank = NULL; +#if TIZEN_FEATURE_ENABLE wl_egl_surface->tss_flusher = NULL; wl_egl_surface->surface_sync = NULL; +#endif wl_egl_surface->post_interval = surface->post_interval; @@ -1665,7 +1691,11 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface) tizen_private->set_window_serial_callback = (void *) __cb_set_window_serial_callback; tizen_private->create_commit_sync_fd = (void *)__cb_create_commit_sync_fd; +#if TIZEN_FEATURE_ENABLE tizen_private->create_presentation_sync_fd = (void *)__cb_create_presentation_sync_fd; +#else + tizen_private->create_presentation_sync_fd = NULL; +#endif wl_egl_window->destroy_window_callback = (void *)__cb_destroy_callback; wl_egl_window->resize_callback = (void *)__cb_resize_callback; @@ -1888,7 +1918,7 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) } wl_egl_surface->vblank = vblank; - +#if TIZEN_FEATURE_ENABLE if (wl_egl_display->tss) { wl_egl_surface->tss_flusher = tizen_surface_shm_get_flusher(wl_egl_display->tss, @@ -1918,7 +1948,7 @@ _thread_wl_egl_surface_init(tpl_wl_egl_surface_t *wl_egl_surface) wl_egl_display->use_explicit_sync = TPL_FALSE; } } - +#endif wl_egl_surface->presentation_feedbacks = __tpl_list_alloc(); } @@ -2222,7 +2252,9 @@ _wl_egl_buffer_init(tpl_wl_egl_buffer_t *wl_egl_buffer, wl_egl_buffer->draw_done = TPL_FALSE; wl_egl_buffer->need_to_commit = TPL_TRUE; +#if TIZEN_FEATURE_ENABLE wl_egl_buffer->buffer_release = NULL; +#endif wl_egl_buffer->transform = tizen_private->transform; if (wl_egl_buffer->w_transform != tizen_private->window_transform) { @@ -2448,17 +2480,21 @@ __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; + /* If wl_egl_buffer->release_fence_fd is -1, * the tbm_surface can be used immediately. * If not, user(EGL) have to wait until signaled. */ if (release_fence) { +#if TIZEN_FEATURE_ENABLE if (wl_egl_surface->surface_sync) { *release_fence = wl_egl_buffer->release_fence_fd; TPL_DEBUG("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; - } else { + } else +#endif + { *release_fence = -1; } } @@ -2753,9 +2789,12 @@ _thread_surface_queue_acquire(tpl_wl_egl_surface_t *wl_egl_surface) } if (wl_egl_buffer->acquire_fence_fd != -1) { +#if TIZEN_FEATURE_ENABLE if (wl_egl_surface->surface_sync) ready_to_commit = TPL_TRUE; - else { + else +#endif + { if (wl_egl_buffer->waiting_source) { tpl_gsource_destroy(wl_egl_buffer->waiting_source, TPL_FALSE); wl_egl_buffer->waiting_source = NULL; @@ -2826,6 +2865,7 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error, } /* -- END -- tdm_client vblank callback function */ +#if TIZEN_FEATURE_ENABLE static void __cb_buffer_fenced_release(void *data, struct zwp_linux_buffer_release_v1 *release, int32_t fence) @@ -2930,6 +2970,7 @@ static const struct zwp_linux_buffer_release_v1_listener zwp_release_listner = { __cb_buffer_fenced_release, __cb_buffer_immediate_release, }; +#endif static void __cb_wl_buffer_release(void *data, struct wl_proxy *wl_buffer) @@ -2977,7 +3018,7 @@ __cb_wl_buffer_release(void *data, struct wl_proxy *wl_buffer) static const struct wl_buffer_listener wl_buffer_release_listener = { (void *)__cb_wl_buffer_release, }; - +#if TIZEN_FEATURE_ENABLE static void __cb_presentation_feedback_sync_output(void *data, struct wp_presentation_feedback *presentation_feedback, @@ -3091,6 +3132,7 @@ static const struct wp_presentation_feedback_listener feedback_listener = { __cb_presentation_feedback_presented, __cb_presentation_feedback_discarded }; +#endif static tpl_result_t _thread_surface_vblank_wait(tpl_wl_egl_surface_t *wl_egl_surface) @@ -3137,6 +3179,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, version = wl_proxy_get_version((struct wl_proxy *)wl_surface); +#if TIZEN_FEATURE_ENABLE /* create presentation feedback and add listener */ tpl_gmutex_lock(&wl_egl_surface->presentation_sync.mutex); if (wl_egl_display->presentation && wl_egl_buffer->presentation_sync_fd != -1) { @@ -3169,6 +3212,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, } } tpl_gmutex_unlock(&wl_egl_surface->presentation_sync.mutex); +#endif if (wl_egl_buffer->w_rotated == TPL_TRUE) { wayland_tbm_client_set_buffer_transform( @@ -3226,7 +3270,7 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, wayland_tbm_client_set_buffer_serial(wl_egl_display->wl_tbm_client, (void *)wl_egl_buffer->wl_buffer, wl_egl_buffer->serial); - +#if TIZEN_FEATURE_ENABLE if (wl_egl_display->use_explicit_sync && wl_egl_surface->surface_sync) { @@ -3246,7 +3290,9 @@ _thread_wl_surface_commit(tpl_wl_egl_surface_t *wl_egl_surface, wl_egl_buffer->buffer_release, &zwp_release_listner, wl_egl_buffer); TPL_DEBUG("add explicit_sync_release_listener."); } - } else { + } else +#endif + { wl_buffer_add_listener((void *)wl_egl_buffer->wl_buffer, &wl_buffer_release_listener, wl_egl_buffer); } @@ -3383,6 +3429,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) wl_egl_buffer->wl_buffer = NULL; } +#if TIZEN_FEATURE_ENABLE if (wl_egl_buffer->buffer_release) { zwp_linux_buffer_release_v1_destroy(wl_egl_buffer->buffer_release); wl_egl_buffer->buffer_release = NULL; @@ -3392,6 +3439,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer) close(wl_egl_buffer->release_fence_fd); wl_egl_buffer->release_fence_fd = -1; } +#endif if (wl_egl_buffer->waiting_source) { tpl_gsource_destroy(wl_egl_buffer->waiting_source, TPL_FALSE); diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index f883334..c1e2017 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -19,8 +19,14 @@ #include +#ifndef TIZEN_FEATURE_ENABLE +#define TIZEN_FEATURE_ENABLE 1 +#endif + +#if TIZEN_FEATURE_ENABLE #include #include +#endif #include "tpl_utils_gthread.h" @@ -60,8 +66,9 @@ struct _tpl_wl_vk_display { int min_buffer; int max_buffer; int present_modes; - +#if TIZEN_FEATURE_ENABLE struct zwp_linux_explicit_synchronization_v1 *explicit_sync; /* for explicit fence sync */ +#endif }; struct _tpl_wl_vk_swapchain { @@ -96,8 +103,9 @@ struct _tpl_wl_vk_surface { tpl_wl_vk_swapchain_t *swapchain; struct wl_surface *wl_surface; +#if TIZEN_FEATURE_ENABLE struct zwp_linux_surface_synchronization_v1 *surface_sync; /* for explicit fence sync */ - +#endif tdm_client_vblank *vblank; /* surface information */ @@ -164,8 +172,10 @@ struct _tpl_wl_vk_buffer { /* for checking need_to_commit (frontbuffer mode) */ tpl_bool_t need_to_commit; +#if TIZEN_FEATURE_ENABLE /* to get release event via zwp_linux_buffer_release_v1 */ struct zwp_linux_buffer_release_v1 *buffer_release; +#endif /* each buffers own its release_fence_fd, until it passes ownership * to it to EGL */ @@ -321,13 +331,12 @@ _thread_tdm_init(tpl_wl_vk_display_t *wl_vk_display) return TPL_ERROR_NONE; } -#define IMPL_TIZEN_SURFACE_SHM_VERSION 2 - static void __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, uint32_t name, const char *interface, uint32_t version) { +#if TIZEN_FEATURE_ENABLE tpl_wl_vk_display_t *wl_vk_display = (tpl_wl_vk_display_t *)data; if (strcmp(interface, "zwp_linux_explicit_synchronization_v1") == 0) { @@ -342,6 +351,7 @@ __cb_wl_resistry_global_callback(void *data, struct wl_registry *wl_registry, TPL_DEBUG("bind zwp_linux_explicit_synchronization_v1_interface"); } } +#endif } static void @@ -461,12 +471,14 @@ _thread_wl_display_init(tpl_wl_vk_display_t *wl_vk_display) goto fini; } +#if TIZEN_FEATURE_ENABLE if (wl_vk_display->explicit_sync) { wl_proxy_set_queue((struct wl_proxy *)wl_vk_display->explicit_sync, wl_vk_display->ev_queue); TPL_LOG_T("WL_VK", "zwp_linux_explicit_synchronization_v1(%p) init.", wl_vk_display->explicit_sync); } +#endif wl_vk_display->wl_initialized = TPL_TRUE; @@ -474,10 +486,11 @@ _thread_wl_display_init(tpl_wl_vk_display_t *wl_vk_display) "wl_vk_display(%p) wl_display(%p) wl_tbm_client(%p) event_queue(%p)", wl_vk_display, wl_vk_display->wl_display, wl_vk_display->wl_tbm_client, wl_vk_display->ev_queue); +#if TIZEN_FEATURE_ENABLE TPL_INFO("[WAYLAND_INIT]", "explicit_sync(%p)", wl_vk_display->explicit_sync); - +#endif fini: if (display_wrapper) wl_proxy_wrapper_destroy(display_wrapper); @@ -503,6 +516,7 @@ _thread_wl_display_fini(tpl_wl_vk_display_t *wl_vk_display) _wl_display_print_err(wl_vk_display, "dispatch_queue_pending"); } +#if TIZEN_FEATURE_ENABLE if (wl_vk_display->explicit_sync) { TPL_INFO("[EXPLICIT_SYNC_DESTROY]", "wl_vk_display(%p) zwp_linux_explicit_synchronization_v1(%p) fini.", @@ -510,6 +524,7 @@ _thread_wl_display_fini(tpl_wl_vk_display_t *wl_vk_display) zwp_linux_explicit_synchronization_v1_destroy(wl_vk_display->explicit_sync); wl_vk_display->explicit_sync = NULL; } +#endif if (wl_vk_display->wl_tbm_client) { struct wl_proxy *wl_tbm = NULL; @@ -708,7 +723,9 @@ __tpl_wl_vk_display_init(tpl_display_t *display) wl_vk_display->prepared = TPL_FALSE; /* Wayland Interfaces */ +#if TIZEN_FEATURE_ENABLE wl_vk_display->explicit_sync = NULL; +#endif wl_vk_display->wl_tbm_client = NULL; /* Vulkan specific surface capabilities */ @@ -1053,6 +1070,7 @@ _thread_wl_vk_surface_init(tpl_wl_vk_surface_t *wl_vk_surface) wl_vk_surface->vblank); } +#if TIZEN_FEATURE_ENABLE if (wl_vk_display->explicit_sync && wl_vk_display->use_explicit_sync) { wl_vk_surface->surface_sync = zwp_linux_explicit_synchronization_v1_get_synchronization( @@ -1067,7 +1085,7 @@ _thread_wl_vk_surface_init(tpl_wl_vk_surface_t *wl_vk_surface) wl_vk_display->use_explicit_sync = TPL_FALSE; } } - +#endif wl_vk_surface->vblank_waiting_buffers = __tpl_list_alloc(); } @@ -1085,6 +1103,7 @@ _thread_wl_vk_surface_fini(tpl_wl_vk_surface_t *wl_vk_surface) wl_vk_surface->vblank_waiting_buffers = NULL; } +#if TIZEN_FEATURE_ENABLE if (wl_vk_surface->surface_sync) { TPL_INFO("[SURFACE_SYNC_DESTROY]", "wl_vk_surface(%p) surface_sync(%p)", @@ -1092,6 +1111,7 @@ _thread_wl_vk_surface_fini(tpl_wl_vk_surface_t *wl_vk_surface) zwp_linux_surface_synchronization_v1_destroy(wl_vk_surface->surface_sync); wl_vk_surface->surface_sync = NULL; } +#endif if (wl_vk_surface->vblank) { TPL_INFO("[VBLANK_DESTROY]", @@ -1220,7 +1240,9 @@ __tpl_wl_vk_surface_init(tpl_surface_t *surface) wl_vk_surface->render_done_cnt = 0; wl_vk_surface->vblank = NULL; +#if TIZEN_FEATURE_ENABLE wl_vk_surface->surface_sync = NULL; +#endif wl_vk_surface->sent_message = NONE_MESSAGE; @@ -1788,10 +1810,12 @@ __cb_wl_vk_buffer_free(tpl_wl_vk_buffer_t *wl_vk_buffer) wl_vk_buffer->wl_buffer = NULL; } +#if TIZEN_FEATURE_ENABLE if (wl_vk_buffer->buffer_release) { zwp_linux_buffer_release_v1_destroy(wl_vk_buffer->buffer_release); wl_vk_buffer->buffer_release = NULL; } +#endif if (wl_vk_buffer->release_fence_fd != -1) { close(wl_vk_buffer->release_fence_fd); @@ -1855,8 +1879,9 @@ _wl_vk_buffer_create(tpl_wl_vk_surface_t *wl_vk_surface, wl_vk_buffer->num_rects = 0; wl_vk_buffer->need_to_commit = TPL_FALSE; +#if TIZEN_FEATURE_ENABLE wl_vk_buffer->buffer_release = NULL; - +#endif tpl_gmutex_init(&wl_vk_buffer->mutex); tpl_gcond_init(&wl_vk_buffer->cond); @@ -1975,12 +2000,15 @@ __tpl_wl_vk_surface_dequeue_buffer(tpl_surface_t *surface, wl_vk_buffer->status = DEQUEUED; if (release_fence) { +#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)", wl_vk_surface, wl_vk_buffer, *release_fence); wl_vk_buffer->release_fence_fd = -1; - } else { + } else +#endif + { *release_fence = -1; } } @@ -2196,6 +2224,7 @@ _thread_surface_queue_acquire(tpl_wl_vk_surface_t *wl_vk_surface) return TPL_ERROR_NONE; } +#if TIZEN_FEATURE_ENABLE static void __cb_buffer_fenced_release(void *data, struct zwp_linux_buffer_release_v1 *release, @@ -2319,6 +2348,7 @@ static const struct zwp_linux_buffer_release_v1_listener zwp_release_listner = { __cb_buffer_fenced_release, __cb_buffer_immediate_release, }; +#endif static void __cb_wl_buffer_release(void *data, struct wl_proxy *wl_buffer) @@ -2491,6 +2521,7 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, } } +#if TIZEN_FEATURE_ENABLE if (wl_vk_display->use_explicit_sync && wl_vk_surface->surface_sync && wl_vk_buffer->acquire_fence_fd != -1) { @@ -2512,6 +2543,7 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, TPL_DEBUG("add explicit_sync_release_listener."); } } +#endif wl_surface_commit(wl_surface); -- 2.7.4