tests: Add CmdCopyImage region extents checks
Added two tests to check validation of regionsize against src and
dest image sizes.
Change-Id: Ic3afbc32a63b791a6ad302c91bdcc60a86ae5ace
diff --git a/tests/layer_validation_tests.cpp b/tests/layer_validation_tests.cpp
index d54250c..87ba507 100644
--- a/tests/layer_validation_tests.cpp
+++ b/tests/layer_validation_tests.cpp
@@ -17781,6 +17781,83 @@
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
+TEST_F(VkLayerTest, CopyImageSrcSizeExceeded) {
+
+ // Image copy with source region specified greater than src image size
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ "exceeds extents srcImage was created with");
+
+ ASSERT_NO_FATAL_FAILURE(InitState());
+
+ VkImageObj src_image(m_device);
+ src_image.init(32, 32, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_LINEAR, 0);
+ VkImageObj dst_image(m_device);
+ dst_image.init(64, 64, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_LINEAR, 0);
+
+ BeginCommandBuffer();
+ VkImageCopy copy_region;
+ copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copy_region.srcSubresource.mipLevel = 0;
+ copy_region.srcSubresource.baseArrayLayer = 0;
+ copy_region.srcSubresource.layerCount = 0;
+ copy_region.srcOffset.x = 0;
+ copy_region.srcOffset.y = 0;
+ copy_region.srcOffset.z = 0;
+ copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copy_region.dstSubresource.mipLevel = 0;
+ copy_region.dstSubresource.baseArrayLayer = 0;
+ copy_region.dstSubresource.layerCount = 0;
+ copy_region.dstOffset.x = 0;
+ copy_region.dstOffset.y = 0;
+ copy_region.dstOffset.z = 0;
+ copy_region.extent.width = 64;
+ copy_region.extent.height = 64;
+ copy_region.extent.depth = 1;
+ m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1,
+ ©_region);
+ EndCommandBuffer();
+
+ m_errorMonitor->VerifyFound();
+}
+
+TEST_F(VkLayerTest, CopyImageDstSizeExceeded) {
+
+ // Image copy with dest region specified greater than dest image size
+ m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "exceeds extents dstImage was created with");
+
+ ASSERT_NO_FATAL_FAILURE(InitState());
+
+ VkImageObj src_image(m_device);
+ src_image.init(64, 64, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT, VK_IMAGE_TILING_LINEAR, 0);
+ VkImageObj dst_image(m_device);
+ dst_image.init(32, 32, VK_FORMAT_B8G8R8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_TILING_LINEAR, 0);
+
+ BeginCommandBuffer();
+ VkImageCopy copy_region;
+ copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copy_region.srcSubresource.mipLevel = 0;
+ copy_region.srcSubresource.baseArrayLayer = 0;
+ copy_region.srcSubresource.layerCount = 0;
+ copy_region.srcOffset.x = 0;
+ copy_region.srcOffset.y = 0;
+ copy_region.srcOffset.z = 0;
+ copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ copy_region.dstSubresource.mipLevel = 0;
+ copy_region.dstSubresource.baseArrayLayer = 0;
+ copy_region.dstSubresource.layerCount = 0;
+ copy_region.dstOffset.x = 0;
+ copy_region.dstOffset.y = 0;
+ copy_region.dstOffset.z = 0;
+ copy_region.extent.width = 64;
+ copy_region.extent.height = 64;
+ copy_region.extent.depth = 1;
+ m_commandBuffer->CopyImage(src_image.image(), VK_IMAGE_LAYOUT_GENERAL, dst_image.image(), VK_IMAGE_LAYOUT_GENERAL, 1,
+ ©_region);
+ EndCommandBuffer();
+
+ m_errorMonitor->VerifyFound();
+}
+
TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) {
VkResult err;
bool pass;