Assert multisample resolve has equal input and output formats

While our generic Blitter routine can handle resolving any multisample
format into any other format, the 'fastResolve()' method performs simple
per-component sample averaging, thus assuming the input and output
formats are identical.

This is also demanded by the Vulkan specification:
- vkCmdResolveImage: "srcImage and dstImage must have been created with
  the same image format."
- VkSubpassDescription: "each resolve attachment that is not
  VK_ATTACHMENT_UNUSED must have the same VkFormat as its corresponding
  color attachment."

This change adds an assert which would catch violations of that.

Bug: b/147802090
Change-Id: I23d2d463efbbaed04a782a0cf61b255bf1c25b03
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48088
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index 29767d1..f709c31 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -1882,6 +1882,17 @@
 
 void Blitter::resolve(const vk::Image *src, vk::Image *dst, VkImageResolve region)
 {
+	// "The aspectMask member of srcSubresource and dstSubresource must only contain VK_IMAGE_ASPECT_COLOR_BIT"
+	ASSERT(region.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
+	ASSERT(region.dstSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
+	// "The layerCount member of srcSubresource and dstSubresource must match"
+	ASSERT(region.srcSubresource.layerCount == region.dstSubresource.layerCount);
+
+	// We use this method both for explicit resolves from vkCmdResolveImage, and implicit ones for resolve attachments.
+	// - vkCmdResolveImage: "srcImage and dstImage must have been created with the same image format."
+	// - VkSubpassDescription: "each resolve attachment that is not VK_ATTACHMENT_UNUSED must have the same VkFormat as its corresponding color attachment."
+	ASSERT(src->getFormat() == dst->getFormat());
+
 	if(fastResolve(src, dst, region))
 	{
 		return;
@@ -1913,11 +1924,6 @@
 
 bool Blitter::fastResolve(const vk::Image *src, vk::Image *dst, VkImageResolve region)
 {
-	// "The aspectMask member of srcSubresource and dstSubresource must only contain VK_IMAGE_ASPECT_COLOR_BIT"
-	ASSERT(region.srcSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
-	ASSERT(region.dstSubresource.aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
-	ASSERT(region.srcSubresource.layerCount == region.dstSubresource.layerCount);
-
 	if(region.dstOffset != VkOffset3D{ 0, 0, 0 })
 	{
 		return false;