layers: image transfer granularity check fixes
authorCort Stratton <cort@google.com>
Fri, 4 May 2018 05:12:23 +0000 (01:12 -0400)
committerTobin Ehlis <tobine@google.com>
Fri, 4 May 2018 19:37:14 +0000 (13:37 -0600)
- Use appropriate VUIDs for all checks
- Update tests to check for VUIDs instead of message substrings
- Image granularity tests should be also be run on compressed images.
  They're *mostly* redundant with existing compressed-format-only checks,
  but I can't convince myself that they're *always* redundant, and the
  spec doesn't say to skip them.
- Removed comments that the checks should be moved elsewhere; IMO they're
  fine where they are, but I welcome second opinions.
- Compressed-format alignment checks should also apply to _422 single-plane
  formats.

layers/buffer_validation.cpp
layers/buffer_validation.h
layers/vk_validation_error_database.txt
tests/layer_validation_tests.cpp

index 330e187..6605b60 100644 (file)
@@ -1297,7 +1297,8 @@ static inline bool IsExtentAligned(const VkExtent3D *extent, const VkExtent3D *g
 
 // Check elements of a VkOffset3D structure against a queue family's Image Transfer Granularity values
 static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkOffset3D *offset,
-                                  const VkExtent3D *granularity, const uint32_t i, const char *function, const char *member) {
+                                  const VkExtent3D *granularity, const uint32_t i, const char *function, const char *member,
+                                  UNIQUE_VALIDATION_ERROR_CODE vuid) {
     const debug_report_data *report_data = core_validation::GetReportData(device_data);
     bool skip = false;
     VkExtent3D offset_extent = {};
@@ -1308,7 +1309,7 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
         // If the queue family image transfer granularity is (0, 0, 0), then the offset must always be (0, 0, 0)
         if (IsExtentAllZeroes(&offset_extent) == false) {
             skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
-                            HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+                            HandleToUint64(cb_node->commandBuffer), vuid,
                             "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) must be (x=0, y=0, z=0) when the command buffer's queue family "
                             "image transfer granularity is (w=0, h=0, d=0).",
                             function, i, member, offset->x, offset->y, offset->z);
@@ -1318,7 +1319,7 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
         // integer multiples of the image transfer granularity.
         if (IsExtentAligned(&offset_extent, granularity) == false) {
             skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
-                            HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+                            HandleToUint64(cb_node->commandBuffer), vuid,
                             "%s: pRegion[%d].%s (x=%d, y=%d, z=%d) dimensions must be even integer multiples of this command "
                             "buffer's queue family image transfer granularity (w=%d, h=%d, d=%d).",
                             function, i, member, offset->x, offset->y, offset->z, granularity->width, granularity->height,
@@ -1331,7 +1332,8 @@ static inline bool CheckItgOffset(layer_data *device_data, const GLOBAL_CB_NODE
 // Check elements of a VkExtent3D structure against a queue family's Image Transfer Granularity values
 static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE *cb_node, const VkExtent3D *extent,
                                   const VkOffset3D *offset, const VkExtent3D *granularity, const VkExtent3D *subresource_extent,
-                                  const VkImageType image_type, const uint32_t i, const char *function, const char *member) {
+                                  const VkImageType image_type, const uint32_t i, const char *function, const char *member,
+                                  UNIQUE_VALIDATION_ERROR_CODE vuid) {
     const debug_report_data *report_data = core_validation::GetReportData(device_data);
     bool skip = false;
     if (IsExtentAllZeroes(granularity)) {
@@ -1339,7 +1341,7 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
         // subresource extent.
         if (IsExtentEqual(extent, subresource_extent) == false) {
             skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
-                            HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+                            HandleToUint64(cb_node->commandBuffer), vuid,
                             "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d) "
                             "when the command buffer's queue family image transfer granularity is (w=0, h=0, d=0).",
                             function, i, member, extent->width, extent->height, extent->depth, subresource_extent->width,
@@ -1375,7 +1377,7 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
         }
         if (!(x_ok && y_ok && z_ok)) {
             skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
-                            HandleToUint64(cb_node->commandBuffer), DRAWSTATE_IMAGE_TRANSFER_GRANULARITY,
+                            HandleToUint64(cb_node->commandBuffer), vuid,
                             "%s: pRegion[%d].%s (w=%d, h=%d, d=%d) dimensions must be even integer multiples of this command "
                             "buffer's queue family image transfer granularity (w=%d, h=%d, d=%d) or offset (x=%d, y=%d, z=%d) + "
                             "extent (w=%d, h=%d, d=%d) must match the image subresource extents (w=%d, h=%d, d=%d).",
@@ -1390,28 +1392,14 @@ static inline bool CheckItgExtent(layer_data *device_data, const GLOBAL_CB_NODE
 // Check valid usage Image Transfer Granularity requirements for elements of a VkBufferImageCopy structure
 bool ValidateCopyBufferImageTransferGranularityRequirements(layer_data *device_data, const GLOBAL_CB_NODE *cb_node,
                                                             const IMAGE_STATE *img, const VkBufferImageCopy *region,
-                                                            const uint32_t i, const char *function) {
+                                                            const uint32_t i, const char *function,
+                                                            UNIQUE_VALIDATION_ERROR_CODE vuid) {
     bool skip = false;
-    if (FormatIsCompressed(img->createInfo.format) == true) {
-        // TODO: Add granularity checking for compressed formats
-
-        // bufferRowLength must be a multiple of the compressed texel block width
-        // bufferImageHeight must be a multiple of the compressed texel block height
-        // all members of imageOffset must be a multiple of the corresponding dimensions of the compressed texel block
-        // bufferOffset must be a multiple of the compressed texel block size in bytes
-        // imageExtent.width must be a multiple of the compressed texel block width or (imageExtent.width + imageOffset.x)
-        //     must equal the image subresource width
-        // imageExtent.height must be a multiple of the compressed texel block height or (imageExtent.height + imageOffset.y)
-        //     must equal the image subresource height
-        // imageExtent.depth must be a multiple of the compressed texel block depth or (imageExtent.depth + imageOffset.z)
-        //     must equal the image subresource depth
-    } else {
-        VkExtent3D granularity = GetScaledItg(device_data, cb_node, img);
-        skip |= CheckItgOffset(device_data, cb_node, &region->imageOffset, &granularity, i, function, "imageOffset");
-        VkExtent3D subresource_extent = GetImageSubresourceExtent(img, &region->imageSubresource);
-        skip |= CheckItgExtent(device_data, cb_node, &region->imageExtent, &region->imageOffset, &granularity, &subresource_extent,
-                               img->createInfo.imageType, i, function, "imageExtent");
-    }
+    VkExtent3D granularity = GetScaledItg(device_data, cb_node, img);
+    skip |= CheckItgOffset(device_data, cb_node, &region->imageOffset, &granularity, i, function, "imageOffset", vuid);
+    VkExtent3D subresource_extent = GetImageSubresourceExtent(img, &region->imageSubresource);
+    skip |= CheckItgExtent(device_data, cb_node, &region->imageExtent, &region->imageOffset, &granularity, &subresource_extent,
+                           img->createInfo.imageType, i, function, "imageExtent", vuid);
     return skip;
 }
 
@@ -1422,21 +1410,23 @@ bool ValidateCopyImageTransferGranularityRequirements(layer_data *device_data, c
     bool skip = false;
     // Source image checks
     VkExtent3D granularity = GetScaledItg(device_data, cb_node, src_img);
-    skip |= CheckItgOffset(device_data, cb_node, &region->srcOffset, &granularity, i, function, "srcOffset");
+    skip |=
+        CheckItgOffset(device_data, cb_node, &region->srcOffset, &granularity, i, function, "srcOffset", VALIDATION_ERROR_19000dee);
     VkExtent3D subresource_extent = GetImageSubresourceExtent(src_img, &region->srcSubresource);
     const VkExtent3D extent = region->extent;
     skip |= CheckItgExtent(device_data, cb_node, &extent, &region->srcOffset, &granularity, &subresource_extent,
-                           src_img->createInfo.imageType, i, function, "extent");
+                           src_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000dee);
 
     // Destination image checks
     granularity = GetScaledItg(device_data, cb_node, dst_img);
-    skip |= CheckItgOffset(device_data, cb_node, &region->dstOffset, &granularity, i, function, "dstOffset");
+    skip |=
+        CheckItgOffset(device_data, cb_node, &region->dstOffset, &granularity, i, function, "dstOffset", VALIDATION_ERROR_19000df0);
     // Adjust dest extent, if necessary
     const VkExtent3D dest_effective_extent =
         GetAdjustedDestImageExtent(src_img->createInfo.format, dst_img->createInfo.format, extent);
     subresource_extent = GetImageSubresourceExtent(dst_img, &region->dstSubresource);
     skip |= CheckItgExtent(device_data, cb_node, &dest_effective_extent, &region->dstOffset, &granularity, &subresource_extent,
-                           dst_img->createInfo.imageType, i, function, "extent");
+                           dst_img->createInfo.imageType, i, function, "extent", VALIDATION_ERROR_19000df0);
     return skip;
 }
 
@@ -3766,10 +3756,7 @@ bool ValidateBufferImageCopyData(const debug_report_data *report_data, uint32_t
         }
 
         // Checks that apply only to compressed images
-        // TODO: there is a comment in ValidateCopyBufferImageTransferGranularityRequirements() in core_validation.cpp that
-        //       reserves a place for these compressed image checks.  This block of code could move there once the image
-        //       stuff is moved into core validation.
-        if (FormatIsCompressed(image_state->createInfo.format)) {
+        if (FormatIsCompressed(image_state->createInfo.format) || FormatIsSinglePlane_422(image_state->createInfo.format)) {
             auto block_size = FormatCompressedTexelBlockExtent(image_state->createInfo.format);
 
             //  BufferRowLength must be a multiple of block width
@@ -4000,7 +3987,7 @@ bool PreCallValidateCmdCopyImageToBuffer(layer_data *device_data, VkImageLayout
                                   VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_1920017c,
                                   &hit_error);
         skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, src_image_state, &pRegions[i], i,
-                                                                       "vkCmdCopyImageToBuffer()");
+                                                                       "vkCmdCopyImageToBuffer()", VALIDATION_ERROR_19200e04);
     }
     return skip;
 }
@@ -4054,7 +4041,7 @@ bool PreCallValidateCmdCopyBufferToImage(layer_data *device_data, VkImageLayout
                                   VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e0016a,
                                   &hit_error);
         skip |= ValidateCopyBufferImageTransferGranularityRequirements(device_data, cb_node, dst_image_state, &pRegions[i], i,
-                                                                       "vkCmdCopyBufferToImage()");
+                                                                       "vkCmdCopyBufferToImage()", VALIDATION_ERROR_18e00e02);
     }
     return skip;
 }
