Call wayland_tbm_client_create_surface_queue_tiled and
authorXuelian Bai <xuelian.bai@samsung.com>
Thu, 7 Mar 2019 11:57:49 +0000 (19:57 +0800)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 3 Apr 2019 07:41:22 +0000 (16:41 +0900)
set flags for  tbm_surface_queue_sequence_create, if
GPU support tiled memory.

Change-Id: I64da5f16368589777b1d53444f00fa976c783202

src/tpl_wayland_egl.c
src/tpl_wayland_egl_thread.c

index 387882d..f358985 100644 (file)
@@ -504,6 +504,9 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
        tpl_wayland_egl_display_t *wayland_egl_display;
        tpl_wayland_egl_surface_t *wayland_egl_surface;
        struct wl_egl_window *wl_egl_window;
+       tbm_bufmgr bufmgr = NULL;
+       unsigned int capability;
+       int flags = TBM_BO_DEFAULT;
 
        TPL_ASSERT(surface);
        TPL_ASSERT(surface->display);
@@ -550,22 +553,39 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface)
                goto alloc_dequeue_buffers_fail;
        }
 
+       bufmgr = tbm_bufmgr_init(-1);
+       capability = tbm_bufmgr_get_capability(bufmgr);
+       tbm_bufmgr_deinit(bufmgr);
+
+       if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY)
+         flags = TBM_BO_TILED;
+
        if (wl_egl_window->surface) {
-               wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue(
-                                                                                        wayland_egl_display->wl_tbm_client,
-                                                                                        wl_egl_window->surface,
-                                                                                        surface->num_buffers,
-                                                                                        wl_egl_window->width,
-                                                                                        wl_egl_window->height,
-                                                                                        surface->format);
+               if (flags == TBM_BO_TILED) {
+                       wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue_tiled(
+                                                                                                wayland_egl_display->wl_tbm_client,
+                                                                                                wl_egl_window->surface,
+                                                                                                surface->num_buffers,
+                                                                                                wl_egl_window->width,
+                                                                                                wl_egl_window->height,
+                                                                                                surface->format);
+               } else {
+                       wayland_egl_surface->tbm_queue = wayland_tbm_client_create_surface_queue(
+                                                                                               wayland_egl_display->wl_tbm_client,
+                                                                                               wl_egl_window->surface,
+                                                                                               surface->num_buffers,
+                                                                                               wl_egl_window->width,
+                                                                                               wl_egl_window->height,
+                                                                                               surface->format);
+               }
        } else
                /*Why wl_surface is NULL ?*/
                wayland_egl_surface->tbm_queue = tbm_surface_queue_sequence_create(
-                                                                                        surface->num_buffers,
-                                                                                        wl_egl_window->width,
-                                                                                        wl_egl_window->height,
-                                                                                        surface->format,
-                                                                                        0);
+                                                                                                surface->num_buffers,
+                                                                                                wl_egl_window->width,
+                                                                                                wl_egl_window->height,
+                                                                                                surface->format,
+                                                                                                flags);
 
        if (!wayland_egl_surface->tbm_queue) {
                TPL_ERR("TBM surface queue creation failed!");
index ce438ff..30227a0 100644 (file)
@@ -2146,6 +2146,8 @@ _twe_surface_create_tbm_queue(twe_wl_surf_source *source,
 {
        tbm_surface_queue_h tbm_queue = NULL;
        struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)native_handle;
+       tbm_bufmgr bufmgr = NULL;
+       unsigned int capability;
 
        if (!wl_tbm_client || !wl_egl_window) {
                TPL_ERR("Invalid parameters. wl_tbm_client(%p) wl_egl_window(%p)",
@@ -2153,13 +2155,27 @@ _twe_surface_create_tbm_queue(twe_wl_surf_source *source,
                return NULL;
        }
 
-       tbm_queue = wayland_tbm_client_create_surface_queue(
-                                       wl_tbm_client,
-                                       wl_egl_window->surface,
-                                       num_buffers,
-                                       wl_egl_window->width,
-                                       wl_egl_window->height,
-                                       format);
+       bufmgr = tbm_bufmgr_init(-1);
+       capability = tbm_bufmgr_get_capability(bufmgr);
+       tbm_bufmgr_deinit(bufmgr);
+
+       if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY) {
+               tbm_queue = wayland_tbm_client_create_surface_queue_tiled(
+                                               wl_tbm_client,
+                                               wl_egl_window->surface,
+                                               num_buffers,
+                                               wl_egl_window->width,
+                                               wl_egl_window->height,
+                                               format);
+       } else {
+               tbm_queue = wayland_tbm_client_create_surface_queue(
+                                               wl_tbm_client,
+                                               wl_egl_window->surface,
+                                               num_buffers,
+                                               wl_egl_window->width,
+                                               wl_egl_window->height,
+                                               format);
+       }
 
        if (!tbm_queue) {
                TPL_ERR("Failed to create tbm_surface_queue.");
@@ -2529,6 +2545,8 @@ twe_surface_create_swapchain(twe_surface_h twe_surface,
        twe_wl_surf_source *surf_source = (twe_wl_surf_source *)twe_surface;
        twe_wl_disp_source *disp_source = NULL;
        GMainContext *context;
+       tbm_bufmgr bufmgr = NULL;
+       unsigned int capability;
 
        if (!surf_source || g_source_is_destroyed(&surf_source->gsource)) {
                TPL_ERR("twe_surface(%p) is invalid.", twe_surface);
@@ -2568,12 +2586,25 @@ twe_surface_create_swapchain(twe_surface_h twe_surface,
                }
        }
 
-       surf_source->tbm_queue = wayland_tbm_client_create_surface_queue(
-                                                               disp_source->wl_tbm_client,
-                                                               surf_source->surf,
-                                                               buffer_count,
-                                                               width, height,
-                                                               TBM_FORMAT_ARGB8888);
+       bufmgr = tbm_bufmgr_init(-1);
+       capability = tbm_bufmgr_get_capability(bufmgr);
+       tbm_bufmgr_deinit(bufmgr);
+
+       if (capability & TBM_BUFMGR_CAPABILITY_TILED_MEMORY) {
+               surf_source->tbm_queue = wayland_tbm_client_create_surface_queue_tiled(
+                                                                       disp_source->wl_tbm_client,
+                                                                       surf_source->surf,
+                                                                       buffer_count,
+                                                                       width, height,
+                                                                       TBM_FORMAT_ARGB8888);
+       } else {
+               surf_source->tbm_queue = wayland_tbm_client_create_surface_queue(
+                                                                       disp_source->wl_tbm_client,
+                                                                       surf_source->surf,
+                                                                       buffer_count,
+                                                                       width, height,
+                                                                       TBM_FORMAT_ARGB8888);
+       }
 
        if (!surf_source->tbm_queue) {
                TPL_ERR("TBM surface queue creation failed!");
@@ -3203,8 +3234,8 @@ twe_surface_queue_force_flush(twe_surface_h twe_surface)
        g_mutex_unlock(&surf_source->surf_mutex);
 
        TPL_LOG_T(BACKEND,
-                         "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)",
-                         surf_source, surf_source->tbm_queue);
+                               "[FORCE_FLUSH] surf_source(%p) tbm_queue(%p)",
+                               surf_source, surf_source->tbm_queue);
 
        return TPL_ERROR_NONE;
 }