From bb924dcfaed6df181b6509ea5b6adf838e9f79a2 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 13 Aug 2021 11:04:56 +0900 Subject: [PATCH] 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