diff options
author | Xuelian Bai <xuelian.bai@samsung.com> | 2023-10-19 09:44:15 +0800 |
---|---|---|
committer | Xuelian Bai <xuelian.bai@samsung.com> | 2024-01-16 16:22:49 +0800 |
commit | c09a7161c8563f86bf882a5645b172f11debac12 (patch) | |
tree | 71c1851afbafb6d3b3b738e01833ca0d9a9cee5d | |
parent | 0eeda3d1056fc1b5d5f2560ceb465afe90686aae (diff) | |
download | vulkan-wsi-layer-c09a7161c8563f86bf882a5645b172f11debac12.tar.gz vulkan-wsi-layer-c09a7161c8563f86bf882a5645b172f11debac12.tar.bz2 vulkan-wsi-layer-c09a7161c8563f86bf882a5645b172f11debac12.zip |
Fix some issues for pvr riscv & pixel phone
1. Fix
dEQP-VK.api.info.get_physical_device_properties2.features.
image_compression_control_swapchain_features_ext
failed issue.
2. Add support for vkGetPhysicalDeviceSurfaceCapabilities2KHR
3. Call vkGetDeviceQueue2 only for VK_IMAGE_CREATE_PROTECTED_BIT,
or pvr ICD and pixel phone ICD will crash
Change-Id: Ia05100a3bb8159bce0ce93ebca225b4ac41ddfa5
Signed-Off-by: Xuelian Bai <xuelian.bai@samsung.com>
-rw-r--r-- | layer/layer.cpp | 5 | ||||
-rw-r--r-- | layer/private_data.hpp | 4 | ||||
-rw-r--r-- | layer/surface_api.cpp | 2 | ||||
-rw-r--r-- | packaging/vulkan-wsi-layer.spec | 2 | ||||
-rw-r--r-- | wsi/surface_properties.hpp | 3 | ||||
-rw-r--r-- | wsi/swapchain_base.cpp | 34 | ||||
-rw-r--r-- | wsi/tizen/surface_properties.cpp | 54 | ||||
-rw-r--r-- | wsi/tizen/surface_properties.hpp | 2 | ||||
-rw-r--r-- | wsi/tizen/swapchain.cpp | 16 | ||||
-rw-r--r-- | wsi/tizen/swapchain.hpp | 3 |
10 files changed, 91 insertions, 34 deletions
diff --git a/layer/layer.cpp b/layer/layer.cpp index c04d15e..705cb4c 100644 --- a/layer/layer.cpp +++ b/layer/layer.cpp @@ -375,8 +375,7 @@ wsi_layer_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateIn } VWL_VKAPI_CALL(VkResult) -VWL_VKAPI_EXPORT wsi_layer_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) - VWL_API_POST +VWL_VKAPI_EXPORT wsi_layer_vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct) VWL_API_POST { WSI_LOG_INFO("Call Api - [%s]", __func__); assert(pVersionStruct); @@ -496,7 +495,7 @@ wsi_layer_vkGetInstanceProcAddr(VkInstance instance, const char *funcName) VWL_A GET_PROC_ADDR(vkCreateDevice); GET_PROC_ADDR(vkGetPhysicalDevicePresentRectanglesKHR); - if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures2")) + if (!strcmp(funcName, "vkGetPhysicalDeviceFeatures2") || !strcmp(funcName, "vkGetPhysicalDeviceFeatures2KHR")) { return (PFN_vkVoidFunction)wsi_layer_vkGetPhysicalDeviceFeatures2KHR; } diff --git a/layer/private_data.hpp b/layer/private_data.hpp index 244b105..f25406a 100644 --- a/layer/private_data.hpp +++ b/layer/private_data.hpp @@ -120,7 +120,6 @@ struct instance_dispatch_table /* Vulkan 1.0 */ \ REQUIRED(GetDeviceProcAddr) \ REQUIRED(GetDeviceQueue) \ - REQUIRED(GetDeviceQueue2) \ REQUIRED(QueueSubmit) \ REQUIRED(QueueWaitIdle) \ REQUIRED(CreateCommandPool) \ @@ -165,7 +164,8 @@ struct instance_dispatch_table OPTIONAL(GetFenceFdKHR) \ OPTIONAL(ImportFenceFdKHR) \ /* VK_KHR_external_semaphore_fd */ \ - OPTIONAL(ImportSemaphoreFdKHR) + OPTIONAL(ImportSemaphoreFdKHR) \ + OPTIONAL(GetDeviceQueue2) struct device_dispatch_table { diff --git a/layer/surface_api.cpp b/layer/surface_api.cpp index efdfbca..1085f3d 100644 --- a/layer/surface_api.cpp +++ b/layer/surface_api.cpp @@ -75,7 +75,7 @@ wsi_layer_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDe * swapchain implementation so it is safe to ignore pNext here, even if * the extensions are supported by the ICD. */ - return props->get_surface_capabilities(physicalDevice, &pSurfaceCapabilities->surfaceCapabilities); + return props->get_surface_capabilities2(physicalDevice, pSurfaceCapabilities); } return instance.disp.GetPhysicalDeviceSurfaceCapabilities2KHR(physicalDevice, pSurfaceInfo, pSurfaceCapabilities); diff --git a/packaging/vulkan-wsi-layer.spec b/packaging/vulkan-wsi-layer.spec index 341ff53..a0e7094 100644 --- a/packaging/vulkan-wsi-layer.spec +++ b/packaging/vulkan-wsi-layer.spec @@ -41,7 +41,7 @@ cp %{SOURCE1001} . cmake . -Bbuild \ -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_WSI_TIZEN=ON \ - -DBUILD_WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN=ON + -DBUILD_WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN=ON make -C build diff --git a/wsi/surface_properties.hpp b/wsi/surface_properties.hpp index aa75da0..fb59699 100644 --- a/wsi/surface_properties.hpp +++ b/wsi/surface_properties.hpp @@ -53,6 +53,9 @@ public: virtual VkResult get_surface_capabilities(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *surface_capabilities) = 0; + virtual VkResult get_surface_capabilities2(VkPhysicalDevice physical_device, + VkSurfaceCapabilities2KHR *surface_capabilities) = 0; + /** * @brief Implementation of vkGetPhysicalDeviceSurfaceFormatsKHR for the specific VkSurface type. */ diff --git a/wsi/swapchain_base.cpp b/wsi/swapchain_base.cpp index 9974bc7..1e3de16 100644 --- a/wsi/swapchain_base.cpp +++ b/wsi/swapchain_base.cpp @@ -252,13 +252,6 @@ 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; - queue_info_flags = VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT; - } #if BUILD_WSI_TIZEN VkResult result = m_free_image_semaphore.init(0); #else @@ -281,16 +274,25 @@ VkResult swapchain_base::init(VkDevice device, const VkSwapchainCreateInfoKHR *s &img.present_semaphore)); } - const VkDeviceQueueInfo2 queueInfo = + if (swapchain_create_info->flags & VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR) { - 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); + VkDeviceQueueCreateFlags queue_info_flags = 0u; + 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; + + 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); + } + else + m_device_data.disp.GetDeviceQueue(m_device, 0, 0, &m_queue); if (!m_queue) { diff --git a/wsi/tizen/surface_properties.cpp b/wsi/tizen/surface_properties.cpp index 30af26c..81a7170 100644 --- a/wsi/tizen/surface_properties.cpp +++ b/wsi/tizen/surface_properties.cpp @@ -123,37 +123,69 @@ VkResult surface_properties::get_surface_capabilities(VkPhysicalDevice physical_ return VK_SUCCESS; } +VkResult surface_properties::get_surface_capabilities2(VkPhysicalDevice physical_device, + VkSurfaceCapabilities2KHR *surface_capabilities) +{ + assert(surface_capabilities->sType == VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR); + + VkResult result = + get_surface_capabilities(physical_device, + &surface_capabilities->surfaceCapabilities); + + VkSurfaceCapabilities2KHR* caps = surface_capabilities; + while(caps->pNext) + { + caps = (VkSurfaceCapabilities2KHR*)caps->pNext; + + if (caps->sType == VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR) + { + VkSurfaceProtectedCapabilitiesKHR* protected_caps = (VkSurfaceProtectedCapabilitiesKHR *)caps; + protected_caps->supportsProtected = VK_FALSE; + } + } + return result; +} + VkResult surface_properties::get_surface_formats(VkPhysicalDevice physical_device, uint32_t *surfaceFormatCount, VkSurfaceFormatKHR *surfaceFormats, VkSurfaceFormat2KHR *extended_surface_formats) { - VkResult res = VK_SUCCESS; + /* Construct a list of all formats supported by the driver - for color attachment */ + std::array<surface_format_properties, 2> formats_prop{}; /* TODO: Hardcoding a list of sensible formats, may be query it from compositor later. */ static std::array<const VkFormat, 2> formats = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_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].format = formats[i]; - surfaceFormats[i].colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - } + formats_prop[i] = surface_format_properties{ static_cast<VkFormat>(formats[i]) }; + VkPhysicalDeviceImageFormatInfo2KHR format_info = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR, + nullptr, + static_cast<VkFormat>(formats[i]), + VK_IMAGE_TYPE_2D, + VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + 0 }; +#if WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN + if (layer::instance_private_data::get(physical_device).has_image_compression_support(physical_device)) + { + formats_prop[i].add_device_compression_support(physical_device, format_info); + } +#endif + } } - return res; + return surface_properties_formats_helper(formats_prop.begin(), formats_prop.begin() + formats.size(), surfaceFormatCount, + surfaceFormats, extended_surface_formats); } VkResult surface_properties::get_surface_formats_2(VkPhysicalDevice physical_device, VkSurfaceKHR surface, diff --git a/wsi/tizen/surface_properties.hpp b/wsi/tizen/surface_properties.hpp index ccc02e0..1437590 100644 --- a/wsi/tizen/surface_properties.hpp +++ b/wsi/tizen/surface_properties.hpp @@ -42,6 +42,8 @@ public: VkResult get_surface_capabilities(VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) override; + VkResult get_surface_capabilities2(VkPhysicalDevice physical_device, + VkSurfaceCapabilities2KHR *surface_capabilities) override; VkResult get_surface_formats(VkPhysicalDevice physical_device, uint32_t *surfaceFormatCount, VkSurfaceFormatKHR *surfaceFormats, VkSurfaceFormat2KHR *extended_surface_formats)override; diff --git a/wsi/tizen/swapchain.cpp b/wsi/tizen/swapchain.cpp index 03f82bc..4e7dc66 100644 --- a/wsi/tizen/swapchain.cpp +++ b/wsi/tizen/swapchain.cpp @@ -77,6 +77,9 @@ swapchain::swapchain(layer::device_private_data &dev_data, const VkAllocationCal , m_tpl_display(nullptr) , m_tpl_surface(nullptr) , m_image_creation_parameters(m_allocator, {}, {}) +#if WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN + , m_image_compression_control{} +#endif { } @@ -434,6 +437,19 @@ VkResult swapchain::allocate_image(tizen_image_data *image_data, VkImage *image) m_image_create_info.tiling = VK_IMAGE_TILING_LINEAR; image_data->is_disjoint = is_disjoint; +#if WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN + if (m_device_data.is_swapchain_compression_control_enabled()) + { + /* Initialize compression control */ + m_image_compression_control.sType = VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT; + m_image_compression_control.compressionControlPlaneCount = + m_image_compression_control_params.compression_control_plane_count; + m_image_compression_control.flags = m_image_compression_control_params.flags; + m_image_compression_control.pFixedRateFlags = m_image_compression_control_params.fixed_rate_flags.data(); + m_image_compression_control.pNext = m_image_create_info.pNext; + m_image_create_info.pNext = &m_image_compression_control; + } +#endif VkResult result = m_device_data.disp.CreateImage(m_device, &m_image_create_info, get_allocation_callbacks(), image); if (result != VK_SUCCESS) diff --git a/wsi/tizen/swapchain.hpp b/wsi/tizen/swapchain.hpp index 07bc46d..5e09a67 100644 --- a/wsi/tizen/swapchain.hpp +++ b/wsi/tizen/swapchain.hpp @@ -183,6 +183,9 @@ private: * @brief Image creation parameters used for all swapchain images. */ struct image_creation_parameters m_image_creation_parameters; +#if WSI_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN + VkImageCompressionControlEXT m_image_compression_control; +#endif /* * @brief Allocate memory for an image plane. |