From 57378335838ca343e6bf8fcdca1acbe109e59650 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Wed, 16 Jan 2019 15:17:24 -0800 Subject: [PATCH] Produce correct error result for unsupported formats MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Alexis Hétu Tested-by: Chris Forbes --- src/Vulkan/libVulkan.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp index 5853bf6c3..568412247 100644 --- a/src/Vulkan/libVulkan.cpp +++ b/src/Vulkan/libVulkan.cpp @@ -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; -- 2.11.0