Fix issues of CTS verificate 66/269966/1
authorTianhao Ni <tianhao.ni@samsung.com>
Thu, 26 Aug 2021 07:20:39 +0000 (15:20 +0800)
committerTianhao Ni <tianhao.ni@samsung.com>
Mon, 24 Jan 2022 01:19:34 +0000 (09:19 +0800)
- Fix incorrect TPL calling sequence, remove function:
   vkCreateWaylandSurfaceKHR
   vkDestroySurfaceKHR
- Implement Functions
   vkAcquireNextImage2KHR
   vkGetPhysicalDeviceSurfaceCapabilities2KHR
   vkGetPhysicalDeviceSurfaceCapabilities2EXT
   vkGetPhysicalDeviceSurfaceFormats2KHR
   vkGetPhysicalDevicePresentRectanglesKHR
- Add dlog for debug

Change-Id: I81b13173ff98dd268bb6ba8b6a2acd5231b7961d
Signed-off-by: Tianhao Ni <tianhao.ni@samsung.com>
13 files changed:
layer/VkLayer_window_system_integration.json
layer/layer.cpp
layer/private_data.hpp
layer/surface_api.cpp
layer/surface_api.hpp
layer/swapchain_api.hpp
util/log_util.hpp [new file with mode: 0644]
wsi/surface_properties.hpp
wsi/swapchain_base_tizen.hpp
wsi/tizen/surface_properties.cpp
wsi/tizen/surface_properties.hpp
wsi/tizen/swapchain.cpp
wsi/tizen/swapchain.hpp

index 4390b104415f2cb3a835f64636fa6192158682bb..b63be97c0b1048885e5d980d123696ea1594e1af 100644 (file)
@@ -32,6 +32,9 @@
                 ]
             },
                {"name" : "VK_KHR_incremental_present", "spec_version" : "1"}