index 8cf1d83..7c7df98 100644 (file)
@@ -207,7 +207,8 @@ void PostCallRecordCreateImageView(layer_data *device_data, const VkImageViewCre
 
 bool ValidateCopyBufferImageTransferGranularityRequirements(layer_data *device_data, const GLOBAL_CB_NODE *cb_node,
                                                             const IMAGE_STATE *img, const VkBufferImageCopy *region,
-                                                            const uint32_t i, const char *function);
+                                                            const uint32_t i, const char *function,
+                                                            UNIQUE_VALIDATION_ERROR_CODE vuid);
 
 void PreCallRecordCmdCopyImage(layer_data *device_data, GLOBAL_CB_NODE *cb_node, IMAGE_STATE *src_image_state,
                                IMAGE_STATE *dst_image_state, uint32_t region_count, const VkImageCopy *regions,
index c20957e..b8d18c2 100644 (file)
@@ -1890,7 +1890,7 @@ VALIDATION_ERROR_18e0016a~^~Y~^~Unknown~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCop
 VALIDATION_ERROR_18e00ae8~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-dstImageLayout-01396~^~(VK_KHR_shared_presentable_image)~^~The spec valid usage text states 'dstImageLayout must be VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, or VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-dstImageLayout-01396)~^~
 VALIDATION_ERROR_18e00d4a~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-imageSubresource-01701~^~core~^~The spec valid usage text states 'The imageSubresource.mipLevel member of each element of pRegions must be less than the mipLevels specified in VkImageCreateInfo when dstImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyBufferToImage-imageSubresource-01701)~^~
 VALIDATION_ERROR_18e00d4c~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-imageSubresource-01702~^~core~^~The spec valid usage text states 'The imageSubresource.baseArrayLayer + imageSubresource.layerCount of each element of pRegions must be less than or equal to the arrayLayers specified in VkImageCreateInfo when dstImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyBufferToImage-imageSubresource-01702)~^~
-VALIDATION_ERROR_18e00e02~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-imageOffset-01793~^~core~^~The spec valid usage text states 'The imageOffset and and imageExtent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyBufferToImage-imageOffset-01793)~^~
+VALIDATION_ERROR_18e00e02~^~Y~^~CompressedImageMipCopyTests~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-imageOffset-01793~^~core~^~The spec valid usage text states 'The imageOffset and and imageExtent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyBufferToImage-imageOffset-01793)~^~
 VALIDATION_ERROR_18e00e48~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-commandBuffer-01828~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then srcBuffer must not be a protected buffer' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-commandBuffer-01828)~^~
 VALIDATION_ERROR_18e00e4a~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-commandBuffer-01829~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then dstImage must not be a protected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-commandBuffer-01829)~^~
 VALIDATION_ERROR_18e00e4c~^~N~^~None~^~vkCmdCopyBufferToImage~^~VUID-vkCmdCopyBufferToImage-commandBuffer-01830~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, then dstImage must not be an unprotected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyBufferToImage-commandBuffer-01830)~^~
