tests: Fix ImageLayerUnsupportedFormat errors
Fix ImageLayerUnsupportedFormat unexpected errors.
Change-Id: I7dd4f2b9bae69885abf5031a6257ee3f6fad21fb
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index f237d64..32c6d63 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -589,72 +589,79 @@
bool skip_call = false;
const debug_report_data *report_data = core_validation::GetReportData(device_data);
- if (pCreateInfo->format != VK_FORMAT_UNDEFINED) {
- const VkFormatProperties *properties = GetFormatProperties(device_data, pCreateInfo->format);
-
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && (properties->linearTilingFeatures == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format";
- skip_call |=
- log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
- VALIDATION_ERROR_02150, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02150]);
- }
-
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && (properties->optimalTilingFeatures == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format";
- skip_call |=
- log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
- VALIDATION_ERROR_02155, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02155]);
- }
-
- // Validate that format supports usage as color attachment
- if (pCreateInfo->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) &&
- ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format)
- << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT";
- skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
- __LINE__, VALIDATION_ERROR_02158, "IMAGE", "%s. %s", ss.str().c_str(),
- validation_error_map[VALIDATION_ERROR_02158]);
- }
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) &&
- ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format)
- << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT";
- skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
- __LINE__, VALIDATION_ERROR_02153, "IMAGE", "%s. %s", ss.str().c_str(),
- validation_error_map[VALIDATION_ERROR_02153]);
- }
- }
- // Validate that format supports usage as depth/stencil attachment
- if (pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) &&
- ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format)
- << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT";
- skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
- __LINE__, VALIDATION_ERROR_02159, "IMAGE", "%s. %s", ss.str().c_str(),
- validation_error_map[VALIDATION_ERROR_02159]);
- }
- if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) &&
- ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
- std::stringstream ss;
- ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format)
- << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT";
- skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
- __LINE__, VALIDATION_ERROR_02154, "IMAGE", "%s. %s", ss.str().c_str(),
- validation_error_map[VALIDATION_ERROR_02154]);
- }
- }
- } else {
+ if (pCreateInfo->format == VK_FORMAT_UNDEFINED) {
skip_call |=
log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
VALIDATION_ERROR_00715, "IMAGE", "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED. %s",
validation_error_map[VALIDATION_ERROR_00715]);
+
+ return skip_call;
+ }
+
+ const VkFormatProperties *properties = GetFormatProperties(device_data, pCreateInfo->format);
+
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) && (properties->linearTilingFeatures == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02150, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02150]);
+
+ return skip_call;
+ }
+
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) && (properties->optimalTilingFeatures == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage format parameter (" << string_VkFormat(pCreateInfo->format) << ") is an unsupported format";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02155, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02155]);
+
+ return skip_call;
+ }
+
+ // Validate that format supports usage as color attachment
+ if (pCreateInfo->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) {
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) &&
+ ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format)
+ << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02158, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02158]);
+ }
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) &&
+ ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format)
+ << ") does not support requested Image usage type VK_IMAGE_USAGE_COLOR_ATTACHMENT";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02153, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02153]);
+ }
+ }
+
+ // Validate that format supports usage as depth/stencil attachment
+ if (pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) {
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) &&
+ ((properties->optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage: VkFormat for TILING_OPTIMAL image (" << string_VkFormat(pCreateInfo->format)
+ << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02159, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02159]);
+ }
+ if ((pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) &&
+ ((properties->linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
+ std::stringstream ss;
+ ss << "vkCreateImage: VkFormat for TILING_LINEAR image (" << string_VkFormat(pCreateInfo->format)
+ << ") does not support requested Image usage type VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT";
+ skip_call |=
+ log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0, __LINE__,
+ VALIDATION_ERROR_02154, "IMAGE", "%s. %s", ss.str().c_str(), validation_error_map[VALIDATION_ERROR_02154]);
+ }
}
const VkImageFormatProperties *ImageFormatProperties = GetImageFormatProperties(
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index af00b66..6517f38 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -15912,10 +15912,6 @@
ASSERT_NO_FATAL_FAILURE(InitState());
ASSERT_NO_FATAL_FAILURE(InitRenderTarget());
- VkImageObj image(m_device);
- image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
- VK_IMAGE_TILING_OPTIMAL, 0);
- ASSERT_TRUE(image.initialized());
// Create image with unsupported format - Expect FORMAT_UNSUPPORTED
VkImageCreateInfo image_create_info = {};
@@ -15934,16 +15930,12 @@
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
"vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED");
- VkImage localImage;
- m_errorMonitor->SetUnexpectedError("CreateImage extents exceed allowable limits for format");
- m_errorMonitor->SetUnexpectedError("CreateImage mipLevels=1 exceeds allowable maximum supported by format of 0");
- m_errorMonitor->SetUnexpectedError("arrayLayers must be less than or equal to VkImageFormatProperties::maxArrayLayers");
- m_errorMonitor->SetUnexpectedError("samples must be a bit value that is set in VkImageFormatProperties::sampleCounts");
- vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage);
+ VkImage image;
+ vkCreateImage(m_device->handle(), &image_create_info, NULL, &image);
m_errorMonitor->VerifyFound();
- VkFormat unsupported = VK_FORMAT_UNDEFINED;
// Look for a format that is COMPLETELY unsupported with this hardware
+ VkFormat unsupported = VK_FORMAT_UNDEFINED;
for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) {
VkFormat format = static_cast<VkFormat>(f);
VkFormatProperties fProps = m_device->format_properties(format);
@@ -15957,15 +15949,7 @@
image_create_info.format = unsupported;
m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "is an unsupported format");
- m_errorMonitor->SetUnexpectedError("CreateImage extents exceed allowable limits for format");
- m_errorMonitor->SetUnexpectedError("CreateImage resource size exceeds allowable maximum Image resource size");
- m_errorMonitor->SetUnexpectedError("CreateImage mipLevels=1 exceeds allowable maximum supported by format of 0");
- m_errorMonitor->SetUnexpectedError("arrayLayers must be less than or equal to VkImageFormatProperties::maxArrayLayers");
- m_errorMonitor->SetUnexpectedError(
- "samples must be a bit value that is set in VkImageFormatProperties::sampleCounts returned by "
- "vkGetPhysicalDeviceImageFormatProperties with format, type, tiling, usage, and flags equal to those in this "
- "structure");
- vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage);
+ vkCreateImage(m_device->handle(), &image_create_info, NULL, &image);
m_errorMonitor->VerifyFound();
}
}