tpl_wayland_egl_thread: Partially modified event_fd processing method. 91/165691/3
authorjoonbum.ko <joonbum.ko@samsung.com>
Tue, 2 Jan 2018 10:34:45 +0000 (19:34 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 3 Jan 2018 09:25:28 +0000 (18:25 +0900)
 - Partially modified the way event_fd is handled between vk_sub_thread and twe_thread.
 - Twe buffers are in draw_done state and write twice to event_fd to send event,
  but in twe_thread, event_fd may be read only once, and only one buffer may be acquired.
 - Supplemented it by adding draw_done_count to surf_source.
 - It is a valid patch only while using vk_sub_thread.

Change-Id: I341907ca1cc6466af4d5e2f6bb5173e9382d925f
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c

index 49dcb7e..c23c77e 100644 (file)
@@ -128,6 +128,7 @@ struct _twe_wl_surf_source {
        GMainLoop *vk_sub_loop;
        GMutex sub_thread_mutex;
        GCond sub_thread_cond;
+       int draw_done_count;
 };
 
 struct _twe_wl_buffer_info {
@@ -2047,6 +2048,14 @@ _twe_thread_wl_surface_dispatch(GSource *source, GSourceFunc cb, gpointer data)
                        TPL_ERR("Failed to read from event_fd(%d)",
                                        surf_source->event_fd);
 
+               if (surf_source->disp_source->is_vulkan_dpy) {
+                       g_mutex_lock(&surf_source->sub_thread_mutex);
+                       while (surf_source->draw_done_count > 0) {
+                               _twe_thread_wl_surface_acquire_and_commit(surf_source);
+                               surf_source->draw_done_count--;
+                       }
+                       g_mutex_unlock(&surf_source->sub_thread_mutex);
+               }
                _twe_thread_wl_surface_acquire_and_commit(surf_source);
        }
 
@@ -2411,6 +2420,7 @@ twe_surface_add(twe_thread* thread,
 
        source->vk_sub_loop = NULL;
        source->vk_sub_thread = NULL;
+       source->draw_done_count = 0;
 
        __tpl_object_init(&source->obj, TPL_OBJECT_SURFACE, NULL);
 
@@ -2863,6 +2873,7 @@ _twe_thread_sync_draw_source_dispatch(GSource *source, GSourceFunc cb, gpointer
                int ret;
                uint64_t value = 1;
                tbm_surface_h tbm_surface = sync_draw_source->tbm_surface;
+               twe_wl_surf_source *surf_source = sync_draw_source->buf_info->surf_source;
 
                tbm_surface_internal_ref(tbm_surface);
 
@@ -2883,6 +2894,10 @@ _twe_thread_sync_draw_source_dispatch(GSource *source, GSourceFunc cb, gpointer
                                        sync_draw_source->draw_fence_fd, errno, buf);
                }
 
+               g_mutex_lock(&surf_source->sub_thread_mutex);
+               surf_source->draw_done_count++;
+               g_mutex_unlock(&surf_source->sub_thread_mutex);
+
                /* Draw done */
                /* Send event to twe_wl_surf_source */
                ret = write(sync_draw_source->draw_done_signal_fd,