@@ -1929,8 +1929,8 @@ VALIDATION_ERROR_19000d40~^~Y~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-srcS
 VALIDATION_ERROR_19000d42~^~Y~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-dstSubresource-01697~^~core~^~The spec valid usage text states 'The dstSubresource.mipLevel member of each element of pRegions must be less than the mipLevels specified in VkImageCreateInfo when dstImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-dstSubresource-01697)~^~
 VALIDATION_ERROR_19000d44~^~Y~^~CopyImageTypeExtentMismatch~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-srcSubresource-01698~^~core~^~The spec valid usage text states 'The srcSubresource.baseArrayLayer + srcSubresource.layerCount of each element of pRegions must be less than or equal to the arrayLayers specified in VkImageCreateInfo when srcImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-srcSubresource-01698)~^~
 VALIDATION_ERROR_19000d46~^~Y~^~CopyImageTypeExtentMismatch~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-dstSubresource-01699~^~core~^~The spec valid usage text states 'The dstSubresource.baseArrayLayer + dstSubresource.layerCount of each element of pRegions must be less than or equal to the arrayLayers specified in VkImageCreateInfo when dstImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-dstSubresource-01699)~^~
-VALIDATION_ERROR_19000dee~^~N~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-srcOffset-01783~^~core~^~The spec valid usage text states 'The srcOffset and and extent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-srcOffset-01783)~^~
-VALIDATION_ERROR_19000df0~^~N~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-dstOffset-01784~^~core~^~The spec valid usage text states 'The dstOffset and and extent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-dstOffset-01784)~^~
+VALIDATION_ERROR_19000dee~^~Y~^~DSImageTransferGranularityTests~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-srcOffset-01783~^~core~^~The spec valid usage text states 'The srcOffset and and extent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-srcOffset-01783)~^~
+VALIDATION_ERROR_19000df0~^~Y~^~DSImageTransferGranularityTests~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-dstOffset-01784~^~core~^~The spec valid usage text states 'The dstOffset and and extent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImage-dstOffset-01784)~^~
 VALIDATION_ERROR_19000e42~^~N~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-commandBuffer-01825~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then srcImage must not be a protected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImage-commandBuffer-01825)~^~
 VALIDATION_ERROR_19000e44~^~N~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-commandBuffer-01826~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then dstImage must not be a protected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImage-commandBuffer-01826)~^~
 VALIDATION_ERROR_19000e46~^~N~^~None~^~vkCmdCopyImage~^~VUID-vkCmdCopyImage-commandBuffer-01827~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, then dstImage must not be an unprotected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImage-commandBuffer-01827)~^~
