Merge vk-gl-cts/vulkan-cts-1.1.0 into vk-gl-cts/vulkan-cts-1.1.1

Change-Id: I2d8288ee3b75ef786496453b0efa6591f4f5c0ad
diff --git a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp
index e988a3c..6e5bce2 100644
--- a/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp
+++ b/external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp
@@ -2079,12 +2079,26 @@
 												const tcu::ConstPixelBufferAccess&	unclampedExpected,
 												const tcu::TextureFormat&			srcFormat)
 {
-	tcu::TestLog&				log			(m_context.getTestContext().getLog());
-	const tcu::TextureFormat	dstFormat	= result.getFormat();
-	bool						isOk		= false;
+	tcu::TestLog&					log				(m_context.getTestContext().getLog());
+	const tcu::TextureFormat		dstFormat		= result.getFormat();
+	const tcu::TextureChannelClass	dstChannelClass = tcu::getTextureChannelClass(dstFormat.type);
+	const tcu::TextureChannelClass	srcChannelClass = tcu::getTextureChannelClass(srcFormat.type);
+	bool							isOk			= false;
 
 	log << tcu::TestLog::Section("ClampedSourceImage", "Region with clamped edges on source image.");
 
+	// if either of srcImage or dstImage was created with a signed/unsigned integer VkFormat,
+	// the other must also have been created with a signed/unsigned integer VkFormat
+	bool dstImageIsIntClass = dstChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
+							  dstChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+	bool srcImageIsIntClass = srcChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
+							  srcChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+	if (dstImageIsIntClass != srcImageIsIntClass)
+	{
+		log << tcu::TestLog::EndSection;
+		return false;
+	}
+
 	if (isFloatFormat(dstFormat))
 	{
 		const bool		srcIsSRGB	= tcu::isSRGB(srcFormat);
@@ -2315,7 +2329,9 @@
 {
 	tcu::TestLog&					log				(m_context.getTestContext().getLog());
 	const tcu::TextureFormat		dstFormat		= result.getFormat();
+	const tcu::TextureFormat		srcFormat		= source.getFormat();
 	const tcu::TextureChannelClass	dstChannelClass = tcu::getTextureChannelClass(dstFormat.type);
+	const tcu::TextureChannelClass	srcChannelClass = tcu::getTextureChannelClass(srcFormat.type);
 
 	tcu::TextureLevel		errorMaskStorage	(tcu::TextureFormat(tcu::TextureFormat::RGB, tcu::TextureFormat::UNORM_INT8), result.getWidth(), result.getHeight());
 	tcu::PixelBufferAccess	errorMask			= errorMaskStorage.getAccess();
@@ -2325,8 +2341,16 @@
 
 	tcu::clear(errorMask, tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0));
 
-	if (dstChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
-		dstChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER)
+	// if either of srcImage or dstImage was created with a signed/unsigned integer VkFormat,
+	// the other must also have been created with a signed/unsigned integer VkFormat
+	bool dstImageIsIntClass = dstChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
+							  dstChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+	bool srcImageIsIntClass = srcChannelClass == tcu::TEXTURECHANNELCLASS_SIGNED_INTEGER ||
+							  srcChannelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
+	if (dstImageIsIntClass != srcImageIsIntClass)
+		return false;
+
+	if (dstImageIsIntClass)
 	{
 		ok = intNearestBlitCompare(source, result, errorMask, m_params.regions);
 	}
@@ -3360,7 +3384,7 @@
 	virtual tcu::TestStatus						iterate						(void);
 protected:
 	virtual tcu::TestStatus						checkTestResult				(tcu::ConstPixelBufferAccess result = tcu::ConstPixelBufferAccess());
-	void										copyMSImageToMSImage		(void);
+	void										copyMSImageToMSImage		(deUint32 copyArraySize);
 private:
 	Move<VkImage>								m_multisampledImage;
 	de::MovePtr<Allocation>						m_multisampledImageAlloc;
@@ -3918,11 +3942,17 @@
 	generateBuffer(m_sourceTextureLevel->getAccess(), m_params.src.image.extent.width, m_params.src.image.extent.height, m_params.dst.image.extent.depth, FILL_MODE_MULTISAMPLE);
 	generateExpectedResult();
 
+	VkImage		sourceImage		= m_multisampledImage.get();
+	deUint32	sourceArraySize	= getArraySize(m_params.src.image);
+
 	switch (m_options)
 	{
-		case COPY_MS_IMAGE_TO_MS_IMAGE:
 		case COPY_MS_IMAGE_TO_ARRAY_MS_IMAGE:
-			copyMSImageToMSImage();
+			// Duplicate the multisampled image to a multisampled image array
+			sourceArraySize	= getArraySize(m_params.dst.image);
+		case COPY_MS_IMAGE_TO_MS_IMAGE:
+			copyMSImageToMSImage(sourceArraySize);
+			sourceImage	= m_multisampledCopyImage.get();
 			break;
 		default:
 			break;
@@ -3948,13 +3978,13 @@
 			VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,		// VkImageLayout			newLayout;
 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					srcQueueFamilyIndex;
 			VK_QUEUE_FAMILY_IGNORED,					// deUint32					dstQueueFamilyIndex;
-			m_multisampledImage.get(),					// VkImage					image;
+			sourceImage,								// VkImage					image;
 			{											// VkImageSubresourceRange	subresourceRange;
 				getAspectFlags(srcTcuFormat),		// VkImageAspectFlags	aspectMask;
 				0u,									// deUint32				baseMipLevel;
 				1u,									// deUint32				mipLevels;
 				0u,									// deUint32				baseArraySlice;
-				getArraySize(m_params.src.image)	// deUint32				arraySize;
+				sourceArraySize						// deUint32				arraySize;
 			}
 		},
 		// destination image
@@ -4008,7 +4038,7 @@
 
 	VK_CHECK(vk.beginCommandBuffer(*m_cmdBuffer, &cmdBufferBeginInfo));
 	vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, DE_LENGTH_OF_ARRAY(imageBarriers), imageBarriers);
-	vk.cmdResolveImage(*m_cmdBuffer, m_multisampledImage.get(), VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageResolves.data());
+	vk.cmdResolveImage(*m_cmdBuffer, sourceImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, m_destination.get(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, (deUint32)m_params.regions.size(), imageResolves.data());
 	vk.cmdPipelineBarrier(*m_cmdBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_HOST_BIT, (VkDependencyFlags)0, 0, (const VkMemoryBarrier*)DE_NULL, 0, (const VkBufferMemoryBarrier*)DE_NULL, 1, &postImageBarrier);
 	VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
 	submitCommandsAndWait(vk, vkDevice, queue, *m_cmdBuffer);
@@ -4052,7 +4082,7 @@
 	tcu::copy(dstSubRegion, srcSubRegion);
 }
 
-void ResolveImageToImage::copyMSImageToMSImage (void)
+void ResolveImageToImage::copyMSImageToMSImage (deUint32 copyArraySize)
 {
 	const DeviceInterface&			vk					= m_context.getDeviceInterface();
 	const VkDevice					vkDevice			= m_context.getDevice();
@@ -4060,7 +4090,7 @@
 	const tcu::TextureFormat		srcTcuFormat		= mapVkFormat(m_params.src.image.format);
 	std::vector<VkImageCopy>		imageCopies;
 
-	for (deUint32 layerNdx = 0; layerNdx < getArraySize(m_params.dst.image); ++layerNdx)
+	for (deUint32 layerNdx = 0; layerNdx < copyArraySize; ++layerNdx)
 	{
 		const VkImageSubresourceLayers	sourceSubresourceLayers	=
 		{
@@ -4126,13 +4156,13 @@
 				0u,									// deUint32				baseMipLevel;
 				1u,									// deUint32				mipLevels;
 				0u,									// deUint32				baseArraySlice;
-				getArraySize(m_params.dst.image)	// deUint32				arraySize;
+				copyArraySize						// deUint32				arraySize;
 			}
 		},
 	};
 
 	const VkImageMemoryBarrier	postImageBarriers		=
-	// source image
+	// destination image
 	{
 		VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,		// VkStructureType			sType;
 		DE_NULL,									// const void*				pNext;
@@ -4148,7 +4178,7 @@
 			0u,									// deUint32				baseMipLevel;
 			1u,									// deUint32				mipLevels;
 			0u,									// deUint32				baseArraySlice;
-			getArraySize(m_params.dst.image)	// deUint32				arraySize;
+			copyArraySize						// deUint32				arraySize;
 		}
 	};
 
@@ -4167,8 +4197,6 @@
 	VK_CHECK(vk.endCommandBuffer(*m_cmdBuffer));
 
 	submitCommandsAndWait (vk, vkDevice, queue, *m_cmdBuffer);
-
-	m_multisampledImage = m_multisampledCopyImage;
 }
 
 class ResolveImageToImageTestCase : public vkt::TestCase