Fix image slice / plane name usage

Image planes have a distinct meaning in Vulkan, signifying the disjoint
memory regions which store components of a texel format. Typically this
includes YCbCr formats that can have 2 or 3 planes for luminance and
chroma data.

Slices refer to 2D sections of 3D images. Currently we also use slices
for storing each sample of a multisample image separately. Note only
2D images can be multisampled, so there are no 3D images with slices
for the depth and the number of samples.

Bug: b/159210008
Change-Id: I4b70a7b8bb49e79c7494e28aa8280752a5b9727d
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46288
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index f4a266d..7fb2182 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -342,8 +342,8 @@
 		return device->getBlitter()->blit(this, dstImage, blitRegion, VK_FILTER_NEAREST);
 	}
 
-	int srcBytesPerBlock = srcFormat.bytesPerBlock();
-	ASSERT(srcBytesPerBlock == dstFormat.bytesPerBlock());
+	int bytesPerBlock = srcFormat.bytesPerBlock();
+	ASSERT(bytesPerBlock == dstFormat.bytesPerBlock());
 
 	const uint8_t *srcMem = static_cast<const uint8_t *>(getTexelPointer(region.srcOffset, { region.srcSubresource.aspectMask, region.srcSubresource.mipLevel, region.srcSubresource.baseArrayLayer }));
 	uint8_t *dstMem = static_cast<uint8_t *>(dstImage->getTexelPointer(region.dstOffset, { region.dstSubresource.aspectMask, region.dstSubresource.mipLevel, region.dstSubresource.baseArrayLayer }));
@@ -357,8 +357,8 @@
 	VkExtent3D dstExtent = dstImage->getMipLevelExtent(dstAspect, region.dstSubresource.mipLevel);
 	VkExtent3D copyExtent = imageExtentInBlocks(region.extent, srcAspect);
 
-	bool isSinglePlane = (copyExtent.depth == 1);
-	bool isSingleLine = (copyExtent.height == 1) && isSinglePlane;
+	bool isSingleSlice = (copyExtent.depth == 1);
+	bool isSingleLine = (copyExtent.height == 1) && isSingleSlice;
 	// In order to copy multiple lines using a single memcpy call, we
 	// have to make sure that we need to copy the entire line and that
 	// both source and destination lines have the same length in bytes
@@ -373,36 +373,36 @@
 	                    // srcRowPitchBytes * dstBlockWidth == dstRowPitchBytes * srcBlockWidth
 	                    ((srcRowPitchBytes * dstFormat.blockWidth()) ==
 	                     (dstRowPitchBytes * srcFormat.blockWidth()));
-	// In order to copy multiple planes using a single memcpy call, we
-	// have to make sure that we need to copy the entire plane and that
-	// both source and destination planes have the same length in bytes
-	bool isEntirePlane = isEntireLine &&
+	// In order to copy multiple slices using a single memcpy call, we
+	// have to make sure that we need to copy the entire slice and that
+	// both source and destination slices have the same length in bytes
+	bool isEntireSlice = isEntireLine &&
 	                     (copyExtent.height == srcExtent.height) &&
 	                     (copyExtent.height == dstExtent.height) &&
 	                     (srcSlicePitchBytes == dstSlicePitchBytes);
 
 	if(isSingleLine)  // Copy one line
 	{
-		size_t copySize = copyExtent.width * srcBytesPerBlock;
+		size_t copySize = copyExtent.width * bytesPerBlock;
 		ASSERT((srcMem + copySize) < end());
 		ASSERT((dstMem + copySize) < dstImage->end());
 		memcpy(dstMem, srcMem, copySize);
 	}
-	else if(isEntireLine && isSinglePlane)  // Copy one plane
+	else if(isEntireLine && isSingleSlice)  // Copy one slice
 	{
 		size_t copySize = copyExtent.height * srcRowPitchBytes;
 		ASSERT((srcMem + copySize) < end());
 		ASSERT((dstMem + copySize) < dstImage->end());
 		memcpy(dstMem, srcMem, copySize);
 	}
-	else if(isEntirePlane)  // Copy multiple planes
+	else if(isEntireSlice)  // Copy multiple slices
 	{
 		size_t copySize = copyExtent.depth * srcSlicePitchBytes;
 		ASSERT((srcMem + copySize) < end());
 		ASSERT((dstMem + copySize) < dstImage->end());
 		memcpy(dstMem, srcMem, copySize);
 	}