@@ -1960,7 +1960,7 @@ VALIDATION_ERROR_19200180~^~Y~^~Unknown~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCop
 VALIDATION_ERROR_19200aea~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-srcImageLayout-01397~^~(VK_KHR_shared_presentable_image)~^~The spec valid usage text states 'srcImageLayout must be VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-srcImageLayout-01397)~^~
 VALIDATION_ERROR_19200d4e~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-imageSubresource-01703~^~core~^~The spec valid usage text states 'The imageSubresource.mipLevel member of each element of pRegions must be less than the mipLevels specified in VkImageCreateInfo when srcImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-imageSubresource-01703)~^~
 VALIDATION_ERROR_19200d50~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-imageSubresource-01704~^~core~^~The spec valid usage text states 'The imageSubresource.baseArrayLayer + imageSubresource.layerCount of each element of pRegions must be less than or equal to the arrayLayers specified in VkImageCreateInfo when srcImage was created' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-imageSubresource-01704)~^~
-VALIDATION_ERROR_19200e04~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-imageOffset-01794~^~core~^~The spec valid usage text states 'The imageOffset and and imageExtent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-imageOffset-01794)~^~
+VALIDATION_ERROR_19200e04~^~Y~^~CompressedImageMipCopyTests~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-imageOffset-01794~^~core~^~The spec valid usage text states 'The imageOffset and and imageExtent members of each element of pRegions must respect the image transfer granularity requirements of commandBuffer's command pool's queue family, as described in VkQueueFamilyProperties' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-imageOffset-01794)~^~
 VALIDATION_ERROR_19200e4e~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-commandBuffer-01831~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then srcImage must not be a protected image' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-commandBuffer-01831)~^~
 VALIDATION_ERROR_19200e50~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-commandBuffer-01832~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is an unprotected command buffer, then dstBuffer must not be a protected buffer' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-commandBuffer-01832)~^~
 VALIDATION_ERROR_19200e52~^~N~^~None~^~vkCmdCopyImageToBuffer~^~VUID-vkCmdCopyImageToBuffer-commandBuffer-01833~^~(VK_VERSION_1_1)~^~The spec valid usage text states 'If commandBuffer is a protected command buffer, then dstBuffer must not be an unprotected buffer' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/html/vkspec.html#VUID-vkCmdCopyImageToBuffer-commandBuffer-01833)~^~
