From: Ari Suonpaa Date: Fri, 6 Aug 2021 12:08:21 +0000 (+0300) Subject: Relax protected heap allocation tests X-Git-Tag: upstream/1.3.5~550^2~6^2^2~1^2~1^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57495824896d195d55b645e3b65244ef83a3992f;p=platform%2Fupstream%2FVK-GL-CTS.git Relax protected heap allocation tests Some implementations have limitations on protected heap allocations, and these limitations cannot be queried using the Vulkan API. This change allows an out-of-memory to happen after a certain number of allocations to compensate that. VK-GL-CTS Issue: 3038 Affects: dEQP-VK.memory.*allocation.* Components: Vulkan Change-Id: I3a34637c8c15eb8670613dce9b6e394a622a4c71 --- diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp index a1bc610..c1f5211 100644 --- a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp +++ b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp @@ -402,7 +402,7 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) { for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++) { - VkMemoryAllocateInfo alloc = + VkMemoryAllocateInfo alloc = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // sType m_useDeviceGroups ? &m_allocFlagsInfo : DE_NULL, // pNext @@ -410,7 +410,15 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) m_memoryTypeIndex // memoryTypeIndex; }; - VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx])); + VkResult res = vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx]); + + // Some implementations might have limitations on protected heap, and these limitations + // don't show up in Vulkan queries. Use a hard coded threshold after which out of memory + // is allowed. + if (res == VK_ERROR_OUT_OF_DEVICE_MEMORY && memoryType.propertyFlags & vk::VK_MEMORY_PROPERTY_PROTECTED_BIT && ndx > 80) + break; + + VK_CHECK(res); TCU_CHECK(!!memoryObjects[ndx]); } @@ -421,8 +429,11 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) { const VkDeviceMemory mem = memoryObjects[memoryObjects.size() - 1 - ndx]; - vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); - memoryObjects[memoryObjects.size() - 1 - ndx] = (VkDeviceMemory)0; + if (!!mem) + { + vkd.freeMemory(device, mem, (const VkAllocationCallbacks *) DE_NULL); + memoryObjects[memoryObjects.size() - 1 - ndx] = (VkDeviceMemory) 0; + } } } else @@ -431,8 +442,11 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) { const VkDeviceMemory mem = memoryObjects[ndx]; - vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL); - memoryObjects[ndx] = (VkDeviceMemory)0; + if (!!mem) + { + vkd.freeMemory(device, mem, (const VkAllocationCallbacks *) DE_NULL); + memoryObjects[ndx] = (VkDeviceMemory) 0; + } } } }