+            {"name" : "VK_KHR_get_surface_capabilities2", "spec_version" : "1"},
+            {"name" : "VK_KHR_surface_protected_capabilities", "spec_version" : "1"},
+            {"name" : "VK_EXT_display_surface_counter", "spec_version" : "1"}
         ],
         "disable_environment": {
             "DISABLE_WSI_LAYER": "1"
index 261d954c1659d3489587c4ebf7eb7d77bf722bf9..14923a3cdab03bb20f60cbdada27b8eb559093d6 100644 (file)
@@ -472,6 +472,9 @@ wsi_layer_vkGetInstanceProcAddr(VkInstance instance, const char *funcName) VWL_A
       GET_PROC_ADDR(vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
       GET_PROC_ADDR(vkGetPhysicalDeviceSurfaceFormatsKHR);
       GET_PROC_ADDR(vkGetPhysicalDeviceSurfacePresentModesKHR);
+         GET_PROC_ADDR(vkGetPhysicalDeviceSurfaceCapabilities2KHR);
+      GET_PROC_ADDR(vkGetPhysicalDeviceSurfaceCapabilities2EXT);
+      GET_PROC_ADDR(vkGetPhysicalDeviceSurfaceFormats2KHR);
       GET_PROC_ADDR(vkDestroySurfaceKHR);
    }
 
index 11fa5ce8c02a2458176fe78ab9cbd31b252437b2..a9bd42b39bdd72e43f861ccd82af22bfced0ed23 100644 (file)
@@ -63,7 +63,10 @@ namespace layer
    REQUIRED(GetPhysicalDeviceImageFormatProperties)     \
    REQUIRED(EnumerateDeviceExtensionProperties)         \
    OPTIONAL(GetPhysicalDeviceSurfaceCapabilitiesKHR)    \
+   OPTIONAL(GetPhysicalDeviceSurfaceCapabilities2KHR)   \
+   OPTIONAL(GetPhysicalDeviceSurfaceCapabilities2EXT)   \
    OPTIONAL(GetPhysicalDeviceSurfaceFormatsKHR)         \
+   OPTIONAL(GetPhysicalDeviceSurfaceFormats2KHR)        \
    OPTIONAL(GetPhysicalDeviceSurfacePresentModesKHR)    \
    OPTIONAL(GetPhysicalDeviceSurfaceSupportKHR)         \
    OPTIONAL(CreateHeadlessSurfaceEXT)                   \
index bf9aca6832bb3637af7b2b7bfd8f564dd7b7ab48..7a4f8582f0bdbb1419c2b087b4a233276bd31b56 100644 (file)
@@ -117,3 +117,107 @@ wsi_layer_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
    instance_data.remove_surface(
       surface, util::allocator{ instance_data.get_allocator(), VK_SYSTEM_ALLOCATION_SCOPE_OBJECT, pAllocator });
 }
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
+                                                                        const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+                                                                        VkSurfaceCapabilities2KHR *pSurfaceCapabilities)
+{
+   auto &instance = layer::instance_private_data::get(physicalDevice);
+   if (instance.should_layer_handle_surface(physicalDevice, pSurfaceInfo->surface))
+   {
+      wsi::surface_properties *props = wsi::get_surface_properties(pSurfaceInfo->surface);
+      assert(props != nullptr);
+         const void *pNext = pSurfaceCapabilities->pNext;
+         while (pNext) {
+         VkSurfaceProtectedCapabilitiesKHR *pProctedCap =
+                          const_cast<VkSurfaceProtectedCapabilitiesKHR *>(reinterpret_cast<const VkSurfaceProtectedCapabilitiesKHR *>(pNext));
+         if (pProctedCap->sType == VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR) {
+            pProctedCap->supportsProtected = VK_FALSE;
+                       break;
+                }
+                pNext = pProctedCap->pNext;
+         }
+      return props->get_surface_capabilities(physicalDevice, pSurfaceInfo->surface, &pSurfaceCapabilities->surfaceCapabilities);
+   }
+
+   /* If the layer cannot handle this surface, then necessarily the surface must have been created by the ICDs (or a
+    * layer below us.) So it is safe to assume that the ICDs (or layers below us) support VK_KHR_surface and therefore
+    * it is safe to can call down. This holds for other entrypoints below.
+    */
+   return instance.disp.GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, pSurfaceInfo, pSurfaceCapabilities);
+}
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
+                                                                   const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+                                                                   uint32_t *pSurfaceFormatCount,
+                                                                   VkSurfaceFormat2KHR *pSurfaceFormats)
+{
+   auto &instance = layer::instance_private_data::get(physicalDevice);
+   if (instance.should_layer_handle_surface(physicalDevice, pSurfaceInfo->surface))
+   {
+      wsi::surface_properties *props = wsi::get_surface_properties(pSurfaceInfo->surface);
+      assert(props != nullptr);
+      return props->get_surface_formats_2(physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, pSurfaceFormats);
+   }
+
+   return instance.disp.GetPhysicalDeviceSurfaceFormats2KHR(physicalDevice, pSurfaceInfo, pSurfaceFormatCount,
+                                                           pSurfaceFormats);
+}
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice,
+                                                                        VkSurfaceKHR surface, uint32_t* pRectCount,
+                                                                        VkRect2D* pRects)
+{
+   auto &instance = layer::instance_private_data::get(physicalDevice);
+   if (instance.should_layer_handle_surface(physicalDevice, surface))
+   {
+      wsi::surface_properties *props = wsi::get_surface_properties(surface);
+      assert(props != nullptr);
+      return props->get_surface_present_rects(physicalDevice, surface, pRectCount, pRects);
+   }
+
+   return instance.disp.GetPhysicalDevicePresentRectanglesKHR(physicalDevice, surface, pRectCount, pRects);
+}
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice,
+                                                                            VkSurfaceKHR surface,
+                                                                            VkSurfaceCapabilities2EXT* pSurfaceCapabilities)
+{
+   auto &instance = layer::instance_private_data::get(physicalDevice);
+   if (instance.should_layer_handle_surface(physicalDevice, surface))
+   {
+      VkResult res = VK_SUCCESS;
+      wsi::surface_properties *props = wsi::get_surface_properties(surface);
+      assert(props != nullptr);
+
+         VkSurfaceCapabilitiesKHR surfaceCaps;
+      res = props->get_surface_capabilities(physicalDevice, surface, &surfaceCaps);
+         if (res != VK_SUCCESS)
+            return res;
+
+         pSurfaceCapabilities->minImageCount            = surfaceCaps.minImageCount;
+         pSurfaceCapabilities->maxImageCount            = surfaceCaps.maxImageCount;
+         pSurfaceCapabilities->currentExtent            = surfaceCaps.currentExtent;
+         pSurfaceCapabilities->minImageExtent           = surfaceCaps.minImageExtent;
+         pSurfaceCapabilities->maxImageExtent           = surfaceCaps.maxImageExtent;
+         pSurfaceCapabilities->maxImageArrayLayers      = surfaceCaps.maxImageArrayLayers;
+         pSurfaceCapabilities->supportedTransforms      = surfaceCaps.supportedTransforms;
+         pSurfaceCapabilities->currentTransform         = surfaceCaps.currentTransform;
+         pSurfaceCapabilities->supportedCompositeAlpha  = surfaceCaps.supportedCompositeAlpha;
+         pSurfaceCapabilities->supportedUsageFlags      = surfaceCaps.supportedUsageFlags;
+         pSurfaceCapabilities->supportedSurfaceCounters = 0;
+
+         return VK_SUCCESS;
+   }
+
+   /* If the layer cannot handle this surface, then necessarily the surface must have been created by the ICDs (or a
+   * layer below us.) So it is safe to assume that the ICDs (or layers below us) support VK_KHR_surface and therefore
+   * it is safe to can call down. This holds for other entrypoints below.
+   */
+   return instance.disp.GetPhysicalDeviceSurfaceCapabilities2EXT(physicalDevice, surface, pSurfaceCapabilities);
+
+}
index 8fb570d67b4b48868a460de20341c27c2da3b057..8bda47aee1316e750ae709541068fcbc3d86ff34 100644 (file)
 #include <vulkan/vulkan.h>
 #include "util/macros.hpp"
 
