From: Matthew Netsch Date: Tue, 28 Aug 2018 18:44:45 +0000 (-0400) Subject: Fixes memory allocation tests X-Git-Tag: upstream/1.3.5~2324^2~20^2~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0f658f6c6a12a7356ce494cd6eaf9034da0a84b7;p=platform%2Fupstream%2FVK-GL-CTS.git Fixes memory allocation tests Queries the platform specific alignment restrictions with a temp buffer instead of estimating. Components: Vulkan VK-GL-CTS issue: 1259 Affects: dEQP-VK.memory.allocation.basic.size_* Change-Id: I272026f9e29b5606b8a4265ef0034752ac43a71a --- diff --git a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp index d21a51d..9bfde7e 100644 --- a/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp +++ b/external/vulkancts/modules/vulkan/memory/vktMemoryAllocationTests.cpp @@ -253,6 +253,33 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) TestLog& log = m_context.getTestContext().getLog(); const VkDevice device = getDevice(); const DeviceInterface& vkd = getDeviceInterface(); + VkMemoryRequirements memReqs; + const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex(); + VkBufferCreateFlags createFlags = (vk::VkBufferCreateFlagBits)0u; + VkBufferUsageFlags usageFlags = vk::VK_BUFFER_USAGE_TRANSFER_SRC_BIT|VK_BUFFER_USAGE_TRANSFER_DST_BIT; + VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE; + Move buffer; + + if ((m_memoryProperties.memoryTypes[m_memoryTypeIndex].propertyFlags & vk::VK_MEMORY_PROPERTY_PROTECTED_BIT) == vk::VK_MEMORY_PROPERTY_PROTECTED_BIT) + { + createFlags |= vk::VK_BUFFER_CREATE_PROTECTED_BIT; + } + + // Create a minimal buffer first to get the supported memory types + VkBufferCreateInfo bufferParams = + { + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; + DE_NULL, // const void* pNext; + createFlags, // VkBufferCreateFlags flags; + 1u, // VkDeviceSize size; + usageFlags, // VkBufferUsageFlags usage; + sharingMode, // VkSharingMode sharingMode; + 1u, // uint32_t queueFamilyIndexCount; + &queueFamilyIndex, // const uint32_t* pQueueFamilyIndices; + }; + + buffer = createBuffer(vkd, device, &bufferParams); + vkd.getBufferMemoryRequirements(device, *buffer, &memReqs); DE_ASSERT(m_config.memoryAllocationCount <= MAX_ALLOCATION_COUNT); @@ -276,7 +303,7 @@ tcu::TestStatus AllocateFreeTestInstance::iterate (void) const VkMemoryType memoryType = m_memoryProperties.memoryTypes[m_memoryTypeIndex]; const VkMemoryHeap memoryHeap = m_memoryProperties.memoryHeaps[memoryType.heapIndex]; - const VkDeviceSize allocationSize = (m_config.memorySize ? *m_config.memorySize : (VkDeviceSize)(*m_config.memoryPercentage * (float)memoryHeap.size)); + const VkDeviceSize allocationSize = (m_config.memorySize ? memReqs.size : (VkDeviceSize)(*m_config.memoryPercentage * (float)memoryHeap.size)); const VkDeviceSize roundedUpAllocationSize = roundUpToNextMultiple(allocationSize, m_memoryLimits.deviceMemoryAllocationGranularity); vector memoryObjects (m_config.memoryAllocationCount, (VkDeviceMemory)0);