diff options
author | Joonbum Ko <joonbum.ko@samsung.com> | 2022-04-05 15:25:15 +0900 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2024-01-16 16:22:49 +0800 |
commit | 02d862ecc0f95ce7dc60f526f6785ebf5e83c168 (patch) | |
tree | 318ae0732a1199a0d62047538afb064271789465 | |
parent | 17390af377a2b2c8842d2c5a5d28794ce5042db0 (diff) | |
download | vulkan-wsi-layer-02d862ecc0f95ce7dc60f526f6785ebf5e83c168.tar.gz vulkan-wsi-layer-02d862ecc0f95ce7dc60f526f6785ebf5e83c168.tar.bz2 vulkan-wsi-layer-02d862ecc0f95ce7dc60f526f6785ebf5e83c168.zip |
Fix to support swapchain re-create
Change-Id: I062e7dbc138da2a25fa5aebc2c628a139f3bfe1c
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
Fix to support swapchain re-create
Change-Id: I062e7dbc138da2a25fa5aebc2c628a139f3bfe1c
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
-rw-r--r-- | layer/swapchain_api.cpp | 6 | ||||
-rw-r--r-- | wsi/tizen/swapchain.cpp | 19 |
2 files changed, 18 insertions, 7 deletions
diff --git a/layer/swapchain_api.cpp b/layer/swapchain_api.cpp index c188b74..b6dba31 100644 --- a/layer/swapchain_api.cpp +++ b/layer/swapchain_api.cpp @@ -39,15 +39,15 @@ #include <util/helpers.hpp> #include <util/log.hpp> -static bool swapchain_on_prensent = false; +//static bool swapchain_on_prensent = false; VWL_VKAPI_CALL(VkResult) wsi_layer_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pSwapchainCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain) VWL_API_POST { - if (swapchain_on_prensent) { + /*if (swapchain_on_prensent) { WSI_LOG_ERROR("Already created other swapchain"); return VK_ERROR_INITIALIZATION_FAILED; - } + }*/ assert(pSwapchain != nullptr); layer::device_private_data &device_data = layer::device_private_data::get(device); diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp index 076ae6b..fa40b61 100644 --- a/wsi/tizen/swapchain.cpp +++ b/wsi/tizen/swapchain.cpp @@ -86,9 +86,8 @@ swapchain::~swapchain() if (m_tpl_surface) { tpl_surface_destroy_swapchain(m_tpl_surface); tpl_object_unreference((tpl_object_t *)m_tpl_surface); - - tpl_object_get_reference((tpl_object_t *)m_tpl_surface); } + if (m_tpl_display) { tpl_object_unreference((tpl_object_t *)m_tpl_display); } @@ -139,6 +138,8 @@ wsi_tizen_get_tbm_format(VkFormat format, VkCompositeAlphaFlagBitsKHR comp) /* 8 8 8 8 */ case VK_FORMAT_B8G8R8A8_UNORM: RETURN_FORMAT(comp, XRGB8888, ARGB8888, 0, ARGB8888); + case VK_FORMAT_R8G8B8A8_UNORM: + RETURN_FORMAT(comp, RGBA8888, RGBA8888, 0, RGBA8888); case VK_FORMAT_A8B8G8R8_UNORM_PACK32: RETURN_FORMAT(comp, XBGR8888, ABGR8888, 0, ABGR8888); /* 2 10 10 10 */ @@ -176,8 +177,8 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH format = wsi_tizen_get_tbm_format(swapchain_create_info->imageFormat, swapchain_create_info->compositeAlpha); m_tpl_surface = tpl_surface_create(m_tpl_display, m_wl_surface, TPL_SURFACE_TYPE_WINDOW, format); } else { - WSI_LOG_ERROR("tpl_surface[%p] already in use", m_tpl_surface); - return VK_ERROR_INITIALIZATION_FAILED; + format = wsi_tizen_get_tbm_format(swapchain_create_info->imageFormat, swapchain_create_info->compositeAlpha); + tpl_object_unreference(reinterpret_cast<tpl_object_t *>(m_tpl_display)); } if (m_tpl_surface == NULL) { @@ -239,6 +240,7 @@ VkResult swapchain::init_platform(VkDevice device, const VkSwapchainCreateInfoKH m_tbm_buffers.insert(std::make_pair(buffers[i], false)); } + m_swapchain_images.try_resize(tbm_buf_cnt); // Tizen platform don't need page flip thread to manage buffer use_presentation_thread = false; @@ -600,6 +602,15 @@ VkResult swapchain::get_free_buffer(uint64_t *timeout) tbm_surface_h tbm_buf = tpl_surface_dequeue_buffer_with_sync(m_tpl_surface, *timeout, NULL); if (tbm_buf == NULL) { + if (tpl_surface_validate(m_tpl_surface) == TPL_FALSE) { + /* Returning VK_ERROR_OUT_OF_DATE_KHR calls swapchain_tpl_deinit + * to destroy the existing swapchain, but does not want the existing + * tpl_surface and tpl_display to be destroyed. */ + tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_display)); + tpl_object_reference(reinterpret_cast<tpl_object_t *>(m_tpl_surface)); + return VK_ERROR_OUT_OF_DATE_KHR; + } + WSI_LOG_ERROR("Dequeue buffer failed, swapchain [%p], tpl_surface [%p]", this, m_tpl_surface); return VK_ERROR_SURFACE_LOST_KHR; } |