summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-06-11 09:11:14 -0700
committerJason Ekstrand <[email protected]>2015-06-11 09:11:16 -0700
commita566b1e08a269850189011ec3cd06f6408c7adf6 (patch)
tree5bbd5de4b349b2c4bb72f90358aeef277959d751
parent2a3c29698c43601751e43c0344d8f5ba1f57937d (diff)
vk/formats: Refactor format properties code
Along with the refactor, we now do the right thing when we hit an unsupported format: Set the flags to 0 and return VK_SUCCESS.
-rw-r--r--src/vulkan/formats.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/src/vulkan/formats.c b/src/vulkan/formats.c
index e915156c1be..c119be6d041 100644
--- a/src/vulkan/formats.c
+++ b/src/vulkan/formats.c
@@ -246,16 +246,11 @@ VkResult anv_validate_GetFormatInfo(
return anv_GetFormatInfo(_device, _format, infoType, pDataSize, pData);
}
-VkResult anv_GetFormatInfo(
- VkDevice _device,
- VkFormat _format,
- VkFormatInfoType infoType,
- size_t* pDataSize,
- void* pData)
+static void
+anv_format_get_properties(struct anv_device *device,
+ const struct anv_format *format,
+ VkFormatProperties *properties)
{
- struct anv_device *device = (struct anv_device *) _device;
- VkFormatProperties *properties;
- const struct anv_format *format;
const struct surface_format_info *info;
int gen;
@@ -263,14 +258,12 @@ VkResult anv_GetFormatInfo(
if (device->info.is_haswell)
gen += 5;
- format = anv_format_for_vk_format(_format);
- if (format == 0)
- return vk_error(VK_ERROR_INVALID_VALUE);
if (format->format == UNSUPPORTED)
- return VK_UNSUPPORTED;
+ goto unsupported;
+
info = &surface_formats[format->format];
if (!info->exists)
- return VK_UNSUPPORTED;
+ goto unsupported;
uint32_t linear = 0, tiled = 0;
if (info->sampling <= gen) {
@@ -289,16 +282,39 @@ VkResult anv_GetFormatInfo(
linear |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
}
+ properties->linearTilingFeatures = linear;
+ properties->optimalTilingFeatures = tiled;
+ return;
+
+ unsupported:
+ properties->linearTilingFeatures = 0;
+ properties->optimalTilingFeatures = 0;
+}
+
+VkResult anv_GetFormatInfo(
+ VkDevice _device,
+ VkFormat _format,
+ VkFormatInfoType infoType,
+ size_t* pDataSize,
+ void* pData)
+{
+ struct anv_device *device = (struct anv_device *) _device;
+ const struct anv_format *format;
+ VkFormatProperties *properties;
+
+ format = anv_format_for_vk_format(_format);
+ if (format == 0)
+ return vk_error(VK_ERROR_INVALID_VALUE);
+
switch (infoType) {
case VK_FORMAT_INFO_TYPE_PROPERTIES:
- properties = pData;
+ properties = (VkFormatProperties *)pData;
*pDataSize = sizeof(*properties);
if (pData == NULL)
return VK_SUCCESS;
- properties->linearTilingFeatures = linear;
- properties->optimalTilingFeatures = tiled;
+ anv_format_get_properties(device, format, properties);
return VK_SUCCESS;
default: