From: Joonbum Ko Date: Fri, 30 Apr 2021 06:20:04 +0000 (+0900) Subject: Fix a problem when explicit_fence was not used. X-Git-Tag: accepted/tizen/unified/20210506.103530~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fff67364f948809741a869732ece2147d33a0ff;p=platform%2Fcore%2Fuifw%2Flibtpl-egl.git Fix a problem when explicit_fence was not used. - Wayland error logs are printed due to attempt to add the buffer release listener in duplicate. Change-Id: I1c5653ea3802a5a901cbf7fa07df73f0a822afaf Signed-off-by: Joonbum Ko --- diff --git a/src/tpl_wl_vk_thread.c b/src/tpl_wl_vk_thread.c index 643f496..67d2256 100644 --- a/src/tpl_wl_vk_thread.c +++ b/src/tpl_wl_vk_thread.c @@ -140,7 +140,7 @@ struct _tpl_wl_vk_buffer { tbm_surface_h tbm_surface; int bo_name; - struct wl_proxy *wl_buffer; + struct wl_buffer *wl_buffer; int dx, dy; /* position to attach to wl_surface */ int width, height; /* size to attach to wl_surface */ @@ -180,6 +180,8 @@ static int _get_tbm_surface_bo_name(tbm_surface_h tbm_surface); static void __cb_wl_vk_buffer_free(tpl_wl_vk_buffer_t *wl_vk_buffer); +static void +__cb_wl_buffer_release(void *data, struct wl_proxy *wl_buffer); static tpl_result_t _thread_swapchain_create_tbm_queue(tpl_wl_vk_surface_t *wl_vk_surface); static void @@ -1205,7 +1207,7 @@ __tpl_wl_vk_surface_init(tpl_surface_t *surface) wl_vk_surface->reset = TPL_FALSE; wl_vk_surface->is_activated = TPL_FALSE; - wl_vk_surface->vblank_done = TPL_FALSE; + wl_vk_surface->vblank_done = TPL_TRUE; wl_vk_surface->render_done_cnt = 0; @@ -1764,7 +1766,7 @@ __cb_wl_vk_buffer_free(tpl_wl_vk_buffer_t *wl_vk_buffer) if (wl_vk_buffer->wl_buffer) { wayland_tbm_client_destroy_buffer(wl_vk_display->wl_tbm_client, - (void *)wl_vk_buffer->wl_buffer); + wl_vk_buffer->wl_buffer); wl_vk_buffer->wl_buffer = NULL; } @@ -2098,6 +2100,10 @@ __tpl_wl_vk_surface_enqueue_buffer(tpl_surface_t *surface, return TPL_ERROR_NONE; } +static const struct wl_buffer_listener wl_buffer_release_listener = { + (void *)__cb_wl_buffer_release, +}; + static tpl_result_t _thread_surface_queue_acquire(tpl_wl_vk_surface_t *wl_vk_surface) { @@ -2134,8 +2140,7 @@ _thread_surface_queue_acquire(tpl_wl_vk_surface_t *wl_vk_surface) _get_tbm_surface_bo_name(tbm_surface)); if (wl_vk_buffer->wl_buffer == NULL) { - wl_vk_buffer->wl_buffer = - (struct wl_proxy *)wayland_tbm_client_create_buffer( + wl_vk_buffer->wl_buffer = wayland_tbm_client_create_buffer( wl_vk_display->wl_tbm_client, tbm_surface); if (!wl_vk_buffer->wl_buffer) { @@ -2146,6 +2151,12 @@ _thread_surface_queue_acquire(tpl_wl_vk_surface_t *wl_vk_surface) "[WL_BUFFER_CREATE] wl_vk_buffer(%p) wl_buffer(%p) tbm_surface(%p)", wl_vk_buffer, wl_vk_buffer->wl_buffer, tbm_surface); } + + if (wl_vk_buffer->acquire_fence_fd == -1 || + wl_vk_display->use_explicit_sync == TPL_FALSE) { + wl_buffer_add_listener(wl_vk_buffer->wl_buffer, + &wl_buffer_release_listener, wl_vk_buffer); + } } if (!wl_vk_display->use_wait_vblank || wl_vk_surface->vblank_done) @@ -2340,10 +2351,6 @@ __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, -}; - static void __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error, unsigned int sequence, unsigned int tv_sec, @@ -2414,17 +2421,22 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, "wl_vk_buffer sould be not NULL"); if (wl_vk_buffer->wl_buffer == NULL) { - wl_vk_buffer->wl_buffer = - (struct wl_proxy *)wayland_tbm_client_create_buffer( - wl_vk_display->wl_tbm_client, - wl_vk_buffer->tbm_surface); + wl_vk_buffer->wl_buffer = wayland_tbm_client_create_buffer( + wl_vk_display->wl_tbm_client, + wl_vk_buffer->tbm_surface); + if (wl_vk_buffer->wl_buffer && + (wl_vk_buffer->acquire_fence_fd == -1 || + wl_vk_display->use_explicit_sync == TPL_FALSE)) { + wl_buffer_add_listener(wl_vk_buffer->wl_buffer, + &wl_buffer_release_listener, wl_vk_buffer); + } } TPL_CHECK_ON_FALSE_ASSERT_FAIL(wl_vk_buffer->wl_buffer != NULL, "[FATAL] Failed to create wl_buffer"); version = wl_proxy_get_version((struct wl_proxy *)wl_surface); - wl_surface_attach(wl_surface, (void *)wl_vk_buffer->wl_buffer, + wl_surface_attach(wl_surface, wl_vk_buffer->wl_buffer, wl_vk_buffer->dx, wl_vk_buffer->dy); if (wl_vk_buffer->num_rects < 1 || wl_vk_buffer->rects == NULL) { @@ -2460,7 +2472,8 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, } if (wl_vk_display->use_explicit_sync && - wl_vk_surface->surface_sync) { + wl_vk_surface->surface_sync && + wl_vk_buffer->acquire_fence_fd != -1) { zwp_linux_surface_synchronization_v1_set_acquire_fence(wl_vk_surface->surface_sync, wl_vk_buffer->acquire_fence_fd); @@ -2478,9 +2491,6 @@ _thread_wl_surface_commit(tpl_wl_vk_surface_t *wl_vk_surface, wl_vk_buffer->buffer_release, &zwp_release_listner, wl_vk_buffer); TPL_DEBUG("add explicit_sync_release_listener."); } - } else { - wl_buffer_add_listener((void *)wl_vk_buffer->wl_buffer, - &wl_buffer_release_listener, wl_vk_buffer); } wl_surface_commit(wl_surface);