Produce correct error result for unsupported formats

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>
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 5853bf6..5684122 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -152,6 +152,23 @@
 	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;