From: Slawomir Cygan Date: Fri, 7 Jul 2017 14:41:30 +0000 (+0200) Subject: cross_instance sync: run without VK_KHR_get_memory_requirements2 X-Git-Tag: upstream/0.1.0~9^2~77 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5347290c8dc160d1dd3d47fac6b5597060e4720f;p=platform%2Fupstream%2FVK-GL-CTS.git cross_instance sync: run without VK_KHR_get_memory_requirements2 This extension is used in the test, to check if resource needs dedicated allocations (to be used created by dependent VK_KHR_dedicated_allocation extension). If the extension is not supported assume there is no need for dedicated allocations. Affects: dEQP-VK.synchronization.cross_instance.* VK-GL-CTS issue: 548 Components: Vulkan Change-Id: Icb4f5a34b98da213d0cb665bcc4e6b048d7b8a3c --- diff --git a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp index e655d19..784e6ca 100644 --- a/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp +++ b/external/vulkancts/modules/vulkan/synchronization/vktSynchronizationCrossInstanceSharingTests.cpp @@ -220,7 +220,8 @@ vk::Move createDevice (const vk::InstanceInterface& vki, vk::VkPhysicalDevice physicalDevice, vk::VkExternalMemoryHandleTypeFlagBitsKHR memoryHandleType, vk::VkExternalSemaphoreHandleTypeFlagBitsKHR semaphoreHandleType, - bool dedicated) + bool dedicated, + bool khrMemReqSupported) { const float priority = 0.0f; const std::vector queueFamilyProperties = vk::getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice); @@ -230,7 +231,9 @@ vk::Move createDevice (const vk::InstanceInterface& vki, if (dedicated) extensions.push_back("VK_KHR_dedicated_allocation"); - extensions.push_back("VK_KHR_get_memory_requirements2"); + if (khrMemReqSupported) + extensions.push_back("VK_KHR_get_memory_requirements2"); + extensions.push_back("VK_KHR_external_semaphore"); extensions.push_back("VK_KHR_external_memory"); @@ -348,33 +351,46 @@ de::MovePtr allocateAndBindMemory (const vk::DeviceInterface& vk::VkDevice device, vk::VkBuffer buffer, vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType, - bool dedicated) + bool dedicated, + bool getMemReq2Supported) { - const vk::VkBufferMemoryRequirementsInfo2KHR requirementInfo = - { - vk::VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR, - DE_NULL, - buffer - }; - vk::VkMemoryDedicatedRequirementsKHR dedicatedRequirements = + vk::VkMemoryRequirements memoryRequirements = { 0u, 0u, 0u, }; + + if (getMemReq2Supported) { - vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, - DE_NULL, - VK_FALSE, - VK_FALSE - }; - vk::VkMemoryRequirements2KHR requirements = + const vk::VkBufferMemoryRequirementsInfo2KHR requirementInfo = + { + vk::VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR, + DE_NULL, + buffer + }; + vk::VkMemoryDedicatedRequirementsKHR dedicatedRequirements = + { + vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, + DE_NULL, + VK_FALSE, + VK_FALSE + }; + vk::VkMemoryRequirements2KHR requirements = + { + vk::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, + &dedicatedRequirements, + { 0u, 0u, 0u, } + }; + vkd.getBufferMemoryRequirements2KHR(device, &requirementInfo, &requirements); + + if (!dedicated && dedicatedRequirements.requiresDedicatedAllocation) + TCU_THROW(NotSupportedError, "Memory requires dedicated allocation"); + + memoryRequirements = requirements.memoryRequirements; + } + else { - vk::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, - &dedicatedRequirements, - { 0u, 0u, 0u, } - }; - vkd.getBufferMemoryRequirements2KHR(device, &requirementInfo, &requirements); + vkd.getBufferMemoryRequirements(device, buffer, &memoryRequirements); + } - if (!dedicated && dedicatedRequirements.requiresDedicatedAllocation) - TCU_THROW(NotSupportedError, "Memory requires dedicated allocation"); - vk::Move memory = allocateExportableMemory(vkd, device, requirements.memoryRequirements, externalType, dedicated ? buffer : (vk::VkBuffer)0); + vk::Move memory = allocateExportableMemory(vkd, device, memoryRequirements, externalType, dedicated ? buffer : (vk::VkBuffer)0); VK_CHECK(vkd.bindBufferMemory(device, buffer, *memory, 0u)); return de::MovePtr(new SimpleAllocation(vkd, device, memory.disown())); @@ -384,33 +400,43 @@ de::MovePtr allocateAndBindMemory (const vk::DeviceInterface& vk::VkDevice device, vk::VkImage image, vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType, - bool dedicated) + bool dedicated, + bool getMemReq2Supported) { - const vk::VkImageMemoryRequirementsInfo2KHR requirementInfo = - { - vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR, - DE_NULL, - image - }; - vk::VkMemoryDedicatedRequirementsKHR dedicatedRequirements = - { - vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, - DE_NULL, - VK_FALSE, - VK_FALSE - }; - vk::VkMemoryRequirements2KHR requirements = + vk::VkMemoryRequirements memoryRequirements = { 0u, 0u, 0u, }; + + if (getMemReq2Supported) { - vk::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, - &dedicatedRequirements, - { 0u, 0u, 0u, } - }; - vkd.getImageMemoryRequirements2KHR(device, &requirementInfo, &requirements); + const vk::VkImageMemoryRequirementsInfo2KHR requirementInfo = + { + vk::VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR, + DE_NULL, + image + }; + vk::VkMemoryDedicatedRequirementsKHR dedicatedRequirements = + { + vk::VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR, + DE_NULL, + VK_FALSE, + VK_FALSE + }; + vk::VkMemoryRequirements2KHR requirements = + { + vk::VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, + &dedicatedRequirements, + { 0u, 0u, 0u, } + }; + vkd.getImageMemoryRequirements2KHR(device, &requirementInfo, &requirements); - if (!dedicated && dedicatedRequirements.requiresDedicatedAllocation) - TCU_THROW(NotSupportedError, "Memomry requires dedicated allocation"); + if (!dedicated && dedicatedRequirements.requiresDedicatedAllocation) + TCU_THROW(NotSupportedError, "Memory requires dedicated allocation"); + } + else + { + vkd.getImageMemoryRequirements(device, image, &memoryRequirements); + } - vk::Move memory = allocateExportableMemory(vkd, device, requirements.memoryRequirements, externalType, dedicated ? image : (vk::VkImage)0); + vk::Move memory = allocateExportableMemory(vkd, device, memoryRequirements, externalType, dedicated ? image : (vk::VkImage)0); VK_CHECK(vkd.bindImageMemory(device, image, *memory, 0u)); return de::MovePtr(new SimpleAllocation(vkd, device, memory.disown())); @@ -423,7 +449,8 @@ de::MovePtr createResource (const vk::DeviceInterface& vkd, const OperationSupport& readOp, const OperationSupport& writeOp, vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType, - bool dedicated) + bool dedicated, + bool getMemReq2Supported) { if (resourceDesc.type == RESOURCE_TYPE_IMAGE) { @@ -476,7 +503,7 @@ de::MovePtr createResource (const vk::DeviceInterface& vkd, }; vk::Move image = vk::createImage(vkd, device, &createInfo); - de::MovePtr allocation = allocateAndBindMemory(vkd, device, *image, externalType, dedicated); + de::MovePtr allocation = allocateAndBindMemory(vkd, device, *image, externalType, dedicated, getMemReq2Supported); return de::MovePtr(new Resource(image, allocation, extent, resourceDesc.imageType, resourceDesc.imageFormat, subresourceRange, subresourceLayers)); } @@ -504,7 +531,7 @@ de::MovePtr createResource (const vk::DeviceInterface& vkd, &queueFamilyIndices[0] }; vk::Move buffer = vk::createBuffer(vkd, device, &createInfo); - de::MovePtr allocation = allocateAndBindMemory(vkd, device, *buffer, externalType, dedicated); + de::MovePtr allocation = allocateAndBindMemory(vkd, device, *buffer, externalType, dedicated, getMemReq2Supported); return de::MovePtr(new Resource(resourceDesc.type, buffer, allocation, offset, size)); } @@ -786,6 +813,8 @@ private: const std::vector m_queueFamiliesA; const std::vector m_queueFamilyIndicesA; + const bool m_getMemReq2Supported; + const vk::Unique m_deviceA; const vk::DeviceDriver m_vkdA; @@ -820,7 +849,8 @@ SharingTestInstance::SharingTestInstance (Context& context, , m_physicalDeviceA (getPhysicalDevice(m_vkiA, *m_instanceA, context.getTestContext().getCommandLine())) , m_queueFamiliesA (vk::getPhysicalDeviceQueueFamilyProperties(m_vkiA, m_physicalDeviceA)) , m_queueFamilyIndicesA (getFamilyIndices(m_queueFamiliesA)) - , m_deviceA (createDevice(m_vkiA, m_physicalDeviceA, m_config.memoryHandleType, m_config.semaphoreHandleType, m_config.dedicated)) + , m_getMemReq2Supported (de::contains(context.getInstanceExtensions().begin(), context.getInstanceExtensions().end(), "VK_KHR_get_memory_requirements2")) + , m_deviceA (createDevice(m_vkiA, m_physicalDeviceA, m_config.memoryHandleType, m_config.semaphoreHandleType, m_config.dedicated, m_getMemReq2Supported)) , m_vkdA (m_vkiA, *m_deviceA) , m_instanceB (createInstance(context.getPlatformInterface())) @@ -829,7 +859,7 @@ SharingTestInstance::SharingTestInstance (Context& context, , m_physicalDeviceB (getPhysicalDevice(m_vkiB, *m_instanceB, getDeviceId(m_vkiA, m_physicalDeviceA))) , m_queueFamiliesB (vk::getPhysicalDeviceQueueFamilyProperties(m_vkiB, m_physicalDeviceB)) , m_queueFamilyIndicesB (getFamilyIndices(m_queueFamiliesB)) - , m_deviceB (createDevice(m_vkiB, m_physicalDeviceB, m_config.memoryHandleType, m_config.semaphoreHandleType, m_config.dedicated)) + , m_deviceB (createDevice(m_vkiB, m_physicalDeviceB, m_config.memoryHandleType, m_config.semaphoreHandleType, m_config.dedicated, m_getMemReq2Supported)) , m_vkdB (m_vkiB, *m_deviceB) , m_semaphoreHandleType (m_config.semaphoreHandleType) @@ -956,7 +986,7 @@ tcu::TestStatus SharingTestInstance::iterate (void) const vk::Unique semaphoreA (createExportableSemaphore(m_vkdA, *m_deviceA, m_semaphoreHandleType)); const vk::Unique semaphoreB (createSemaphore(m_vkdB, *m_deviceB)); - const de::UniquePtr resourceA (createResource(m_vkdA, *m_deviceA, m_config.resource, m_queueFamilyIndicesA, *m_supportReadOp, *m_supportWriteOp, m_memoryHandleType, m_config.dedicated)); + const de::UniquePtr resourceA (createResource(m_vkdA, *m_deviceA, m_config.resource, m_queueFamilyIndicesA, *m_supportReadOp, *m_supportWriteOp, m_memoryHandleType, m_config.dedicated, m_getMemReq2Supported)); NativeHandle nativeMemoryHandle; getMemoryNative(m_vkdA, *m_deviceA, resourceA->getMemory(), m_memoryHandleType, nativeMemoryHandle);