C Specification

The VkMemoryAllocateInfo structure is defined as:

// Provided by VK_VERSION_1_0
typedef struct VkMemoryAllocateInfo {
    VkStructureType    sType;
    const void*        pNext;
    VkDeviceSize       allocationSize;
    uint32_t           memoryTypeIndex;
} VkMemoryAllocateInfo;

Members

  • sType is a VkStructureType value identifying this structure.

  • pNext is NULL or a pointer to a structure extending this structure.

  • allocationSize is the size of the allocation in bytes.

  • memoryTypeIndex is an index identifying a memory type from the memoryTypes array of the VkPhysicalDeviceMemoryProperties structure.

Description

The internal data of an allocated device memory object must include a reference to implementation-specific resources, referred to as the memory object’s payload. Applications can also import and export that internal data to and from device memory objects to share data between Vulkan instances and other compatible APIs. A VkMemoryAllocateInfo structure defines a memory import operation if its pNext chain includes one of the following structures:

If the parameters define an import operation and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCI_BUF_BIT_NV, allocationSize is ignored. The implementation must query the size of this allocation from the NvSciBufAttrList associated with the external NvSciBufObj.

Whether device memory objects constructed via a memory import operation hold a reference to their payload depends on the properties of the handle type used to perform the import, as defined below for each valid handle type. Importing memory must not modify the content of the memory. Implementations must ensure that importing memory does not enable the importing Vulkan instance to access any memory or resources in other Vulkan instances other than that corresponding to the memory object imported. Implementations must also ensure accessing imported memory which has not been initialized does not allow the importing Vulkan instance to obtain data from the exporting Vulkan instance or vice-versa.

Note

How exported and imported memory is isolated is left to the implementation, but applications should be aware that such isolation may prevent implementations from placing multiple exportable memory objects in the same physical or virtual page. Hence, applications should avoid creating many small external memory objects whenever possible.

Importing memory must not increase overall heap usage within a system. However, it must affect the following per-process values:

When performing a memory import operation, it is the responsibility of the application to ensure the external handles and their associated payloads meet all valid usage requirements. However, implementations must perform sufficient validation of external handles and payloads to ensure that the operation results in a valid memory object which will not cause program termination, device loss, queue stalls, or corruption of other resources when used as allowed according to its allocation parameters. If the external handle provided does not meet these requirements, the implementation must fail the memory import operation with the error code VK_ERROR_INVALID_EXTERNAL_HANDLE.

Valid Usage
  • VUID-VkMemoryAllocateInfo-allocationSize-07897
    If the parameters do not define an import or export operation, allocationSize must be greater than 0

  • VUID-VkMemoryAllocateInfo-None-06657
    The parameters must not define more than one import operation

  • VUID-VkMemoryAllocateInfo-allocationSize-07899
    If the parameters define an export operation , allocationSize must be greater than 0

  • VUID-VkMemoryAllocateInfo-allocationSize-01742
    If the parameters define an import operation, the external handle specified was created by the Vulkan API, and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, then the values of allocationSize and memoryTypeIndex must match those specified when the payload being imported was created

  • VUID-VkMemoryAllocateInfo-memoryTypeIndex-00648
    If the parameters define an import operation and the external handle is a POSIX file descriptor created outside of the Vulkan API, the value of memoryTypeIndex must be one of those returned by vkGetMemoryFdPropertiesKHR

  • VUID-VkMemoryAllocateInfo-memoryTypeIndex-01872
    If the protectedMemory feature is not enabled, the VkMemoryAllocateInfo::memoryTypeIndex must not indicate a memory type that reports VK_MEMORY_PROPERTY_PROTECTED_BIT

  • VUID-VkMemoryAllocateInfo-memoryTypeIndex-01744
    If the parameters define an import operation and the external handle is a host pointer, the value of memoryTypeIndex must be one of those returned by vkGetMemoryHostPointerPropertiesEXT

  • VUID-VkMemoryAllocateInfo-allocationSize-01745
    If the parameters define an import operation and the external handle is a host pointer, allocationSize must be an integer multiple of VkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment

  • VUID-VkMemoryAllocateInfo-screenBufferImport-08941
    If the parameters define an import operation and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX, VkPhysicalDeviceExternalMemoryScreenBufferFeaturesQNX::screenBufferImport must be enabled

  • VUID-VkMemoryAllocateInfo-allocationSize-08942
    If the parameters define an import operation and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX, allocationSize must be the size returned by vkGetScreenBufferPropertiesQNX for the QNX Screen buffer

  • VUID-VkMemoryAllocateInfo-memoryTypeIndex-08943
    If the parameters define an import operation and the external handle type is VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX, memoryTypeIndex must be one of those returned by vkGetScreenBufferPropertiesQNX for the QNX Screen buffer

  • VUID-VkMemoryAllocateInfo-pNext-08944
    If the parameters define an import operation, the external handle is a QNX Screen buffer, and the pNext chain includes a VkMemoryDedicatedAllocateInfo with image that is not VK_NULL_HANDLE, the QNX Screen’s buffer must be a valid QNX Screen buffer

  • VUID-VkMemoryAllocateInfo-pNext-08945
    If the parameters define an import operation, the external handle is an QNX Screen buffer, and the pNext chain includes a VkMemoryDedicatedAllocateInfo with image that is not VK_NULL_HANDLE, the format of image must be VK_FORMAT_UNDEFINED or the format returned by vkGetScreenBufferPropertiesQNX in VkScreenBufferFormatPropertiesQNX::format for the QNX Screen buffer

  • VUID-VkMemoryAllocateInfo-pNext-08946
    If the parameters define an import operation, the external handle is a QNX Screen buffer, and the pNext chain includes a VkMemoryDedicatedAllocateInfo structure with image that is not VK_NULL_HANDLE, the width, height, and array layer dimensions of image and the QNX Screen buffer’s _screen_buffer must be identical

  • VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329
    If VkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress is not zero, VkMemoryAllocateFlagsInfo::flags must include VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT

  • VUID-VkMemoryAllocateInfo-flags-03330
    If VkMemoryAllocateFlagsInfo::flags includes VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, the bufferDeviceAddressCaptureReplay feature must be enabled

  • VUID-VkMemoryAllocateInfo-flags-03331
    If VkMemoryAllocateFlagsInfo::flags includes VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, the bufferDeviceAddress feature must be enabled

  • VUID-VkMemoryAllocateInfo-pNext-03332
    If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, VkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress must be zero

  • VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333
    If the parameters define an import operation, VkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress must be zero

  • VUID-VkMemoryAllocateInfo-pNext-05097
    If the pNext chain includes a VkExportMemorySciBufInfoNV structure, VkPhysicalDeviceExternalMemorySciBufFeaturesNV::sciBufExport must be enabled

  • VUID-VkMemoryAllocateInfo-pNext-05098
    If the pNext chain includes a VkImportMemorySciBufInfoNV structure, VkPhysicalDeviceExternalMemorySciBufFeaturesNV::sciBufImport must be enabled

  • VUID-VkMemoryAllocateInfo-memoryTypeIndex-05099
    If the parameters define an import operation and the external handle is a NvSciBufObj, the value of memoryTypeIndex must be one of those returned by vkGetPhysicalDeviceExternalMemorySciBufPropertiesNV

Valid Usage (Implicit)

See Also

Document Notes

For more information, see the Vulkan Specification

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0