Ensure compressed image copy is height compliant

Image copy operations on compressed formats must have dimensions that are multiples of the block dimensions, unless the extent dimension + its corresponding offset is equal to the image subresource dimension. Bug: b/168025369 Change-Id: I3e77bfefe78347d4635128ece10f9d48aef40daa Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48188Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarSean Risser <srisser@google.com> Commit-Queue: Alexis Hétu <sugoi@google.com>
parent a98fb3f8
...@@ -703,6 +703,7 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI ...@@ -703,6 +703,7 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI
VkExtent2D adjustedExtent = extent; VkExtent2D adjustedExtent = extent;
VkImageAspectFlagBits aspect = static_cast<VkImageAspectFlagBits>(region.imageSubresource.aspectMask); VkImageAspectFlagBits aspect = static_cast<VkImageAspectFlagBits>(region.imageSubresource.aspectMask);
Format usedFormat = getFormat(aspect); Format usedFormat = getFormat(aspect);
if(region.bufferRowLength != 0) if(region.bufferRowLength != 0)
{ {
adjustedExtent.width = region.bufferRowLength; adjustedExtent.width = region.bufferRowLength;
...@@ -710,10 +711,11 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI ...@@ -710,10 +711,11 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI
if(usedFormat.isCompressed()) if(usedFormat.isCompressed())
{ {
int blockWidth = usedFormat.blockWidth(); int blockWidth = usedFormat.blockWidth();
ASSERT((adjustedExtent.width % blockWidth) == 0); ASSERT((adjustedExtent.width % blockWidth == 0) || (adjustedExtent.width + region.imageOffset.x == extent.width));
adjustedExtent.width /= blockWidth; adjustedExtent.width = (region.bufferRowLength + blockWidth - 1) / blockWidth;
} }
} }
if(region.bufferImageHeight != 0) if(region.bufferImageHeight != 0)
{ {
adjustedExtent.height = region.bufferImageHeight; adjustedExtent.height = region.bufferImageHeight;
...@@ -721,10 +723,11 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI ...@@ -721,10 +723,11 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D &extent, const VkBufferI
if(usedFormat.isCompressed()) if(usedFormat.isCompressed())
{ {
int blockHeight = usedFormat.blockHeight(); int blockHeight = usedFormat.blockHeight();
ASSERT((adjustedExtent.height % blockHeight) == 0); ASSERT((adjustedExtent.height % blockHeight == 0) || (adjustedExtent.height + region.imageOffset.y == extent.height));
adjustedExtent.height /= blockHeight; adjustedExtent.height = (region.bufferImageHeight + blockHeight - 1) / blockHeight;
} }
} }
return adjustedExtent; return adjustedExtent;
} }
......
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