diff options
author | Chad Versace <[email protected]> | 2017-01-25 12:12:18 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2017-01-25 19:18:43 -0800 |
commit | 582619009514a4b7320037a52252ec3eda65ce5e (patch) | |
tree | c1003fcc18a98815136620fd6e6ad7a088081966 /src/intel/vulkan/anv_formats.c | |
parent | b2de77a07dc8d506ff07efd9f93244c3787156bb (diff) |
anv: Refactor anv_GetPhysicalDeviceFormatProperties()
Add a helper function, anv_get_image_format_properties(), which does all
the work and has a VkPhysicalDeviceImageFormatInfo2KHR parameter. This
patch reduces churn in the following patch that implements
vkGetPhysicalDeviceImageFormatProperties2KHR.
Reviewed-by: Jason Ekstranad <[email protected]>
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_formats.c')
-rw-r--r-- | src/intel/vulkan/anv_formats.c | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c index f4183f0c362..47f939b47ee 100644 --- a/src/intel/vulkan/anv_formats.c +++ b/src/intel/vulkan/anv_formats.c @@ -462,16 +462,12 @@ void anv_GetPhysicalDeviceFormatProperties( pFormatProperties); } -VkResult anv_GetPhysicalDeviceImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkImageTiling tiling, - VkImageUsageFlags usage, - VkImageCreateFlags createFlags, - VkImageFormatProperties* pImageFormatProperties) +static VkResult +anv_get_image_format_properties( + struct anv_physical_device *physical_device, + const VkPhysicalDeviceImageFormatInfo2KHR *info, + VkImageFormatProperties *pImageFormatProperties) { - ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); VkFormatProperties format_props; VkFormatFeatureFlags format_feature_flags; VkExtent3D maxExtent; @@ -479,24 +475,24 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( uint32_t maxArraySize; VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT; - if (anv_formats[format].isl_format == ISL_FORMAT_UNSUPPORTED) + if (anv_formats[info->format].isl_format == ISL_FORMAT_UNSUPPORTED) goto unsupported; - anv_physical_device_get_format_properties(physical_device, format, + anv_physical_device_get_format_properties(physical_device, info->format, &format_props); /* Extract the VkFormatFeatureFlags that are relevant for the queried * tiling. */ - if (tiling == VK_IMAGE_TILING_LINEAR) { + if (info->tiling == VK_IMAGE_TILING_LINEAR) { format_feature_flags = format_props.linearTilingFeatures; - } else if (tiling == VK_IMAGE_TILING_OPTIMAL) { + } else if (info->tiling == VK_IMAGE_TILING_OPTIMAL) { format_feature_flags = format_props.optimalTilingFeatures; } else { unreachable("bad VkImageTiling"); } - switch (type) { + switch (info->type) { default: unreachable("bad VkImageType"); case VK_IMAGE_TYPE_1D: @@ -532,22 +528,22 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( * if the Surface Type is SURFTYPE_1D. * * This field cannot be ASTC format if the Surface Type is SURFTYPE_1D. */ - if (type == VK_IMAGE_TYPE_1D && - isl_format_is_compressed(anv_formats[format].isl_format)) { + if (info->type == VK_IMAGE_TYPE_1D && + isl_format_is_compressed(anv_formats[info->format].isl_format)) { goto unsupported; } - if (tiling == VK_IMAGE_TILING_OPTIMAL && - type == VK_IMAGE_TYPE_2D && + if (info->tiling == VK_IMAGE_TILING_OPTIMAL && + info->type == VK_IMAGE_TYPE_2D && (format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) && - !(createFlags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && - !(usage & VK_IMAGE_USAGE_STORAGE_BIT)) { + !(info->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) && + !(info->usage & VK_IMAGE_USAGE_STORAGE_BIT)) { sampleCounts = isl_device_get_sample_counts(&physical_device->isl_dev); } - if (usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | - VK_IMAGE_USAGE_TRANSFER_DST_BIT)) { + if (info->usage & (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | + VK_IMAGE_USAGE_TRANSFER_DST_BIT)) { /* Accept transfers on anything we can sample from or renderer to. */ if (!(format_feature_flags & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT | @@ -556,35 +552,35 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties( } } - if (usage & VK_IMAGE_USAGE_SAMPLED_BIT) { + if (info->usage & VK_IMAGE_USAGE_SAMPLED_BIT) { if (!(format_feature_flags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) { goto unsupported; } } - if (usage & VK_IMAGE_USAGE_STORAGE_BIT) { + if (info->usage & VK_IMAGE_USAGE_STORAGE_BIT) { if (!(format_feature_flags & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT)) { goto unsupported; } } - if (usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) { + if (info->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) { if (!(format_feature_flags & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT)) { goto unsupported; } } - if (usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { + if (info->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) { if (!(format_feature_flags & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) { goto unsupported; } } - if (usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) { + if (info->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) { /* Nothing to check. */ } - if (usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) { + if (info->usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) { /* Ignore this flag because it was removed from the * provisional_I_20150910 header. */ @@ -616,6 +612,31 @@ unsupported: return VK_ERROR_FORMAT_NOT_SUPPORTED; } +VkResult anv_GetPhysicalDeviceImageFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags createFlags, + VkImageFormatProperties* pImageFormatProperties) +{ + ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice); + + const VkPhysicalDeviceImageFormatInfo2KHR info = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR, + .pNext = NULL, + .format = format, + .type = type, + .tiling = tiling, + .usage = usage, + .flags = createFlags, + }; + + return anv_get_image_format_properties(physical_device, &info, + pImageFormatProperties); +} + void anv_GetPhysicalDeviceSparseImageFormatProperties( VkPhysicalDevice physicalDevice, VkFormat format, |