Fixes sparse image padding tests
authorMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 7 May 2021 15:40:31 +0000 (11:40 -0400)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 7 May 2021 15:40:31 +0000 (11:40 -0400)
Tests were attempting to verify the
values inside the padding X bits of
formats like 10x6, where spec says
they are undefined.

Components: Vulkan
VK-GL-CTS Issue: 2916

Affects:
dEQP-VK.sparse_resources.image_sparse_binding.2d*

Change-Id: Ic785fba111ecebb5a030673642b78872c404d925

external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesImageSparseBinding.cpp
external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesTestsUtil.cpp
external/vulkancts/modules/vulkan/sparse_resources/vktSparseResourcesTestsUtil.hpp

index efa80f07fb3fa8d20051e511ad14682159e79b21..19e056d4b44e59f9c3f5bdc49909efa47194f5db 100755 (executable)
@@ -413,7 +413,9 @@ tcu::TestStatus ImageSparseBindingInstance::iterate (void)
                // Wait for sparse queue to become idle
                deviceInterface.queueWaitIdle(sparseQueue.queueHandle);
 
-               const deUint8* outputData = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
+               const deUint8*  outputData              = static_cast<const deUint8*>(outputBufferAlloc->getHostPtr());
+               bool                    ignoreLsb6Bits  = areLsb6BitsDontCare(imageSparseInfo.format);
+               bool                    ignoreLsb4Bits  = areLsb4BitsDontCare(imageSparseInfo.format);
 
                for (deUint32 planeNdx = 0; planeNdx < formatDescription.numPlanes; ++planeNdx)
                {
@@ -437,20 +439,21 @@ tcu::TestStatus ImageSparseBindingInstance::iterate (void)
                                        }
                                }
 
-                               if (!is8bitSnormComponent)
+                               for (size_t byteNdx = 0; byteNdx < mipLevelSizeInBytes; byteNdx++)
                                {
-                                       if (deMemCmp(outputData + bufferOffset, &referenceData[bufferOffset], mipLevelSizeInBytes) != 0)
-                                               return tcu::TestStatus::fail("Failed");
-                               }
-                               else
-                               {
-                                       for (deUint32 byte = 0; byte < mipLevelSizeInBytes; byte++)
-                                       {
-                                               deUint32 entryOffset = bufferOffset + byte;
+                                       const deUint8   res     = *(outputData + bufferOffset + byteNdx);
+                                       const deUint8   ref     = referenceData[bufferOffset + byteNdx];
 
-                                               // Ignore 0x80 which is undefined data for a 8 bit snorm component
-                                               if ((referenceData[entryOffset] != 0x80) && (deMemCmp(outputData + entryOffset, &referenceData[entryOffset], 1) != 0))
-                                                       return tcu::TestStatus::fail("Failed");
+                                       deUint8 mask = 0xFF;
+
+                                       if (!(byteNdx & 0x01) && (ignoreLsb6Bits))
+                                               mask = 0xC0;
+                                       else if (!(byteNdx & 0x01) && (ignoreLsb4Bits))
+                                               mask = 0xF0;
+
+                                       if (((!is8bitSnormComponent) || (ref != 0x80)) &&  ((res & mask) != (ref & mask)))
+                                       {
+                                               return tcu::TestStatus::fail("Failed");
                                        }
                                }
                        }
index 815e9ae0524a4cf97c9fe71cbe83697f3f5614ff..ea24b97f33ac16eb6341d3382e76b4ca02494ca6 100644 (file)
@@ -1009,5 +1009,43 @@ vk::VkFormat getPlaneCompatibleFormatForWriting(const vk::PlanarFormatDescriptio
        return result;
 }
 
+bool areLsb6BitsDontCare(vk::VkFormat format)
+{
+       if ((format == vk::VK_FORMAT_R10X6_UNORM_PACK16)                         ||
+               (format == vk::VK_FORMAT_R10X6G10X6_UNORM_2PACK16)                   ||
+               (format == vk::VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16)         ||
+               (format == vk::VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16)     ||
+               (format == vk::VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16)     ||
+               (format == vk::VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16)  ||
+               (format == vk::VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16) ||
+               (format == vk::VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16) ||
+               (format == vk::VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16)  ||
+               (format == vk::VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16))
+       {
+               return true;
+       }
+
+       return false;
+}
+
+bool areLsb4BitsDontCare(vk::VkFormat format)
+{
+       if ((format == vk::VK_FORMAT_R12X4_UNORM_PACK16)                         ||
+               (format == vk::VK_FORMAT_R12X4G12X4_UNORM_2PACK16)                   ||
+               (format == vk::VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16)         ||
+               (format == vk::VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16)     ||
+               (format == vk::VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16)     ||
+               (format == vk::VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16) ||
+               (format == vk::VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16)  ||
+               (format == vk::VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16) ||
+               (format == vk::VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16)  ||
+               (format == vk::VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16))
+       {
+               return true;
+       }
+
+       return false;
+}
+
 } // sparse
 } // vkt
index 0cf8572b760dea3ced6e5b71b09819822d3e5300..2c7861abab8e91c6930af11c927b83d5e3f8bec6 100644 (file)
@@ -245,6 +245,10 @@ deUint32                                           getSparseAspectRequirementsIndex        (const std::vector<vk::VkSparseIm
 vk::VkFormat                                   getPlaneCompatibleFormatForWriting      (const vk::PlanarFormatDescription&     formatInfo,
                                                                                                                                         deUint32                                                       planeNdx);
 
+bool                                                   areLsb6BitsDontCare(vk::VkFormat format);
+
+bool                                                   areLsb4BitsDontCare(vk::VkFormat format);
+
 template<typename T>
 inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr (vk::Move<T> vkMove)
 {