Fix requirements tests for multiplane images
authorJames Fitzpatrick <james.fitzpatrick@imgtec.com>
Wed, 8 Dec 2021 12:17:29 +0000 (12:17 +0000)
committerMatthew Netsch <quic_mnetsch@quicinc.com>
Fri, 7 Jan 2022 17:08:12 +0000 (17:08 +0000)
The memory requirements tests for multiplane images would previously
assume that bits were not sparsely set in memoryTypeBits.

This could lead to the tests assuming that an implementation was
returning a lazily allocated memory type for an image without
transient attachment set.

Affects: dEQP-VK.memory.requirements.*multiplane_image*

Components: Vulkan

VK-GL-CTS issue: 3405

Change-Id: Ic1e56d7412ac413da907059c79b3f7064b3c664b

external/vulkancts/modules/vulkan/memory/vktMemoryRequirementsTests.cpp

index 4010f52..6d35e68 100644 (file)
@@ -1657,13 +1657,15 @@ tcu::TestStatus testMultiplaneImages (Context& context, ImageTestParams params)
 
                                        if (result.check(requirements.memoryRequirements.memoryTypeBits != 0, "No supported memory types"))
                                        {
-                                               bool    hasHostVisibleType      = false;
+                                               typedef std::vector<deUint32>::const_iterator   IndexIterator;
+                                               const std::vector<deUint32>                                             usedMemoryTypeIndices   = bitsToIndices(requirements.memoryRequirements.memoryTypeBits);
+                                               bool                                                                                    hasHostVisibleType              = false;
 
-                                               for (deUint32 memoryTypeIndex = 0; (0x1u << memoryTypeIndex) <= requirements.memoryRequirements.memoryTypeBits; memoryTypeIndex++)
+                                               for (IndexIterator memoryTypeNdx = usedMemoryTypeIndices.begin(); memoryTypeNdx != usedMemoryTypeIndices.end(); ++memoryTypeNdx)
                                                {
-                                                       if (result.check(memoryTypeIndex < memoryProperties.memoryTypeCount, "Unknown memory type bits set in memory requirements"))
+                                                       if (result.check(*memoryTypeNdx < memoryProperties.memoryTypeCount, "Unknown memory type bits set in memory requirements"))
                                                        {
-                                                               const VkMemoryPropertyFlags     propertyFlags   (memoryProperties.memoryTypes[memoryTypeIndex].propertyFlags);
+                                                               const VkMemoryPropertyFlags     propertyFlags   (memoryProperties.memoryTypes[*memoryTypeNdx].propertyFlags);
 
                                                                if (propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
                                                                        hasHostVisibleType = true;