diff options
author | Xuelian Bai <xuelian.bai@samsung.com> | 2023-07-19 09:07:18 +0800 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2024-01-16 16:22:49 +0800 |
commit | 0eeda3d1056fc1b5d5f2560ceb465afe90686aae (patch) | |
tree | d128caaaa7efb3293f72e32d209d92e11940d144 | |
parent | 9e149e6c4b60f06b4752ad59910232ed7f265858 (diff) | |
download | vulkan-wsi-layer-0eeda3d1056fc1b5d5f2560ceb465afe90686aae.tar.gz vulkan-wsi-layer-0eeda3d1056fc1b5d5f2560ceb465afe90686aae.tar.bz2 vulkan-wsi-layer-0eeda3d1056fc1b5d5f2560ceb465afe90686aae.zip |
Fix issue for android-cts9 cases on pixel phone
1. Add support for vkGetSwapchainStatusKHR
2. Add support for queue with VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
3. Fixed memory leak issue
Change-Id: I51eb4fad07b4cba0dde89af7d77b3a3d1258a09a
Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r-- | layer/VkLayer_window_system_integration.json | 3 | ||||
-rw-r--r-- | layer/layer.cpp | 2 | ||||
-rw-r--r-- | layer/private_data.hpp | 1 | ||||
-rw-r--r-- | layer/swapchain_api.cpp | 11 | ||||
-rw-r--r-- | layer/swapchain_api.hpp | 3 | ||||
-rw-r--r-- | wsi/swapchain_base.cpp | 18 | ||||
-rw-r--r-- | wsi/tizen/swapchain.cpp | 5 |
7 files changed, 37 insertions, 6 deletions
diff --git a/layer/VkLayer_window_system_integration.json b/layer/VkLayer_window_system_integration.json index 5402133..46d85ca 100644 --- a/layer/VkLayer_window_system_integration.json +++ b/layer/VkLayer_window_system_integration.json @@ -36,7 +36,8 @@ {"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"} + {"name" : "VK_EXT_display_surface_counter", "spec_version" : "1"}, + {"name" : "VK_KHR_shared_presentable_image", "spec_version": "1"} ], "disable_environment": { "DISABLE_WSI_LAYER": "0" diff --git a/layer/layer.cpp b/layer/layer.cpp index e6c2b28..c04d15e 100644 --- a/layer/layer.cpp +++ b/layer/layer.cpp @@ -434,6 +434,8 @@ wsi_layer_vkGetDeviceProcAddr(VkDevice device, const char *funcName) VWL_API_POS GET_PROC_ADDR(vkGetDeviceGroupPresentCapabilitiesKHR); GET_PROC_ADDR(vkGetDeviceGroupSurfacePresentModesKHR); } + if (layer::device_private_data::get(device).is_device_extension_enabled(VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME)) + GET_PROC_ADDR(vkGetSwapchainStatusKHR); GET_PROC_ADDR(vkDestroyDevice); GET_PROC_ADDR(vkCreateImage); diff --git a/layer/private_data.hpp b/layer/private_data.hpp index 352cc9a..244b105 100644 --- a/layer/private_data.hpp +++ b/layer/private_data.hpp @@ -120,6 +120,7 @@ struct instance_dispatch_table /* Vulkan 1.0 */ \ REQUIRED(GetDeviceProcAddr) \ REQUIRED(GetDeviceQueue) \ + REQUIRED(GetDeviceQueue2) \ REQUIRED(QueueSubmit) \ REQUIRED(QueueWaitIdle) \ REQUIRED(CreateCommandPool) \ diff --git a/layer/swapchain_api.cpp b/layer/swapchain_api.cpp index b6dba31..41cd23b 100644 --- a/layer/swapchain_api.cpp +++ b/layer/swapchain_api.cpp @@ -371,3 +371,14 @@ wsi_layer_vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, } return VK_SUCCESS; } +VWL_VKAPI_CALL(VkResult) +wsi_layer_vkGetSwapchainStatusKHR( + VkDevice device, VkSwapchainKHR swapc) VWL_API_POST +{ + layer::device_private_data &device_data = layer::device_private_data::get(device); + + if (!device_data.layer_owns_swapchain(swapc)) + return VK_ERROR_OUT_OF_DATE_KHR; + + return VK_SUCCESS; +} diff --git a/layer/swapchain_api.hpp b/layer/swapchain_api.hpp index df0c146..0f54658 100644 --- a/layer/swapchain_api.hpp +++ b/layer/swapchain_api.hpp @@ -77,3 +77,6 @@ wsi_layer_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, c VWL_VKAPI_CALL(VkResult) wsi_layer_vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo *pBindInfos) VWL_API_POST; + +VWL_VKAPI_CALL(VkResult) +wsi_layer_vkGetSwapchainStatusKHR(VkDevice device, VkSwapchainKHR swapc) VWL_API_POST; diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp index c0a47c9..9974bc7 100644 --- a/wsi/swapchain_base.cpp +++ b/wsi/swapchain_base.cpp @@ -252,10 +252,12 @@ VkResult swapchain_base::init(VkDevice device, const VkSwapchainCreateInfoKHR *s image_create_info.pQueueFamilyIndices = swapchain_create_info->pQueueFamilyIndices; image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + VkDeviceQueueCreateFlags queue_info_flags = 0u; if (swapchain_create_info->flags & VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR) { - image_create_info.flags |= VK_IMAGE_CREATE_PROTECTED_BIT; - image_create_info.initialLayout = VK_IMAGE_LAYOUT_GENERAL; + image_create_info.flags |= VK_IMAGE_CREATE_PROTECTED_BIT; + image_create_info.initialLayout = VK_IMAGE_LAYOUT_GENERAL; + queue_info_flags = VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT; } #if BUILD_WSI_TIZEN VkResult result = m_free_image_semaphore.init(0); @@ -279,7 +281,17 @@ VkResult swapchain_base::init(VkDevice device, const VkSwapchainCreateInfoKHR *s &img.present_semaphore)); } - m_device_data.disp.GetDeviceQueue(m_device, 0, 0, &m_queue); + const VkDeviceQueueInfo2 queueInfo = + { + VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2, // sType + NULL, // pNext + queue_info_flags, // flags + 0, // queueFamilyIndex + 0, // queueIndex + }; + + m_device_data.disp.GetDeviceQueue2(m_device, &queueInfo, &m_queue); + if (!m_queue) { WSI_LOG_ERROR("Device Queue is NULL"); diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp index 631f887..03f82bc 100644 --- a/wsi/tizen/swapchain.cpp +++ b/wsi/tizen/swapchain.cpp @@ -275,6 +275,7 @@ VkResult swapchain::allocate_plane_memory(int fd, VkDeviceMemory *memory) import_mem_info.sType = VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR; import_mem_info.handleType = VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT; import_mem_info.fd = fd; + import_mem_info.pNext = nullptr; VkMemoryAllocateInfo alloc_info = {}; alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; @@ -564,7 +565,7 @@ void swapchain::destroy_image(swapchain_image &image) { m_device_data.disp.FreeMemory(m_device, image_data->memory[plane], get_allocation_callbacks()); } - else if (image_data->buffer_fd[plane] >= 0) + if (image_data->buffer_fd[plane] >= 0) { const auto same_fd_index = get_same_fd_index(image_data->buffer_fd[plane], image_data->buffer_fd); if (same_fd_index == plane) @@ -593,7 +594,7 @@ VkResult swapchain::get_free_buffer(uint64_t *timeout) * 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)); + //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); |