Check for compatible memory type in VK_EXT_external_memory_host tests
authorIgor Ostrowski <igor.ostrowski@intel.com>
Tue, 25 Sep 2018 12:02:06 +0000 (14:02 +0200)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Sun, 30 Sep 2018 14:25:30 +0000 (10:25 -0400)
Affects:
dEQP-VK.memory.external_memory_host.*

Components: Vulkan
VK-GL-CTS issue: 1372

Change-Id: I37a3058acd6f838de259ded01032f7793012566b

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

index 67c0482fb424d44f497777c143ef83521b4c44ed..d8f2b37da15f6d087dbfce828c5cea5514802255 100644 (file)
@@ -78,6 +78,7 @@ protected:
        deUint32                                                getHostPointerMemoryTypeBits                            (void* hostPointer);
        Move<VkDeviceMemory>                    allocateMemoryFromHostPointer                           (deUint32 memoryTypeIndex);
        void                                                    logMemoryTypeIndexPropertyFlags                         (deUint32 index);
+       bool                                                    findCompatibleMemoryTypeIndexToTest                     (deUint32 resourceMemoryTypeBits, deUint32 hostPointerMemoryTypeBits, deUint32* outMemoryTypeIndexToTest);
        bool                                                    findMemoryTypeIndexToTest                                       (deUint32 hostPointerMemoryTypeBits, deUint32* outMemoryTypeIndexToTest);
 
        const InstanceInterface&                                                m_vki;
@@ -245,11 +246,11 @@ void ExternalMemoryHostBaseTestInstance::logMemoryTypeIndexPropertyFlags (deUint
        m_log << tcu::TestLog::Message << getMemoryPropertyFlagsStr(m_memoryProps.memoryTypes[index].propertyFlags) << tcu::TestLog::EndMessage;
 }
 
-bool ExternalMemoryHostBaseTestInstance::findMemoryTypeIndexToTest (deUint32 hostPointerMemoryTypeBits, deUint32* outMemoryTypeIndexToTest)
+bool ExternalMemoryHostBaseTestInstance::findCompatibleMemoryTypeIndexToTest (deUint32 resourceMemoryTypeBits, deUint32 hostPointerMemoryTypeBits, deUint32* outMemoryTypeIndexToTest)
 {
        for (deUint32 bitMaskPosition = 0; bitMaskPosition < VK_MAX_MEMORY_TYPES; bitMaskPosition++)
        {
-               if (isBitSet(hostPointerMemoryTypeBits, bitMaskPosition))
+               if (isBitSet(resourceMemoryTypeBits & hostPointerMemoryTypeBits, bitMaskPosition))
                {
                        logMemoryTypeIndexPropertyFlags(bitMaskPosition);
                        *outMemoryTypeIndexToTest = bitMaskPosition;
@@ -259,6 +260,11 @@ bool ExternalMemoryHostBaseTestInstance::findMemoryTypeIndexToTest (deUint32 hos
        return false;
 }
 
+bool ExternalMemoryHostBaseTestInstance::findMemoryTypeIndexToTest (deUint32 hostPointerMemoryTypeBits, deUint32* outMemoryTypeIndexToTest)
+{
+       return findCompatibleMemoryTypeIndexToTest(~0u, hostPointerMemoryTypeBits, outMemoryTypeIndexToTest);
+}
+
 tcu::TestStatus ExternalMemoryHostBaseTestInstance::iterate (void)
 {
        deUint32                        hostPointerMemoryTypeBits;
@@ -340,10 +346,10 @@ tcu::TestStatus ExternalMemoryHostRenderImageTestInstance::iterate ()
 
        //find the usable memory type index
        hostPointerMemoryTypeBits                       = getHostPointerMemoryTypeBits(m_hostMemoryAlloc);
-       if (findMemoryTypeIndexToTest(hostPointerMemoryTypeBits, &memoryTypeIndexToTest))
-               m_deviceMemoryAllocatedFromHostPointer  = allocateMemoryFromHostPointer(memoryTypeIndexToTest);
+       if (findCompatibleMemoryTypeIndexToTest(imageMemoryRequirements.memoryTypeBits, hostPointerMemoryTypeBits, &memoryTypeIndexToTest))
+               m_deviceMemoryAllocatedFromHostPointer = allocateMemoryFromHostPointer(memoryTypeIndexToTest);
        else
-               return tcu::TestStatus::fail("Fail");
+               TCU_THROW(NotSupportedError, "Compatible memory type not found");
 
        VK_CHECK(m_vkd.bindImageMemory(m_device, *m_image, *m_deviceMemoryAllocatedFromHostPointer, (m_testParams.m_useOffset ? imageMemoryRequirements.alignment : 0)));
 
@@ -793,10 +799,10 @@ tcu::TestStatus ExternalMemoryHostSynchronizationTestInstance::iterate ()
 
        //find the usable memory type index
        hostPointerMemoryTypeBits                               = getHostPointerMemoryTypeBits(m_hostMemoryAlloc);
-       if (findMemoryTypeIndexToTest(hostPointerMemoryTypeBits, &memoryTypeIndexToTest))
+       if (findCompatibleMemoryTypeIndexToTest(bufferMemoryRequirements.memoryTypeBits, hostPointerMemoryTypeBits, &memoryTypeIndexToTest))
                m_deviceMemoryAllocatedFromHostPointer = allocateMemoryFromHostPointer(memoryTypeIndexToTest);
        else
-               return tcu::TestStatus::fail("Fail");
+               TCU_THROW(NotSupportedError, "Compatible memory type not found");
 
        VK_CHECK(m_vkd.bindBufferMemory(m_device, *m_dataBuffer, *m_deviceMemoryAllocatedFromHostPointer, 0));