diff options
-rw-r--r-- | vulkan/libvulkan/driver.cpp | 44 | ||||
-rw-r--r-- | vulkan/libvulkan/swapchain.cpp | 57 |
2 files changed, 72 insertions, 29 deletions
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp index 4927150b6a..a99355f047 100644 --- a/vulkan/libvulkan/driver.cpp +++ b/vulkan/libvulkan/driver.cpp @@ -1027,8 +1027,11 @@ void QueryPresentationProperties( } } -bool GetAndroidNativeBufferSpecVersion9Support( - VkPhysicalDevice physicalDevice) { +VkResult GetAndroidNativeBufferSpecVersion9Support( + VkPhysicalDevice physicalDevice, + bool& support) { + support = false; + const InstanceData& data = GetData(physicalDevice); // Call to get propertyCount @@ -1038,6 +1041,10 @@ bool GetAndroidNativeBufferSpecVersion9Support( physicalDevice, nullptr, &propertyCount, nullptr); ATRACE_END(); + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + return result; + } + // Call to enumerate properties std::vector<VkExtensionProperties> properties(propertyCount); ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); @@ -1045,6 +1052,10 @@ bool GetAndroidNativeBufferSpecVersion9Support( physicalDevice, nullptr, &propertyCount, properties.data()); ATRACE_END(); + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + return result; + } + for (uint32_t i = 0; i < propertyCount; i++) { auto& prop = properties[i]; @@ -1053,11 +1064,12 @@ bool GetAndroidNativeBufferSpecVersion9Support( continue; if (prop.specVersion >= 9) { - return true; + support = true; + return result; } } - return false; + return result; } VkResult EnumerateDeviceExtensionProperties( @@ -1101,18 +1113,30 @@ VkResult EnumerateDeviceExtensionProperties( swapchainCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT; swapchainCompFeats.pNext = nullptr; + swapchainCompFeats.imageCompressionControlSwapchain = false; VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {}; imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = &swapchainCompFeats; + imageCompFeats.imageCompressionControl = false; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; feats2.pNext = &imageCompFeats; - GetPhysicalDeviceFeatures2(physicalDevice, &feats2); + const auto& driver = GetData(physicalDevice).driver; + if (driver.GetPhysicalDeviceFeatures2 || + driver.GetPhysicalDeviceFeatures2KHR) { + GetPhysicalDeviceFeatures2(physicalDevice, &feats2); + } - bool anb9 = GetAndroidNativeBufferSpecVersion9Support(physicalDevice); + bool anb9 = false; + VkResult result = + GetAndroidNativeBufferSpecVersion9Support(physicalDevice, anb9); + + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + return result; + } if (anb9 && imageCompFeats.imageCompressionControl) { loader_extensions.push_back( @@ -1142,7 +1166,7 @@ VkResult EnumerateDeviceExtensionProperties( } ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties"); - VkResult result = data.driver.EnumerateDeviceExtensionProperties( + result = data.driver.EnumerateDeviceExtensionProperties( physicalDevice, pLayerName, pPropertyCount, pProperties); ATRACE_END(); @@ -1532,6 +1556,11 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, } break; case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: { + VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT* + compressionFeat = reinterpret_cast< + VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT*>( + pFeats); + compressionFeat->imageCompressionControlSwapchain = false; imageCompressionControlSwapchainInChain = true; } break; @@ -1551,6 +1580,7 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, imageCompFeats.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT; imageCompFeats.pNext = nullptr; + imageCompFeats.imageCompressionControl = false; VkPhysicalDeviceFeatures2 feats2 = {}; feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp index 48a75c5c05..2e22c36f35 100644 --- a/vulkan/libvulkan/swapchain.cpp +++ b/vulkan/libvulkan/swapchain.cpp @@ -950,27 +950,36 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR( return GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, nullptr); - } else { - // temp vector for forwarding; we'll marshal it into the pSurfaceFormats - // after the call. - std::vector<VkSurfaceFormatKHR> surface_formats(*pSurfaceFormatCount); - VkResult result = GetPhysicalDeviceSurfaceFormatsKHR( - physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, - surface_formats.data()); - - if (result == VK_SUCCESS || result == VK_INCOMPLETE) { - const auto& driver = GetData(physicalDevice).driver; - - // marshal results individually due to stride difference. - uint32_t formats_to_marshal = *pSurfaceFormatCount; - for (uint32_t i = 0u; i < formats_to_marshal; i++) { - pSurfaceFormats[i].surfaceFormat = surface_formats[i]; - - // Query the compression properties for the surface format - if (pSurfaceFormats[i].pNext) { + } + + // temp vector for forwarding; we'll marshal it into the pSurfaceFormats + // after the call. + std::vector<VkSurfaceFormatKHR> surface_formats(*pSurfaceFormatCount); + VkResult result = GetPhysicalDeviceSurfaceFormatsKHR( + physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount, + surface_formats.data()); + + if (result != VK_SUCCESS && result != VK_INCOMPLETE) { + return result; + } + + const auto& driver = GetData(physicalDevice).driver; + + // marshal results individually due to stride difference. + uint32_t formats_to_marshal = *pSurfaceFormatCount; + for (uint32_t i = 0u; i < formats_to_marshal; i++) { + pSurfaceFormats[i].surfaceFormat = surface_formats[i]; + + // Query the compression properties for the surface format + VkSurfaceFormat2KHR* pSurfaceFormat = &pSurfaceFormats[i]; + while (pSurfaceFormat->pNext) { + pSurfaceFormat = + reinterpret_cast<VkSurfaceFormat2KHR*>(pSurfaceFormat->pNext); + switch (pSurfaceFormat->sType) { + case VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT: { VkImageCompressionPropertiesEXT* surfaceCompressionProps = reinterpret_cast<VkImageCompressionPropertiesEXT*>( - pSurfaceFormats[i].pNext); + pSurfaceFormat); if (surfaceCompressionProps && driver.GetPhysicalDeviceImageFormatProperties2KHR) { @@ -1012,12 +1021,16 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR( return compressionRes; } } - } + } break; + + default: + // Ignore all other extension structs + break; } } - - return result; } + + return result; } VKAPI_ATTR |