vk::VkPhysicalDevice physicalDevice,
vk::VkExternalMemoryHandleTypeFlagBitsKHR memoryHandleType,
vk::VkExternalSemaphoreHandleTypeFlagBitsKHR semaphoreHandleType,
- bool dedicated)
+ bool dedicated,
+ bool khrMemReqSupported)
{
const float priority = 0.0f;
const std::vector<vk::VkQueueFamilyProperties> queueFamilyProperties = vk::getPhysicalDeviceQueueFamilyProperties(vki, physicalDevice);
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");
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<vk::VkDeviceMemory> memory = allocateExportableMemory(vkd, device, requirements.memoryRequirements, externalType, dedicated ? buffer : (vk::VkBuffer)0);
+ vk::Move<vk::VkDeviceMemory> memory = allocateExportableMemory(vkd, device, memoryRequirements, externalType, dedicated ? buffer : (vk::VkBuffer)0);
VK_CHECK(vkd.bindBufferMemory(device, buffer, *memory, 0u));
return de::MovePtr<vk::Allocation>(new SimpleAllocation(vkd, device, memory.disown()));
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<vk::VkDeviceMemory> memory = allocateExportableMemory(vkd, device, requirements.memoryRequirements, externalType, dedicated ? image : (vk::VkImage)0);
+ vk::Move<vk::VkDeviceMemory> memory = allocateExportableMemory(vkd, device, memoryRequirements, externalType, dedicated ? image : (vk::VkImage)0);
VK_CHECK(vkd.bindImageMemory(device, image, *memory, 0u));
return de::MovePtr<vk::Allocation>(new SimpleAllocation(vkd, device, memory.disown()));
const OperationSupport& readOp,
const OperationSupport& writeOp,
vk::VkExternalMemoryHandleTypeFlagBitsKHR externalType,
- bool dedicated)
+ bool dedicated,
+ bool getMemReq2Supported)
{
if (resourceDesc.type == RESOURCE_TYPE_IMAGE)
{
};
vk::Move<vk::VkImage> image = vk::createImage(vkd, device, &createInfo);
- de::MovePtr<vk::Allocation> allocation = allocateAndBindMemory(vkd, device, *image, externalType, dedicated);
+ de::MovePtr<vk::Allocation> allocation = allocateAndBindMemory(vkd, device, *image, externalType, dedicated, getMemReq2Supported);
return de::MovePtr<Resource>(new Resource(image, allocation, extent, resourceDesc.imageType, resourceDesc.imageFormat, subresourceRange, subresourceLayers));
}
&queueFamilyIndices[0]
};
vk::Move<vk::VkBuffer> buffer = vk::createBuffer(vkd, device, &createInfo);
- de::MovePtr<vk::Allocation> allocation = allocateAndBindMemory(vkd, device, *buffer, externalType, dedicated);
+ de::MovePtr<vk::Allocation> allocation = allocateAndBindMemory(vkd, device, *buffer, externalType, dedicated, getMemReq2Supported);
return de::MovePtr<Resource>(new Resource(resourceDesc.type, buffer, allocation, offset, size));
}
const std::vector<vk::VkQueueFamilyProperties> m_queueFamiliesA;
const std::vector<deUint32> m_queueFamilyIndicesA;
+ const bool m_getMemReq2Supported;
+
const vk::Unique<vk::VkDevice> m_deviceA;
const vk::DeviceDriver m_vkdA;
, 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()))
, 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)
const vk::Unique<vk::VkSemaphore> semaphoreA (createExportableSemaphore(m_vkdA, *m_deviceA, m_semaphoreHandleType));
const vk::Unique<vk::VkSemaphore> semaphoreB (createSemaphore(m_vkdB, *m_deviceB));
- const de::UniquePtr<Resource> resourceA (createResource(m_vkdA, *m_deviceA, m_config.resource, m_queueFamilyIndicesA, *m_supportReadOp, *m_supportWriteOp, m_memoryHandleType, m_config.dedicated));
+ const de::UniquePtr<Resource> 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);