tbm_queue_surface: modified tbm_queue_surface related funcs 99/104799/3
authordeasung.kim <deasung.kim@samsung.com>
Wed, 14 Dec 2016 09:38:15 +0000 (18:38 +0900)
committerGwan-gyeong Mun <kk.moon@samsung.com>
Wed, 11 Jan 2017 09:38:38 +0000 (01:38 -0800)
handle new WSI surface type VK_ICD_WSI_PLATFORM_TBM_QUEUE

Change-Id: I68c796ee1743902920a5ee5e481f0e97ea2a943a

src/wsi/surface.c
src/wsi/swapchain.c
src/wsi/swapchain_tpl.c
src/wsi/wsi.h

index f9492a7..2bfcfad 100644 (file)
@@ -45,20 +45,24 @@ vk_GetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice       pdev,
 }
 
 static VkResult
-tpl_get_surface_capabilities(VkIcdSurfaceWayland               *sfc,
+tpl_get_surface_capabilities(VkIcdSurfaceBase                  *sfc,
                                                         VkSurfaceCapabilitiesKHR       *caps)
 {
        tpl_display_t           *display;
        int                                      min, max;
        tpl_result_t             res;
+       tpl_handle_t             native_window;
 
-       display = vk_get_tpl_display(sfc->display);
+       display = vk_get_tpl_display(sfc);
        VK_CHECK(display, return VK_ERROR_DEVICE_LOST, "vk_get_tpl_display() failed.\n");
 
-       res = tpl_display_query_supported_buffer_count_from_native_window(display, sfc->surface, &min, &max);
+       native_window = vk_get_tpl_native_window(sfc);
+       res = tpl_display_query_supported_buffer_count_from_native_window(display, native_window,
+                                                                                                                                         &min, &max);
        VK_CHECK(res == TPL_ERROR_NONE, return VK_ERROR_DEVICE_LOST,
                         "tpl_display_query_native_window_supported_buffer_count() failed.\n");
 
+
        /* TODO: Hard-coded. */
        caps->minImageCount = min;
        caps->maxImageCount = max;
@@ -142,8 +146,12 @@ vk_GetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice                         pdev,
                                                                                   VkSurfaceCapabilitiesKHR     *caps)
 {
        switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
                case VK_ICD_WSI_PLATFORM_WAYLAND:
-                       return tpl_get_surface_capabilities((VkIcdSurfaceWayland *)
+                       return tpl_get_surface_capabilities((VkIcdSurfaceBase *)
                                                                                                (uintptr_t)surface, caps);
                case VK_ICD_WSI_PLATFORM_DISPLAY:
                        return tdm_get_surface_capabilities((VkIcdSurfaceDisplay *)
@@ -187,7 +195,7 @@ static const struct {
 };
 
 static VkResult
-tpl_get_surface_formats(VkIcdSurfaceWayland    *sfc,
+tpl_get_surface_formats(VkIcdSurfaceBase       *sfc,
                                                uint32_t                        *format_count,
                                                VkSurfaceFormatKHR      *formats)
 {
@@ -284,8 +292,12 @@ vk_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice              pdev,
                                                                          VkSurfaceFormatKHR    *formats)
 {
        switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
                case VK_ICD_WSI_PLATFORM_WAYLAND:
-                       return tpl_get_surface_formats((VkIcdSurfaceWayland *)
+                       return tpl_get_surface_formats((VkIcdSurfaceBase *)
                                                                                   (uintptr_t)surface, format_count, formats);
                case VK_ICD_WSI_PLATFORM_DISPLAY:
                        return tdm_get_surface_formats((VkIcdSurfaceDisplay *)
@@ -296,22 +308,21 @@ vk_GetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice             pdev,
 }
 
 static VkResult
-tpl_get_surface_present_modes(VkIcdSurfaceWayland      *sfc,
+tpl_get_surface_present_modes(VkIcdSurfaceBase *sfc,
                                                          uint32_t                              *mode_count,
                                                          VkPresentModeKHR              *modes)
 {
        tpl_display_t           *display;
        tpl_result_t             res;
+       tpl_handle_t             native_window;
        int                                      tpl_support_modes;
        uint32_t                         support_mode_cnt = 0;
 
-       VK_CHECK(sfc->base.platform == VK_ICD_WSI_PLATFORM_WAYLAND, return VK_ERROR_DEVICE_LOST,
-                        "Not supported platform surface.\n");
-
-       display = vk_get_tpl_display(sfc->display);
+       display = vk_get_tpl_display(sfc);
        VK_CHECK(display, return VK_ERROR_DEVICE_LOST, "vk_get_tpl_display() failed.\n");
 
-       res = tpl_display_query_supported_present_modes_from_native_window(display, sfc->surface,
+       native_window = vk_get_tpl_native_window(sfc);
+       res = tpl_display_query_supported_present_modes_from_native_window(display, native_window,
                                                                                                                                           &tpl_support_modes);
        tpl_object_unreference((tpl_object_t *)display);
        VK_CHECK(res == TPL_ERROR_NONE, return VK_ERROR_DEVICE_LOST,
@@ -385,8 +396,12 @@ vk_GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice         pdev,
                                                                                   VkPresentModeKHR     *modes)
 {
        switch (((VkIcdSurfaceBase *)(uintptr_t)surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
                case VK_ICD_WSI_PLATFORM_WAYLAND:
-                       return tpl_get_surface_present_modes((VkIcdSurfaceWayland *)
+                       return tpl_get_surface_present_modes((VkIcdSurfaceBase *)
                                                                                                 (uintptr_t)surface, mode_count, modes);
                case VK_ICD_WSI_PLATFORM_DISPLAY:
                        return tdm_get_surface_present_modes((VkIcdSurfaceDisplay *)
index 543ea2a..0f839dc 100644 (file)
@@ -102,6 +102,10 @@ vk_CreateSwapchainKHR(VkDevice                                                      device,
        vk_icd_t                        *icd = vk_get_icd();
 
        switch(((VkIcdSurfaceBase *)(uintptr_t)info->surface)->platform) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+#pragma GCC diagnostic pop
                case VK_ICD_WSI_PLATFORM_WAYLAND:
                        init = swapchain_tpl_init;
                        break;
index 1d9812d..9612fae 100644 (file)
@@ -126,8 +126,9 @@ swapchain_tpl_init(VkDevice                                                  device,
                                   tbm_format                                            format)
 {
        tpl_result_t             res;
-       VkIcdSurfaceWayland     *surface = (VkIcdSurfaceWayland *)(uintptr_t)info->surface;
+       VkIcdSurfaceBase        *surface = (VkIcdSurfaceBase *)(uintptr_t)info->surface;
        vk_swapchain_tpl_t      *swapchain_tpl;
+       tpl_handle_t             native_window;
        int                                      tpl_present_mode;
 
        VkResult error = VK_ERROR_DEVICE_LOST;
@@ -140,11 +141,12 @@ swapchain_tpl_init(VkDevice                                                        device,
 
        /* Don't check NULL for display and window. There might be default ones for some systems. */
 
-       swapchain_tpl->tpl_display = vk_get_tpl_display(surface->display);
+       swapchain_tpl->tpl_display = vk_get_tpl_display(surface);
        VK_CHECK(swapchain_tpl->tpl_display, goto error, "vk_get_tpl_display() failed.\n");
+       native_window = vk_get_tpl_native_window(surface);
 
        swapchain_tpl->tpl_surface = tpl_surface_create(swapchain_tpl->tpl_display,
-                                                                                                                  surface->surface,
+                                                                                                                  native_window,
                                                                                                                   TPL_SURFACE_TYPE_WINDOW, format);
        VK_CHECK(swapchain_tpl->tpl_surface, goto error, "tpl_surface_create() failed.\n");
 
index 1980e3c..e629922 100644 (file)
@@ -173,10 +173,28 @@ vk_realloc(const VkAllocationCallbacks *allocator, void *mem, size_t size,
 void
 vk_free(const VkAllocationCallbacks *allocator, void *mem);
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wswitch"
 static inline tpl_display_t *
-vk_get_tpl_display(tpl_handle_t native_dpy)
+vk_get_tpl_display(VkIcdSurfaceBase            *sfc)
 {
-       tpl_display_t *display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI, native_dpy);
+       tpl_backend_type_t type = TPL_BACKEND_UNKNOWN;
+       tpl_handle_t native_dpy = NULL;
+
+       switch (sfc->platform) {
+               case VK_ICD_WSI_PLATFORM_WAYLAND:
+                       type = TPL_BACKEND_WAYLAND_VULKAN_WSI;
+                       native_dpy = ((VkIcdSurfaceWayland *)(uintptr_t)sfc)->display;
+                       break;
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+                       type = TPL_BACKEND_TBM;
+                       native_dpy = ((vk_tbm_queue_surface_t *)(uintptr_t)sfc)->bufmgr;
+                       break;
+               default:
+                       return NULL;
+       }
+
+       tpl_display_t *display = tpl_display_create(type, native_dpy);
        if (display == NULL) {
                display = tpl_display_get(native_dpy);
                tpl_object_reference((tpl_object_t *)display);
@@ -184,6 +202,21 @@ vk_get_tpl_display(tpl_handle_t native_dpy)
        return display;
 };
 
+static inline tpl_handle_t
+vk_get_tpl_native_window(VkIcdSurfaceBase              *sfc)
+{
+       switch (sfc->platform) {
+               case VK_ICD_WSI_PLATFORM_WAYLAND:
+                       return ((VkIcdSurfaceWayland *)(uintptr_t)sfc)->surface;
+               case VK_ICD_WSI_PLATFORM_TBM_QUEUE:
+                       return ((vk_tbm_queue_surface_t *)(uintptr_t)sfc)->tbm_queue;
+               default:
+                       return NULL;
+       }
+       return NULL;
+}
+#pragma GCC diagnostic pop
+
 VkResult
 swapchain_tpl_init(VkDevice device, const VkSwapchainCreateInfoKHR *info,
                                   vk_swapchain_t *chain, tbm_format format);