Commit e8dd233c by Corentin Wallez Committed by Corentin Wallez

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: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarCorentin Wallez <cwallez@google.com>
parent 0a8f44c5
...@@ -524,36 +524,30 @@ void Image::copy(Buffer *buffer, const VkBufferImageCopy &region, bool bufferIsS ...@@ -524,36 +524,30 @@ void Image::copy(Buffer *buffer, const VkBufferImageCopy &region, bool bufferIsS
(imageSlicePitchBytes == bufferSlicePitchBytes); (imageSlicePitchBytes == bufferSlicePitchBytes);
VkDeviceSize copySize = 0; VkDeviceSize copySize = 0;
VkDeviceSize bufferLayerSize = 0;
if(isSingleRow) if(isSingleRow)
{ {
copySize = imageExtent.width * bytesPerBlock; copySize = imageExtent.width * bytesPerBlock;
bufferLayerSize = copySize;
} }
else if(isEntireRow && isSingleSlice) else if(isEntireRow && isSingleSlice)
{ {
copySize = imageExtent.height * imageRowPitchBytes; copySize = imageExtent.height * imageRowPitchBytes;
bufferLayerSize = copySize;
} }
else if(isEntireSlice) else if(isEntireSlice)
{ {
copySize = imageExtent.depth * imageSlicePitchBytes; // Copy multiple slices copySize = imageExtent.depth * imageSlicePitchBytes; // Copy multiple slices
bufferLayerSize = copySize;
} }
else if(isEntireRow) // Copy slice by slice else if(isEntireRow) // Copy slice by slice
{ {
copySize = imageExtent.height * imageRowPitchBytes; copySize = imageExtent.height * imageRowPitchBytes;
bufferLayerSize = copySize * imageExtent.depth;
} }
else // Copy row by row else // Copy row by row
{ {
copySize = imageExtent.width * bytesPerBlock; copySize = imageExtent.width * bytesPerBlock;
bufferLayerSize = copySize * imageExtent.depth * imageExtent.height;
} }
VkDeviceSize imageLayerSize = getLayerSize(aspect); VkDeviceSize imageLayerSize = getLayerSize(aspect);
VkDeviceSize srcLayerSize = bufferIsSource ? bufferLayerSize : imageLayerSize; VkDeviceSize srcLayerSize = bufferIsSource ? bufferSlicePitchBytes : imageLayerSize;
VkDeviceSize dstLayerSize = bufferIsSource ? imageLayerSize : bufferLayerSize; VkDeviceSize dstLayerSize = bufferIsSource ? imageLayerSize : bufferSlicePitchBytes;
for(uint32_t i = 0; i < region.imageSubresource.layerCount; i++) for(uint32_t i = 0; i < region.imageSubresource.layerCount; i++)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment