Small resolveDepthStencil refactor

Only pass down the required information to resolveDepthStencil,
which is the resolve modes, rather than the full
VkSubpassDescriptionDepthStencilResolve structure.

Bug: b/204502119
Change-Id: Ief04f3f8687b133a09662859c1003f3cec3b899e
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/62969
Tested-by: Alexis Hétu <sugoi@google.com>
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index 8bde18b..5b5cd5f 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -1964,9 +1964,9 @@
 	dst->contentsChanged(dstSubresRange);
 }
 
-static void resolveDepth(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc)
+static void resolveDepth(const vk::ImageView *src, vk::ImageView *dst, const VkResolveModeFlagBits depthResolveMode)
 {
-	if(dsrDesc.depthResolveMode == VK_RESOLVE_MODE_NONE)
+	if(depthResolveMode == VK_RESOLVE_MODE_NONE)
 	{
 		return;
 	}
@@ -1984,7 +1984,7 @@
 
 	size_t formatSize = format.bytes();
 	// TODO(b/167558951) support other resolve modes.
-	ASSERT(dsrDesc.depthResolveMode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
+	ASSERT(depthResolveMode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
 	for(int y = 0; y < height; y++)
 	{
 		memcpy(dest, source, formatSize * width);
@@ -1996,9 +1996,9 @@
 	dst->contentsChanged(vk::Image::DIRECT_MEMORY_ACCESS);
 }
 
-static void resolveStencil(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc)
+static void resolveStencil(const vk::ImageView *src, vk::ImageView *dst, const VkResolveModeFlagBits stencilResolveMode)
 {
-	if(dsrDesc.stencilResolveMode == VK_RESOLVE_MODE_NONE)
+	if(stencilResolveMode == VK_RESOLVE_MODE_NONE)
 	{
 		return;
 	}
@@ -2014,7 +2014,7 @@
 	uint8_t *dest = reinterpret_cast<uint8_t *>(dst->getOffsetPointer({ 0, 0, 0 }, VK_IMAGE_ASPECT_STENCIL_BIT, 0, 0));
 
 	// TODO(b/167558951) support other resolve modes.
-	ASSERT(dsrDesc.stencilResolveMode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
+	ASSERT(stencilResolveMode == VK_RESOLVE_MODE_SAMPLE_ZERO_BIT);
 	for(int y = 0; y < height; y++)
 	{
 		// Stencil is always 8 bits, so the width of the resource we're resolving is
@@ -2028,7 +2028,7 @@
 	dst->contentsChanged(vk::Image::DIRECT_MEMORY_ACCESS);
 }
 
-void Blitter::resolveDepthStencil(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc)
+void Blitter::resolveDepthStencil(const vk::ImageView *src, vk::ImageView *dst, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode)
 {
 	VkImageSubresourceRange srcRange = src->getSubresourceRange();
 	VkImageSubresourceRange dstRange = src->getSubresourceRange();
@@ -2038,11 +2038,11 @@
 
 	if(srcRange.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT)
 	{
-		resolveDepth(src, dst, dsrDesc);
+		resolveDepth(src, dst, depthResolveMode);
 	}
 	if(srcRange.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT)
 	{
-		resolveStencil(src, dst, dsrDesc);
+		resolveStencil(src, dst, stencilResolveMode);
 	}
 }
 
diff --git a/src/Device/Blitter.hpp b/src/Device/Blitter.hpp
index fe60164..65a9cf6 100644
--- a/src/Device/Blitter.hpp
+++ b/src/Device/Blitter.hpp
@@ -145,7 +145,7 @@
 
 	void blit(const vk::Image *src, vk::Image *dst, VkImageBlit2KHR region, VkFilter filter);
 	void resolve(const vk::Image *src, vk::Image *dst, VkImageResolve2KHR region);
-	void resolveDepthStencil(const vk::ImageView *src, vk::ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsrDesc);
+	void resolveDepthStencil(const vk::ImageView *src, vk::ImageView *dst, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode);
 	void copy(const vk::Image *src, uint8_t *dst, unsigned int dstPitch);
 
 	void updateBorders(const vk::Image *image, const VkImageSubresource &subresource);
diff --git a/src/Vulkan/VkFramebuffer.cpp b/src/Vulkan/VkFramebuffer.cpp
index 8eb821f..77eb295 100644
--- a/src/Vulkan/VkFramebuffer.cpp
+++ b/src/Vulkan/VkFramebuffer.cpp
@@ -226,7 +226,8 @@
 		if(depthStencilAttachment != VK_ATTACHMENT_UNUSED)
 		{
 			ImageView *imageView = attachments[depthStencilAttachment];
-			imageView->resolveDepthStencil(attachments[dsResolve.pDepthStencilResolveAttachment->attachment], dsResolve);
+			imageView->resolveDepthStencil(attachments[dsResolve.pDepthStencilResolveAttachment->attachment],
+			                               dsResolve.depthResolveMode, dsResolve.stencilResolveMode);
 		}
 	}
 }
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index 4c57dc0..1533e49 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -1036,9 +1036,9 @@
 	device->getBlitter()->resolve(this, dstImage, region);
 }
 
-void Image::resolveDepthStencilTo(const ImageView *src, ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &dsResolve) const
+void Image::resolveDepthStencilTo(const ImageView *src, ImageView *dst, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode) const
 {
-	device->getBlitter()->resolveDepthStencil(src, dst, dsResolve);
+	device->getBlitter()->resolveDepthStencil(src, dst, depthResolveMode, stencilResolveMode);
 }
 
 uint32_t Image::getLastLayerIndex(const VkImageSubresourceRange &subresourceRange) const
diff --git a/src/Vulkan/VkImage.hpp b/src/Vulkan/VkImage.hpp
index 0f059e9..75d22cd 100644
--- a/src/Vulkan/VkImage.hpp
+++ b/src/Vulkan/VkImage.hpp
@@ -66,7 +66,7 @@
 	void blitTo(Image *dstImage, const VkImageBlit2KHR &region, VkFilter filter) const;
 	void copyTo(uint8_t *dst, unsigned int dstPitch) const;
 	void resolveTo(Image *dstImage, const VkImageResolve2KHR &region) const;
-	void resolveDepthStencilTo(const ImageView *src, ImageView *dst, const VkSubpassDescriptionDepthStencilResolve &depthStencilResolve) const;
+	void resolveDepthStencilTo(const ImageView *src, ImageView *dst, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode) const;
 	void clear(const VkClearValue &clearValue, const vk::Format &viewFormat, const VkRect2D &renderArea, const VkImageSubresourceRange &subresourceRange);
 	void clear(const VkClearColorValue &color, const VkImageSubresourceRange &subresourceRange);
 	void clear(const VkClearDepthStencilValue &color, const VkImageSubresourceRange &subresourceRange);
diff --git a/src/Vulkan/VkImageView.cpp b/src/Vulkan/VkImageView.cpp
index c555695..677a9f3 100644
--- a/src/Vulkan/VkImageView.cpp
+++ b/src/Vulkan/VkImageView.cpp
@@ -291,7 +291,7 @@
 	}
 }
 
-void ImageView::resolveDepthStencil(ImageView *resolveAttachment, const VkSubpassDescriptionDepthStencilResolve &dsResolve)
+void ImageView::resolveDepthStencil(ImageView *resolveAttachment, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode)
 {
 	ASSERT(subresourceRange.levelCount == 1 && resolveAttachment->subresourceRange.levelCount == 1);
 	if((subresourceRange.layerCount != 1) || (resolveAttachment->subresourceRange.layerCount != 1))
@@ -299,7 +299,7 @@
 		UNIMPLEMENTED("b/148242443: layerCount != 1");  // FIXME(b/148242443)
 	}
 
-	image->resolveDepthStencilTo(this, resolveAttachment, dsResolve);
+	image->resolveDepthStencilTo(this, resolveAttachment, depthResolveMode, stencilResolveMode);
 }
 
 const Image *ImageView::getImage(Usage usage) const
diff --git a/src/Vulkan/VkImageView.hpp b/src/Vulkan/VkImageView.hpp
index ede2bb1..94c03f2 100644
--- a/src/Vulkan/VkImageView.hpp
+++ b/src/Vulkan/VkImageView.hpp
@@ -98,7 +98,7 @@
 	void resolve(ImageView *resolveAttachment);
 	void resolve(ImageView *resolveAttachment, int layer);
 	void resolveWithLayerMask(ImageView *resolveAttachment, uint32_t layerMask);
-	void resolveDepthStencil(ImageView *resolveAttachment, const VkSubpassDescriptionDepthStencilResolve &dsResolve);
+	void resolveDepthStencil(ImageView *resolveAttachment, VkResolveModeFlagBits depthResolveMode, VkResolveModeFlagBits stencilResolveMode);
 
 	VkImageViewType getType() const { return viewType; }
 	Format getFormat(Usage usage = RAW) const;