};
#if (DE_OS == DE_OS_WIN32)
-deUint32 chooseMemoryType (deUint32 bits)
+deUint32 chooseWin32MemoryType(deUint32 bits)
{
if (bits == 0)
TCU_THROW(NotSupportedError, "No compatible memory type found");
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
// \note Buffer is only allocated to get memory requirements
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
const vk::VkExportMemoryWin32HandleInfoKHR win32Info =
(vk::VkExternalMemoryHandleTypeFlags)config.externalType
};
- exportedMemoryTypeIndex = chooseMemoryType(requirements.memoryTypeBits & compatibleMemTypes);
- const vk::VkMemoryAllocateInfo info =
+ const deUint32 exportedMemoryTypeIndex = chooseWin32MemoryType(requirements.memoryTypeBits & compatibleMemTypes);
+ const vk::VkMemoryAllocateInfo info =
{
vk::VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
&exportInfo,
requirements.size,
exportedMemoryTypeIndex
};
- const vk::Unique<vk::VkDeviceMemory> memory (vk::allocateMemory(vkd, *device, &info));
+ const vk::Unique<vk::VkDeviceMemory> memory (vk::allocateMemory(vkd, *device, &info));
NativeHandle handleA;
if (config.hostVisible)
#endif
}
+deUint32 getExportedMemoryTypeIndex(const vk::InstanceDriver& vki, const vk::VkPhysicalDevice physicalDevice, bool hostVisible, deUint32 memoryBits)
+{
+ if (hostVisible)
+ {
+ const vk::VkPhysicalDeviceMemoryProperties properties(vk::getPhysicalDeviceMemoryProperties(vki, physicalDevice));
+ return chooseHostVisibleMemoryType(memoryBits, properties);
+ }
+
+ return chooseMemoryType(memoryBits);
+}
+
tcu::TestStatus testMemoryImportTwice (Context& context, MemoryTestConfig config)
{
const vk::PlatformInterface& vkp (context.getPlatformInterface());
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
- const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
- const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
- NativeHandle handleA;
+ const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
+ const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
+ NativeHandle handleA;
if (config.hostVisible)
writeHostMemory(vkd, *device, *memory, testData.size(), &testData[0]);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
NativeHandle handleA;
getMemoryNative(vkd, *device, *memory, config.externalType, handleA);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
for (size_t ndx = 0; ndx < count; ndx++)
{
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
vk::VkMemoryFdPropertiesKHR properties;
NativeHandle handle;
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
if (config.hostVisible)
writeHostMemory(vkd, *device, *memory, testData.size(), &testData[0]);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
if (config.hostVisible)
writeHostMemory(vkd, *device, *memory, testData.size(), &testData[0]);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
if (config.hostVisible)
writeHostMemory(vkd, *device, *memory, testData.size(), &testData[0]);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> buffer (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *buffer));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vki, physicalDevice, vkd, *device, requirements, config.externalType, config.hostVisible, config.dedicated ? *buffer : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (getExportedMemoryTypeIndex(vki, physicalDevice, config.hostVisible, requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *buffer : (vk::VkBuffer)0));
if (config.hostVisible)
writeHostMemory(vkd, *device, *memory, testData.size(), &testData[0]);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> bufferA (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *bufferA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0));
NativeHandle handle;
VK_CHECK(vkd.bindBufferMemory(*device, *bufferA, *memoryA, 0u));
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> bufferA (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *bufferA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0));
NativeHandle handle;
getMemoryNative(vkd, *device, *memoryA, config.externalType, handle);
checkBufferSupport(vki, physicalDevice, config.externalType, 0u, usage, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Buffer is only allocated to get memory requirements
const vk::Unique<vk::VkBuffer> bufferA (createExternalBuffer(vkd, *device, queueFamilyIndex, config.externalType, bufferSize, 0u, usage));
const vk::VkMemoryRequirements requirements (getBufferMemoryRequirements(vkd, *device, *bufferA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *bufferA : (vk::VkBuffer)0));
NativeHandle handle;
getMemoryNative(vkd, *device, *memoryA, config.externalType, handle);
checkImageSupport(vki, physicalDevice, config.externalType, 0u, usage, format, tiling, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkImage> imageA (createExternalImage(vkd, *device, queueFamilyIndex, config.externalType, format, width, height, tiling, 0u, usage));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *imageA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0));
NativeHandle handle;
VK_CHECK(vkd.bindImageMemory(*device, *imageA, *memoryA, 0u));
checkImageSupport(vki, physicalDevice, config.externalType, 0u, usage, format, tiling, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkImage> imageA (createExternalImage(vkd, *device, queueFamilyIndex, config.externalType, format, width, height, tiling, 0u, usage));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *imageA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0));
NativeHandle handle;
getMemoryNative(vkd, *device, *memoryA, config.externalType, handle);
checkImageSupport(vki, physicalDevice, config.externalType, 0u, usage, format, tiling, config.dedicated);
- deUint32 exportedMemoryTypeIndex = ~0U;
// \note Image is only allocated to get memory requirements
const vk::Unique<vk::VkImage> imageA (createExternalImage(vkd, *device, queueFamilyIndex, config.externalType, format, width, height, tiling, 0u, usage));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *imageA));
- const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memoryA (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, config.externalType, config.dedicated ? *imageA : (vk::VkImage)0));
NativeHandle handle;
getMemoryNative(vkd, *device, *memoryA, config.externalType, handle);
};
for (size_t i = 0; i < DE_LENGTH_OF_ARRAY(sizes); i++)
{
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkImage> image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, sizes[i].width, sizes[i].height, tiling, createFlag, usage));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements, externalMemoryType, *image, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image));
NativeHandle handle;
VK_CHECK(vkd.bindImageMemory(*device, *image, *memory, 0u));
if (properties.imageFormatProperties.maxMipLevels > 1u)
{
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkImage> image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, 64u, 64u, tiling, createFlag, usage, properties.imageFormatProperties.maxMipLevels));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements, externalMemoryType, *image, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image));
NativeHandle handle;
VK_CHECK(vkd.bindImageMemory(*device, *image, *memory, 0u));
if ((properties.imageFormatProperties.maxArrayLayers > 1u) && enableMaxLayerTest)
{
- deUint32 exportedMemoryTypeIndex = ~0U;
const vk::Unique<vk::VkImage> image (createExternalImage(vkd, *device, queueFamilyIndex, externalMemoryType, format, 64u, 64u, tiling, createFlag, usage, 1u, properties.imageFormatProperties.maxArrayLayers));
const vk::VkMemoryRequirements requirements (getImageMemoryRequirements(vkd, *device, *image));
- const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements, externalMemoryType, *image, exportedMemoryTypeIndex));
+ const deUint32 exportedMemoryTypeIndex (chooseMemoryType(requirements.memoryTypeBits));
+ const vk::Unique<vk::VkDeviceMemory> memory (allocateExportableMemory(vkd, *device, requirements.size, exportedMemoryTypeIndex, externalMemoryType, *image));
NativeHandle handle;
VK_CHECK(vkd.bindImageMemory(*device, *image, *memory, 0u));