tpl_bool_t use_sync_fence;
int post_interval;
+
+ struct {
+ tbm_surface_h tbm_surface;
+ int sync_fd;
+ } sync_info;
};
struct _twe_wl_buffer_info {
static struct tizen_private *
_get_tizen_private(struct wl_egl_window *);
+tpl_result_t
+_twe_thread_fence_wait_source_attach(twe_wl_surf_source *surf_source,
+ tbm_surface_h tbm_surface, tbm_fd sync_fd);
+
static gpointer
_twe_thread_loop(gpointer data)
{
g_mutex_lock(&surf_source->surf_mutex);
- if (!surf_source->use_sync_fence) {
- ret = write(surf_source->event_fd, &value, sizeof(uint64_t));
- if (ret == -1) {
- TPL_ERR("failed to send acquirable event. twe_wl_surf_source(%p)",
- surf_source);
- g_mutex_unlock(&surf_source->surf_mutex);
- return;
- }
+ ret = write(surf_source->event_fd, &value, sizeof(uint64_t));
+ if (ret == -1) {
+ TPL_ERR("failed to send acquirable event. twe_wl_surf_source(%p)",
+ surf_source);
+ g_mutex_unlock(&surf_source->surf_mutex);
+ return;
}
g_mutex_unlock(&surf_source->surf_mutex);
res = TPL_ERROR_INVALID_CONNECTION;
}
- _twe_thread_wl_surface_acquire_and_commit(surf_source);
+ if (surf_source->use_sync_fence &&
+ surf_source->sync_info.sync_fd > 0 &&
+ surf_source->sync_info.tbm_surface) {
+
+ int sync_fd = surf_source->sync_info.sync_fd;
+ tbm_surface_h tbm_surface = surf_source->sync_info.tbm_surface;
+ res = _twe_thread_fence_wait_source_attach(surf_source, tbm_surface, sync_fd);
+ if (res != TPL_ERROR_NONE) {
+ TPL_ERR("Failed to attach source with fence_fd(%d) ret(%d)",
+ sync_fd, res);
+ surf_source->use_sync_fence = TPL_FALSE;
+ }
+
+ surf_source->sync_info.sync_fd = -1;
+ surf_source->sync_info.tbm_surface = NULL;
+ } else {
+ _twe_thread_wl_surface_acquire_and_commit(surf_source);
+ }
}
if (cond && !(cond & G_IO_IN)) {
source->presentation_sync_ts_backup = 0;
source->presentation_sync_req_cnt = 0;
+ source->sync_info.tbm_surface = NULL;
+ source->sync_info.sync_fd = -1;
+
if (!disp_source->is_vulkan_dpy) {
struct wl_egl_window *wl_egl_window =
(struct wl_egl_window *)native_handle;
G_IO_IN);
/* When waiting is over, it will be removed from the list. */
- g_mutex_lock(&surf_source->surf_mutex);
__tpl_list_push_back(surf_source->fence_waiting_sources, (void *)wait_source);
- g_mutex_unlock(&surf_source->surf_mutex);
g_source_attach(&wait_source->gsource, g_main_loop_get_context(_twe_ctx->twe_loop));
+ TPL_LOG_T(BACKEND, "fence_wait_source(%p) attached | tbm_surface(%p) fence_fd(%d)",
+ wait_source, tbm_surface, sync_fd);
+
return TPL_ERROR_NONE;
}
return TPL_ERROR_INVALID_PARAMETER;
}
- ret = _twe_thread_fence_wait_source_attach(surf_source, tbm_surface, sync_fd);
- if (ret != TPL_ERROR_NONE) {
- TPL_ERR("Failed to attach source with fence_fd(%d) ret(%d)",
- sync_fd, ret);
- surf_source->use_sync_fence = TPL_FALSE;
- return ret;
- }
-
+ g_mutex_lock(&surf_source->surf_mutex);
+ surf_source->sync_info.sync_fd = sync_fd;
+ surf_source->sync_info.tbm_surface = tbm_surface;
surf_source->use_sync_fence = TPL_TRUE;
+ TPL_DEBUG("set sync fd | surf_source(%p) tbm_surface(%p) sync_fd(%d)",
+ surf_source, tbm_surface, sync_fd);
+ g_mutex_unlock(&surf_source->surf_mutex);
return ret;
}