OSDN Git Service

Produce correct error result for unsupported formats
authorChris Forbes <chrisforbes@google.com>
Wed, 16 Jan 2019 23:17:24 +0000 (15:17 -0800)
committerChris Forbes <chrisforbes@google.com>
Thu, 17 Jan 2019 15:20:39 +0000 (15:20 +0000)
vkGetPhysicalDeviceImageFormatProperties is required to return
VK_ERROR_FORMAT_NOT_SUPPORTED when the format is not supported.

CTS (validly) assumes that the format /is/ supported if this function
returns VK_SUCCESS.

Bug: b/119620767
Change-Id: I1f7d3ff8dbbfbc2dd100af7c3c4d7204f350dd06
Reviewed-on: https://swiftshader-review.googlesource.com/c/23668
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
src/Vulkan/libVulkan.cpp

index 5853bf6..5684122 100644 (file)
@@ -152,6 +152,23 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysic
        TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkFormat format = %d, VkImageType type = %d, VkImageTiling tiling = %d, VkImageUsageFlags usage = %d, VkImageCreateFlags flags = %d, VkImageFormatProperties* pImageFormatProperties = 0x%X)",
                        physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
 
+       VkFormatProperties properties;
+       vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
+
+       switch (tiling)
+       {
+       case VK_IMAGE_TILING_LINEAR:
+               if (properties.linearTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
+               break;
+
+       case VK_IMAGE_TILING_OPTIMAL:
+               if (properties.optimalTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
+               break;
+
+       default:
+               UNIMPLEMENTED();
+       }
+
        vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties);
 
        return VK_SUCCESS;