From cb7ce6a934349d98a96409e8deb4ffd85b125793 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 14 Oct 2024 17:35:13 -0700 Subject: [PATCH] panvk: check VkPhysicalDeviceImageDrmFormatModifierInfoEXT Make sure VK_ERROR_FORMAT_NOT_SUPPORTED is returned when VkPhysicalDeviceImageDrmFormatModifierInfoEXT specifies an unsupported modifier. Part-of: --- src/panfrost/vulkan/panvk_physical_device.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 3bba2527a85..e11ddfe7d74 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -1104,25 +1104,30 @@ get_image_format_properties(struct panvk_physical_device *physical_device, case VK_IMAGE_TILING_LINEAR: format_feature_flags = format_props.linearTilingFeatures; break; + case VK_IMAGE_TILING_OPTIMAL: + format_feature_flags = format_props.optimalTilingFeatures; + break; + case VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT: { + const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *mod_info = + vk_find_struct_const( + info->pNext, PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT); + if (mod_info->drmFormatModifier != DRM_FORMAT_MOD_LINEAR) + goto unsupported; - case VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT: /* The only difference between optimal and linear is currently whether * depth/stencil attachments are allowed on depth/stencil formats. * There's no reason to allow importing depth/stencil textures, so just * disallow it and then this annoying edge case goes away. - * - * TODO: If anyone cares, we could enable this by looking at the - * modifier and checking if it's LINEAR or not. */ if (util_format_is_depth_or_stencil(format)) goto unsupported; assert(format_props.optimalTilingFeatures == format_props.linearTilingFeatures); - FALLTHROUGH; - case VK_IMAGE_TILING_OPTIMAL: - format_feature_flags = format_props.optimalTilingFeatures; + + format_feature_flags = format_props.linearTilingFeatures; break; + } default: unreachable("bad VkPhysicalDeviceImageFormatInfo2"); }