Commit 0839cbda by Alexis Hetu Committed by Alexis Hétu

Proper mipmap size allocation for compressed textures

Bug b/119620767 Change-Id: I2d0513ab4947e6794fb5122e625641ed1a7c84cb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28108Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 979f940a
...@@ -375,10 +375,9 @@ VkExtent3D Image::imageExtentInBlocks(const VkExtent3D& extent, VkImageAspectFla ...@@ -375,10 +375,9 @@ VkExtent3D Image::imageExtentInBlocks(const VkExtent3D& extent, VkImageAspectFla
int blockWidth = usedFormat.blockWidth(); int blockWidth = usedFormat.blockWidth();
int blockHeight = usedFormat.blockHeight(); int blockHeight = usedFormat.blockHeight();
ASSERT(((extent.width % blockWidth) == 0) && ((extent.height % blockHeight) == 0)); // We can't offset within a block // Mip level allocations will round up to the next block for compressed texture
adjustedExtent.width = ((adjustedExtent.width + blockWidth - 1) / blockWidth);
adjustedExtent.width /= blockWidth; adjustedExtent.height = ((adjustedExtent.height + blockHeight - 1) / blockHeight);
adjustedExtent.height /= blockHeight;
} }
return adjustedExtent; return adjustedExtent;
} }
...@@ -476,6 +475,12 @@ int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) cons ...@@ -476,6 +475,12 @@ int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) cons
ASSERT((aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) != ASSERT((aspect & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) !=
(VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)); (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
VkExtent3D mipLevelExtent = getMipLevelExtent(mipLevel); VkExtent3D mipLevelExtent = getMipLevelExtent(mipLevel);
Format usedFormat = getFormat(aspect);
if(usedFormat.isCompressed())
{
sw::align(mipLevelExtent.width, usedFormat.blockWidth());
sw::align(mipLevelExtent.height, usedFormat.blockHeight());
}
return getFormat(aspect).sliceB(mipLevelExtent.width, mipLevelExtent.height, isCube() ? 1 : 0, true); return getFormat(aspect).sliceB(mipLevelExtent.width, mipLevelExtent.height, isCube() ? 1 : 0, true);
} }
......
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