Snap for 5821701 from c9358ed664a8f29c5a1e7227a7fdb8094b21ace2 to qt-c2f2-release

Change-Id: Ib056ef2c922a499d05fda674cc0e39f74204391c
diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp
index 5d6bc77..d8c22be 100644
--- a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp
+++ b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp
@@ -297,6 +297,12 @@
 		const VkDeviceSize		allocationSize	= (m_config.memorySize ? memReqs.size : (VkDeviceSize)(*m_config.memoryPercentage * (float)memoryHeap.size));
 		const VkDeviceSize		roundedUpAllocationSize	 = roundUpToNextMultiple(allocationSize, m_memoryLimits.deviceMemoryAllocationGranularity);
 		vector<VkDeviceMemory>	memoryObjects	(m_config.memoryAllocationCount, (VkDeviceMemory)0);
+		deUint32				totalAllocateCount		= m_config.memoryAllocationCount;
+		VkResult				result					= vk::VK_SUCCESS;
+		// Because of the size limitation of protect heap, we ignore the "VK_ERROR_OUT_OF_DEVICE_MEMORY"
+		// when total number of protected memory reaches 80 times.
+		const deUint32			protectHeapLimit		= 80;
+
 
 		log << TestLog::Message << "Memory type index: " << m_memoryTypeIndex << TestLog::EndMessage;
 
@@ -345,24 +351,35 @@
 									m_memoryTypeIndex									// memoryTypeIndex;
 								};
 
-								VK_CHECK(vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx]));
+								result = vkd.allocateMemory(device, &alloc, (const VkAllocationCallbacks*)DE_NULL, &memoryObjects[ndx]);
+								if ( VK_ERROR_OUT_OF_DEVICE_MEMORY == result &&
+								    (memoryType.propertyFlags & vk::VK_MEMORY_PROPERTY_PROTECTED_BIT) == vk::VK_MEMORY_PROPERTY_PROTECTED_BIT &&
+								    ndx >= protectHeapLimit)
+								{
+									totalAllocateCount = (deUint32)ndx + 1;
+									break;
+								}
+								else
+								{
+									VK_CHECK(result);
+								}
 
 								TCU_CHECK(!!memoryObjects[ndx]);
 							}
 
 							if (m_config.order == TestConfig::ALLOC_FREE)
 							{
-								for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++)
+								for (size_t ndx = 0; ndx < totalAllocateCount; ndx++)
 								{
-									const VkDeviceMemory mem = memoryObjects[memoryObjects.size() - 1 - ndx];
+									const VkDeviceMemory mem = memoryObjects[totalAllocateCount - 1 - ndx];
 
 									vkd.freeMemory(device, mem, (const VkAllocationCallbacks*)DE_NULL);
-									memoryObjects[memoryObjects.size() - 1 - ndx] = (VkDeviceMemory)0;
+									memoryObjects[totalAllocateCount - 1 - ndx] = (VkDeviceMemory)0;
 								}
 							}
 							else
 							{
-								for (size_t ndx = 0; ndx < m_config.memoryAllocationCount; ndx++)
+								for (size_t ndx = 0; ndx < totalAllocateCount; ndx++)
 								{
 									const VkDeviceMemory mem = memoryObjects[ndx];