diff options
| author | Dave Houlton <daveh@lunarg.com> | 2018-04-16 11:46:56 -0600 |
|---|---|---|
| committer | Dave Houlton <daveh@lunarg.com> | 2018-04-26 13:47:30 -0600 |
| commit | e1288f79ba8a14b240fa63050f632f4c461a5a9e (patch) | |
| tree | ee9fbf9a8d1b00cc7c0f10b376c33691783e93f1 | |
| parent | 01d1eae970084b253eb283d9c2e1b20c244bb899 (diff) | |
| download | usermoji-e1288f79ba8a14b240fa63050f632f4c461a5a9e.tar.xz | |
layers: multiplane view format compatibility
Add check for compatible format when creating an imageview of a
plane of a multiplane image.
Add test to exercise.
Change-Id: Id3388aa49b42a16e84dc1d459121ee908b2e5f0f
| -rw-r--r-- | layers/buffer_validation.cpp | 46 | ||||
| -rw-r--r-- | layers/vk_validation_error_database.txt | 2 |
2 files changed, 38 insertions, 10 deletions
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp index 99b3fa06..ca1f57cb 100644 --- a/layers/buffer_validation.cpp +++ b/layers/buffer_validation.cpp @@ -3375,18 +3375,46 @@ bool PreCallValidateCreateImageView(layer_data *device_data, const VkImageViewCr // Validate VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT state if (image_flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT) { - if ((!GetDeviceExtensions(device_data)->vk_khr_maintenance2 || - !(image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR))) { - // Format MUST be compatible (in the same format compatibility class) as the format the image was created with - if (FormatCompatibilityClass(image_format) != FormatCompatibilityClass(view_format)) { + if (FormatIsMultiplane(image_format)) { + // View format must match the multiplane compatible format + uint32_t plane = 3; // invalid + switch (aspect_mask) { + case VK_IMAGE_ASPECT_PLANE_0_BIT: + plane = 0; + break; + case VK_IMAGE_ASPECT_PLANE_1_BIT: + plane = 1; + break; + case VK_IMAGE_ASPECT_PLANE_2_BIT: + plane = 2; + break; + default: + break; + } + + VkFormat compat_format = FindMultiplaneCompatibleFormat(image_format, plane); + if (view_format != compat_format) { std::stringstream ss; ss << "vkCreateImageView(): ImageView format " << string_VkFormat(view_format) - << " is not in the same format compatibility class as image (" << HandleToUint64(create_info->image) - << ") format " << string_VkFormat(image_format) - << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " - << "can support ImageViews with differing formats but they must be in the same compatibility class."; + << " is not compatible with plane " << plane << " of underlying image format " + << string_VkFormat(image_format) << ", must be " << string_VkFormat(compat_format) << "."; skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, - VALIDATION_ERROR_0ac007f4, "%s", ss.str().c_str()); + VALIDATION_ERROR_0ac00c64, "%s", ss.str().c_str()); + } + } else { + if ((!GetDeviceExtensions(device_data)->vk_khr_maintenance2 || + !(image_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR))) { + // Format MUST be compatible (in the same format compatibility class) as the format the image was created with + if (FormatCompatibilityClass(image_format) != FormatCompatibilityClass(view_format)) { + std::stringstream ss; + ss << "vkCreateImageView(): ImageView format " << string_VkFormat(view_format) + << " is not in the same format compatibility class as image (" << HandleToUint64(create_info->image) + << ") format " << string_VkFormat(image_format) + << ". Images created with the VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " + << "can support ImageViews with differing formats but they must be in the same compatibility class."; + skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, + VALIDATION_ERROR_0ac007f4, "%s", ss.str().c_str()); + } } } } else { diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt index dd2a09e5..d2b7cec3 100644 --- a/layers/vk_validation_error_database.txt +++ b/layers/vk_validation_error_database.txt @@ -828,7 +828,7 @@ VALIDATION_ERROR_0ac00b9a~^~Y~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewC VALIDATION_ERROR_0ac00c5e~^~N~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-image-01583~^~(VK_VERSION_1_1,VK_KHR_maintenance2)~^~The spec valid usage text states 'If image was created with the VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT flag, format must be compatible with, or must be an uncompressed format that is size-compatible with, the format used to create image.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01583)~^~ VALIDATION_ERROR_0ac00c60~^~N~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-image-01584~^~(VK_VERSION_1_1,VK_KHR_maintenance2)~^~The spec valid usage text states 'If image was created with the VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT flag, the levelCount and layerCount members of subresourceRange must both be 1.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01584)~^~ VALIDATION_ERROR_0ac00c62~^~N~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-pNext-01585~^~(VK_KHR_image_format_list)~^~The spec valid usage text states 'If a VkImageFormatListCreateInfoKHR structure was included in the pNext chain of the VkImageCreateInfo struct used when creating image and the viewFormatCount field of VkImageFormatListCreateInfoKHR is not zero then format must be one of the formats in VkImageFormatListCreateInfoKHR::pViewFormats.' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-pNext-01585)~^~ -VALIDATION_ERROR_0ac00c64~^~N~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-image-01586~^~(VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion)~^~The spec valid usage text states 'If image was created with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT flag, if the format of the image is a multi-planar format, and if subresourceRange.aspectMask is one of VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT, then format must be compatible with the VkFormat for the plane of the image format indicated by subresourceRange.aspectMask, as defined in features-formats-compatible-planes' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01586)~^~ +VALIDATION_ERROR_0ac00c64~^~Y~^~MultiplaneIncompatibleViewFormat~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-image-01586~^~(VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion)~^~The spec valid usage text states 'If image was created with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT flag, if the format of the image is a multi-planar format, and if subresourceRange.aspectMask is one of VK_IMAGE_ASPECT_PLANE_0_BIT, VK_IMAGE_ASPECT_PLANE_1_BIT, or VK_IMAGE_ASPECT_PLANE_2_BIT, then format must be compatible with the VkFormat for the plane of the image format indicated by subresourceRange.aspectMask, as defined in features-formats-compatible-planes' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01586)~^~ VALIDATION_ERROR_0ac00d6c~^~Y~^~CreateImageViewInvalidSubresourceRange~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-subresourceRange-01718~^~core~^~The spec valid usage text states 'If subresourceRange.levelCount is not VK_REMAINING_MIP_LEVELS, subresourceRange.baseMipLevel + subresourceRange.levelCount must be less than or equal to the mipLevels specified in VkImageCreateInfo when image was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageViewCreateInfo-subresourceRange-01718)~^~ VALIDATION_ERROR_0ac00d6e~^~Y~^~CreateImageViewInvalidSubresourceRange~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-subresourceRange-01719~^~!(VK_VERSION_1_1,VK_KHR_maintenance1)~^~The spec valid usage text states 'If subresourceRange.layerCount is not VK_REMAINING_ARRAY_LAYERS, subresourceRange.baseArrayLayer + subresourceRange.layerCount must be less than or equal to the arrayLayers specified in VkImageCreateInfo when image was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageViewCreateInfo-subresourceRange-01719)~^~ VALIDATION_ERROR_0ac00dbe~^~N~^~None~^~VkImageViewCreateInfo~^~VUID-VkImageViewCreateInfo-image-01759~^~(VK_VERSION_1_1,VK_KHR_maintenance2)+!(VK_VERSION_1_1,VK_KHR_sampler_ycbcr_conversion)~^~The spec valid usage text states 'If image was created with the VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT flag, but without the VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT flag, format must be compatible with the format used to create image, as defined in Format Compatibility Classes' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01759)~^~ |