-VKAPI_ATTR VkResult wsi_layer_vkCreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
-                                                              const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
-
-VKAPI_ATTR void wsi_layer_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator);
-
 /**
  * @brief Implements vkGetPhysicalDeviceSurfaceCapabilitiesKHR Vulkan entrypoint.
  */
@@ -73,3 +68,26 @@ wsi_layer_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice,
 VWL_VKAPI_CALL(void)
 wsi_layer_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
                               const VkAllocationCallbacks *pAllocator) VWL_API_POST;
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice,
+                                                                        const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+                                                                        VkSurfaceCapabilities2KHR *pSurfaceCapabilities);
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice,
+                                                                   const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+                                                                   uint32_t *pSurfaceFormatCount,
+                                                                   VkSurfaceFormat2KHR *pSurfaceFormats);
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice,
+                                                                        VkSurfaceKHR surface, uint32_t* pRectCount,
+                                                                        VkRect2D* pRects);
+
+VWL_VKAPI_CALL(VkResult)
+wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2EXT(VkPhysicalDevice physicalDevice,
+                                                                            VkSurfaceKHR surface,
+                                                                            VkSurfaceCapabilities2EXT* pSurfaceCapabilities);
+
+}
index 36f1467c2eb3e59e1b3beff677e17f217b772756..df0c146606680d2e59b25f3da999b4ab098b5d8b 100644 (file)
@@ -57,6 +57,7 @@ VWL_VKAPI_CALL(VkResult)
 wsi_layer_vkGetDeviceGroupPresentCapabilitiesKHR(
    VkDevice device, VkDeviceGroupPresentCapabilitiesKHR *pDeviceGroupPresentCapabilities) VWL_API_POST;
 
