Mesa 21.2.3 Now support VkExternalMemoryImageCreateInfoKHR 68/269968/1
authorTianhao Ni <tianhao.ni@samsung.com>
Thu, 28 Oct 2021 01:36:39 +0000 (09:36 +0800)
committerTianhao Ni <tianhao.ni@samsung.com>
Mon, 24 Jan 2022 01:20:49 +0000 (09:20 +0800)
Change-Id: Ia08011a571d804e4d62be11a550cff29f5c28113
Signed-off-by: Tianhao Ni <tianhao.ni@samsung.com>
packaging/vulkan-wsi-layer.spec
wsi/swapchain_base_tizen.cpp
wsi/swapchain_base_tizen.hpp
wsi/tizen/swapchain.cpp
wsi/tizen/swapchain.hpp

index 5c82e4bf199fa302dc207acbfa2170d533fdbc50..a026e53cc7d35b346c83de7a86ce470962630a26 100644 (file)
@@ -24,7 +24,7 @@ BuildRequires: pkgconfig(libdrm)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: vulkan-headers
 
-#%define VULKAN_ICD mali_nikem
+#%%define VULKAN_ICD mali_nikem
 
 #%define _unpackaged_files_terminate_build 0
 %global TZ_SYS_RO_SHARE  %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share}
@@ -43,6 +43,7 @@ cmake . -Bbuild                     \
 %if "%{VULKAN_ICD}" == "mali_nikem"
         -DUSE_ICD_MALI_NIKEM=ON
 %endif
+
 make -C build
 
 %install
index c488a0a2127e556e7bdce68f8fc379a17e5f64c6..c64d6e5f25ed384892bf0f3773f160dd2e1452bb 100644 (file)
@@ -203,7 +203,6 @@ VkResult swapchain_base::queue_present(VkQueue queue, const VkPresentInfoKHR *pr
    return VK_SUCCESS;
 }
 
-#ifdef USE_ICD_MALI_NIKEM
 VkResult swapchain_base::create_swapchain_images(VkImageCreateInfo* pCreateInfo,
                                                        const VkAllocationCallbacks* pAllocator,
                                                        VkImage* pImage)
@@ -215,7 +214,6 @@ VkResult swapchain_base::bind_swapchain_images(const uint32_t image_index, VkIma
 {
    return bind_external_image(image_index, image);
 }
-#endif
 
 void swapchain_base::deprecate(VkSwapchainKHR descendant)
 {
index 63e97dd0c4ffc31378eae239d117cf3f61016da1..c98d10e88ee78b48f5d311e027c40e4169f1efe7 100644 (file)
@@ -17,9 +17,7 @@ struct swapchain_image
    VkImage image{VK_NULL_HANDLE};
    VkFence present_fence{VK_NULL_HANDLE};
 
-#ifdef USE_ICD_MALI_NIKEM
    bool is_external{false};
-#endif
 };
 
 /**
@@ -93,13 +91,13 @@ public:
     * otherwise returns VK_SUCCESS.
     */
    VkResult queue_present(VkQueue queue, const VkPresentInfoKHR *present_info, const uint32_t image_index, const VkPresentRegionKHR *region);
-#ifdef USE_ICD_MALI_NIKEM
+
    VkResult create_swapchain_images(VkImageCreateInfo* pCreateInfo,
                                           const VkAllocationCallbacks* pAllocator,
                                           VkImage* pImage);
 
    VkResult bind_swapchain_images(const uint32_t image_index, VkImage image);
-#endif
+
 protected:
 
    layer::device_private_data &m_device_data;
@@ -240,11 +238,9 @@ protected:
     * @param image Handle to the image about to be released.
     */
    virtual void destroy_image(void){};
-#ifdef USE_ICD_MALI_NIKEM
    virtual VkResult create_external_image(VkImageCreateInfo* pCreateInfo,
                                            const VkAllocationCallbacks* pAllocator, VkImage* pImage) = 0;
    virtual VkResult bind_external_image(const uint32_t image_index, VkImage image) = 0;
-#endif
 };
 
 } /* namespace wsi */
