layers: Fix CreateImage extent validation
Spec has changed and no longer allows any member of the extents
structure to be <= zero. Fixed validation and added correct VU ID,
updated test and database.
Change-Id: Ifafedf8cd6d59ecba975ae1b25c9f00d86247504
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index 1b650aa..e886b13 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -115,36 +115,13 @@
VkDeviceSize imageGranularity = core_validation::GetPhysicalDeviceProperties(device_data)->limits.bufferImageGranularity;
imageGranularity = imageGranularity == 1 ? 0 : imageGranularity;
- // Make sure all required dimension are non-zero at least.
- bool failedMinSize = false;
- switch (pCreateInfo->imageType) {
- case VK_IMAGE_TYPE_3D:
- if (pCreateInfo->extent.depth == 0) {
- failedMinSize = true;
- }
- // Intentional fall-through
- case VK_IMAGE_TYPE_2D:
- if (pCreateInfo->extent.height == 0) {
- failedMinSize = true;
- }
- // Intentional fall-through
- case VK_IMAGE_TYPE_1D:
- if (pCreateInfo->extent.width == 0) {
- failedMinSize = true;
- }
- break;
- default:
- break;
- }
- // TODO: VALIDATION_ERROR_00716
- // this is *almost* VU 00716, except should not be condidtional on image type - all extents must be non-zero for all types
- if (failedMinSize) {
- skip_call |=
- log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__,
- IMAGE_INVALID_FORMAT_LIMITS_VIOLATION, "Image",
- "CreateImage extents is 0 for at least one required dimension for image of type %d: "
- "Width = %d Height = %d Depth = %d.",
- pCreateInfo->imageType, pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth);
+ if ((pCreateInfo->extent.width <= 0) || (pCreateInfo->extent.height <= 0) || (pCreateInfo->extent.depth <= 0)) {
+ skip_call |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, 0, __LINE__,
+ VALIDATION_ERROR_00716, "Image",
+ "CreateImage extent is 0 for at least one required dimension for image: "
+ "Width = %d Height = %d Depth = %d. %s",
+ pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth,
+ validation_error_map[VALIDATION_ERROR_00716]);
}
// TODO: VALIDATION_ERROR_02125 VALIDATION_ERROR_02126 VALIDATION_ERROR_02128 VALIDATION_ERROR_00720
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index 793b773..14045a1 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -704,7 +704,7 @@
VALIDATION_ERROR_00713~^~Y~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of queueFamilyIndexCount uint32_t values' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
VALIDATION_ERROR_00714~^~Y~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
VALIDATION_ERROR_00715~^~Y~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'format must not be VK_FORMAT_UNDEFINED' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
-VALIDATION_ERROR_00716~^~N~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'The width, height, and depth members of extent must all be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
+VALIDATION_ERROR_00716~^~Y~^~CreateImageLimitsViolationMinWidth~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'The width, height, and depth members of extent must all be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
VALIDATION_ERROR_00717~^~N~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'mipLevels must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
VALIDATION_ERROR_00718~^~N~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'arrayLayers must be greater than 0' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
VALIDATION_ERROR_00719~^~N~^~Unknown~^~vkCreateImage~^~For more information refer to Vulkan Spec Section '11.3. Images' which states 'If flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, imageType must be VK_IMAGE_TYPE_2D' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#VkImageCreateInfo)~^~
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index d349b94..26eacef 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -14557,8 +14557,7 @@
}
TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) {
- m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
- "CreateImage extents is 0 for at least one required dimension");
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_00716);
ASSERT_NO_FATAL_FAILURE(InitState());