aboutsummaryrefslogtreecommitdiff
path: root/layers/buffer_validation.cpp
diff options
context:
space:
mode:
authorDave Houlton <daveh@lunarg.com>2018-04-16 11:46:56 -0600
committerDave Houlton <daveh@lunarg.com>2018-04-26 13:47:30 -0600
commite1288f79ba8a14b240fa63050f632f4c461a5a9e (patch)
treeee9fbf9a8d1b00cc7c0f10b376c33691783e93f1 /layers/buffer_validation.cpp
parent01d1eae970084b253eb283d9c2e1b20c244bb899 (diff)
downloadusermoji-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
Diffstat (limited to 'layers/buffer_validation.cpp')
-rw-r--r--layers/buffer_validation.cpp46
1 files changed, 37 insertions, 9 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 {