+
 VWL_VKAPI_CALL(VkResult)
 wsi_layer_vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface,
                                                  VkDeviceGroupPresentModeFlagsKHR *pModes) VWL_API_POST;
diff --git a/util/log_util.hpp b/util/log_util.hpp
new file mode 100644 (file)
index 0000000..4789199
--- /dev/null
@@ -0,0 +1,8 @@
+#pragma once
+
+#define LOG_TAG "WSI"
+#include <dlog/dlog.h>
+
+#define wsi_info(f, x...)    LOGI(f, ##x)
+#define wsi_error(f, x...)   LOGE(f, ##x)
+
index 23d49f9d8966c6a3d54736690882f32dd86bf744..8bfefd573987a8cbda38d19fa6bb463c00cf2cee 100644 (file)
@@ -55,12 +55,18 @@ public:
    virtual VkResult get_surface_formats(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
                                         uint32_t *surface_format_count, VkSurfaceFormatKHR *surface_formats) = 0;
 
+   virtual VkResult get_surface_formats_2(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
+                                        uint32_t *surface_format_count, VkSurfaceFormat2KHR *surface_formats) = 0;
+
    /**
     * @brief Implementation of vkGetPhysicalDeviceSurfacePresentModesKHR for the specific VkSurface type.
     */
    virtual VkResult get_surface_present_modes(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
                                               uint32_t *present_mode_count, VkPresentModeKHR *present_modes) = 0;
 
+   virtual VkResult get_surface_present_rects(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
+                                              uint32_t* pRectCount, VkRect2D* pRects) = 0;
+
    /**
     * @brief Return the device extensions that this surface_properties implementation needs.
     */
index 308384ac214d434c242d29b0c696918e67f13cd0..b020c805ac983d0346939f62bafe3a7a5e472a1d 100644 (file)
@@ -5,12 +5,7 @@
 #include <layer/private_data.hpp>
 #include <util/timed_semaphore.hpp>
 #include <util/custom_allocator.hpp>
