Fix low memory in dedicated_alloc buffer tests
authorTom Cooper <tom.cooper@arm.com>
Mon, 12 Feb 2018 16:20:58 +0000 (16:20 +0000)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 22 Feb 2018 11:05:27 +0000 (06:05 -0500)
Observe platform memory limits to avoid low memory conditions.

Components: Vulkan

VK-GL-CTS issue: 1008

Affects: dEQP-VK.api.buffer.dedicated_alloc.create_buffer_*

Change-Id: Ib184b648126e8cb6e1acff533447a86be9a1a612

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

index 024e826..256ec1e 100644 (file)
@@ -565,11 +565,20 @@ tcu::TestStatus                                                   DedicatedAllocationBufferTestInstance::bufferCreateAndAllo
        const deUint32                                          heapTypeIndex                                   = static_cast<deUint32>(deCtz32(memReqs.memoryRequirements.memoryTypeBits));
        const VkMemoryType                                      memoryType                                              = memoryProperties.memoryTypes[heapTypeIndex];
        const VkMemoryHeap                                      memoryHeap                                              = memoryProperties.memoryHeaps[memoryType.heapIndex];
-       const VkDeviceSize                                      maxBufferSize                                   = deAlign64(memoryHeap.size >> 1u, memReqs.memoryRequirements.alignment);
        const deUint32                                          shrinkBits                                              = 4u;   // number of bits to shift when reducing the size with each iteration
 
+       // Buffer size - Choose half of the reported heap size for the maximum buffer size, we
+       // should attempt to test as large a portion as possible.
+       //
+       // However on a system where device memory is shared with the system, the maximum size
+       // should be tested against the platform memory limits as a significant portion of the heap
+       // may already be in use by the operating system and other running processes.
+       const VkDeviceSize maxBufferSize = getMaxBufferSize(memoryHeap.size,
+                                                                                                          memReqs.memoryRequirements.alignment,
+                                                                                                          getPlatformMemoryLimits(m_context));
+
        Move<VkDeviceMemory>                            memory;
-       size = std::min(size, maxBufferSize);
+       size = deAlign64(std::min(size, maxBufferSize >> 1), memReqs.memoryRequirements.alignment);
        while (*memory == DE_NULL)
        {
                // Create the buffer