index c5e1415..250f160 100644 (file)
@@ -4051,6 +4051,7 @@ TEST_F(VkLayerTest, DSImageTransferGranularityTests) {
     if ((queue_family_properties[index].minImageTransferGranularity.depth < 4) ||
         (queue_family_properties[index].minImageTransferGranularity.width < 4) ||
         (queue_family_properties[index].minImageTransferGranularity.height < 4)) {
+        printf("             Image transfer granularity is too small to test meaningfully. Skipping.\n");
         return;
     }
 
@@ -4130,14 +4131,16 @@ TEST_F(VkLayerTest, DSImageTransferGranularityTests) {
 
     // Introduce failure by setting srcOffset to a bad granularity value
     copyRegion.srcOffset.y = 3;
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // srcOffset image transfer granularity
     m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &copyRegion);
     m_errorMonitor->VerifyFound();
 
     // Introduce failure by setting extent to a bad granularity value
     copyRegion.srcOffset.y = 0;
     copyRegion.extent.width = 3;
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // src extent image transfer granularity
     m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &copyRegion);
     m_errorMonitor->VerifyFound();
 
@@ -4160,14 +4163,14 @@ TEST_F(VkLayerTest, DSImageTransferGranularityTests) {
 
     // Introduce failure by setting imageExtent to a bad granularity value
     region.imageExtent.width = 3;
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_19200e04);  // image transfer granularity
     vkCmdCopyImageToBuffer(m_commandBuffer->handle(), srcImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, buffer.handle(), 1, &region);
     m_errorMonitor->VerifyFound();
     region.imageExtent.width = 16;
 
     // Introduce failure by setting imageOffset to a bad granularity value
     region.imageOffset.z = 3;
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_18e00e02);  // image transfer granularity
     vkCmdCopyBufferToImage(m_commandBuffer->handle(), buffer.handle(), srcImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &region);
     m_errorMonitor->VerifyFound();
 
