Fix some wrong implementations. 82/254782/1
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 4 Feb 2021 06:19:29 +0000 (15:19 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Tue, 9 Mar 2021 08:51:35 +0000 (17:51 +0900)
 - wl_egl_surface->need_to_enqueue should be
  initialized to TPL_TRUE at first time.
 - If release_fence, which is from tpl_surface_dequeue,
  is not null and surface_sync is not used,
   it should be initialized to -1.
 - _thread_wl_surface_commit should be called only if
  there is a buffer in vblank_waiting_buffers
  when vblank event occurs.
 - Some debug logs were added.

Change-Id: I8dc72c5b0ddbb0d38e149d809191620691caf698
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
src/tpl_wl_egl.c

index 55eb6cd..cea25e9 100644 (file)
@@ -1609,7 +1609,7 @@ __tpl_wl_egl_surface_init(tpl_surface_t *surface)
 
        wl_egl_surface->reset                  = TPL_FALSE;
        wl_egl_surface->is_activated           = TPL_FALSE;
-       wl_egl_surface->need_to_enqueue        = TPL_FALSE;
+       wl_egl_surface->need_to_enqueue        = TPL_TRUE;
        wl_egl_surface->prerotation_capability = TPL_FALSE;
        wl_egl_surface->vblank_done            = TPL_TRUE;
        wl_egl_surface->use_render_done_fence  = TPL_FALSE;
@@ -2277,10 +2277,14 @@ __tpl_wl_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns,
        /* 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 && 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);
+       if (release_fence) {
+               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);
+               } else {
+                       *release_fence = -1;
+               }
        }
 
        if (surface->is_frontbuffer_mode && is_activated)
@@ -2459,6 +2463,9 @@ __thread_func_waiting_source_dispatch(tpl_gsource *gsource, uint64_t message)
        TRACE_ASYNC_END(wl_egl_buffer->acquire_fence_fd, "FENCE WAIT fd(%d)",
                                        wl_egl_buffer->acquire_fence_fd);
 
+       TPL_DEBUG("[RENDER DONE] wl_egl_buffer(%p) tbm_surface(%p)",
+                         wl_egl_buffer, tbm_surface);
+
        tpl_gmutex_lock(&wl_egl_buffer->mutex);
        tpl_gcond_signal(&wl_egl_buffer->cond);
        wl_egl_buffer->status = WAITING_VBLANK;
@@ -2590,6 +2597,7 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error,
        tbm_surface_h tbm_surface            = NULL;
 
        TRACE_ASYNC_END((int)wl_egl_surface, "WAIT_VBLANK");
+       TPL_DEBUG("[VBLANK] wl_egl_surface(%p)", wl_egl_surface);
 
        if (error == TDM_ERROR_TIMEOUT)
                TPL_WARN("[TDM_ERROR_TIMEOUT] It will keep going. wl_egl_surface(%p)",
@@ -2601,7 +2609,8 @@ __cb_tdm_client_vblank(tdm_client_vblank *vblank, tdm_error error,
        tbm_surface = (tbm_surface_h)__tpl_list_pop_front(
                                                wl_egl_surface->vblank_waiting_buffers,
                                                NULL);
-       _thread_wl_surface_commit(wl_egl_surface, tbm_surface);
+       if (tbm_surface)
+               _thread_wl_surface_commit(wl_egl_surface, tbm_surface);
        tpl_gmutex_unlock(&wl_egl_surface->surf_mutex);
 }
 /* -- END -- tdm_client vblank callback function */
@@ -3128,7 +3137,7 @@ __cb_wl_egl_buffer_free(tpl_wl_egl_buffer_t *wl_egl_buffer)
                         wl_egl_buffer, wl_egl_buffer->wl_buffer, wl_egl_buffer->tbm_surface);
 
        tpl_gmutex_lock(&wl_egl_surface->buffers_mutex);
-       if (wl_egl_buffer->idx > 0 && wl_egl_surface->buffers[wl_egl_buffer->idx]) {
+       if (wl_egl_buffer->idx >= 0 && wl_egl_surface->buffers[wl_egl_buffer->idx]) {
                wl_egl_surface->buffers[wl_egl_buffer->idx] = NULL;
                wl_egl_surface->buffer_cnt--;