Class VkMemoryAllocateInfo
- java.lang.Object
-
- org.lwjgl.system.Pointer.Default
-
- org.lwjgl.system.Struct
-
- org.lwjgl.vulkan.VkMemoryAllocateInfo
-
- All Implemented Interfaces:
java.lang.AutoCloseable,org.lwjgl.system.NativeResource,org.lwjgl.system.Pointer
public class VkMemoryAllocateInfo extends org.lwjgl.system.Struct implements org.lwjgl.system.NativeResourceStructure containing parameters of a memory allocation.Description
An instance of the
VkMemoryAllocateInfostructure defines a memory import operation if thepNextchain contains an instance of one of the following structures:VkImportMemoryWin32HandleInfoKHRwith non-zerohandleTypevalueVkImportMemoryFdInfoKHRwith a non-zerohandleTypevalueVkImportMemoryHostPointerInfoEXTwith a non-zerohandleTypevalue
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.
When performing a memory import operation, it is the responsibility of the application to ensure the external handles meet all valid usage requirements. However, implementations must perform sufficient validation of external handles 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.Valid Usage
allocationSizemust be greater than 0- If the
pNextchain contains an instance ofVkExportMemoryAllocateInfo, and any of the handle types specified inVkExportMemoryAllocateInfo::handleTypesrequire a dedicated allocation, as reported byGetPhysicalDeviceImageFormatProperties2inVkExternalImageFormatProperties::externalMemoryProperties::externalMemoryFeaturesorVkExternalBufferProperties::externalMemoryProperties::externalMemoryFeatures, thepNextchain must contain an instance ofVkMemoryDedicatedAllocateInfoorVkDedicatedAllocationMemoryAllocateInfoNVwith either itsimageorbufferfield set to a value other thanNULL_HANDLE. - If the
pNextchain contains an instance ofVkExportMemoryAllocateInfo, it must not contain an instance ofVkExportMemoryAllocateInfoNVorVkExportMemoryWin32HandleInfoNV. - If the
pNextchain contains an instance ofVkImportMemoryWin32HandleInfoKHR, it must not contain an instance ofVkImportMemoryWin32HandleInfoNV. - 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_KHR, then the values ofallocationSizeandmemoryTypeIndexmust match those specified when the memory object 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
VkMemoryAllocateFlagsInfomust match that specified when the memory object 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
AllocateMemorymust match the list of physical devices that comprise the logical device on which the memory 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
memoryTypeIndexmust be one of those returned byGetMemoryWin32HandlePropertiesKHR. - 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_KHRorEXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR, then the values ofallocationSizeandmemoryTypeIndexmust match those specified when the memory object being imported was created. - If 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, orEXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT,allocationSizemust match the size reported in the memory requirements of theimageorbuffermember of the instance ofVkDedicatedAllocationMemoryAllocateInfoNVincluded in thepNextchain. - If the parameters define an import operation and the external handle type is
EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT,allocationSizemust match the size specified when creating the Direct3D 12 heap from which the external handle 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
memoryTypeIndexmust be one of those returned byGetMemoryFdPropertiesKHR. - If the protected memory feature is not enabled, the
VkMemoryAllocateInfo::memoryTypeIndexmust not indicate a memory type that reportsMEMORY_PROPERTY_PROTECTED_BIT. - If the parameters define an import operation and the external handle is a host pointer, the value of
memoryTypeIndexmust be one of those returned byGetMemoryHostPointerPropertiesEXT - If the parameters define an import operation and the external handle is a host pointer,
allocationSizemust be an integer multiple ofVkPhysicalDeviceExternalMemoryHostPropertiesEXT::minImportedHostPointerAlignment
Valid Usage (Implicit)
sTypemust beSTRUCTURE_TYPE_MEMORY_ALLOCATE_INFO- Each
pNextmember of any structure (including this one) in thepNextchain must be eitherNULLor a pointer to a valid instance ofVkDedicatedAllocationMemoryAllocateInfoNV,VkExportMemoryAllocateInfo,VkExportMemoryAllocateInfoNV,VkExportMemoryWin32HandleInfoKHR,VkExportMemoryWin32HandleInfoNV,VkImportMemoryFdInfoKHR,VkImportMemoryHostPointerInfoEXT,VkImportMemoryWin32HandleInfoKHR,VkImportMemoryWin32HandleInfoNV,VkMemoryAllocateFlagsInfo,VkMemoryDedicatedAllocateInfo, orVkMemoryPriorityAllocateInfoEXT - Each
sTypemember in thepNextchain must be unique
See Also
Member documentation
sType– the type of this structure.pNext–NULLor a pointer to an extension-specific structure.allocationSize– the size of the allocation in bytesmemoryTypeIndex– an index identifying a memory type from thememoryTypesarray of theVkPhysicalDeviceMemoryPropertiesstructure
Layout
struct VkMemoryAllocateInfo { VkStructureType sType; void const * pNext; VkDeviceSize allocationSize; uint32_t memoryTypeIndex; }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classVkMemoryAllocateInfo.BufferAn array ofVkMemoryAllocateInfostructs.
-
Field Summary
Fields Modifier and Type Field Description static intALIGNOFThe struct alignment in bytes.static intALLOCATIONSIZE
MEMORYTYPEINDEX
PNEXTThe struct member offsets.static intSIZEOFThe struct size in bytes.static intSTYPEThe struct member offsets.
-
Constructor Summary
Constructors Constructor Description VkMemoryAllocateInfo(java.nio.ByteBuffer container)Creates aVkMemoryAllocateInfoinstance at the current position of the specifiedByteBuffercontainer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longallocationSize()Returns the value of theallocationSizefield.VkMemoryAllocateInfoallocationSize(long value)Sets the specified value to theallocationSizefield.static VkMemoryAllocateInfocalloc()Returns a newVkMemoryAllocateInfoinstance allocated withmemCalloc.static VkMemoryAllocateInfo.Buffercalloc(int capacity)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withmemCalloc.static VkMemoryAllocateInfocallocStack()Returns a newVkMemoryAllocateInfoinstance allocated on the thread-localMemoryStackand initializes all its bits to zero.static VkMemoryAllocateInfo.BuffercallocStack(int capacity)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the thread-localMemoryStackand initializes all its bits to zero.static VkMemoryAllocateInfo.BuffercallocStack(int capacity, org.lwjgl.system.MemoryStack stack)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.static VkMemoryAllocateInfocallocStack(org.lwjgl.system.MemoryStack stack)Returns a newVkMemoryAllocateInfoinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.static VkMemoryAllocateInfocreate()Returns a newVkMemoryAllocateInfoinstance allocated withBufferUtils.static VkMemoryAllocateInfo.Buffercreate(int capacity)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withBufferUtils.static VkMemoryAllocateInfocreate(long address)Returns a newVkMemoryAllocateInfoinstance for the specified memory address.static VkMemoryAllocateInfo.Buffercreate(long address, int capacity)Create aVkMemoryAllocateInfo.Bufferinstance at the specified memory.static VkMemoryAllocateInfocreateSafe(long address)static VkMemoryAllocateInfo.BuffercreateSafe(long address, int capacity)static VkMemoryAllocateInfomalloc()Returns a newVkMemoryAllocateInfoinstance allocated withmemAlloc.static VkMemoryAllocateInfo.Buffermalloc(int capacity)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withmemAlloc.static VkMemoryAllocateInfomallocStack()Returns a newVkMemoryAllocateInfoinstance allocated on the thread-localMemoryStack.static VkMemoryAllocateInfo.BuffermallocStack(int capacity)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the thread-localMemoryStack.static VkMemoryAllocateInfo.BuffermallocStack(int capacity, org.lwjgl.system.MemoryStack stack)Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the specifiedMemoryStack.static VkMemoryAllocateInfomallocStack(org.lwjgl.system.MemoryStack stack)Returns a newVkMemoryAllocateInfoinstance allocated on the specifiedMemoryStack.intmemoryTypeIndex()Returns the value of thememoryTypeIndexfield.VkMemoryAllocateInfomemoryTypeIndex(int value)Sets the specified value to thememoryTypeIndexfield.static longnallocationSize(long struct)Unsafe version ofallocationSize().static voidnallocationSize(long struct, long value)Unsafe version ofallocationSize.static intnmemoryTypeIndex(long struct)Unsafe version ofmemoryTypeIndex().static voidnmemoryTypeIndex(long struct, int value)Unsafe version ofmemoryTypeIndex.static longnpNext(long struct)Unsafe version ofpNext().static voidnpNext(long struct, long value)Unsafe version ofpNext.static intnsType(long struct)Unsafe version ofsType().static voidnsType(long struct, int value)Unsafe version ofsType.longpNext()Returns the value of thepNextfield.VkMemoryAllocateInfopNext(long value)Sets the specified value to thepNextfield.VkMemoryAllocateInfoset(int sType, long pNext, long allocationSize, int memoryTypeIndex)Initializes this struct with the specified values.VkMemoryAllocateInfoset(VkMemoryAllocateInfo src)Copies the specified struct data to this struct.intsizeof()intsType()Returns the value of thesTypefield.VkMemoryAllocateInfosType(int value)Sets the specified value to thesTypefield.
-
-
-
Constructor Detail
-
VkMemoryAllocateInfo
public VkMemoryAllocateInfo(java.nio.ByteBuffer container)
Creates aVkMemoryAllocateInfoinstance at the current position of the specifiedByteBuffercontainer. Changes to the buffer's content will be visible to the struct instance and vice versa.The created instance holds a strong reference to the container object.
-
-
Method Detail
-
sizeof
public int sizeof()
- Specified by:
sizeofin classorg.lwjgl.system.Struct
-
sType
public int sType()
Returns the value of thesTypefield.
-
pNext
public long pNext()
Returns the value of thepNextfield.
-
allocationSize
public long allocationSize()
Returns the value of theallocationSizefield.
-
memoryTypeIndex
public int memoryTypeIndex()
Returns the value of thememoryTypeIndexfield.
-
sType
public VkMemoryAllocateInfo sType(int value)
Sets the specified value to thesTypefield.
-
pNext
public VkMemoryAllocateInfo pNext(long value)
Sets the specified value to thepNextfield.
-
allocationSize
public VkMemoryAllocateInfo allocationSize(long value)
Sets the specified value to theallocationSizefield.
-
memoryTypeIndex
public VkMemoryAllocateInfo memoryTypeIndex(int value)
Sets the specified value to thememoryTypeIndexfield.
-
set
public VkMemoryAllocateInfo set(int sType, long pNext, long allocationSize, int memoryTypeIndex)
Initializes this struct with the specified values.
-
set
public VkMemoryAllocateInfo set(VkMemoryAllocateInfo src)
Copies the specified struct data to this struct.- Parameters:
src- the source struct- Returns:
- this struct
-
malloc
public static VkMemoryAllocateInfo malloc()
Returns a newVkMemoryAllocateInfoinstance allocated withmemAlloc. The instance must be explicitly freed.
-
calloc
public static VkMemoryAllocateInfo calloc()
Returns a newVkMemoryAllocateInfoinstance allocated withmemCalloc. The instance must be explicitly freed.
-
create
public static VkMemoryAllocateInfo create()
Returns a newVkMemoryAllocateInfoinstance allocated withBufferUtils.
-
create
public static VkMemoryAllocateInfo create(long address)
Returns a newVkMemoryAllocateInfoinstance for the specified memory address.
-
createSafe
@Nullable public static VkMemoryAllocateInfo createSafe(long address)
-
malloc
public static VkMemoryAllocateInfo.Buffer malloc(int capacity)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withmemAlloc. The instance must be explicitly freed.- Parameters:
capacity- the buffer capacity
-
calloc
public static VkMemoryAllocateInfo.Buffer calloc(int capacity)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withmemCalloc. The instance must be explicitly freed.- Parameters:
capacity- the buffer capacity
-
create
public static VkMemoryAllocateInfo.Buffer create(int capacity)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated withBufferUtils.- Parameters:
capacity- the buffer capacity
-
create
public static VkMemoryAllocateInfo.Buffer create(long address, int capacity)
Create aVkMemoryAllocateInfo.Bufferinstance at the specified memory.- Parameters:
address- the memory addresscapacity- the buffer capacity
-
createSafe
@Nullable public static VkMemoryAllocateInfo.Buffer createSafe(long address, int capacity)
-
mallocStack
public static VkMemoryAllocateInfo mallocStack()
Returns a newVkMemoryAllocateInfoinstance allocated on the thread-localMemoryStack.
-
callocStack
public static VkMemoryAllocateInfo callocStack()
Returns a newVkMemoryAllocateInfoinstance allocated on the thread-localMemoryStackand initializes all its bits to zero.
-
mallocStack
public static VkMemoryAllocateInfo mallocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVkMemoryAllocateInfoinstance allocated on the specifiedMemoryStack.- Parameters:
stack- the stack from which to allocate
-
callocStack
public static VkMemoryAllocateInfo callocStack(org.lwjgl.system.MemoryStack stack)
Returns a newVkMemoryAllocateInfoinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.- Parameters:
stack- the stack from which to allocate
-
mallocStack
public static VkMemoryAllocateInfo.Buffer mallocStack(int capacity)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the thread-localMemoryStack.- Parameters:
capacity- the buffer capacity
-
callocStack
public static VkMemoryAllocateInfo.Buffer callocStack(int capacity)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the thread-localMemoryStackand initializes all its bits to zero.- Parameters:
capacity- the buffer capacity
-
mallocStack
public static VkMemoryAllocateInfo.Buffer mallocStack(int capacity, org.lwjgl.system.MemoryStack stack)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the specifiedMemoryStack.- Parameters:
stack- the stack from which to allocatecapacity- the buffer capacity
-
callocStack
public static VkMemoryAllocateInfo.Buffer callocStack(int capacity, org.lwjgl.system.MemoryStack stack)
Returns a newVkMemoryAllocateInfo.Bufferinstance allocated on the specifiedMemoryStackand initializes all its bits to zero.- Parameters:
stack- the stack from which to allocatecapacity- the buffer capacity
-
nsType
public static int nsType(long struct)
Unsafe version ofsType().
-
npNext
public static long npNext(long struct)
Unsafe version ofpNext().
-
nallocationSize
public static long nallocationSize(long struct)
Unsafe version ofallocationSize().
-
nmemoryTypeIndex
public static int nmemoryTypeIndex(long struct)
Unsafe version ofmemoryTypeIndex().
-
nsType
public static void nsType(long struct, int value)Unsafe version ofsType.
-
npNext
public static void npNext(long struct, long value)Unsafe version ofpNext.
-
nallocationSize
public static void nallocationSize(long struct, long value)Unsafe version ofallocationSize.
-
nmemoryTypeIndex
public static void nmemoryTypeIndex(long struct, int value)Unsafe version ofmemoryTypeIndex.
-
-