index 6da418548a4c2851d89eb6a7ac028e0f10936a95..fcea070e6393e91fa7469d3a3fc7b85d0157831e 100644 (file)
@@ -57,6 +57,7 @@ swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCal
 
 swapchain::~swapchain()
 {
+   wsi_info("Release swapchain[%p]", this);
    teardown();
    destroy_image();
    if (m_tpl_surface) {
@@ -145,7 +146,7 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
       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);
+   wsi_info("Get tpl_surface[%p] from tpl_display[%p] for wl_surface[%p]", m_tpl_surface, m_tpl_display, vk_surf->surface);
    if (m_tpl_surface == NULL) {
       format = wsi_tizen_get_tbm_format(pSwapchainCreateInfo->imageFormat, pSwapchainCreateInfo->compositeAlpha);
       m_tpl_surface = tpl_surface_create(m_tpl_display, vk_surf->surface, TPL_SURFACE_TYPE_WINDOW, format);
@@ -180,8 +181,15 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH
    res = tpl_surface_create_swapchain(m_tpl_surface, format,
                                       pSwapchainCreateInfo->imageExtent.width, pSwapchainCreateInfo->imageExtent.height,
                                       pSwapchainCreateInfo->minImageCount, tpl_present_mode);
+   wsi_info("create swapchain with extent: width[%d], height[%d], image count[%d]",
+            pSwapchainCreateInfo->imageExtent.width, pSwapchainCreateInfo->imageExtent.height,
+            pSwapchainCreateInfo->minImageCount);
+
    if (res != TPL_ERROR_NONE) {
       wsi_error("create swapchain failed, ret[%d].\n", res);
+      if (res == TPL_ERROR_OUT_OF_MEMORY) {
+         return VK_ERROR_OUT_OF_HOST_MEMORY;
+      }
       return VK_ERROR_INITIALIZATION_FAILED;
    }
 
@@ -325,11 +333,10 @@ VkResult swapchain::create_image(const VkImageCreateInfo &image_create_info)
       }
 
       tbm_bo bo = tbm_surface_internal_get_bo(buffers[i], 0);
-      tbm_bo_handle bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_3D);
+      //tbm_bo_handle bo_handle = tbm_bo_get_handle(bo, TBM_DEVICE_3D);
       image_data->tbm_buffer = buffers[i];
-      image_data->buffer_fd = bo_handle.u32;//tbm_bo_export_fd(bo);
+      image_data->buffer_fd = tbm_bo_export_fd(bo);//bo_handle.u32;
       image_data->memory = VK_NULL_HANDLE;
-
 #ifndef USE_ICD_MALI_NIKEM
       tbm_surface_info_s info;
       tbm_surface_get_info(buffers[i], &info);
@@ -340,9 +347,7 @@ VkResult swapchain::create_image(const VkImageCreateInfo &image_create_info)
       wsi_info("New image[%d] - tbm_buffer [%p], buffer fd [%d]", i, image_data->tbm_buffer, image_data->buffer_fd);
 
       image.data = static_cast<void *>(image_data);
-#ifdef USE_ICD_MALI_NIKEM
       image.is_external = false;
-#endif
 
       result = allocate_image(image_create_info, image_data, &image.image);
       if (result != VK_SUCCESS)
@@ -421,7 +426,7 @@ void swapchain::destroy_image(void)
          m_device_data.disp.DestroyFence(m_device, image.present_fence, get_allocation_callbacks());
          image.present_fence = VK_NULL_HANDLE;
       }
-#ifdef USE_ICD_MALI_NIKEM
+#if 1
       if (image.image != VK_NULL_HANDLE && !image.is_external)
 #else
       if (image.image != VK_NULL_HANDLE)
@@ -437,7 +442,7 @@ void swapchain::destroy_image(void)
          {
             m_device_data.disp.FreeMemory(m_device, image_data->memory, get_allocation_callbacks());
          }
-         else if (image_data->buffer_fd >= 0)
+         if (image_data->buffer_fd >= 0)
          {
             close(image_data->buffer_fd);
          }
@@ -454,7 +459,6 @@ void swapchain::destroy_image(void)
    }
 }
 
-#ifdef USE_ICD_MALI_NIKEM
 VkResult swapchain::create_external_image(VkImageCreateInfo* pCreateInfo,
                                            const VkAllocationCallbacks* pAllocator, VkImage* pImage)
 {
@@ -502,7 +506,6 @@ VkResult swapchain::bind_external_image(const uint32_t image_index, VkImage imag
 
    return result;
 }
-#endif
 
 } // namespace wayland
 } // namespace wsi
index 8714fd92f2b88eab0ba06315ece82173cac8eadf..63c6788b28c52689eea9e62d8d56fd1b6ddb9fb8 100644 (file)
@@ -79,11 +79,9 @@ protected:
     */
    void destroy_image(void) override;
 
-#ifdef USE_ICD_MALI_NIKEM
    virtual VkResult create_external_image(VkImageCreateInfo* pCreateInfo,
                                            const VkAllocationCallbacks* pAllocator, VkImage* pImage) override;
    virtual VkResult bind_external_image(const uint32_t image_index, VkImage image) override;
-#endif
 
 private:
    struct tizen_image_data;