Fix buffer copy extents in blit tests
authorGraeme Leese <gleese@broadcom.com>
Fri, 4 Jun 2021 13:50:34 +0000 (14:50 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Tue, 29 Jun 2021 07:13:51 +0000 (07:13 +0000)
The buffer extents of copies to/from compressed images should account
for the extra size of the compressed block that might not fit in the
actual image but it was not.

Component: Vulkan
Affects: dEQP-VK.api.copy_and_blit.*

Change-Id: Ia4a47554078722b3cd4548df413bcdb62451cba5

external/vulkancts/modules/vulkan/api/vktApiCopiesAndBlittingTests.cpp

index c7e351a..45dab70 100644 (file)
@@ -707,11 +707,17 @@ void CopiesAndBlittingTestInstance::uploadImageAspect (const tcu::ConstPixelBuff
                        imageExtent.depth
                };
 
+               const bool              isCompressed    = isCompressedFormat(parms.format);
+               const deUint32  blockWidth              = (isCompressed) ? getBlockWidth(parms.format) : 1u;
+               const deUint32  blockHeight             = (isCompressed) ? getBlockHeight(parms.format) : 1u;
+               deUint32 rowLength              = ((copyExtent.width + blockWidth-1) / blockWidth) * blockWidth;
+               deUint32 imageHeight    = ((copyExtent.height + blockHeight-1) / blockHeight) * blockHeight;
+
                const VkBufferImageCopy copyRegion      =
                {
                        0u,                                                                                             // VkDeviceSize                         bufferOffset;
-                       copyExtent.width,                                                               // deUint32                                     bufferRowLength;
-                       copyExtent.height,                                                              // deUint32                                     bufferImageHeight;
+                       rowLength,                                                                              // deUint32                                     bufferRowLength;
+                       imageHeight,                                                                    // deUint32                                     bufferImageHeight;
                        {
                                getAspectFlags(imageAccess.getFormat()),                // VkImageAspectFlags   aspect;
                                mipLevelNdx,                                                                    // deUint32                             mipLevel;
@@ -910,12 +916,18 @@ void CopiesAndBlittingTestInstance::readImageAspect (vk::VkImage                                  image,
        };
 
        // Copy image to buffer
+       const bool              isCompressed    = isCompressedFormat(imageParms.format);
+       const deUint32  blockWidth              = (isCompressed) ? getBlockWidth(imageParms.format) : 1u;
+       const deUint32  blockHeight             = (isCompressed) ? getBlockHeight(imageParms.format) : 1u;
+       deUint32 rowLength              = ((imageExtent.width + blockWidth-1) / blockWidth) * blockWidth;
+       deUint32 imageHeight    = ((imageExtent.height + blockHeight-1) / blockHeight) * blockHeight;
+
        const VkImageAspectFlags        aspect                  = getAspectFlags(dst.getFormat());
        const VkBufferImageCopy         copyRegion              =
        {
                0u,                                                             // VkDeviceSize                         bufferOffset;
-               imageExtent.width,                              // deUint32                                     bufferRowLength;
-               imageExtent.height,                             // deUint32                                     bufferImageHeight;
+               rowLength,                                              // deUint32                                     bufferRowLength;
+               imageHeight,                                    // deUint32                                     bufferImageHeight;
                {
                        aspect,                                                 // VkImageAspectFlags           aspect;
                        mipLevel,                                               // deUint32                                     mipLevel;