@@ -19135,29 +19138,41 @@ TEST_F(VkLayerTest, CompressedImageMipCopyTests) {
     // Copy width < compressed block size, but not the full mip width
     region.imageExtent = {1, 2, 1};
     region.imageSubresource.mipLevel = 4;
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_0160019e);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_0160019e);  // width not a multiple of compressed block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_19200e04);  // image transfer granularity
     vkCmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, &region);
     m_errorMonitor->VerifyFound();
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_0160019e);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_0160019e);  // width not a multiple of compressed block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_18e00e02);  // image transfer granularity
     vkCmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &region);
     m_errorMonitor->VerifyFound();
 
     // Copy height < compressed block size but not the full mip height
     region.imageExtent = {2, 1, 1};
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_016001a0);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_016001a0);  // height not a multiple of compressed block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_19200e04);  // image transfer granularity
     vkCmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, &region);
     m_errorMonitor->VerifyFound();
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_016001a0);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_016001a0);  // height not a multiple of compressed block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_18e00e02);  // image transfer granularity
     vkCmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &region);
     m_errorMonitor->VerifyFound();
 
     // Offsets must be multiple of compressed block size
     region.imageOffset = {1, 1, 0};
     region.imageExtent = {1, 1, 1};
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_0160019a);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_0160019a);  // imageOffset not a multiple of block size
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_19200e04);  // image transfer granularity
     vkCmdCopyImageToBuffer(m_commandBuffer->handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, &region);
     m_errorMonitor->VerifyFound();
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_0160019a);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_0160019a);  // imageOffset not a multiple of block size
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_18e00e02);  // image transfer granularity
     vkCmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &region);
     m_errorMonitor->VerifyFound();
 
@@ -19179,10 +19194,14 @@ TEST_F(VkLayerTest, CompressedImageMipCopyTests) {
 
     // Offset + extent width < mip width and not a multiple of block width - should fail
     region.imageExtent = {3, 3, 1};
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_016001a0);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_016001a0);  // offset+extent not a multiple of block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_19200e04);  // image transfer granularity
     vkCmdCopyImageToBuffer(m_commandBuffer->handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16.handle(), 1, &region);
     m_errorMonitor->VerifyFound();
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_016001a0);
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_016001a0);  // offset+extent not a multiple of block width
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_18e00e02);  // image transfer granularity
     vkCmdCopyBufferToImage(m_commandBuffer->handle(), buffer_16.handle(), odd_image.handle(), VK_IMAGE_LAYOUT_GENERAL, 1, &region);
     m_errorMonitor->VerifyFound();
 }