-	else if(isEntireLine)  // Copy plane by plane
+	else if(isEntireLine)  // Copy slice by slice
 	{
 		size_t copySize = copyExtent.height * srcRowPitchBytes;
 
@@ -415,7 +415,7 @@
 	}
 	else  // Copy line by line
 	{
-		size_t copySize = copyExtent.width * srcBytesPerBlock;
+		size_t copySize = copyExtent.width * bytesPerBlock;
 
 		for(uint32_t z = 0; z < copyExtent.depth; z++, dstMem += dstSlicePitchBytes, srcMem += srcSlicePitchBytes)
 		{
@@ -472,11 +472,11 @@
 	int dstRowPitchBytes = bufferIsSource ? imageRowPitchBytes : bufferRowPitchBytes;
 
 	VkExtent3D mipLevelExtent = getMipLevelExtent(aspect, region.imageSubresource.mipLevel);
-	bool isSinglePlane = (imageExtent.depth == 1);
-	bool isSingleLine = (imageExtent.height == 1) && isSinglePlane;
+	bool isSingleSlice = (imageExtent.depth == 1);
+	bool isSingleLine = (imageExtent.height == 1) && isSingleSlice;
 	bool isEntireLine = (imageExtent.width == mipLevelExtent.width) &&
 	                    (imageRowPitchBytes == bufferRowPitchBytes);
-	bool isEntirePlane = isEntireLine && (imageExtent.height == mipLevelExtent.height) &&
+	bool isEntireSlice = isEntireLine && (imageExtent.height == mipLevelExtent.height) &&
 	                     (imageSlicePitchBytes == bufferSlicePitchBytes);
 
 	VkDeviceSize copySize = 0;
@@ -486,17 +486,17 @@
 		copySize = imageExtent.width * bytesPerBlock;
 		bufferLayerSize = copySize;
 	}
-	else if(isEntireLine && isSinglePlane)
+	else if(isEntireLine && isSingleSlice)
 	{
 		copySize = imageExtent.height * imageRowPitchBytes;
 		bufferLayerSize = copySize;
 	}
-	else if(isEntirePlane)
+	else if(isEntireSlice)
 	{
-		copySize = imageExtent.depth * imageSlicePitchBytes;  // Copy multiple planes
+		copySize = imageExtent.depth * imageSlicePitchBytes;  // Copy multiple slices
 		bufferLayerSize = copySize;
 	}
-	else if(isEntireLine)  // Copy plane by plane
+	else if(isEntireLine)  // Copy slice by slice
 	{
 		copySize = imageExtent.height * imageRowPitchBytes;
 		bufferLayerSize = copySize * imageExtent.depth;
@@ -513,23 +513,23 @@
 
 	for(uint32_t i = 0; i < region.imageSubresource.layerCount; i++)
 	{
-		if(isSingleLine || (isEntireLine && isSinglePlane) || isEntirePlane)
+		if(isSingleLine || (isEntireLine && isSingleSlice) || isEntireSlice)
 		{
 			ASSERT(((bufferIsSource ? dstMemory : srcMemory) + copySize) < end());
 			ASSERT(((bufferIsSource ? srcMemory : dstMemory) + copySize) < buffer->end());
 			memcpy(dstMemory, srcMemory, copySize);
 		}
-		else if(isEntireLine)  // Copy plane by plane
+		else if(isEntireLine)  // Copy slice by slice
 		{
-			uint8_t *srcPlaneMemory = srcMemory;
-			uint8_t *dstPlaneMemory = dstMemory;
+			uint8_t *srcSliceMemory = srcMemory;
+			uint8_t *dstSliceMemory = dstMemory;
 			for(uint32_t z = 0; z < imageExtent.depth; z++)
 			{
-				ASSERT(((bufferIsSource ? dstPlaneMemory : srcPlaneMemory) + copySize) < end());
-				ASSERT(((bufferIsSource ? srcPlaneMemory : dstPlaneMemory) + copySize) < buffer->end());
-				memcpy(dstPlaneMemory, srcPlaneMemory, copySize);
-				srcPlaneMemory += srcSlicePitchBytes;
-				dstPlaneMemory += dstSlicePitchBytes;
+				ASSERT(((bufferIsSource ? dstSliceMemory : srcSliceMemory) + copySize) < end());
+				ASSERT(((bufferIsSource ? srcSliceMemory : dstSliceMemory) + copySize) < buffer->end());
+				memcpy(dstSliceMemory, srcSliceMemory, copySize);
+				srcSliceMemory += srcSlicePitchBytes;
+				dstSliceMemory += dstSlicePitchBytes;
 			}
 		}
 		else  // Copy line by line
@@ -538,15 +538,15 @@
 			uint8_t *dstLayerMemory = dstMemory;
 			for(uint32_t z = 0; z < imageExtent.depth; z++)
 			{
-				uint8_t *srcPlaneMemory = srcLayerMemory;
-				uint8_t *dstPlaneMemory = dstLayerMemory;
+				uint8_t *srcSliceMemory = srcLayerMemory;
+				uint8_t *dstSliceMemory = dstLayerMemory;
 				for(uint32_t y = 0; y < imageExtent.height; y++)
 				{
-					ASSERT(((bufferIsSource ? dstPlaneMemory : srcPlaneMemory) + copySize) < end());
-					ASSERT(((bufferIsSource ? srcPlaneMemory : dstPlaneMemory) + copySize) < buffer->end());
-					memcpy(dstPlaneMemory, srcPlaneMemory, copySize);
-					srcPlaneMemory += srcRowPitchBytes;
-					dstPlaneMemory += dstRowPitchBytes;
+					ASSERT(((bufferIsSource ? dstSliceMemory : srcSliceMemory) + copySize) < end());
+					ASSERT(((bufferIsSource ? srcSliceMemory : dstSliceMemory) + copySize) < buffer->end());
+					memcpy(dstSliceMemory, srcSliceMemory, copySize);
+					srcSliceMemory += srcRowPitchBytes;
+					dstSliceMemory += dstRowPitchBytes;
 				}
 				srcLayerMemory += srcSlicePitchBytes;
 				dstLayerMemory += dstSlicePitchBytes;