layers: Add VU 01185 and a test
Added check for valid usage 01185. Added test
CopyImageSampleCountMismatch() to verify the check.
Change-Id: I51e76e0334bd4f1c0fe564f241646fc8b788da1e
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index 32c6d63..0bafc23 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -1443,6 +1443,14 @@
}
}
+ // Source and dest image sample counts must match
+ if (src_image_state->createInfo.samples != dst_image_state->createInfo.samples) {
+ char const str[] = "vkCmdCopyImage() called on image pair with non-identical sample counts.";
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
+ reinterpret_cast<uint64_t &>(command_buffer), __LINE__, VALIDATION_ERROR_01185, "IMAGE", "%s %s", str,
+ validation_error_map[VALIDATION_ERROR_01185]);
+ }
+
skip |= ValidateMemoryIsBoundToImage(device_data, src_image_state, "vkCmdCopyImage()", VALIDATION_ERROR_02533);
skip |= ValidateMemoryIsBoundToImage(device_data, dst_image_state, "vkCmdCopyImage()", VALIDATION_ERROR_02534);
// Validate that SRC & DST images have correct usage flags set
diff --git a/layers/vk_validation_error_database.txt b/layers/vk_validation_error_database.txt
index d371b84..ca79938 100644
--- a/layers/vk_validation_error_database.txt
+++ b/layers/vk_validation_error_database.txt
@@ -1173,7 +1173,7 @@
VALIDATION_ERROR_01182~^~N~^~Unknown~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'dstImageLayout must specify the layout of the image subresources of dstImage specified in pRegions at the time this command is executed on a VkDevice' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~
VALIDATION_ERROR_01183~^~Y~^~Unknown~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'dstImageLayout must be either of VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL or VK_IMAGE_LAYOUT_GENERAL' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~
VALIDATION_ERROR_01184~^~Y~^~CopyImageFormatSizeMismatch~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'The VkFormat of each of srcImage and dstImage must be compatible, as defined below' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~
-VALIDATION_ERROR_01185~^~N~^~Unknown~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'The sample count of srcImage and dstImage must match' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~
+VALIDATION_ERROR_01185~^~Y~^~CopyImageMiscAttributesMismatch~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'The sample count of srcImage and dstImage must match' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~
VALIDATION_ERROR_01186~^~Y~^~None~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'commandBuffer must be a valid VkCommandBuffer handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~implicit
VALIDATION_ERROR_01187~^~Y~^~None~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'srcImage must be a valid VkImage handle' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~implicit
VALIDATION_ERROR_01188~^~N~^~Unknown~^~vkCmdCopyImage~^~For more information refer to Vulkan Spec Section '18.3. Copying Data Between Images' which states 'srcImageLayout must be a valid VkImageLayout value' (https://www.khronos.org/registry/vulkan/specs/1.0-extensions/xhtml/vkspec.html#vkCmdCopyImage)~^~implicit
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index 9a6f777..a416b29 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -17139,6 +17139,93 @@
vkFreeMemory(m_device->device(), destMem, NULL);
}
+TEST_F(VkLayerTest, CopyImageMiscAttributesMismatch) {
+ TEST_DESCRIPTION("Image copies with various attribute mis-matches");
+
+ ASSERT_NO_FATAL_FAILURE(InitState());
+
+ VkImageFormatProperties image_format_properties;
+ vkGetPhysicalDeviceImageFormatProperties(gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL,
+ VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, 0,
+ &image_format_properties);
+
+ if ((0 == (VK_SAMPLE_COUNT_2_BIT & image_format_properties.sampleCounts)) ||
+ (0 == (VK_SAMPLE_COUNT_4_BIT & image_format_properties.sampleCounts))) {
+ printf(" Image multi-sample support not found; skipped.\n");
+ return;
+ }
+
+ VkImageCreateInfo ci;
+ ci.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ ci.pNext = NULL;
+ ci.flags = 0;
+ ci.imageType = VK_IMAGE_TYPE_2D;
+ ci.format = VK_FORMAT_R8G8B8A8_UNORM;
+ ci.extent = {128, 128, 1};
+ ci.mipLevels = 1;
+ ci.arrayLayers = 1;
+ ci.samples = VK_SAMPLE_COUNT_1_BIT;
+ ci.tiling = VK_IMAGE_TILING_OPTIMAL;
+ ci.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ ci.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ ci.queueFamilyIndexCount = 0;
+ ci.pQueueFamilyIndices = NULL;
+ ci.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+
+ VkImageObj image1(m_device);
+ image1.init(&ci);
+ ASSERT_TRUE(image1.initialized());
+
+ ci.samples = VK_SAMPLE_COUNT_2_BIT;
+ VkImageObj image2(m_device);
+ image2.init(&ci);
+ ASSERT_TRUE(image2.initialized());
+
+ ci.samples = VK_SAMPLE_COUNT_4_BIT;
+ VkImageObj image4(m_device);
+ image4.init(&ci);
+ ASSERT_TRUE(image4.initialized());
+
+ m_commandBuffer->BeginCommandBuffer();
+
+ VkImageCopy copyRegion;
+ copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copyRegion.srcSubresource.mipLevel = 0;
+ copyRegion.srcSubresource.baseArrayLayer = 0;
+ copyRegion.srcSubresource.layerCount = 1;
+ copyRegion.srcOffset = {0, 0, 0};
+ copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copyRegion.dstSubresource.mipLevel = 0;
+ copyRegion.dstSubresource.baseArrayLayer = 0;
+ copyRegion.dstSubresource.layerCount = 1;
+ copyRegion.dstOffset = {0, 0, 0};
+ copyRegion.extent = {128, 128, 1};
+
+ // Copy a single sample image to/from a multi-sample image
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01185);
+ vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), image1.handle(), VK_IMAGE_LAYOUT_GENERAL, image4.handle(),
+ VK_IMAGE_LAYOUT_GENERAL, 1, ©Region);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01185);
+ vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), image2.handle(), VK_IMAGE_LAYOUT_GENERAL, image1.handle(),
+ VK_IMAGE_LAYOUT_GENERAL, 1, ©Region);
+ m_errorMonitor->VerifyFound();
+
+ // Copy between multi-sample images with different sample counts
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01185);
+ vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), image2.handle(), VK_IMAGE_LAYOUT_GENERAL, image4.handle(),
+ VK_IMAGE_LAYOUT_GENERAL, 1, ©Region);
+ m_errorMonitor->VerifyFound();
+
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, VALIDATION_ERROR_01185);
+ vkCmdCopyImage(m_commandBuffer->GetBufferHandle(), image4.handle(), VK_IMAGE_LAYOUT_GENERAL, image2.handle(),
+ VK_IMAGE_LAYOUT_GENERAL, 1, ©Region);
+ m_errorMonitor->VerifyFound();
+
+ m_commandBuffer->EndCommandBuffer();
+}
+
TEST_F(VkLayerTest, ResolveImageLowSampleCount) {
VkResult err;
bool pass;