tpl_wayland_egl_thread: Added new internal APIs related with swapchain for vulkan. 66/161966/2
authorjoonbum.ko <joonbum.ko@samsung.com>
Fri, 29 Sep 2017 04:31:17 +0000 (13:31 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Tue, 28 Nov 2017 10:37:27 +0000 (19:37 +0900)
Change-Id: Ieceb7c1d6f08a684ba30de204818764e0c621754
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
src/tpl_wayland_egl_thread.c
src/tpl_wayland_egl_thread.h

index 9cb4735..6b66c2c 100644 (file)
@@ -93,6 +93,11 @@ struct _twe_wl_surf_source {
        int rotation;
        void *cb_data;
        int format;
+       struct {
+               int width, height;
+               int buffer_count;
+               int present_mode;
+       } swapchain_properties;
        tpl_surface_cb_func_t rotate_cb;
        tpl_bool_t rotation_capability;
        tpl_object_t obj; /* for mutex lock */
@@ -2079,6 +2084,96 @@ twe_surface_del(twe_surface_h twe_surface)
 }
 
 tpl_result_t
+twe_surface_create_swapchain(twe_surface_h twe_surface,
+                                                        int width, int height, int format,
+                                                        int buffer_count, int present_mode)
+{
+       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
+       twe_wl_disp_source *disp_source = NULL;
+
+       if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+               TPL_ERR("twe_surface(%p) is invalid.", twe_surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       disp_source = surf_source->disp_source;
+
+       TPL_ASSERT(disp_source);
+
+       if ((buffer_count < disp_source->surface_capabilities.min_buffer)
+                       || (buffer_count > disp_source->surface_capabilities.max_buffer)) {
+               TPL_ERR("Invalid buffer_count(%d)! min_buffer(%d) max_buffer(%d)",
+                               buffer_count,
+                               disp_source->surface_capabilities.min_buffer,
+                               disp_source->surface_capabilities.max_buffer);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((present_mode & disp_source->surface_capabilities.present_modes) == 0) {
+               /* server not supported current mode check client mode */
+               switch (present_mode) {
+               case TPL_DISPLAY_PRESENT_MODE_FIFO:
+               case TPL_DISPLAY_PRESENT_MODE_FIFO_RELAXED:
+               case TPL_DISPLAY_PRESENT_MODE_MAILBOX:
+               case TPL_DISPLAY_PRESENT_MODE_IMMEDIATE:
+                       break;
+               default:
+                       TPL_ERR("Unsupported present mode: %d", present_mode);
+                       return TPL_ERROR_INVALID_PARAMETER;
+               }
+       }
+
+       /* FIXME: vblank has performance problem so replace all present mode to MAILBOX */
+       present_mode = TPL_DISPLAY_PRESENT_MODE_MAILBOX;
+
+       surf_source->tbm_queue = tbm_surface_queue_create(buffer_count,
+                                                                                                         width,
+                                                                                                         height,
+                                                                                                         TBM_FORMAT_ARGB8888,
+                                                                                                         0);
+       if (!surf_source->tbm_queue) {
+               TPL_ERR("TBM surface queue creation failed!");
+               return TPL_ERROR_OUT_OF_MEMORY;
+       }
+
+       surf_source->format = format;
+       surf_source->swapchain_properties.width = width;
+       surf_source->swapchain_properties.height = height;
+       surf_source->swapchain_properties.present_mode = present_mode;
+       surf_source->swapchain_properties.buffer_count = buffer_count;
+
+       TPL_LOG_T("WL_VK", "[SWAPCHAIN_CREATE][1/2] twe_surface(%p) tbm_queue(%p)",
+                         twe_surface, surf_source->tbm_queue);
+       TPL_LOG_T("WL_VK",
+                         "[SWAPCHAIN_CREATE][2/2] w(%d) h(%d) f(%d) p(%d) b_cnt(%d)",
+                         width, height, present_mode, buffer_count);
+
+       return TPL_ERROR_NONE;
+}
+
+tpl_result_t
+twe_surface_destroy_swapchain(twe_surface_h twe_surface)
+{
+       twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
+
+       if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
+               TPL_ERR("twe_surface(%p) is invalid.", twe_surface);
+               return TPL_ERROR_INVALID_PARAMETER;
+       }
+
+       TPL_LOG_T("WL_VK", "[SWAPCHAIN_DESTROY] twe_surface(%p) tbm_queue(%p)",
+                         twe_surface, surf_source->tbm_queue);
+
+       if (surf_source->tbm_queue) {
+               tbm_surface_queue_destroy(surf_source->tbm_queue);
+               surf_source->tbm_queue = NULL;
+       }
+
+       return TPL_ERROR_NONE;
+}
+
+
+tpl_result_t
 twe_surface_set_rotate_callback(twe_surface_h twe_surface,
                                                                void *data, tpl_surface_cb_func_t rotate_cb)
 {
index 57dd497..c366b43 100644 (file)
@@ -48,6 +48,13 @@ twe_surface_add(twe_thread* thread,
 tpl_result_t
 twe_surface_del(twe_surface_h twe_surface);
 
+tpl_result_t
+twe_surface_create_swapchain(twe_surface_h twe_surface,
+                                                        int width, int height, int format,
+                                                        int buffer_count, int present_mode);
+tpl_result_t
+twe_surface_destroy_swapchain(twe_surface_h twe_surface);
+
 tbm_surface_queue_h
 twe_surface_get_tbm_queue(twe_surface_h twe_surface);