@@ -19513,14 +19532,20 @@ TEST_F(VkLayerTest, ImageBufferCopyTests) {
         region.bufferOffset = 0;
 
         // extents that are not a multiple of compressed block size
-        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_0160019e);
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                             VALIDATION_ERROR_0160019e);  // extent width not a multiple of block size
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                             VALIDATION_ERROR_19200e04);  // image transfer granularity
         region.imageExtent.width = 66;
         vkCmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(),
                                1, &region);
         m_errorMonitor->VerifyFound();
         region.imageExtent.width = 128;
 
-        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_016001a0);
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                             VALIDATION_ERROR_016001a0);  // extent height not a multiple of block size
+        m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                             VALIDATION_ERROR_19200e04);  // image transfer granularity
         region.imageExtent.height = 2;
         vkCmdCopyImageToBuffer(m_commandBuffer->handle(), image_NPOT_4x4comp.handle(), VK_IMAGE_LAYOUT_GENERAL, buffer_16k.handle(),
                                1, &region);
@@ -20719,12 +20744,14 @@ TEST_F(VkLayerTest, CopyImageCompressedBlockAlignment) {
     vuid = ycbcr ? VALIDATION_ERROR_09c00d7e : VALIDATION_ERROR_09c0013a;
     copy_region.srcOffset = {2, 4, 0};  // source width
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // srcOffset image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     copy_region.srcOffset = {12, 1, 0};  // source height
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // srcOffset image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     copy_region.srcOffset = {0, 0, 0};
@@ -20732,12 +20759,14 @@ TEST_F(VkLayerTest, CopyImageCompressedBlockAlignment) {
     vuid = ycbcr ? VALIDATION_ERROR_09c00d86 : VALIDATION_ERROR_09c00144;
     copy_region.dstOffset = {1, 0, 0};  // dest width
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000df0);  // dstOffset image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     copy_region.dstOffset = {4, 1, 0};  // dest height
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000df0);  // dstOffset image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     copy_region.dstOffset = {0, 0, 0};
@@ -20746,26 +20775,30 @@ TEST_F(VkLayerTest, CopyImageCompressedBlockAlignment) {
     vuid = ycbcr ? VALIDATION_ERROR_09c00d80 : VALIDATION_ERROR_09c0013c;
     copy_region.extent = {62, 60, 1};  // source width
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // src extent image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     vuid = ycbcr ? VALIDATION_ERROR_09c00d82 : VALIDATION_ERROR_09c0013e;
     copy_region.extent = {60, 62, 1};  // source height
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000dee);  // src extent image transfer granularity
     m_commandBuffer->CopyImage(image_1.image(), VK_IMAGE_LAYOUT_GENERAL, image_2.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
 
     vuid = ycbcr ? VALIDATION_ERROR_09c00d88 : VALIDATION_ERROR_09c00146;
     copy_region.extent = {62, 60, 1};  // dest width
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000df0);  // dst extent image transfer granularity
     m_commandBuffer->CopyImage(image_2.image(), VK_IMAGE_LAYOUT_GENERAL, image_1.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();
     vuid = ycbcr ? VALIDATION_ERROR_09c00d8a : VALIDATION_ERROR_09c00148;
     copy_region.extent = {60, 62, 1};  // dest height
     m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, vuid);
-    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "queue family image transfer granularity");
+    m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                                         VALIDATION_ERROR_19000df0);  // dst extent image transfer granularity
     m_commandBuffer->CopyImage(image_2.image(), VK_IMAGE_LAYOUT_GENERAL, image_1.image(), VK_IMAGE_LAYOUT_GENERAL, 1, &copy_region);
     m_errorMonitor->VerifyFound();