Class VMA
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MethodHandle
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
final @Nullable MemorySegment
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
allocateMemory
(VmaAllocator allocator, IVkMemoryRequirements pVkMemoryRequirements, IVmaAllocationCreateInfo pCreateInfo, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) General purpose memory allocation.int
allocateMemoryForBuffer
(VmaAllocator allocator, VkBuffer buffer, IVmaAllocationCreateInfo pCreateInfo, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) Allocates memory suitable for givenVkBuffer
.int
allocateMemoryForImage
(VmaAllocator allocator, VkImage image, IVmaAllocationCreateInfo pCreateInfo, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) Allocates memory suitable for givenVkImage
.int
allocateMemoryPages
(VmaAllocator allocator, IVkMemoryRequirements pVkMemoryRequirements, IVmaAllocationCreateInfo pCreateInfo, long allocationCount, VmaAllocation.Ptr pAllocations, @Nullable IVmaAllocationInfo pAllocationInfo) General purpose memory allocation for multiple allocation objects at once.int
beginDefragmentation
(VmaAllocator allocator, IVmaDefragmentationInfo pInfo, VmaDefragmentationContext.Ptr pContext) Begins defragmentation process.int
beginDefragmentationPass
(VmaAllocator allocator, VmaDefragmentationContext context, IVmaDefragmentationPassMoveInfo pPassInfo) Starts single defragmentation pass.int
bindBufferMemory
(VmaAllocator allocator, VmaAllocation allocation, VkBuffer buffer) Binds buffer to allocation.int
bindBufferMemory2
(VmaAllocator allocator, VmaAllocation allocation, long allocationLocalOffset, VkBuffer buffer, MemorySegment pNext) Binds buffer to allocation with additional parameters.int
bindImageMemory
(VmaAllocator allocator, VmaAllocation allocation, VkImage image) Binds image to allocation.int
bindImageMemory2
(VmaAllocator allocator, VmaAllocation allocation, long allocationLocalOffset, VkImage image, MemorySegment pNext) Binds image to allocation with additional parameters.void
buildStatsString
(VmaAllocator allocator, PointerPtr ppStatsString, int detailedMap) Builds and returns statistics as a null-terminated string in JSON format.void
buildVirtualBlockStatsString
(VmaVirtualBlock virtualBlock, PointerPtr ppStatsString, int detailedMap) Builds and returns a null-terminated string in JSON format with information about givenVmaVirtualBlock
.void
calculatePoolStatistics
(VmaAllocator allocator, VmaPool pool, IVmaDetailedStatistics pPoolStats) Retrieves detailed statistics of existingVmaPool
object.void
calculateStatistics
(VmaAllocator allocator, IVmaTotalStatistics pStats) Retrieves statistics from current state of the Allocator.void
calculateVirtualBlockStatistics
(VmaVirtualBlock virtualBlock, IVmaDetailedStatistics pStats) Calculates and returns detailed statistics about virtual allocations and memory usage in givenVmaVirtualBlock
.int
checkCorruption
(VmaAllocator allocator, int memoryTypeBits) Checks magic number in margins around all allocations in given memory types (in both default and custom pools) in search for corruptions.int
checkPoolCorruption
(VmaAllocator allocator, VmaPool pool) Checks magic number in margins around all allocations in given memory pool in search for corruptions.void
clearVirtualBlock
(VmaVirtualBlock virtualBlock) Frees all virtual allocations inside givenVmaVirtualBlock
.int
copyAllocationToMemory
(VmaAllocator allocator, VmaAllocation srcAllocation, long srcAllocationLocalOffset, MemorySegment pDstHostPointer, long size) Invalidates memory in the host caches if needed, maps the allocation temporarily if needed, and copies data from it to a specified host pointer.int
copyMemoryToAllocation
(VmaAllocator allocator, MemorySegment pSrcHostPointer, VmaAllocation dstAllocation, long dstAllocationLocalOffset, long size) Maps the allocation temporarily if needed, copies data from specified host pointer to it, and flushes the memory from the host caches if needed.int
createAliasingBuffer
(VmaAllocator allocator, VmaAllocation allocation, IVkBufferCreateInfo pBufferCreateInfo, VkBuffer.Ptr pBuffer) Creates a newVkBuffer
, binds already created memory for it.int
createAliasingBuffer2
(VmaAllocator allocator, VmaAllocation allocation, long allocationLocalOffset, IVkBufferCreateInfo pBufferCreateInfo, VkBuffer.Ptr pBuffer) Creates a newVkBuffer
, binds already created memory for it.int
createAliasingImage
(VmaAllocator allocator, VmaAllocation allocation, IVkImageCreateInfo pImageCreateInfo, VkImage.Ptr pImage) Function similar to vmaCreateAliasingBuffer() but for images.int
createAliasingImage2
(VmaAllocator allocator, VmaAllocation allocation, long allocationLocalOffset, IVkImageCreateInfo pImageCreateInfo, VkImage.Ptr pImage) Function similar to vmaCreateAliasingBuffer2() but for images.int
createAllocator
(IVmaAllocatorCreateInfo pCreateInfo, VmaAllocator.Ptr pAllocator) CreatesVmaAllocator
object.int
createBuffer
(VmaAllocator allocator, IVkBufferCreateInfo pBufferCreateInfo, IVmaAllocationCreateInfo pAllocationCreateInfo, VkBuffer.Ptr pBuffer, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) Creates a newVkBuffer
, allocates and binds memory for it.int
createBufferWithAlignment
(VmaAllocator allocator, IVkBufferCreateInfo pBufferCreateInfo, IVmaAllocationCreateInfo pAllocationCreateInfo, long minAlignment, VkBuffer.Ptr pBuffer, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) Creates a buffer with additional minimum alignment.int
createImage
(VmaAllocator allocator, IVkImageCreateInfo pImageCreateInfo, IVmaAllocationCreateInfo pAllocationCreateInfo, VkImage.Ptr pImage, VmaAllocation.Ptr pAllocation, @Nullable IVmaAllocationInfo pAllocationInfo) Function similar to vmaCreateBuffer().int
createPool
(VmaAllocator allocator, IVmaPoolCreateInfo pCreateInfo, VmaPool.Ptr pPool) Allocates Vulkan device memory and createsVmaPool
object.int
createVirtualBlock
(IVmaVirtualBlockCreateInfo pCreateInfo, VmaVirtualBlock.Ptr pVirtualBlock) Creates newVmaVirtualBlock
object.void
destroyAllocator
(@Nullable VmaAllocator allocator) Destroys allocator object.void
destroyBuffer
(VmaAllocator allocator, @Nullable VkBuffer buffer, @Nullable VmaAllocation allocation) Destroys Vulkan buffer and frees allocated memory.void
destroyImage
(VmaAllocator allocator, @Nullable VkImage image, @Nullable VmaAllocation allocation) Destroys Vulkan image and frees allocated memory.void
destroyPool
(VmaAllocator allocator, @Nullable VmaPool pool) DestroysVmaPool
object and frees Vulkan device memory.void
destroyVirtualBlock
(@Nullable VmaVirtualBlock virtualBlock) DestroysVmaVirtualBlock
object.void
endDefragmentation
(VmaAllocator allocator, VmaDefragmentationContext context, @Nullable IVmaDefragmentationStats pStats) Ends defragmentation process.int
endDefragmentationPass
(VmaAllocator allocator, VmaDefragmentationContext context, IVmaDefragmentationPassMoveInfo pPassInfo) Ends single defragmentation pass.int
findMemoryTypeIndex
(VmaAllocator allocator, int memoryTypeBits, IVmaAllocationCreateInfo pAllocationCreateInfo, IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given memoryTypeBits and VmaAllocationCreateInfo.int
findMemoryTypeIndexForBufferInfo
(VmaAllocator allocator, IVkBufferCreateInfo pBufferCreateInfo, IVmaAllocationCreateInfo pAllocationCreateInfo, IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given VkBufferCreateInfo and VmaAllocationCreateInfo.int
findMemoryTypeIndexForImageInfo
(VmaAllocator allocator, IVkImageCreateInfo pImageCreateInfo, IVmaAllocationCreateInfo pAllocationCreateInfo, IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given VkImageCreateInfo and VmaAllocationCreateInfo.int
flushAllocation
(VmaAllocator allocator, VmaAllocation allocation, long offset, long size) Flushes memory of given allocation.int
flushAllocations
(VmaAllocator allocator, int allocationCount, VmaAllocation.Ptr allocations, @Nullable LongPtr offsets, @Nullable LongPtr sizes) Flushes memory of given set of allocations.void
freeMemory
(VmaAllocator allocator, @Nullable VmaAllocation allocation) Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage().void
freeMemoryPages
(VmaAllocator allocator, long allocationCount, VmaAllocation.Ptr pAllocations) Frees memory and destroys multiple allocations.void
freeStatsString
(VmaAllocator allocator, @Nullable BytePtr pStatsString) void
freeVirtualBlockStatsString
(VmaVirtualBlock virtualBlock, @Nullable BytePtr pStatsString) Frees a string returned by vmaBuildVirtualBlockStatsString().void
getAllocationInfo
(VmaAllocator allocator, VmaAllocation allocation, IVmaAllocationInfo pAllocationInfo) Returns current information about specified allocation.void
getAllocationInfo2
(VmaAllocator allocator, VmaAllocation allocation, IVmaAllocationInfo2 pAllocationInfo) Returns extended information about specified allocation.void
getAllocationMemoryProperties
(VmaAllocator allocator, VmaAllocation allocation, IntPtr pFlags) Given an allocation, returns Property Flags of its memory type.void
getAllocatorInfo
(VmaAllocator allocator, IVmaAllocatorInfo pAllocatorInfo) Returns information about existingVmaAllocator
object - handle to Vulkan device etc.void
getHeapBudgets
(VmaAllocator allocator, IVmaBudget pBudgets) Retrieves information about current memory usage and budget for all memory heaps.void
getMemoryProperties
(VmaAllocator allocator, PointerPtr ppPhysicalDeviceMemoryProperties) PhysicalDeviceMemoryProperties are fetched from physicalDevice by the allocator.void
getMemoryTypeProperties
(VmaAllocator allocator, int memoryTypeIndex, IntPtr pFlags) Given Memory Type Index, returns Property Flags of this memory type.int
getMemoryWin32Handle
(VmaAllocator allocator, VmaAllocation allocation, MemorySegment hTargetProcess, PointerPtr pHandle) Given an allocation, returns Win32 handle that may be imported by other processes or APIs.void
getPhysicalDeviceProperties
(VmaAllocator allocator, PointerPtr ppPhysicalDeviceProperties) PhysicalDeviceProperties are fetched from physicalDevice by the allocator.void
getPoolName
(VmaAllocator allocator, VmaPool pool, PointerPtr ppName) Retrieves name of a custom pool.void
getPoolStatistics
(VmaAllocator allocator, VmaPool pool, IVmaStatistics pPoolStats) Retrieves statistics of existingVmaPool
object.void
getVirtualAllocationInfo
(VmaVirtualBlock virtualBlock, VmaVirtualAllocation allocation, IVmaVirtualAllocationInfo pVirtualAllocInfo) Returns information about a specific virtual allocation within a virtual block, like its size andpUserData
pointer.void
getVirtualBlockStatistics
(VmaVirtualBlock virtualBlock, IVmaStatistics pStats) Calculates and returns statistics about virtual allocations and memory usage in givenVmaVirtualBlock
.int
invalidateAllocation
(VmaAllocator allocator, VmaAllocation allocation, long offset, long size) Invalidates memory of given allocation.int
invalidateAllocations
(VmaAllocator allocator, int allocationCount, VmaAllocation.Ptr allocations, @Nullable LongPtr offsets, @Nullable LongPtr sizes) Invalidates memory of given set of allocations.int
isVirtualBlockEmpty
(VmaVirtualBlock virtualBlock) Returns true of theVmaVirtualBlock
is empty - contains 0 virtual allocations and has all its space available for new allocations.int
mapMemory
(VmaAllocator allocator, VmaAllocation allocation, PointerPtr ppData) Maps memory represented by given allocation and returns pointer to it.void
setAllocationName
(VmaAllocator allocator, VmaAllocation allocation, @Nullable BytePtr pName) Sets pName in given allocation to new value.void
setAllocationUserData
(VmaAllocator allocator, VmaAllocation allocation, MemorySegment pUserData) Sets pUserData in given allocation to new value.void
setCurrentFrameIndex
(VmaAllocator allocator, int frameIndex) Sets index of the current frame.void
setPoolName
(VmaAllocator allocator, VmaPool pool, @Nullable BytePtr pName) Sets name of a custom pool.void
setVirtualAllocationUserData
(VmaVirtualBlock virtualBlock, VmaVirtualAllocation allocation, MemorySegment pUserData) Changes custom pointer associated with given virtual allocation.void
unmapMemory
(VmaAllocator allocator, VmaAllocation allocation) Unmaps memory represented by given allocation, mapped previously using vmaMapMemory().int
virtualAllocate
(VmaVirtualBlock virtualBlock, IVmaVirtualAllocationCreateInfo pCreateInfo, VmaVirtualAllocation.Ptr pAllocation, @Nullable LongPtr pOffset) Allocates new virtual allocation inside givenVmaVirtualBlock
.void
virtualFree
(VmaVirtualBlock virtualBlock, @Nullable VmaVirtualAllocation allocation) Frees virtual allocation inside givenVmaVirtualBlock
.
-
Field Details
-
SEGMENT$vmaCreateAllocator
-
SEGMENT$vmaDestroyAllocator
-
SEGMENT$vmaGetAllocatorInfo
-
SEGMENT$vmaGetPhysicalDeviceProperties
-
SEGMENT$vmaGetMemoryProperties
-
SEGMENT$vmaGetMemoryTypeProperties
-
SEGMENT$vmaSetCurrentFrameIndex
-
SEGMENT$vmaCalculateStatistics
-
SEGMENT$vmaGetHeapBudgets
-
SEGMENT$vmaFindMemoryTypeIndex
-
SEGMENT$vmaFindMemoryTypeIndexForBufferInfo
-
SEGMENT$vmaFindMemoryTypeIndexForImageInfo
-
SEGMENT$vmaCreatePool
-
SEGMENT$vmaDestroyPool
-
SEGMENT$vmaGetPoolStatistics
-
SEGMENT$vmaCalculatePoolStatistics
-
SEGMENT$vmaCheckPoolCorruption
-
SEGMENT$vmaGetPoolName
-
SEGMENT$vmaSetPoolName
-
SEGMENT$vmaAllocateMemory
-
SEGMENT$vmaAllocateMemoryPages
-
SEGMENT$vmaAllocateMemoryForBuffer
-
SEGMENT$vmaAllocateMemoryForImage
-
SEGMENT$vmaFreeMemory
-
SEGMENT$vmaFreeMemoryPages
-
SEGMENT$vmaGetAllocationInfo
-
SEGMENT$vmaGetAllocationInfo2
-
SEGMENT$vmaSetAllocationUserData
-
SEGMENT$vmaSetAllocationName
-
SEGMENT$vmaGetAllocationMemoryProperties
-
SEGMENT$vmaGetMemoryWin32Handle
-
SEGMENT$vmaMapMemory
-
SEGMENT$vmaUnmapMemory
-
SEGMENT$vmaFlushAllocation
-
SEGMENT$vmaInvalidateAllocation
-
SEGMENT$vmaFlushAllocations
-
SEGMENT$vmaInvalidateAllocations
-
SEGMENT$vmaCopyMemoryToAllocation
-
SEGMENT$vmaCopyAllocationToMemory
-
SEGMENT$vmaCheckCorruption
-
SEGMENT$vmaBeginDefragmentation
-
SEGMENT$vmaEndDefragmentation
-
SEGMENT$vmaBeginDefragmentationPass
-
SEGMENT$vmaEndDefragmentationPass
-
SEGMENT$vmaBindBufferMemory
-
SEGMENT$vmaBindBufferMemory2
-
SEGMENT$vmaBindImageMemory
-
SEGMENT$vmaBindImageMemory2
-
SEGMENT$vmaCreateBuffer
-
SEGMENT$vmaCreateBufferWithAlignment
-
SEGMENT$vmaCreateAliasingBuffer
-
SEGMENT$vmaCreateAliasingBuffer2
-
SEGMENT$vmaDestroyBuffer
-
SEGMENT$vmaCreateImage
-
SEGMENT$vmaCreateAliasingImage
-
SEGMENT$vmaCreateAliasingImage2
-
SEGMENT$vmaDestroyImage
-
SEGMENT$vmaCreateVirtualBlock
-
SEGMENT$vmaDestroyVirtualBlock
-
SEGMENT$vmaIsVirtualBlockEmpty
-
SEGMENT$vmaGetVirtualAllocationInfo
-
SEGMENT$vmaVirtualAllocate
-
SEGMENT$vmaVirtualFree
-
SEGMENT$vmaClearVirtualBlock
-
SEGMENT$vmaSetVirtualAllocationUserData
-
SEGMENT$vmaGetVirtualBlockStatistics
-
SEGMENT$vmaCalculateVirtualBlockStatistics
-
SEGMENT$vmaBuildVirtualBlockStatsString
-
SEGMENT$vmaFreeVirtualBlockStatsString
-
SEGMENT$vmaBuildStatsString
-
SEGMENT$vmaFreeStatsString
-
HANDLE$vmaCreateAllocator
-
HANDLE$vmaDestroyAllocator
-
HANDLE$vmaGetAllocatorInfo
-
HANDLE$vmaGetPhysicalDeviceProperties
-
HANDLE$vmaGetMemoryProperties
-
HANDLE$vmaGetMemoryTypeProperties
-
HANDLE$vmaSetCurrentFrameIndex
-
HANDLE$vmaCalculateStatistics
-
HANDLE$vmaGetHeapBudgets
-
HANDLE$vmaFindMemoryTypeIndex
-
HANDLE$vmaFindMemoryTypeIndexForBufferInfo
-
HANDLE$vmaFindMemoryTypeIndexForImageInfo
-
HANDLE$vmaCreatePool
-
HANDLE$vmaDestroyPool
-
HANDLE$vmaGetPoolStatistics
-
HANDLE$vmaCalculatePoolStatistics
-
HANDLE$vmaCheckPoolCorruption
-
HANDLE$vmaGetPoolName
-
HANDLE$vmaSetPoolName
-
HANDLE$vmaAllocateMemory
-
HANDLE$vmaAllocateMemoryPages
-
HANDLE$vmaAllocateMemoryForBuffer
-
HANDLE$vmaAllocateMemoryForImage
-
HANDLE$vmaFreeMemory
-
HANDLE$vmaFreeMemoryPages
-
HANDLE$vmaGetAllocationInfo
-
HANDLE$vmaGetAllocationInfo2
-
HANDLE$vmaSetAllocationUserData
-
HANDLE$vmaSetAllocationName
-
HANDLE$vmaGetAllocationMemoryProperties
-
HANDLE$vmaGetMemoryWin32Handle
-
HANDLE$vmaMapMemory
-
HANDLE$vmaUnmapMemory
-
HANDLE$vmaFlushAllocation
-
HANDLE$vmaInvalidateAllocation
-
HANDLE$vmaFlushAllocations
-
HANDLE$vmaInvalidateAllocations
-
HANDLE$vmaCopyMemoryToAllocation
-
HANDLE$vmaCopyAllocationToMemory
-
HANDLE$vmaCheckCorruption
-
HANDLE$vmaBeginDefragmentation
-
HANDLE$vmaEndDefragmentation
-
HANDLE$vmaBeginDefragmentationPass
-
HANDLE$vmaEndDefragmentationPass
-
HANDLE$vmaBindBufferMemory
-
HANDLE$vmaBindBufferMemory2
-
HANDLE$vmaBindImageMemory
-
HANDLE$vmaBindImageMemory2
-
HANDLE$vmaCreateBuffer
-
HANDLE$vmaCreateBufferWithAlignment
-
HANDLE$vmaCreateAliasingBuffer
-
HANDLE$vmaCreateAliasingBuffer2
-
HANDLE$vmaDestroyBuffer
-
HANDLE$vmaCreateImage
-
HANDLE$vmaCreateAliasingImage
-
HANDLE$vmaCreateAliasingImage2
-
HANDLE$vmaDestroyImage
-
HANDLE$vmaCreateVirtualBlock
-
HANDLE$vmaDestroyVirtualBlock
-
HANDLE$vmaIsVirtualBlockEmpty
-
HANDLE$vmaGetVirtualAllocationInfo
-
HANDLE$vmaVirtualAllocate
-
HANDLE$vmaVirtualFree
-
HANDLE$vmaClearVirtualBlock
-
HANDLE$vmaSetVirtualAllocationUserData
-
HANDLE$vmaGetVirtualBlockStatistics
-
HANDLE$vmaCalculateVirtualBlockStatistics
-
HANDLE$vmaBuildVirtualBlockStatsString
-
HANDLE$vmaFreeVirtualBlockStatsString
-
HANDLE$vmaBuildStatsString
-
HANDLE$vmaFreeStatsString
-
-
Constructor Details
-
VMA
-
-
Method Details
-
createAllocator
@EnumType(VkResult.class) public int createAllocator(@Pointer IVmaAllocatorCreateInfo pCreateInfo, @Pointer VmaAllocator.Ptr pAllocator) CreatesVmaAllocator
object. -
destroyAllocator
Destroys allocator object. -
getAllocatorInfo
Returns information about existing
VmaAllocator
object - handle to Vulkan device etc.It might be useful if you want to keep just the
VmaAllocator
handle and fetch other required handles toVkPhysicalDevice
,VkDevice
etc. every time using this function. -
getPhysicalDeviceProperties
public void getPhysicalDeviceProperties(VmaAllocator allocator, PointerPtr ppPhysicalDeviceProperties) PhysicalDeviceProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own. -
getMemoryProperties
public void getMemoryProperties(VmaAllocator allocator, PointerPtr ppPhysicalDeviceMemoryProperties) PhysicalDeviceMemoryProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own. -
getMemoryTypeProperties
public void getMemoryTypeProperties(VmaAllocator allocator, @Unsigned int memoryTypeIndex, @EnumType(VkMemoryPropertyFlags.class) IntPtr pFlags) Given Memory Type Index, returns Property Flags of this memory type.
This is just a convenience function. Same information can be obtained using vmaGetMemoryProperties().
-
setCurrentFrameIndex
Sets index of the current frame. -
calculateStatistics
Retrieves statistics from current state of the Allocator.
This function is called "calculate" not "get" because it has to traverse all internal data structures, so it may be quite slow. Use it for debugging purposes. For faster but more brief statistics suitable to be called every frame or every allocation, use vmaGetHeapBudgets().
Note that when using allocator from multiple threads, returned information may immediately become outdated.
-
getHeapBudgets
Retrieves information about current memory usage and budget for all memory heaps.
This function is called "get" not "calculate" because it is very fast, suitable to be called every frame or every allocation. For more detailed statistics use vmaCalculateStatistics().
Note that when using allocator from multiple threads, returned information may immediately become outdated.
- Parameters:
allocator
-pBudgets
- Must point to array with number of elements at least equal to number of memory heaps in physical device used.
-
findMemoryTypeIndex
@EnumType(VkResult.class) public int findMemoryTypeIndex(VmaAllocator allocator, @Unsigned int memoryTypeBits, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @Unsigned IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given memoryTypeBits and VmaAllocationCreateInfo.
This algorithm tries to find a memory type that:
- Is allowed by memoryTypeBits.
- Contains all the flags from pAllocationCreateInfo->requiredFlags.
- Matches intended usage.
- Has as many flags from pAllocationCreateInfo->preferredFlags as possible.
from this function or any other allocating function probably means that your device doesn't support any memory type with requested features for the specific type of resource you want to use it for. Please check parameters of your resource, like image layout (OPTIMAL versus LINEAR) or mip level count.
- Returns:
- Returns VK_ERROR_FEATURE_NOT_PRESENT if not found. Receiving such result
-
findMemoryTypeIndexForBufferInfo
@EnumType(VkResult.class) public int findMemoryTypeIndexForBufferInfo(VmaAllocator allocator, @Pointer IVkBufferCreateInfo pBufferCreateInfo, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @Unsigned IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given VkBufferCreateInfo and VmaAllocationCreateInfo.
It can be useful e.g. to determine value to be used as VmaPoolCreateInfo::memoryTypeIndex. It internally creates a temporary, dummy buffer that never has memory bound.
-
findMemoryTypeIndexForImageInfo
@EnumType(VkResult.class) public int findMemoryTypeIndexForImageInfo(VmaAllocator allocator, @Pointer IVkImageCreateInfo pImageCreateInfo, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @Unsigned IntPtr pMemoryTypeIndex) Helps to find memoryTypeIndex, given VkImageCreateInfo and VmaAllocationCreateInfo.
It can be useful e.g. to determine value to be used as VmaPoolCreateInfo::memoryTypeIndex. It internally creates a temporary, dummy image that never has memory bound.
-
createPool
@EnumType(VkResult.class) public int createPool(VmaAllocator allocator, @Pointer IVmaPoolCreateInfo pCreateInfo, @Pointer VmaPool.Ptr pPool) Allocates Vulkan device memory and createsVmaPool
object.- Parameters:
allocator
- Allocator object.pCreateInfo
- Parameters of pool to create.pPool
- Handle to created pool.
-
destroyPool
DestroysVmaPool
object and frees Vulkan device memory. -
getPoolStatistics
public void getPoolStatistics(VmaAllocator allocator, VmaPool pool, @Pointer IVmaStatistics pPoolStats) Retrieves statistics of existing
VmaPool
object.Note that when using the pool from multiple threads, returned information may immediately become outdated.
- Parameters:
allocator
- Allocator object.pool
- Pool object.pPoolStats
- Statistics of specified pool.
-
calculatePoolStatistics
public void calculatePoolStatistics(VmaAllocator allocator, VmaPool pool, @Pointer IVmaDetailedStatistics pPoolStats) Retrieves detailed statistics of existingVmaPool
object.- Parameters:
allocator
- Allocator object.pool
- Pool object.pPoolStats
- Statistics of specified pool.
-
checkPoolCorruption
Checks magic number in margins around all allocations in given memory pool in search for corruptions.
Corruption detection is enabled only when
VMA_DEBUG_DETECT_CORRUPTION
macro is defined to nonzero,VMA_DEBUG_MARGIN
is defined to nonzero and the pool is created in memory type that isHOST_VISIBLE
andHOST_COHERENT
. For more information, see [Corruption detection](@ref debugging_memory_usage_corruption_detection).Possible return values:
VK_ERROR_FEATURE_NOT_PRESENT
- corruption detection is not enabled for specified pool.VK_SUCCESS
- corruption detection has been performed and succeeded.VK_ERROR_UNKNOWN
- corruption detection has been performed and found memory corruptions around one of the allocations.VMA_ASSERT
is also fired in that case.- Other value: Error returned by Vulkan, e.g. memory mapping failure.
-
getPoolName
Retrieves name of a custom pool.
After the call
ppName
is either null or points to an internally-owned null-terminated string containing name of the pool that was previously set. The pointer becomes invalid when the pool is destroyed or its name is changed using vmaSetPoolName(). -
setPoolName
Sets name of a custom pool.
pName
can be either null or pointer to a null-terminated string with new name for the pool. Function makes internal copy of the string, so it can be changed or freed immediately after this call. -
allocateMemory
@EnumType(VkResult.class) public int allocateMemory(VmaAllocator allocator, @Pointer IVkMemoryRequirements pVkMemoryRequirements, @Pointer IVmaAllocationCreateInfo pCreateInfo, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) General purpose memory allocation.
You should free the memory using vmaFreeMemory() or vmaFreeMemoryPages().
It is recommended to use vmaAllocateMemoryForBuffer(), vmaAllocateMemoryForImage(), vmaCreateBuffer(), vmaCreateImage() instead whenever possible.
- Parameters:
allocator
-pVkMemoryRequirements
-pCreateInfo
-pAllocation
- Handle to allocated memory.pAllocationInfo
- Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo().
-
allocateMemoryPages
@EnumType(VkResult.class) public int allocateMemoryPages(VmaAllocator allocator, @Pointer IVkMemoryRequirements pVkMemoryRequirements, @Pointer IVmaAllocationCreateInfo pCreateInfo, long allocationCount, @Pointer VmaAllocation.Ptr pAllocations, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) General purpose memory allocation for multiple allocation objects at once.
You should free the memory using vmaFreeMemory() or vmaFreeMemoryPages().
Word "pages" is just a suggestion to use this function to allocate pieces of memory needed for sparse binding. It is just a general purpose allocation function able to make multiple allocations at once. It may be internally optimized to be more efficient than calling vmaAllocateMemory()
allocationCount
times.All allocations are made using same parameters. All of them are created out of the same memory pool and type. If any allocation fails, all allocations already made within this function call are also freed, so that when returned result is not
VK_SUCCESS
,pAllocation
array is always entirely filled withVK_NULL_HANDLE
.- Parameters:
allocator
- Allocator object.pVkMemoryRequirements
- Memory requirements for each allocation.pCreateInfo
- Creation parameters for each allocation.allocationCount
- Number of allocations to make.pAllocations
- Pointer to array that will be filled with handles to created allocations.pAllocationInfo
- Optional. Pointer to array that will be filled with parameters of created allocations.
-
allocateMemoryForBuffer
@EnumType(VkResult.class) public int allocateMemoryForBuffer(VmaAllocator allocator, VkBuffer buffer, @Pointer IVmaAllocationCreateInfo pCreateInfo, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) Allocates memory suitable for given
VkBuffer
.It only creates
VmaAllocation
. To bind the memory to the buffer, use vmaBindBufferMemory().This is a special-purpose function. In most cases you should use vmaCreateBuffer().
You must free the allocation using vmaFreeMemory() when no longer needed.
- Parameters:
allocator
-buffer
-pCreateInfo
-pAllocation
- Handle to allocated memory.pAllocationInfo
- Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo().
-
allocateMemoryForImage
@EnumType(VkResult.class) public int allocateMemoryForImage(VmaAllocator allocator, VkImage image, @Pointer IVmaAllocationCreateInfo pCreateInfo, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) Allocates memory suitable for given
VkImage
.It only creates
VmaAllocation
. To bind the memory to the buffer, use vmaBindImageMemory().This is a special-purpose function. In most cases you should use vmaCreateImage().
You must free the allocation using vmaFreeMemory() when no longer needed.
- Parameters:
allocator
-image
-pCreateInfo
-pAllocation
- Handle to allocated memory.pAllocationInfo
- Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo().
-
freeMemory
Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage().
Passing
VK_NULL_HANDLE
asallocation
is valid. Such function call is just skipped. -
freeMemoryPages
public void freeMemoryPages(VmaAllocator allocator, long allocationCount, @Pointer VmaAllocation.Ptr pAllocations) Frees memory and destroys multiple allocations.
Word "pages" is just a suggestion to use this function to free pieces of memory used for sparse binding. It is just a general purpose function to free memory and destroy allocations made using e.g. vmaAllocateMemory(), vmaAllocateMemoryPages() and other functions. It may be internally optimized to be more efficient than calling vmaFreeMemory()
allocationCount
times.Allocations in
pAllocations
array can come from any memory pools and types. PassingVK_NULL_HANDLE
as elements ofpAllocations
array is valid. Such entries are just skipped. -
getAllocationInfo
public void getAllocationInfo(VmaAllocator allocator, VmaAllocation allocation, @Pointer IVmaAllocationInfo pAllocationInfo) Returns current information about specified allocation.
Current parameters of given allocation are returned in
pAllocationInfo
.Although this function doesn't lock any mutex, so it should be quite efficient, you should avoid calling it too often. You can retrieve same VmaAllocationInfo structure while creating your resource, from function vmaCreateBuffer(), vmaCreateImage(). You can remember it if you are sure parameters don't change (e.g. due to defragmentation).
There is also a new function vmaGetAllocationInfo2() that offers extended information about the allocation, returned using new structure
VmaAllocationInfo2
. -
getAllocationInfo2
public void getAllocationInfo2(VmaAllocator allocator, VmaAllocation allocation, @Pointer IVmaAllocationInfo2 pAllocationInfo) Returns extended information about specified allocation.
Current parameters of given allocation are returned in
pAllocationInfo
. Extended parameters in structureVmaAllocationInfo2
include memory block size and a flag telling whether the allocation has dedicated memory. It can be useful e.g. for interop with OpenGL. -
setAllocationUserData
public void setAllocationUserData(VmaAllocator allocator, VmaAllocation allocation, @Pointer(comment="void*") MemorySegment pUserData) Sets pUserData in given allocation to new value.
The value of pointer
pUserData
is copied to allocation'spUserData
. It is opaque, so you can use it however you want - e.g. as a pointer, ordinal number or some handle to you own data. -
setAllocationName
public void setAllocationName(VmaAllocator allocator, VmaAllocation allocation, @Nullable @Nullable BytePtr pName) Sets pName in given allocation to new value.
pName
must be either null, or pointer to a null-terminated string. The function makes local copy of the string and sets it as allocation'spName
. String passed as pName doesn't need to be valid for whole lifetime of the allocation - you can free it after this call. String previously pointed by allocation'spName
is freed from memory. -
getAllocationMemoryProperties
public void getAllocationMemoryProperties(VmaAllocator allocator, VmaAllocation allocation, @EnumType(VkMemoryPropertyFlags.class) IntPtr pFlags) Given an allocation, returns Property Flags of its memory type.
This is just a convenience function. Same information can be obtained using vmaGetAllocationInfo() + vmaGetMemoryProperties().
-
getMemoryWin32Handle
@EnumType(VkResult.class) public int getMemoryWin32Handle(VmaAllocator allocator, VmaAllocation allocation, @Pointer(comment="HANDLE") MemorySegment hTargetProcess, PointerPtr pHandle) Given an allocation, returns Win32 handle that may be imported by other processes or APIs.
handle for the current process.
The function fills
pHandle
with handle that can be used in target process. The handle is fetched using functionvkGetMemoryWin32HandleKHR
. When no longer needed, you must close it using:CloseHandle(handle);
You can close it any time, before or after destroying the allocation object. It is reference-counted internally by Windows.
Note the handle is returned for the entire
VkDeviceMemory
block that the allocation belongs to. If the allocation is sub-allocated from a larger block, you may need to consider the offset of the allocation (VmaAllocationInfo::offset).If the function fails with
VK_ERROR_FEATURE_NOT_PRESENT
error code, please double-check that VmaVulkanFunctions::vkGetMemoryWin32HandleKHR function pointer is set, e.g. either by usingVMA_DYNAMIC_VULKAN_FUNCTIONS
or by manually passing it through VmaAllocatorCreateInfo::pVulkanFunctions.For more information, see chapter vk_khr_external_memory_win32.
- Parameters:
hTargetProcess
- Must be a valid handle to target process or null. If it's null, the function returnspHandle
- Output parameter that returns the handle.
-
mapMemory
@EnumType(VkResult.class) public int mapMemory(VmaAllocator allocator, VmaAllocation allocation, PointerPtr ppData) Maps memory represented by given allocation and returns pointer to it.
Maps memory represented by given allocation to make it accessible to CPU code. When succeeded,
*ppData
contains pointer to first byte of this memory.Warning: If the allocation is part of a bigger
VkDeviceMemory
block, returned pointer is correctly offsetted to the beginning of region assigned to this particular allocation. Unlike the result ofvkMapMemory
, it points to the allocation, not to the beginning of the whole block. You should not add VmaAllocationInfo::offset to it!Mapping is internally reference-counted and synchronized, so despite raw Vulkan function
vkMapMemory()
cannot be used to map same block ofVkDeviceMemory
multiple times simultaneously, it is safe to call this function on allocations assigned to the same memory block. Actual Vulkan memory will be mapped on first mapping and unmapped on last unmapping.If the function succeeded, you must call vmaUnmapMemory() to unmap the allocation when mapping is no longer needed or before freeing the allocation, at the latest.
It also safe to call this function multiple times on the same allocation. You must call vmaUnmapMemory() same number of times as you called vmaMapMemory().
It is also safe to call this function on allocation created with
VMA_ALLOCATION_CREATE_MAPPED_BIT
flag. Its memory stays mapped all the time. You must still call vmaUnmapMemory() same number of times as you called vmaMapMemory(). You must not call vmaUnmapMemory() additional time to free the "0-th" mapping made automatically due toVMA_ALLOCATION_CREATE_MAPPED_BIT
flag.This function fails when used on allocation made in memory type that is not
HOST_VISIBLE
.This function doesn't automatically flush or invalidate caches. If the allocation is made from a memory types that is not
HOST_COHERENT
, you also need to use vmaInvalidateAllocation() / vmaFlushAllocation(), as required by Vulkan specification. -
unmapMemory
Unmaps memory represented by given allocation, mapped previously using vmaMapMemory().
For details, see description of vmaMapMemory().
This function doesn't automatically flush or invalidate caches. If the allocation is made from a memory types that is not
HOST_COHERENT
, you also need to use vmaInvalidateAllocation() / vmaFlushAllocation(), as required by Vulkan specification. -
flushAllocation
@EnumType(VkResult.class) public int flushAllocation(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long offset, @NativeType("VkDeviceSize") @Unsigned long size) Flushes memory of given allocation.
Calls
vkFlushMappedMemoryRanges()
for memory associated with given range of given allocation. It needs to be called after writing to a mapped memory for memory types that are notHOST_COHERENT
. Unmap operation doesn't do that automatically.offset
must be relative to the beginning of allocation.size
can beVK_WHOLE_SIZE
. It means all memory fromoffset
the the end of given allocation.offset
andsize
don't have to be aligned. They are internally rounded down/up to multiply ofnonCoherentAtomSize
.- If
size
is 0, this call is ignored. - If memory type that the
allocation
belongs to is notHOST_VISIBLE
or it isHOST_COHERENT
, this call is ignored.
Warning!
offset
andsize
are relative to the contents of givenallocation
. If you mean whole allocation, you can pass 0 andVK_WHOLE_SIZE
, respectively. Do not pass allocation's offset asoffset
!!!This function returns the
VkResult
fromvkFlushMappedMemoryRanges
if it is called, otherwiseVK_SUCCESS
. -
invalidateAllocation
@EnumType(VkResult.class) public int invalidateAllocation(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long offset, @NativeType("VkDeviceSize") @Unsigned long size) Invalidates memory of given allocation.
Calls
vkInvalidateMappedMemoryRanges()
for memory associated with given range of given allocation. It needs to be called before reading from a mapped memory for memory types that are notHOST_COHERENT
. Map operation doesn't do that automatically.offset
must be relative to the beginning of allocation.size
can beVK_WHOLE_SIZE
. It means all memory fromoffset
the the end of given allocation.offset
andsize
don't have to be aligned. They are internally rounded down/up to multiply ofnonCoherentAtomSize
.- If
size
is 0, this call is ignored. - If memory type that the
allocation
belongs to is notHOST_VISIBLE
or it isHOST_COHERENT
, this call is ignored.
Warning!
offset
andsize
are relative to the contents of givenallocation
. If you mean whole allocation, you can pass 0 andVK_WHOLE_SIZE
, respectively. Do not pass allocation's offset asoffset
!!!This function returns the
VkResult
fromvkInvalidateMappedMemoryRanges
if it is called, otherwiseVK_SUCCESS
. -
flushAllocations
@EnumType(VkResult.class) public int flushAllocations(VmaAllocator allocator, @Unsigned int allocationCount, @Nullable @Pointer VmaAllocation.Ptr allocations, @Nullable @Pointer(comment="VkDeviceSize") @Unsigned @Nullable LongPtr offsets, @Nullable @Pointer(comment="VkDeviceSize") @Unsigned @Nullable LongPtr sizes) Flushes memory of given set of allocations.
Calls
vkFlushMappedMemoryRanges()
for memory associated with given ranges of given allocations. For more information, see documentation of vmaFlushAllocation().This function returns the
VkResult
fromvkFlushMappedMemoryRanges
if it is called, otherwiseVK_SUCCESS
.- Parameters:
allocator
-allocationCount
-allocations
-offsets
- If not null, it must point to an array of offsets of regions to flush, relative to the beginning of respective allocations. Null means all offsets are zero.sizes
- If not null, it must point to an array of sizes of regions to flush in respective allocations. Null meansVK_WHOLE_SIZE
for all allocations.
-
invalidateAllocations
@EnumType(VkResult.class) public int invalidateAllocations(VmaAllocator allocator, @Unsigned int allocationCount, @Nullable @Pointer VmaAllocation.Ptr allocations, @Nullable @Pointer(comment="VkDeviceSize") @Unsigned @Nullable LongPtr offsets, @Nullable @Pointer(comment="VkDeviceSize") @Unsigned @Nullable LongPtr sizes) Invalidates memory of given set of allocations.
Calls
vkInvalidateMappedMemoryRanges()
for memory associated with given ranges of given allocations. For more information, see documentation of vmaInvalidateAllocation().This function returns the
VkResult
fromvkInvalidateMappedMemoryRanges
if it is called, otherwiseVK_SUCCESS
.- Parameters:
allocator
-allocationCount
-allocations
-offsets
- If not null, it must point to an array of offsets of regions to flush, relative to the beginning of respective allocations. Null means all offsets are zero.sizes
- If not null, it must point to an array of sizes of regions to flush in respective allocations. Null meansVK_WHOLE_SIZE
for all allocations.
-
copyMemoryToAllocation
@EnumType(VkResult.class) public int copyMemoryToAllocation(VmaAllocator allocator, @Pointer(comment="void*") MemorySegment pSrcHostPointer, VmaAllocation dstAllocation, @NativeType("VkDeviceSize") @Unsigned long dstAllocationLocalOffset, @NativeType("VkDeviceSize") @Unsigned long size) Maps the allocation temporarily if needed, copies data from specified host pointer to it, and flushes the memory from the host caches if needed.
This is a convenience function that allows to copy data from a host pointer to an allocation easily. Same behavior can be achieved by calling vmaMapMemory(),
memcpy()
, vmaUnmapMemory(), vmaFlushAllocation().This function can be called only for allocations created in a memory type that has
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
flag. It can be ensured e.g. by usingVMA_MEMORY_USAGE_AUTO
andVMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT
orVMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT
. Otherwise, the function will fail and generate a Validation Layers error.dstAllocationLocalOffset
is relative to the contents of givendstAllocation
. If you mean whole allocation, you should pass 0. Do not pass allocation's offset within device memory block this parameter!- Parameters:
allocator
-pSrcHostPointer
- Pointer to the host data that become source of the copy.dstAllocation
- Handle to the allocation that becomes destination of the copy.dstAllocationLocalOffset
- Offset withindstAllocation
where to write copied data, in bytes.size
- Number of bytes to copy.
-
copyAllocationToMemory
@EnumType(VkResult.class) public int copyAllocationToMemory(VmaAllocator allocator, VmaAllocation srcAllocation, @NativeType("VkDeviceSize") @Unsigned long srcAllocationLocalOffset, @Pointer(comment="void*") MemorySegment pDstHostPointer, @NativeType("VkDeviceSize") @Unsigned long size) Invalidates memory in the host caches if needed, maps the allocation temporarily if needed, and copies data from it to a specified host pointer.
This is a convenience function that allows to copy data from an allocation to a host pointer easily. Same behavior can be achieved by calling vmaInvalidateAllocation(), vmaMapMemory(),
memcpy()
, vmaUnmapMemory().This function should be called only for allocations created in a memory type that has
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
andVK_MEMORY_PROPERTY_HOST_CACHED_BIT
flag. It can be ensured e.g. by usingVMA_MEMORY_USAGE_AUTO
andVMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT
. Otherwise, the function may fail and generate a Validation Layers error. It may also work very slowly when reading from an uncached memory.srcAllocationLocalOffset
is relative to the contents of givensrcAllocation
. If you mean whole allocation, you should pass 0. Do not pass allocation's offset within device memory block as this parameter!- Parameters:
allocator
-srcAllocation
- Handle to the allocation that becomes source of the copy.srcAllocationLocalOffset
- Offset withinsrcAllocation
where to read copied data, in bytes.pDstHostPointer
- Pointer to the host memory that become destination of the copy.size
- Number of bytes to copy.
-
checkCorruption
@EnumType(VkResult.class) public int checkCorruption(VmaAllocator allocator, @Unsigned int memoryTypeBits) Checks magic number in margins around all allocations in given memory types (in both default and custom pools) in search for corruptions.
Corruption detection is enabled only when
VMA_DEBUG_DETECT_CORRUPTION
macro is defined to nonzero,VMA_DEBUG_MARGIN
is defined to nonzero and only for memory types that areHOST_VISIBLE
andHOST_COHERENT
. For more information, see [Corruption detection](@ref debugging_memory_usage_corruption_detection).Possible return values:
VK_ERROR_FEATURE_NOT_PRESENT
- corruption detection is not enabled for any of specified memory types.VK_SUCCESS
- corruption detection has been performed and succeeded.VK_ERROR_UNKNOWN
- corruption detection has been performed and found memory corruptions around one of the allocations.VMA_ASSERT
is also fired in that case.- Other value: Error returned by Vulkan, e.g. memory mapping failure.
- Parameters:
allocator
-memoryTypeBits
- Bit mask, where each bit set means that a memory type with that index should be checked.
-
beginDefragmentation
@EnumType(VkResult.class) public int beginDefragmentation(VmaAllocator allocator, @Pointer IVmaDefragmentationInfo pInfo, @Pointer VmaDefragmentationContext.Ptr pContext) Begins defragmentation process.
For more information about defragmentation, see documentation chapter:
invalid reference
Defragmentation
- Parameters:
allocator
- Allocator object.pInfo
- Structure filled with parameters of defragmentation.pContext
- Context object that must be passed to vmaEndDefragmentation() to finish defragmentation.- Returns:
- `VK_SUCCESS` if defragmentation can begin.
- `VK_ERROR_FEATURE_NOT_PRESENT` if defragmentation is not supported.
-
endDefragmentation
public void endDefragmentation(VmaAllocator allocator, VmaDefragmentationContext context, @Nullable @Pointer @Nullable IVmaDefragmentationStats pStats) Ends defragmentation process.
Use this function to finish defragmentation started by vmaBeginDefragmentation().
- Parameters:
allocator
- Allocator object.context
- Context object that has been created by vmaBeginDefragmentation().pStats
- Optional stats for the defragmentation. Can be null.
-
beginDefragmentationPass
@EnumType(VkResult.class) public int beginDefragmentationPass(VmaAllocator allocator, VmaDefragmentationContext context, @Pointer IVmaDefragmentationPassMoveInfo pPassInfo) Starts single defragmentation pass.- Parameters:
allocator
- Allocator object.context
- Context object that has been created by vmaBeginDefragmentation().pPassInfo
- Computed information for current pass.- Returns:
- `VK_SUCCESS` if no more moves are possible. Then you can omit call to vmaEndDefragmentationPass() and simply end whole defragmentation.
- `VK_INCOMPLETE` if there are pending moves returned in `pPassInfo`. You need to perform them, call vmaEndDefragmentationPass(),
-
endDefragmentationPass
@EnumType(VkResult.class) public int endDefragmentationPass(VmaAllocator allocator, VmaDefragmentationContext context, @Pointer IVmaDefragmentationPassMoveInfo pPassInfo) Ends single defragmentation pass.
Returns
VK_SUCCESS
if no more moves are possible orVK_INCOMPLETE
if more defragmentations are possible.Ends incremental defragmentation pass and commits all defragmentation moves from
pPassInfo
. After this call:- Allocations at
pPassInfo[i].srcAllocation
that hadpPassInfo[i].operation ==
VMA_DEFRAGMENTATION_MOVE_OPERATION_COPY
(which is the default) will be pointing to the new destination place. - Allocation at
pPassInfo[i].srcAllocation
that hadpPassInfo[i].operation ==
VMA_DEFRAGMENTATION_MOVE_OPERATION_DESTROY
will be freed.
If no more moves are possible you can end whole defragmentation.
- Parameters:
allocator
- Allocator object.context
- Context object that has been created by vmaBeginDefragmentation().pPassInfo
- Computed information for current pass filled by vmaBeginDefragmentationPass() and possibly modified by you.
- Allocations at
-
bindBufferMemory
@EnumType(VkResult.class) public int bindBufferMemory(VmaAllocator allocator, VmaAllocation allocation, VkBuffer buffer) Binds buffer to allocation.
Binds specified buffer to region of memory represented by specified allocation. Gets
VkDeviceMemory
handle and offset from the allocation. If you want to create a buffer, allocate memory for it and bind them together separately, you should use this function for binding instead of standardvkBindBufferMemory()
, because it ensures proper synchronization so that when aVkDeviceMemory
object is used by multiple allocations, calls tovkBind*Memory()
orvkMapMemory()
won't happen from multiple threads simultaneously (which is illegal in Vulkan).It is recommended to use function vmaCreateBuffer() instead of this one.
-
bindBufferMemory2
@EnumType(VkResult.class) public int bindBufferMemory2(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long allocationLocalOffset, VkBuffer buffer, @Pointer(comment="void*") MemorySegment pNext) Binds buffer to allocation with additional parameters.
This function is similar to vmaBindBufferMemory(), but it provides additional parameters.
If
pNext
is not null,VmaAllocator
object must have been created withVMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT
flag or with VmaAllocatorCreateInfo::vulkanApiVersion>= VK_API_VERSION_1_1
. Otherwise the call fails.- Parameters:
allocator
-allocation
-allocationLocalOffset
- Additional offset to be added while binding, relative to the beginning of theallocation
. Normally it should be 0.buffer
-pNext
- A chain of structures to be attached toVkBindBufferMemoryInfoKHR
structure used internally. Normally it should be null.
-
bindImageMemory
@EnumType(VkResult.class) public int bindImageMemory(VmaAllocator allocator, VmaAllocation allocation, VkImage image) Binds image to allocation.
Binds specified image to region of memory represented by specified allocation. Gets
VkDeviceMemory
handle and offset from the allocation. If you want to create an image, allocate memory for it and bind them together separately, you should use this function for binding instead of standardvkBindImageMemory()
, because it ensures proper synchronization so that when aVkDeviceMemory
object is used by multiple allocations, calls tovkBind*Memory()
orvkMapMemory()
won't happen from multiple threads simultaneously (which is illegal in Vulkan).It is recommended to use function vmaCreateImage() instead of this one.
-
bindImageMemory2
@EnumType(VkResult.class) public int bindImageMemory2(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long allocationLocalOffset, VkImage image, @Pointer(comment="void*") MemorySegment pNext) Binds image to allocation with additional parameters.
This function is similar to vmaBindImageMemory(), but it provides additional parameters.
If
pNext
is not null,VmaAllocator
object must have been created withVMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT
flag or with VmaAllocatorCreateInfo::vulkanApiVersion>= VK_API_VERSION_1_1
. Otherwise the call fails.- Parameters:
allocator
-allocation
-allocationLocalOffset
- Additional offset to be added while binding, relative to the beginning of theallocation
. Normally it should be 0.image
-pNext
- A chain of structures to be attached toVkBindImageMemoryInfoKHR
structure used internally. Normally it should be null.
-
createBuffer
@EnumType(VkResult.class) public int createBuffer(VmaAllocator allocator, @Pointer IVkBufferCreateInfo pBufferCreateInfo, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @Pointer VkBuffer.Ptr pBuffer, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) Creates a new
VkBuffer
, allocates and binds memory for it.This function automatically:
-# Creates buffer. -# Allocates appropriate memory for it. -# Binds the buffer with the memory.
If any of these operations fail, buffer and allocation are not created, returned value is negative error code,
*pBuffer
and*pAllocation
are null.If the function succeeded, you must destroy both buffer and allocation when you no longer need them using either convenience function vmaDestroyBuffer() or separately, using
vkDestroyBuffer()
and vmaFreeMemory().If
VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT
flag was used, VK_KHR_dedicated_allocation extension is used internally to query driver whether it requires or prefers the new buffer to have dedicated allocation. If yes, and if dedicated allocation is possible (VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT
is not used), it creates dedicated allocation for this buffer, just like when usingVMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
.ote This function creates a new
VkBuffer
. Sub-allocation of parts of one large buffer, although recommended as a good practice, is out of scope of this library and could be implemented by the user as a higher-level logic on top of VMA.- Parameters:
allocator
-pBufferCreateInfo
-pAllocationCreateInfo
-pBuffer
- Buffer that was created.pAllocation
- Allocation that was created.pAllocationInfo
- Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo().
-
createBufferWithAlignment
@EnumType(VkResult.class) public int createBufferWithAlignment(VmaAllocator allocator, @Pointer IVkBufferCreateInfo pBufferCreateInfo, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @NativeType("VkDeviceSize") @Unsigned long minAlignment, @Pointer VkBuffer.Ptr pBuffer, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) Creates a buffer with additional minimum alignment.
Similar to vmaCreateBuffer() but provides additional parameter
minAlignment
which allows to specify custom, minimum alignment to be used when placing the buffer inside a larger memory block, which may be needed e.g. for interop with OpenGL. -
createAliasingBuffer
@EnumType(VkResult.class) public int createAliasingBuffer(VmaAllocator allocator, VmaAllocation allocation, @Pointer IVkBufferCreateInfo pBufferCreateInfo, @Pointer VkBuffer.Ptr pBuffer) Creates a new
VkBuffer
, binds already created memory for it.This function automatically:
-# Creates buffer. -# Binds the buffer with the supplied memory.
If any of these operations fail, buffer is not created, returned value is negative error code and
*pBuffer
is null.If the function succeeded, you must destroy the buffer when you no longer need it using
vkDestroyBuffer()
. If you want to also destroy the corresponding allocation you can use convenience function vmaDestroyBuffer().ote There is a new version of this function augmented with parameter
allocationLocalOffset
- see vmaCreateAliasingBuffer2().- Parameters:
allocator
-allocation
- Allocation that provides memory to be used for binding new buffer to it.pBufferCreateInfo
-pBuffer
- Buffer that was created.
-
createAliasingBuffer2
@EnumType(VkResult.class) public int createAliasingBuffer2(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long allocationLocalOffset, @Pointer IVkBufferCreateInfo pBufferCreateInfo, @Pointer VkBuffer.Ptr pBuffer) Creates a new
VkBuffer
, binds already created memory for it.This function automatically:
-# Creates buffer. -# Binds the buffer with the supplied memory.
If any of these operations fail, buffer is not created, returned value is negative error code and
*pBuffer
is null.If the function succeeded, you must destroy the buffer when you no longer need it using
vkDestroyBuffer()
. If you want to also destroy the corresponding allocation you can use convenience function vmaDestroyBuffer().ote This is a new version of the function augmented with parameter
allocationLocalOffset
.- Parameters:
allocator
-allocation
- Allocation that provides memory to be used for binding new buffer to it.allocationLocalOffset
- Additional offset to be added while binding, relative to the beginning of the allocation. Normally it should be 0.pBufferCreateInfo
-pBuffer
- Buffer that was created.
-
destroyBuffer
public void destroyBuffer(VmaAllocator allocator, @Nullable @Nullable VkBuffer buffer, @Nullable @Nullable VmaAllocation allocation) Destroys Vulkan buffer and frees allocated memory.
This is just a convenience function equivalent to:
vkDestroyBuffer(device, buffer, allocationCallbacks); vmaFreeMemory(allocator, allocation);
It is safe to pass null as buffer and/or allocation.
-
createImage
@EnumType(VkResult.class) public int createImage(VmaAllocator allocator, @Pointer IVkImageCreateInfo pImageCreateInfo, @Pointer IVmaAllocationCreateInfo pAllocationCreateInfo, @Pointer VkImage.Ptr pImage, @Pointer VmaAllocation.Ptr pAllocation, @Nullable @Pointer @Nullable IVmaAllocationInfo pAllocationInfo) Function similar to vmaCreateBuffer(). -
createAliasingImage
@EnumType(VkResult.class) public int createAliasingImage(VmaAllocator allocator, VmaAllocation allocation, @Pointer IVkImageCreateInfo pImageCreateInfo, @Pointer VkImage.Ptr pImage) Function similar to vmaCreateAliasingBuffer() but for images. -
createAliasingImage2
@EnumType(VkResult.class) public int createAliasingImage2(VmaAllocator allocator, VmaAllocation allocation, @NativeType("VkDeviceSize") @Unsigned long allocationLocalOffset, @Pointer IVkImageCreateInfo pImageCreateInfo, @Pointer VkImage.Ptr pImage) Function similar to vmaCreateAliasingBuffer2() but for images. -
destroyImage
public void destroyImage(VmaAllocator allocator, @Nullable @Nullable VkImage image, @Nullable @Nullable VmaAllocation allocation) Destroys Vulkan image and frees allocated memory.
This is just a convenience function equivalent to:
vkDestroyImage(device, image, allocationCallbacks); vmaFreeMemory(allocator, allocation);
It is safe to pass null as image and/or allocation.
-
createVirtualBlock
@EnumType(VkResult.class) public int createVirtualBlock(@Pointer IVmaVirtualBlockCreateInfo pCreateInfo, @Pointer VmaVirtualBlock.Ptr pVirtualBlock) Creates newVmaVirtualBlock
object.- Parameters:
pCreateInfo
- Parameters for creation.pVirtualBlock
- Returned virtual block object orVMA_NULL
if creation failed.
-
destroyVirtualBlock
Destroys
VmaVirtualBlock
object.Please note that you should consciously handle virtual allocations that could remain unfreed in the block. You should either free them individually using vmaVirtualFree() or call vmaClearVirtualBlock() if you are sure this is what you want. If you do neither, an assert is called.
If you keep pointers to some additional metadata associated with your virtual allocations in their
pUserData
, don't forget to free them. -
isVirtualBlockEmpty
Returns true of theVmaVirtualBlock
is empty - contains 0 virtual allocations and has all its space available for new allocations. -
getVirtualAllocationInfo
public void getVirtualAllocationInfo(VmaVirtualBlock virtualBlock, VmaVirtualAllocation allocation, @Pointer IVmaVirtualAllocationInfo pVirtualAllocInfo) Returns information about a specific virtual allocation within a virtual block, like its size andpUserData
pointer. -
virtualAllocate
@EnumType(VkResult.class) public int virtualAllocate(VmaVirtualBlock virtualBlock, @Pointer IVmaVirtualAllocationCreateInfo pCreateInfo, @Pointer VmaVirtualAllocation.Ptr pAllocation, @Nullable @Pointer(comment="VkDeviceSize") @Unsigned @Nullable LongPtr pOffset) Allocates new virtual allocation inside given
VmaVirtualBlock
.If the allocation fails due to not enough free space available,
VK_ERROR_OUT_OF_DEVICE_MEMORY
is returned (despite the function doesn't ever allocate actual GPU memory).pAllocation
is then set toVK_NULL_HANDLE
andpOffset
, if not null, it set toUINT64_MAX
.- Parameters:
virtualBlock
- Virtual blockpCreateInfo
- Parameters for the allocationpAllocation
- Returned handle of the new allocationpOffset
- Returned offset of the new allocation. Optional, can be null.
-
virtualFree
public void virtualFree(VmaVirtualBlock virtualBlock, @Nullable @Nullable VmaVirtualAllocation allocation) Frees virtual allocation inside given
VmaVirtualBlock
.It is correct to call this function with
allocation == VK_NULL_HANDLE
- it does nothing. -
clearVirtualBlock
Frees all virtual allocations inside given
VmaVirtualBlock
.You must either call this function or free each virtual allocation individually with vmaVirtualFree() before destroying a virtual block. Otherwise, an assert is called.
If you keep pointer to some additional metadata associated with your virtual allocation in its
pUserData
, don't forget to free it as well. -
setVirtualAllocationUserData
public void setVirtualAllocationUserData(VmaVirtualBlock virtualBlock, VmaVirtualAllocation allocation, @Pointer(comment="void*") MemorySegment pUserData) Changes custom pointer associated with given virtual allocation. -
getVirtualBlockStatistics
Calculates and returns statistics about virtual allocations and memory usage in given
VmaVirtualBlock
.This function is fast to call. For more detailed statistics, see vmaCalculateVirtualBlockStatistics().
-
calculateVirtualBlockStatistics
public void calculateVirtualBlockStatistics(VmaVirtualBlock virtualBlock, @Pointer IVmaDetailedStatistics pStats) Calculates and returns detailed statistics about virtual allocations and memory usage in given
VmaVirtualBlock
.This function is slow to call. Use for debugging purposes. For less detailed statistics, see vmaGetVirtualBlockStatistics().
-
buildVirtualBlockStatsString
public void buildVirtualBlockStatsString(VmaVirtualBlock virtualBlock, PointerPtr ppStatsString, @NativeType("VkBool32") @Unsigned int detailedMap) Builds and returns a null-terminated string in JSON format with information about given
VmaVirtualBlock
.Returned string must be freed using vmaFreeVirtualBlockStatsString().
- Parameters:
virtualBlock
- Virtual block.ppStatsString
- Returned string.detailedMap
- PassVK_FALSE
to only obtain statistics as returned by vmaCalculateVirtualBlockStatistics(). PassVK_TRUE
to also obtain full list of allocations and free spaces.
-
freeVirtualBlockStatsString
public void freeVirtualBlockStatsString(VmaVirtualBlock virtualBlock, @Nullable @Nullable BytePtr pStatsString) Frees a string returned by vmaBuildVirtualBlockStatsString(). -
buildStatsString
public void buildStatsString(VmaAllocator allocator, PointerPtr ppStatsString, @NativeType("VkBool32") @Unsigned int detailedMap) Builds and returns statistics as a null-terminated string in JSON format.- Parameters:
allocator
-ppStatsString
- Must be freed using vmaFreeStatsString() function.detailedMap
-
-
freeStatsString
-