layers: Fix CreateImage extent validation
authorMark Lobodzinski <mark@lunarg.com>
Fri, 27 Jan 2017 18:13:21 +0000 (11:13 -0700)
committerMark Lobodzinski <mark@lunarg.com>
Tue, 31 Jan 2017 16:55:10 +0000 (09:55 -0700)
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

layers/buffer_validation.cpp
layers/vk_validation_error_database.txt

index 1b650aa..e886b13 100644 (file)
@@ -115,36 +115,13 @@ bool PreCallValidateCreateImage(core_validation::layer_data *device_data, const
     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
index 793b773..14045a1 100644 (file)
@@ -704,7 +704,7 @@ VALIDATION_ERROR_00712~^~N~^~Unknown~^~vkCreateImage~^~For more information refe
 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)~^~