Commit 6db9a891 by Alexis Hetu Committed by Alexis Hétu

No border for compressed cube images

Cube images currently have a 1 pixel border around them for seamless cubemaps. To add a border around a compressed image would require adding an entire block's width/height around the image at each mip level, which would take a lot of extra space and wouldn't be so useful right now, since we'll perform both image decompression and cubemap border update before sampling, so might as well do both at the same time and only store a border in the decompressed image, so that compressed cube images don't need to keep a border. Bug b/119620767 Tests: dEQP-VK.pipeline.sampler.view_type.cube.format.* Change-Id: I17974c0148fded37bca7c17a78d08d5e683a2afb Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28548Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 1424ef65
...@@ -431,13 +431,20 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D& extent, const VkBufferI ...@@ -431,13 +431,20 @@ VkExtent2D Image::bufferExtentInBlocks(const VkExtent2D& extent, const VkBufferI
return adjustedExtent; return adjustedExtent;
} }
int Image::borderSize(VkImageAspectFlagBits aspect) const
{
// We won't add a border to compressed cube textures, we'll add it when we decompress the texture
return (isCube() && !format.isCompressed()) ? 1 : 0;
}
VkDeviceSize Image::texelOffsetBytesInStorage(const VkOffset3D& offset, const VkImageSubresourceLayers& subresource) const VkDeviceSize Image::texelOffsetBytesInStorage(const VkOffset3D& offset, const VkImageSubresourceLayers& subresource) const
{ {
VkImageAspectFlagBits aspect = static_cast<VkImageAspectFlagBits>(subresource.aspectMask); VkImageAspectFlagBits aspect = static_cast<VkImageAspectFlagBits>(subresource.aspectMask);
VkOffset3D adjustedOffset = imageOffsetInBlocks(offset, aspect); VkOffset3D adjustedOffset = imageOffsetInBlocks(offset, aspect);
int border = borderSize(aspect);
return adjustedOffset.z * slicePitchBytes(aspect, subresource.mipLevel) + return adjustedOffset.z * slicePitchBytes(aspect, subresource.mipLevel) +
(adjustedOffset.y + (isCube() ? 1 : 0)) * rowPitchBytes(aspect, subresource.mipLevel) + (adjustedOffset.y + border) * rowPitchBytes(aspect, subresource.mipLevel) +
(adjustedOffset.x + (isCube() ? 1 : 0)) * getFormat(aspect).bytesPerBlock(); (adjustedOffset.x + border) * getFormat(aspect).bytesPerBlock();
} }
VkExtent3D Image::getMipLevelExtent(uint32_t mipLevel) const VkExtent3D Image::getMipLevelExtent(uint32_t mipLevel) const
...@@ -467,7 +474,7 @@ int Image::rowPitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const ...@@ -467,7 +474,7 @@ int Image::rowPitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const
// Depth and Stencil pitch should be computed separately // Depth and Stencil pitch should be computed separately
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));
return getFormat(aspect).pitchB(getMipLevelExtent(mipLevel).width, isCube() ? 1 : 0, true); return getFormat(aspect).pitchB(getMipLevelExtent(mipLevel).width, borderSize(aspect), true);
} }
int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const
...@@ -482,7 +489,7 @@ int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) cons ...@@ -482,7 +489,7 @@ int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) cons
sw::align(mipLevelExtent.width, usedFormat.blockWidth()); sw::align(mipLevelExtent.width, usedFormat.blockWidth());
sw::align(mipLevelExtent.height, usedFormat.blockHeight()); 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, borderSize(aspect), true);
} }
int Image::bytesPerTexel(VkImageAspectFlagBits aspect) const int Image::bytesPerTexel(VkImageAspectFlagBits aspect) const
......
...@@ -83,6 +83,7 @@ private: ...@@ -83,6 +83,7 @@ private:
int bytesPerTexel(VkImageAspectFlagBits flags) const; int bytesPerTexel(VkImageAspectFlagBits flags) const;
VkFormat getClearFormat() const; VkFormat getClearFormat() const;
void clear(void* pixelData, VkFormat format, const VkImageSubresourceRange& subresourceRange, const VkRect2D& renderArea); void clear(void* pixelData, VkFormat format, const VkImageSubresourceRange& subresourceRange, const VkRect2D& renderArea);
int borderSize(VkImageAspectFlagBits aspect) const;
const Device *const device = nullptr; const Device *const device = nullptr;
DeviceMemory* deviceMemory = nullptr; DeviceMemory* deviceMemory = nullptr;
......
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