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:
VkImportMemoryWin32HandleInfoKHR with a non-zero handleType valueVkImportMemoryFdInfoKHR with a non-zero handleType valueVkImportMemoryHostPointerInfoEXT with a non-zero handleType valueVkImportAndroidHardwareBufferInfoANDROID with a non-NULL buffer valueIf the parameters define an import operation and the external handle type is EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, or EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, allocationSize is ignored. The implementation must query the size of these allocations from the OS.
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.
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:
VkPhysicalDeviceMaintenance3Properties::maxMemoryAllocationCountVkPhysicalDeviceMemoryBudgetPropertiesEXT::heapUsageWhen 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 ERROR_INVALID_EXTERNAL_HANDLE. If the parameters define an export operation and the external handle type is EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, implementations should not strictly follow memoryTypeIndex. Instead, they should modify the allocation internally to use the required memory type for the application’s given usage. This is because for an export operation, there is currently no way for the client to know the memory type index before allocating.
allocationSize must be greater than 0EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, allocationSize must be greater than 0pNext chain includes a VkExportMemoryAllocateInfo structure, and any of the handle types specified in VkExportMemoryAllocateInfo::handleTypes require a dedicated allocation, as reported by GetPhysicalDeviceImageFormatProperties2 in VkExternalImageFormatProperties::externalMemoryProperties.externalMemoryFeatures, or by GetPhysicalDeviceExternalBufferProperties in VkExternalBufferProperties::externalMemoryProperties.externalMemoryFeatures, the pNext chain must include a VkMemoryDedicatedAllocateInfo or VkDedicatedAllocationMemoryAllocateInfoNV structure with either its image or buffer member set to a value other than NULL_HANDLEpNext chain includes a VkExportMemoryAllocateInfo structure, it must not include a VkExportMemoryAllocateInfoNV or VkExportMemoryWin32HandleInfoNV structurepNext chain includes a VkImportMemoryWin32HandleInfoKHR structure, it must not include a VkImportMemoryWin32HandleInfoNV structureEXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, then the values of allocationSize and memoryTypeIndex must match those specified when the payload being imported was createdVkMemoryAllocateFlagsInfo must match the mask specified when the payload being imported was allocatedAllocateMemory must match the list of physical devices that comprise the logical device on which the payload was originally allocatedmemoryTypeIndex must be one of those returned by GetMemoryWin32HandlePropertiesKHREXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT or EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, then the values of allocationSize and memoryTypeIndex must match those specified when the payload being imported was createdEXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, allocationSize must match the size specified when creating the Direct3D 12 heap from which the payload was extractedmemoryTypeIndex must be one of those returned by GetMemoryFdPropertiesKHRprotectedMemory feature is not enabled, the VkMemoryAllocateInfo::memoryTypeIndex must not indicate a memory type that reports MEMORY_PROPERTY_PROTECTED_BITmemoryTypeIndex must be one of those returned by GetMemoryHostPointerPropertiesEXTallocationSize must be an integer multiple of VkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignmentpNext chain must not include a VkDedicatedAllocationMemoryAllocateInfoNV structure with either its image or buffer field set to a value other than NULL_HANDLEpNext chain must not include a VkMemoryDedicatedAllocateInfo structure with either its image or buffer field set to a value other than NULL_HANDLEEXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, allocationSize must be the size returned by GetAndroidHardwareBufferPropertiesANDROID for the Android hardware bufferEXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, and the pNext chain does not include a VkMemoryDedicatedAllocateInfo structure or VkMemoryDedicatedAllocateInfo::image is NULL_HANDLE, the Android hardware buffer must have a AHardwareBuffer_Desc::format of AHARDWAREBUFFER_FORMAT_BLOB and a AHardwareBuffer_Desc::usage that includes AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFEREXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, memoryTypeIndex must be one of those returned by GetAndroidHardwareBufferPropertiesANDROID for the Android hardware bufferpNext chain includes a VkExportMemoryAllocateInfo structure with EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID included in its handleTypes member, and the pNext chain includes a VkMemoryDedicatedAllocateInfo structure with image not equal to NULL_HANDLE, then allocationSize must be 0EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, and the pNext does not include a VkMemoryDedicatedAllocateInfo structure, allocationSize must be greater than 0EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID, and the pNext chain includes a VkMemoryDedicatedAllocateInfo structure with buffer set to a valid VkBuffer object, allocationSize must be greater than 0pNext chain includes a VkMemoryDedicatedAllocateInfo with image that is not NULL_HANDLE, the Android hardware buffer’s AHardwareBuffer::usage must include at least one of AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER, AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE or AHARDWAREBUFFER_USAGE_GPU_DATA_BUFFERpNext chain includes a VkMemoryDedicatedAllocateInfo with image that is not NULL_HANDLE, the format of image must be FORMAT_UNDEFINED or the format returned by GetAndroidHardwareBufferPropertiesANDROID in VkAndroidHardwareBufferFormatPropertiesANDROID::format for the Android hardware bufferpNext chain includes a VkMemoryDedicatedAllocateInfo structure with image that is not NULL_HANDLE, the width, height, and array layer dimensions of image and the Android hardware buffer’s AHardwareBuffer_Desc must be identicalpNext chain includes a VkMemoryDedicatedAllocateInfo structure with image that is not NULL_HANDLE, and the Android hardware buffer’s AHardwareBuffer::usage includes AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE, the image must have a complete mipmap chainpNext chain includes a VkMemoryDedicatedAllocateInfo structure with image that is not NULL_HANDLE, and the Android hardware buffer’s AHardwareBuffer::usage does not include AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE, the image must have exactly one mipmap levelpNext chain includes a VkMemoryDedicatedAllocateInfo structure with image that is not NULL_HANDLE, each bit set in the usage of image must be listed in AHardwareBuffer Usage Equivalence, and if there is a corresponding AHARDWAREBUFFER_USAGE bit listed that bit must be included in the Android hardware buffer’s AHardwareBuffer_Desc::usageVkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress is not zero, VkMemoryAllocateFlagsInfo::flags must include MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BITVkMemoryAllocateFlagsInfo::flags includes MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, the bufferDeviceAddressCaptureReplay feature must be enabledVkMemoryAllocateFlagsInfo::flags includes MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, the bufferDeviceAddress feature must be enabledpNext chain includes a VkImportMemoryHostPointerInfoEXT structure, VkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress must be zeroVkMemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress must be zeropNext chain includes a VkExportMetalObjectCreateInfoEXT structure, its exportObjectType member must be EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXTsType must be STRUCTURE_TYPE_MEMORY_ALLOCATE_INFOpNext member of any structure (including this one) in the pNext chain must be either NULL or a pointer to a valid instance of VkDedicatedAllocationMemoryAllocateInfoNV, VkExportMemoryAllocateInfo, VkExportMemoryAllocateInfoNV, VkExportMemoryWin32HandleInfoKHR, VkExportMemoryWin32HandleInfoNV, VkExportMetalObjectCreateInfoEXT, VkImportAndroidHardwareBufferInfoANDROID, VkImportMemoryFdInfoKHR, VkImportMemoryHostPointerInfoEXT, VkImportMemoryWin32HandleInfoKHR, VkImportMemoryWin32HandleInfoNV, VkImportMetalBufferInfoEXT, VkMemoryAllocateFlagsInfo, VkMemoryDedicatedAllocateInfo, VkMemoryOpaqueCaptureAddressAllocateInfo, or VkMemoryPriorityAllocateInfoEXTsType value of each struct in the pNext chain must be unique, with the exception of structures of type VkExportMetalObjectCreateInfoEXT
struct VkMemoryAllocateInfo {
VkStructureType sType;
void const * pNext;
VkDeviceSize allocationSize;
uint32_t memoryTypeIndex;
}
| Modifier and Type | Class and Description |
|---|---|
| public static class | VkMemoryAllocateInfo.
An array of |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | ALIGNOF
The struct alignment in bytes. |
| public static final int | ALLOCATIONSIZE
The struct member offsets. |
| public static final int | MEMORYTYPEINDEX
The struct member offsets. |
| public static final int | PNEXT
The struct member offsets. |
| public static final int | SIZEOF
The struct size in bytes. |
| public static final int | STYPE
The struct member offsets. |
| Access | Constructor and Description |
|---|---|
| protected | |
| public | VkMemoryAllocateInfo(ByteBuffer container)
Creates a |
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | calloc(int
the buffer capacity capacity)Returns a new |
| public static VkMemoryAllocateInfo | calloc(MemoryStack
the stack from which to allocate stack)Returns a new |
| public static VkMemoryAllocateInfo. | calloc(int
the buffer capacity capacity, MemoryStack the stack from which to allocate stack)Returns a new |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | |
| public static VkMemoryAllocateInfo. | |
| protected VkMemoryAllocateInfo | create(long
the struct memory address address, ByteBuffer an optional container buffer, to be referenced strongly by the struct instance. container)Implements abstract org. the constructor, but returns the exact type of the Struct subclass.
|
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | create(int
the buffer capacity capacity)Returns a new |
| public static VkMemoryAllocateInfo. | create(long
the memory address address, int the buffer capacity capacity)Create a |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | malloc(int
the buffer capacity capacity)Returns a new |
| public static VkMemoryAllocateInfo | malloc(MemoryStack
the stack from which to allocate stack)Returns a new |
| public static VkMemoryAllocateInfo. | malloc(int
the buffer capacity capacity, MemoryStack the stack from which to allocate stack)Returns a new |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo | |
| public static VkMemoryAllocateInfo. | |
| public static VkMemoryAllocateInfo. | |
| public int | memoryTypeIndex()
an index identifying a memory type from the |
| public VkMemoryAllocateInfo | |
| public static long | |
| public static void | |
| public static int | |
| public static void | |
| public static long | |
| public static void | |
| public static int | |
| public static void | |
| public long | |
| public VkMemoryAllocateInfo | |
| public VkMemoryAllocateInfo | pNext(VkDedicatedAllocationMemoryAllocateInfoNV value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMemoryAllocateInfo value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMemoryAllocateInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMemoryAllocateInfoNV value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMemoryWin32HandleInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMemoryWin32HandleInfoNV value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkExportMetalObjectCreateInfoEXT value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportAndroidHardwareBufferInfoANDROID value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportMemoryFdInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportMemoryHostPointerInfoEXT value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportMemoryWin32HandleInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportMemoryWin32HandleInfoNV value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkImportMetalBufferInfoEXT value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryAllocateFlagsInfo value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryAllocateFlagsInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryDedicatedAllocateInfo value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryDedicatedAllocateInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryOpaqueCaptureAddressAllocateInfo value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryOpaqueCaptureAddressAllocateInfoKHR value)
Prepends the specified |
| public VkMemoryAllocateInfo | pNext(VkMemoryPriorityAllocateInfoEXT value)
Prepends the specified |
| public VkMemoryAllocateInfo | set(int sType, long pNext, long allocationSize, int memoryTypeIndex)
Initializes this struct with the specified values. |
| public VkMemoryAllocateInfo | Returns: this structthe source struct src)Copies the specified struct data to this struct. |
| public int | |
| public int | |
| public VkMemoryAllocateInfo | |
| public VkMemoryAllocateInfo |