Fix B<->T copies of multiple array layers and unpacked rowpitch

When copying between buffers and textures, the bufferLayerSize didn't
take the rowPitch into account and would in most cases just use the size
of the copy.

Fix this by using bufferSlicePitchBytes for src/dstLayerSize.

Bug: swiftshader:152
Change-Id: I716f809bfa068d4836ef02366a01732fc2baa9d3
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46509
Presubmit-Ready: Corentin Wallez <cwallez@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Corentin Wallez <cwallez@google.com>
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index f52ebcd..2036aed 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -524,36 +524,30 @@
 	                     (imageSlicePitchBytes == bufferSlicePitchBytes);
 
 	VkDeviceSize copySize = 0;
-	VkDeviceSize bufferLayerSize = 0;
 	if(isSingleRow)
 	{
 		copySize = imageExtent.width * bytesPerBlock;
-		bufferLayerSize = copySize;
 	}
 	else if(isEntireRow && isSingleSlice)
 	{
 		copySize = imageExtent.height * imageRowPitchBytes;
-		bufferLayerSize = copySize;
 	}
 	else if(isEntireSlice)
 	{
 		copySize = imageExtent.depth * imageSlicePitchBytes;  // Copy multiple slices
-		bufferLayerSize = copySize;
 	}
 	else if(isEntireRow)  // Copy slice by slice
 	{
 		copySize = imageExtent.height * imageRowPitchBytes;
-		bufferLayerSize = copySize * imageExtent.depth;
 	}
 	else  // Copy row by row
 	{
 		copySize = imageExtent.width * bytesPerBlock;
-		bufferLayerSize = copySize * imageExtent.depth * imageExtent.height;
 	}
 
 	VkDeviceSize imageLayerSize = getLayerSize(aspect);
-	VkDeviceSize srcLayerSize = bufferIsSource ? bufferLayerSize : imageLayerSize;
-	VkDeviceSize dstLayerSize = bufferIsSource ? imageLayerSize : bufferLayerSize;
+	VkDeviceSize srcLayerSize = bufferIsSource ? bufferSlicePitchBytes : imageLayerSize;
+	VkDeviceSize dstLayerSize = bufferIsSource ? imageLayerSize : bufferSlicePitchBytes;
 
 	for(uint32_t i = 0; i < region.imageSubresource.layerCount; i++)
 	{