-
-#define LOG_TAG "WSI"
-#include <dlog/dlog.h>
-
-#define wsi_info(f, x...)    LOGI(f, ##x)
-#define wsi_error(f, x...)   LOGE(f, ##x)
+#include <util/log_util.hpp>
 
 namespace wsi
 {
index cfdae9b9df396bc55c87bb0ebed837fe7fa718a2..ea89d6e341383bad38890509575d1170d64b1049 100644 (file)
@@ -57,17 +57,24 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_
    if (vk_surf == NULL || vk_surf->display == NULL || vk_surf->surface == NULL)
       return VK_ERROR_SURFACE_LOST_KHR;
 
-   tpl_display_t *tpl_display = tpl_display_get(reinterpret_cast<tpl_handle_t>(vk_surf->display));
-   if (!tpl_display) {
-      return VK_ERROR_SURFACE_LOST_KHR;
+   tpl_display_t *tpl_display = tpl_display_get_with_backend_type(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
+   if (tpl_display) {
+      tpl_object_reference(reinterpret_cast<tpl_object_t *>(tpl_display));
+   } else {
+      tpl_display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
    }
 
+   if (!tpl_display)
+      return VK_ERROR_SURFACE_LOST_KHR;
+
    int cnt_min = 0, cnt_max = 0;
    res = tpl_display_query_supported_buffer_count_from_native_window(tpl_display, vk_surf->display, &cnt_min, &cnt_max);
    if (res != TPL_ERROR_NONE) {
       return VK_ERROR_SURFACE_LOST_KHR;
    }
 
+   tpl_object_unreference(reinterpret_cast<tpl_object_t *>(tpl_display));
+
    /* Image count limits */
    pSurfaceCapabilities->minImageCount = cnt_min;
    pSurfaceCapabilities->maxImageCount = cnt_max;
@@ -133,6 +140,38 @@ VkResult surface_properties::get_surface_formats(VkPhysicalDevice physical_devic
    return res;
 }
 
+VkResult surface_properties::get_surface_formats_2(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
+                                                 uint32_t *surfaceFormatCount, VkSurfaceFormat2KHR *surfaceFormats)
+{
+
+   VkResult res = VK_SUCCESS;
+   /* TODO: Hardcoding a list of sensible formats, may be query it from compositor later. */
+   static std::array<const VkFormat, 2> formats = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_SRGB };
+
+   assert(surfaceFormatCount != nullptr);
+   res = VK_SUCCESS;
+   if (nullptr == surfaceFormats)
+   {
+      *surfaceFormatCount = formats.size();
+   }
+   else
+   {
+      if (formats.size() > *surfaceFormatCount)
+      {
+         res = VK_INCOMPLETE;
+      }
+
+      *surfaceFormatCount = std::min(*surfaceFormatCount, static_cast<uint32_t>(formats.size()));
+      for (uint32_t i = 0; i < *surfaceFormatCount; ++i)
+      {
+         surfaceFormats[i].surfaceFormat.format = formats[i];
+         surfaceFormats[i].surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
+      }
+   }
+
+   return res;
+}
+
 VkResult surface_properties::get_surface_present_modes(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
                                                        uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
 {
@@ -142,16 +181,23 @@ VkResult surface_properties::get_surface_present_modes(VkPhysicalDevice physical
    if (vk_surf == NULL || vk_surf->display == NULL || vk_surf->surface == NULL)
       return VK_ERROR_SURFACE_LOST_KHR;
 
-   tpl_display_t *tpl_display = tpl_display_get(reinterpret_cast<tpl_handle_t>(vk_surf->display));
-   if (!tpl_display) {
-      return VK_ERROR_SURFACE_LOST_KHR;
+   tpl_display_t *tpl_display = tpl_display_get_with_backend_type(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
+   if (tpl_display) {
+      tpl_object_reference(reinterpret_cast<tpl_object_t *>(tpl_display));
+   } else {
+      tpl_display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
    }
 
+   if (!tpl_display)
+      return VK_ERROR_SURFACE_LOST_KHR;
+
    int tplModes;
    if (tpl_display_query_supported_present_modes_from_native_window(tpl_display, vk_surf->display, &tplModes) != TPL_ERROR_NONE) {
       return VK_ERROR_SURFACE_LOST_KHR;
    }
 
+   tpl_object_unreference(reinterpret_cast<tpl_object_t *>(tpl_display));
+
    std::vector<VkPresentModeKHR> modes = {};
    if (tplModes & TPL_DISPLAY_PRESENT_MODE_IMMEDIATE)
       modes.push_back(VK_PRESENT_MODE_IMMEDIATE_KHR);
@@ -184,6 +230,33 @@ VkResult surface_properties::get_surface_present_modes(VkPhysicalDevice physical
    return res;
 }
 
+VkResult surface_properties::get_surface_present_rects(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
+                                                               uint32_t* pRectCount, VkRect2D* pRects)
+{
+   VkResult res = VK_SUCCESS;
+
+   if (nullptr == pRects)
+   {
+      *pRectCount = 1;
+      res = VK_SUCCESS;
+   }
+   else if (0 == *pRectCount)
+   {
+      res = VK_INCOMPLETE;
+   }
+   else
+   {
+      *pRectCount = 1;
+      pRects[0].offset.x = 0;
+      pRects[0].offset.y = 0;
+      pRects[0].extent = { 0xffffffff, 0xffffffff };
+
+      res = VK_SUCCESS;
+   }
+
+   return res;
+}
+
 static const char *required_device_extensions[] = {
    VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
    VK_KHR_BIND_MEMORY_2_EXTENSION_NAME,
index 444c6a351c7081993bc0cf7b9a77301b3435b5c3..f385030e75625683099c69dd69fdaa3378db4a57 100644 (file)
@@ -40,8 +40,12 @@ public:
                                      VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) override;
    VkResult get_surface_formats(VkPhysicalDevice physical_device, VkSurfaceKHR surface, uint32_t *surfaceFormatCount,
                                 VkSurfaceFormatKHR *surfaceFormats) override;
+   VkResult get_surface_formats_2(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
+                                        uint32_t *surface_format_count, VkSurfaceFormat2KHR *surface_formats) override;
    VkResult get_surface_present_modes(VkPhysicalDevice physical_device, VkSurfaceKHR surface,
                                       uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes) override;
+   VkResult get_surface_present_rects(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface,
+                                      uint32_t* pRectCount, VkRect2D* pRects) override;
 
    const util::extension_list &get_required_device_extensions() override;
 
index 62294333218071e90728577f468238574fb8e5c8..a6f28a5147cf361d1d35f51b1a90da29075416c1 100644 (file)
@@ -50,6 +50,7 @@ struct swapchain::tizen_image_data
 
 swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCallbacks *pAllocator)
    : swapchain_base(dev_data, pAllocator)
+   , m_tpl_display(nullptr)
    , m_tpl_surface(nullptr)
 {
 }
@@ -62,6 +63,9 @@ swapchain::~swapchain()
       tpl_surface_destroy_swapchain(m_tpl_surface);
       tpl_object_unreference((tpl_object_t *)m_tpl_surface);
    }
+   if (m_tpl_display) {
+      tpl_object_unreference((tpl_object_t *)m_tpl_display);
+   }
 }
 
 #define TBM_FORMAT_0   0
@@ -130,17 +134,21 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
    int tpl_present_mode;
    tpl_result_t res;
 
-   tpl_display_t *tpl_display = tpl_display_get(reinterpret_cast<tpl_handle_t>(vk_surf->display));
-   if (!tpl_display) {
-      wsi_error("Get tpl display failed\n");
-      return VK_ERROR_SURFACE_LOST_KHR;
+   m_tpl_display = tpl_display_get_with_backend_type(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
+   if (m_tpl_display) {
+      tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_display));
+   } else {
+      m_tpl_display = tpl_display_create(TPL_BACKEND_WAYLAND_VULKAN_WSI_THREAD, reinterpret_cast<tpl_handle_t>(vk_surf->display));
    }
 
-   m_tpl_surface = tpl_surface_get(tpl_display, vk_surf->surface);
-   wsi_info("Get tpl_surface[%p] from tpl_display[%p]", m_tpl_surface, tpl_display);
+   if (!m_tpl_display)
+      return VK_ERROR_SURFACE_LOST_KHR;
+
+   m_tpl_surface = tpl_surface_get(m_tpl_display, vk_surf->surface);
+   wsi_info("Get tpl_surface[%p] from tpl_display[%p]", m_tpl_surface, m_tpl_display);
    if (m_tpl_surface == NULL) {
       format = wsi_tizen_get_tbm_format(pSwapchainCreateInfo->imageFormat, pSwapchainCreateInfo->compositeAlpha);
-      m_tpl_surface = tpl_surface_create(tpl_display, vk_surf->surface, TPL_SURFACE_TYPE_WINDOW, format);
+      m_tpl_surface = tpl_surface_create(m_tpl_display, vk_surf->surface, TPL_SURFACE_TYPE_WINDOW, format);
    } else {
       wsi_error("tpl_surface[%p] already in use", m_tpl_surface);
       return VK_ERROR_INITIALIZATION_FAILED;
index b6424271e965d4d583a6b8e1f56957c357ed8d2b..d2c277c70e6f068ecbcb23d8221f0f9572cb5b70 100644 (file)
@@ -83,7 +83,7 @@ private:
    struct tizen_image_data;
    VkResult allocate_image(const VkImageCreateInfo &image_create_info, tizen_image_data *image_data, VkImage *image);
 
-   //tpl_display_t *m_tpl_display;
+   tpl_display_t *m_tpl_display;
    tpl_surface_t *m_tpl_surface;
 
 };