Skip unsupported allocations in invariance test
authorRicardo Garcia <rgarcia@igalia.com>
Tue, 8 Jun 2021 10:16:39 +0000 (12:16 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Wed, 16 Jun 2021 06:53:39 +0000 (06:53 +0000)
dEQP-VK.api.invariance.random is a test that performs a high number of
memory allocations (1000 as of this commit). Some of them may throw a
not supported exception that wasn't being caught and would result in the
whole test being marked as unsupported.

This change catches the exception and only returns "not supported" if
none of the allocations were supported. Otherwise, it runs all possible
allocations and checks results for the supported ones.

Affected tests:
dEQP-VK.api.invariance.random

Components: Vulkan
VK-GL-CTS issue: 2110

Change-Id: I92163c42e33671291dd9fc0c753dc43b4a058796

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

index 479e28a..68c76a3 100644 (file)
@@ -253,6 +253,8 @@ tcu::TestStatus InvarianceInstance::iterate (void)
        de::MovePtr<IObjectAllocator>                   objs[testCycles];
        size_t                                                                  refSizes[testCycles];
        unsigned int                                                    order[testCycles];
+       bool                                                                    supported[testCycles];
+       bool                                                                    allUnsupported                                  = true;
        bool                                                                    success                                                 = true;
        const deBool                                                    isDedicatedAllocationSupported  = m_context.isDeviceFunctionalitySupported("VK_KHR_dedicated_allocation");
        const deBool                                                    isYcbcrSupported                                = m_context.isDeviceFunctionalitySupported("VK_KHR_sampler_ycbcr_conversion");
@@ -586,11 +588,23 @@ tcu::TestStatus InvarianceInstance::iterate (void)
        // First get reference values for the object sizes
        for (unsigned int i = 0; i < testCycles; i++)
        {
-               objs[i]->allocate(m_context);
-               refSizes[i] = objs[i]->getSize(m_context);
-               objs[i]->deallocate(m_context);
+               try
+               {
+                       objs[i]->allocate(m_context);
+                       refSizes[i] = objs[i]->getSize(m_context);
+                       objs[i]->deallocate(m_context);
+                       supported[i] = true;
+                       allUnsupported = false;
+               }
+               catch (const tcu::NotSupportedError&)
+               {
+                       supported[i] = false;
+               }
        }
 
+       if (allUnsupported)
+               TCU_THROW(NotSupportedError, "All allocations unsupported");
+
        // Shuffle order by swapping random pairs
        for (unsigned int i = 0; i < testCycles; i++)
        {
@@ -601,11 +615,17 @@ tcu::TestStatus InvarianceInstance::iterate (void)
 
        // Allocate objects in shuffled order
        for (unsigned int i = 0; i < testCycles; i++)
-               objs[order[i]]->allocate(m_context);
+       {
+               if (supported[order[i]])
+                       objs[order[i]]->allocate(m_context);
+       }
 
        // Check for size mismatches
        for (unsigned int i = 0; i < testCycles; i++)
        {
+               if (!supported[order[i]])
+                       continue;
+
                size_t val = objs[order[i]]->getSize(m_context);
 
                if (val != refSizes[order[i]])
@@ -625,7 +645,10 @@ tcu::TestStatus InvarianceInstance::iterate (void)
 
        // Clean up
        for (unsigned int i = 0; i < testCycles; i++)
-               objs[order[i]]->deallocate(m_context);
+       {
+               if (supported[order[i]])
+                       objs[order[i]]->deallocate(m_context);
+       }
 
        if (success)
                return tcu::TestStatus::pass("Pass");