layers: LX581, Warn for null-region blits
authorMark Lobodzinski <mark@lunarg.com>
Tue, 16 Aug 2016 17:51:12 +0000 (11:51 -0600)
committerMark Lobodzinski <mark@lunarg.com>
Tue, 16 Aug 2016 20:23:20 +0000 (14:23 -0600)
Parameters specifying the extents for VkCmdBlitImage are often
misinterpreted from the spec. Add warningis if the extents do not
specify a positively-sized area.

Change-Id: I11324dcf4523b094d7545f406d5f87a1145e0563

layers/image.cpp

index 8d789c6..f2118e7 100644 (file)
@@ -1033,6 +1033,28 @@ CmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcI
     bool skipCall = false;
     layer_data *device_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
 
+    // Warn for zero-sized regions
+    for (uint32_t i = 0; i < regionCount; i++) {
+        if ((pRegions[i].srcOffsets[0].x == pRegions[i].srcOffsets[1].x) ||
+            (pRegions[i].srcOffsets[0].y == pRegions[i].srcOffsets[1].y) ||
+            (pRegions[i].srcOffsets[0].z == pRegions[i].srcOffsets[1].z)) {
+            std::stringstream ss;
+            ss << "vkCmdBlitImage: pRegions[" << i << "].srcOffsets specify a zero-volume area.";
+            skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
+                VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer),
+                __LINE__, IMAGE_INVALID_EXTENTS, "IMAGE", "%s", ss.str().c_str());
+        }
+        if ((pRegions[i].dstOffsets[0].x == pRegions[i].dstOffsets[1].x) ||
+            (pRegions[i].dstOffsets[0].y == pRegions[i].dstOffsets[1].y) ||
+            (pRegions[i].dstOffsets[0].z == pRegions[i].dstOffsets[1].z)) {
+            std::stringstream ss;
+            ss << "vkCmdBlitImage: pRegions[" << i << "].dstOffsets specify a zero-volume area.";
+            skipCall |= log_msg(device_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
+                VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, reinterpret_cast<uint64_t>(commandBuffer),
+                __LINE__, IMAGE_INVALID_EXTENTS, "IMAGE", "%s", ss.str().c_str());
+        }
+    }
+
     auto srcImageEntry = getImageState(device_data, srcImage);
     auto dstImageEntry = getImageState(device_data, dstImage);