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.
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
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 application to know
the memory type index before allocating.
The parameters must not
define more than one
import operation
If the parameters
define an export operation and the handle type is not
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
, allocationSize must be greater than 0
If the parameters define an
import operation from an
BufferCollectionFUCHSIA, and
MemoryDedicatedAllocateInfo::buffer
is present and non-NULL,
ImportMemoryBufferCollectionFUCHSIA::collection
and
ImportMemoryBufferCollectionFUCHSIA::index
must match
BufferCollectionBufferCreateInfoFUCHSIA::collection
and
BufferCollectionBufferCreateInfoFUCHSIA::index,
respectively, of the
BufferCollectionBufferCreateInfoFUCHSIA
structure used to create the
MemoryDedicatedAllocateInfo::buffer
If the parameters define an
import operation from an
BufferCollectionFUCHSIA, and
MemoryDedicatedAllocateInfo::image
is present and non-NULL,
ImportMemoryBufferCollectionFUCHSIA::collection
and
ImportMemoryBufferCollectionFUCHSIA::index
must match
BufferCollectionImageCreateInfoFUCHSIA::collection
and
BufferCollectionImageCreateInfoFUCHSIA::index,
respectively, of the
BufferCollectionImageCreateInfoFUCHSIA
structure used to create the
MemoryDedicatedAllocateInfo::image
If the parameters
define an import operation from an
BufferCollectionFUCHSIA,
allocationSize must match
MemoryRequirements::size value
retrieved by
getImageMemoryRequirements or
getBufferMemoryRequirements for
image-based or buffer-based collections respectively
If the parameters define an
import operation from an
BufferCollectionFUCHSIA, the pNext
chain must include a
MemoryDedicatedAllocateInfo
structure with either its image or buffer field set to a value
other than NULL_HANDLE
If the parameters define an
import operation from an
BufferCollectionFUCHSIA and
MemoryDedicatedAllocateInfo::image
is not NULL_HANDLE, the image must
be created with a
BufferCollectionImageCreateInfoFUCHSIA
structure chained to its
ImageCreateInfo::pNext pointer
If the parameters define an
import operation from an
BufferCollectionFUCHSIA and
MemoryDedicatedAllocateInfo::buffer
is not NULL_HANDLE, the buffer must
be created with a
BufferCollectionBufferCreateInfoFUCHSIA
structure chained to its
BufferCreateInfo::pNext pointer
If the parameters
define an import operation from an
BufferCollectionFUCHSIA,
memoryTypeIndex must be from
BufferCollectionPropertiesFUCHSIA
as retrieved by
getBufferCollectionPropertiesFUCHSIA
If the pNext chain
includes a
ExportMemoryAllocateInfo
structure, and any of the handle types specified in
ExportMemoryAllocateInfo::handleTypes
require a dedicated allocation, as reported by
getPhysicalDeviceImageFormatProperties2
in
ExternalImageFormatProperties::externalMemoryProperties.externalMemoryFeatures,
or by
getPhysicalDeviceExternalBufferProperties
in
ExternalBufferProperties::externalMemoryProperties.externalMemoryFeatures,
the pNext chain must include a
MemoryDedicatedAllocateInfo
or
DedicatedAllocationMemoryAllocateInfoNV
structure with either its image or buffer member set to a value
other than NULL_HANDLE
If the pNext chain
includes a
ExportMemoryAllocateInfo
structure, and any of the handle types specified in
ExportMemoryAllocateInfo::handleTypes
require a dedicated allocation, as reported by
getPhysicalDeviceExternalTensorPropertiesARM
in
ExternalTensorPropertiesARM::externalMemoryProperties.externalMemoryFeatures,
the pNext chain must include a
MemoryDedicatedAllocateInfoTensorARM
structure with its tensor member set to a value other than
NULL_HANDLE
If the pNext chain
includes a
ExportMemoryAllocateInfo
structure, it must not include a
ExportMemoryAllocateInfoNV
or
ExportMemoryWin32HandleInfoNV
structure
If the pNext chain
includes a
ImportMemoryWin32HandleInfoKHR
structure, it must not include a
ImportMemoryWin32HandleInfoNV
structure
If the parameters
define an import operation, the external handle specified was
created by the Vulkan API, and the external handle type is
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
If the parameters define an
import operation and the external handle specified was created by
the Vulkan API, the device mask specified by
MemoryAllocateFlagsInfo
must match the mask specified when the payload being imported was
allocated
If the parameters define an
import operation and the external handle specified was created by
the Vulkan API, the list of physical devices that comprise the
logical device passed to allocateMemory must match the list of
physical devices that comprise the logical device on which the
payload was originally allocated
If the parameters
define an import operation and the external handle is an NT handle
or a global share handle created outside of the Vulkan API, the
value of memoryTypeIndex must be one of those returned by
getMemoryWin32HandlePropertiesKHR
If the parameters
define an import operation, the external handle was created by the
Vulkan API, and the external handle type is
EXTERNAL_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 created
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT,
allocationSize must match the size specified when creating the
Direct3D 12 heap from which the payload was extracted
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
getMemoryFdPropertiesKHR
If the
protectedMemory
feature is not enabled, the MemoryAllocateInfo::memoryTypeIndex
must not indicate a memory type that reports
MEMORY_PROPERTY_PROTECTED_BIT
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
getMemoryHostPointerPropertiesEXT
If the parameters
define an import operation and the external handle is a host
pointer, allocationSize must be an integer multiple of
PhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment
If the parameters define an
import operation and the external handle is a host pointer, the
pNext chain must not include a
DedicatedAllocationMemoryAllocateInfoNV
structure with either its image or buffer field set to a value
other than NULL_HANDLE
If the parameters define an
import operation and the external handle is a host pointer, the
pNext chain must not include a
MemoryDedicatedAllocateInfo
structure with either its image or buffer field set to a value
other than NULL_HANDLE
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
allocationSize must be the size returned by
getAndroidHardwareBufferPropertiesANDROID
for the Android hardware buffer
If the parameters define an
import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
and the pNext chain does not include a
MemoryDedicatedAllocateInfo
structure or
MemoryDedicatedAllocateInfo::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_BUFFER
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
memoryTypeIndex must be one of those returned by
getAndroidHardwareBufferPropertiesANDROID
for the Android hardware buffer
If the parameters do not
define an import operation, and the pNext chain includes a
ExportMemoryAllocateInfo
structure with
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID
included in its handleTypes member, and the pNext chain includes
a
MemoryDedicatedAllocateInfo
structure with image not equal to
NULL_HANDLE, then allocationSize
must be 0
If the parameters define an
export operation, the handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
and the pNext does not include a
MemoryDedicatedAllocateInfo
structure, allocationSize must be greater than 0
If the parameters define an
export operation, the handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
structure with buffer set to a valid
Buffer object, allocationSize must be
greater than 0
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
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_BUFFER
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
with image that is not NULL_HANDLE,
the format of image must be
FORMAT_UNDEFINED or the format returned
by
getAndroidHardwareBufferPropertiesANDROID
in
AndroidHardwareBufferFormatPropertiesANDROID::format
for the Android hardware buffer
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
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 identical
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
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 chain
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
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 level
If the parameters define an
import operation, the external handle is an Android hardware buffer,
and the pNext chain includes a
MemoryDedicatedAllocateInfo
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::usage
If the
parameters define an import operation and the external handle type
is
EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX,
PhysicalDeviceExternalMemoryScreenBufferFeaturesQNX::screenBufferImport
must be enabled
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX,
allocationSize must be the size returned by
getScreenBufferPropertiesQNX
for the QNX Screen buffer
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX,
memoryTypeIndex must be one of those returned by
getScreenBufferPropertiesQNX
for the QNX Screen buffer
If the parameters define an
import operation, the external handle is a QNX Screen buffer, and
the pNext chain includes a
MemoryDedicatedAllocateInfo
with image that is not NULL_HANDLE,
the QNX Screen’s buffer must be a
valid QNX Screen buffer
If the parameters define an
import operation, the external handle is an QNX Screen buffer, and
the pNext chain includes a
MemoryDedicatedAllocateInfo
with image that is not NULL_HANDLE,
the format of image must be
FORMAT_UNDEFINED or the format returned
by
getScreenBufferPropertiesQNX
in
ScreenBufferFormatPropertiesQNX::format
for the QNX Screen buffer
If the parameters define an
import operation, the external handle is a QNX Screen buffer, and
the pNext chain includes a
MemoryDedicatedAllocateInfo
structure with image that is not
NULL_HANDLE, the width, height, and
array layer dimensions of image and the QNX Screen buffer’s
Screen_buffer
must be identical
If the parameters define an
import operation and the external handle is a
EXTERNAL_MEMORY_HANDLE_TYPE_MTLTEXTURE_BIT_EXT,
then pNext must include a
MemoryDedicatedAllocateInfo
with image that is not NULL_HANDLE
If the parameters define an
import operation, the external handle is a Metal MTLTexture, and the
pNext chain includes a
MemoryDedicatedAllocateInfo
structure with image that is not
NULL_HANDLE, the width, height, array
layer dimensions, and mipmap levels of image and the Metal
MTLTexture’s must be identical
If the parameters define an
import operation, the external handle is a Metal MTLTexture, and the
pNext chain includes a
MemoryDedicatedAllocateInfo
structure with image that is not
NULL_HANDLE, allocationSize must be
0
If
MemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress
is not zero,
MemoryAllocateFlagsInfo::flags
must include
MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT
If
MemoryAllocateFlagsInfo::flags
includes
MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT,
the
bufferDeviceAddressCaptureReplay
feature must be enabled
If
MemoryAllocateFlagsInfo::flags
includes
MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT,
the
bufferDeviceAddress
feature must be enabled
If the pNext chain
includes a
ImportMemoryHostPointerInfoEXT
structure,
MemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress
must be zero
If the
parameters define an import operation,
MemoryOpaqueCaptureAddressAllocateInfo::opaqueCaptureAddress
must be zero
If the parameters define an
import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA,
the value of memoryTypeIndex must be an index identifying a
memory type from the memoryTypeBits field of the
MemoryZirconHandlePropertiesFUCHSIA
structure populated by a call to
getMemoryZirconHandlePropertiesFUCHSIA
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA,
the value of allocationSize must be greater than 0
If the parameters
define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA,
the value of allocationSize must be less than or equal to the
size of the VMO as determined by zx_vmo_get_size(handle) where
handle is the VMO handle to the imported external memory
If the pNext chain
includes a
ExportMetalObjectCreateInfoEXT
structure, its exportObjectType member must be
EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT