Class VMA

java.lang.Object
club.doki7.vma.VMA

public final class VMA extends Object
  • Field Details

    • SEGMENT$vmaCreateAllocator

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateAllocator
    • SEGMENT$vmaDestroyAllocator

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaDestroyAllocator
    • SEGMENT$vmaGetAllocatorInfo

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetAllocatorInfo
    • SEGMENT$vmaGetPhysicalDeviceProperties

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetPhysicalDeviceProperties
    • SEGMENT$vmaGetMemoryProperties

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetMemoryProperties
    • SEGMENT$vmaGetMemoryTypeProperties

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetMemoryTypeProperties
    • SEGMENT$vmaSetCurrentFrameIndex

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaSetCurrentFrameIndex
    • SEGMENT$vmaCalculateStatistics

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCalculateStatistics
    • SEGMENT$vmaGetHeapBudgets

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetHeapBudgets
    • SEGMENT$vmaFindMemoryTypeIndex

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFindMemoryTypeIndex
    • SEGMENT$vmaFindMemoryTypeIndexForBufferInfo

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFindMemoryTypeIndexForBufferInfo
    • SEGMENT$vmaFindMemoryTypeIndexForImageInfo

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFindMemoryTypeIndexForImageInfo
    • SEGMENT$vmaCreatePool

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreatePool
    • SEGMENT$vmaDestroyPool

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaDestroyPool
    • SEGMENT$vmaGetPoolStatistics

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetPoolStatistics
    • SEGMENT$vmaCalculatePoolStatistics

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCalculatePoolStatistics
    • SEGMENT$vmaCheckPoolCorruption

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCheckPoolCorruption
    • SEGMENT$vmaGetPoolName

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetPoolName
    • SEGMENT$vmaSetPoolName

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaSetPoolName
    • SEGMENT$vmaAllocateMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaAllocateMemory
    • SEGMENT$vmaAllocateMemoryPages

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaAllocateMemoryPages
    • SEGMENT$vmaAllocateMemoryForBuffer

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaAllocateMemoryForBuffer
    • SEGMENT$vmaAllocateMemoryForImage

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaAllocateMemoryForImage
    • SEGMENT$vmaFreeMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFreeMemory
    • SEGMENT$vmaFreeMemoryPages

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFreeMemoryPages
    • SEGMENT$vmaGetAllocationInfo

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetAllocationInfo
    • SEGMENT$vmaGetAllocationInfo2

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetAllocationInfo2
    • SEGMENT$vmaSetAllocationUserData

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaSetAllocationUserData
    • SEGMENT$vmaSetAllocationName

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaSetAllocationName
    • SEGMENT$vmaGetAllocationMemoryProperties

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetAllocationMemoryProperties
    • SEGMENT$vmaGetMemoryWin32Handle

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetMemoryWin32Handle
    • SEGMENT$vmaMapMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaMapMemory
    • SEGMENT$vmaUnmapMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaUnmapMemory
    • SEGMENT$vmaFlushAllocation

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFlushAllocation
    • SEGMENT$vmaInvalidateAllocation

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaInvalidateAllocation
    • SEGMENT$vmaFlushAllocations

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFlushAllocations
    • SEGMENT$vmaInvalidateAllocations

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaInvalidateAllocations
    • SEGMENT$vmaCopyMemoryToAllocation

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCopyMemoryToAllocation
    • SEGMENT$vmaCopyAllocationToMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCopyAllocationToMemory
    • SEGMENT$vmaCheckCorruption

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCheckCorruption
    • SEGMENT$vmaBeginDefragmentation

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBeginDefragmentation
    • SEGMENT$vmaEndDefragmentation

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaEndDefragmentation
    • SEGMENT$vmaBeginDefragmentationPass

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBeginDefragmentationPass
    • SEGMENT$vmaEndDefragmentationPass

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaEndDefragmentationPass
    • SEGMENT$vmaBindBufferMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBindBufferMemory
    • SEGMENT$vmaBindBufferMemory2

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBindBufferMemory2
    • SEGMENT$vmaBindImageMemory

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBindImageMemory
    • SEGMENT$vmaBindImageMemory2

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBindImageMemory2
    • SEGMENT$vmaCreateBuffer

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateBuffer
    • SEGMENT$vmaCreateBufferWithAlignment

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateBufferWithAlignment
    • SEGMENT$vmaCreateAliasingBuffer

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateAliasingBuffer
    • SEGMENT$vmaCreateAliasingBuffer2

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateAliasingBuffer2
    • SEGMENT$vmaDestroyBuffer

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaDestroyBuffer
    • SEGMENT$vmaCreateImage

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateImage
    • SEGMENT$vmaCreateAliasingImage

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateAliasingImage
    • SEGMENT$vmaCreateAliasingImage2

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateAliasingImage2
    • SEGMENT$vmaDestroyImage

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaDestroyImage
    • SEGMENT$vmaCreateVirtualBlock

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCreateVirtualBlock
    • SEGMENT$vmaDestroyVirtualBlock

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaDestroyVirtualBlock
    • SEGMENT$vmaIsVirtualBlockEmpty

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaIsVirtualBlockEmpty
    • SEGMENT$vmaGetVirtualAllocationInfo

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetVirtualAllocationInfo
    • SEGMENT$vmaVirtualAllocate

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaVirtualAllocate
    • SEGMENT$vmaVirtualFree

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaVirtualFree
    • SEGMENT$vmaClearVirtualBlock

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaClearVirtualBlock
    • SEGMENT$vmaSetVirtualAllocationUserData

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaSetVirtualAllocationUserData
    • SEGMENT$vmaGetVirtualBlockStatistics

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaGetVirtualBlockStatistics
    • SEGMENT$vmaCalculateVirtualBlockStatistics

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaCalculateVirtualBlockStatistics
    • SEGMENT$vmaBuildVirtualBlockStatsString

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBuildVirtualBlockStatsString
    • SEGMENT$vmaFreeVirtualBlockStatsString

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFreeVirtualBlockStatsString
    • SEGMENT$vmaBuildStatsString

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaBuildStatsString
    • SEGMENT$vmaFreeStatsString

      @Nullable public final @Nullable MemorySegment SEGMENT$vmaFreeStatsString
    • HANDLE$vmaCreateAllocator

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateAllocator
    • HANDLE$vmaDestroyAllocator

      @Nullable public final @Nullable MethodHandle HANDLE$vmaDestroyAllocator
    • HANDLE$vmaGetAllocatorInfo

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetAllocatorInfo
    • HANDLE$vmaGetPhysicalDeviceProperties

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetPhysicalDeviceProperties
    • HANDLE$vmaGetMemoryProperties

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetMemoryProperties
    • HANDLE$vmaGetMemoryTypeProperties

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetMemoryTypeProperties
    • HANDLE$vmaSetCurrentFrameIndex

      @Nullable public final @Nullable MethodHandle HANDLE$vmaSetCurrentFrameIndex
    • HANDLE$vmaCalculateStatistics

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCalculateStatistics
    • HANDLE$vmaGetHeapBudgets

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetHeapBudgets
    • HANDLE$vmaFindMemoryTypeIndex

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFindMemoryTypeIndex
    • HANDLE$vmaFindMemoryTypeIndexForBufferInfo

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFindMemoryTypeIndexForBufferInfo
    • HANDLE$vmaFindMemoryTypeIndexForImageInfo

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFindMemoryTypeIndexForImageInfo
    • HANDLE$vmaCreatePool

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreatePool
    • HANDLE$vmaDestroyPool

      @Nullable public final @Nullable MethodHandle HANDLE$vmaDestroyPool
    • HANDLE$vmaGetPoolStatistics

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetPoolStatistics
    • HANDLE$vmaCalculatePoolStatistics

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCalculatePoolStatistics
    • HANDLE$vmaCheckPoolCorruption

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCheckPoolCorruption
    • HANDLE$vmaGetPoolName

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetPoolName
    • HANDLE$vmaSetPoolName

      @Nullable public final @Nullable MethodHandle HANDLE$vmaSetPoolName
    • HANDLE$vmaAllocateMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaAllocateMemory
    • HANDLE$vmaAllocateMemoryPages

      @Nullable public final @Nullable MethodHandle HANDLE$vmaAllocateMemoryPages
    • HANDLE$vmaAllocateMemoryForBuffer

      @Nullable public final @Nullable MethodHandle HANDLE$vmaAllocateMemoryForBuffer
    • HANDLE$vmaAllocateMemoryForImage

      @Nullable public final @Nullable MethodHandle HANDLE$vmaAllocateMemoryForImage
    • HANDLE$vmaFreeMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFreeMemory
    • HANDLE$vmaFreeMemoryPages

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFreeMemoryPages
    • HANDLE$vmaGetAllocationInfo

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetAllocationInfo
    • HANDLE$vmaGetAllocationInfo2

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetAllocationInfo2
    • HANDLE$vmaSetAllocationUserData

      @Nullable public final @Nullable MethodHandle HANDLE$vmaSetAllocationUserData
    • HANDLE$vmaSetAllocationName

      @Nullable public final @Nullable MethodHandle HANDLE$vmaSetAllocationName
    • HANDLE$vmaGetAllocationMemoryProperties

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetAllocationMemoryProperties
    • HANDLE$vmaGetMemoryWin32Handle

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetMemoryWin32Handle
    • HANDLE$vmaMapMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaMapMemory
    • HANDLE$vmaUnmapMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaUnmapMemory
    • HANDLE$vmaFlushAllocation

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFlushAllocation
    • HANDLE$vmaInvalidateAllocation

      @Nullable public final @Nullable MethodHandle HANDLE$vmaInvalidateAllocation
    • HANDLE$vmaFlushAllocations

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFlushAllocations
    • HANDLE$vmaInvalidateAllocations

      @Nullable public final @Nullable MethodHandle HANDLE$vmaInvalidateAllocations
    • HANDLE$vmaCopyMemoryToAllocation

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCopyMemoryToAllocation
    • HANDLE$vmaCopyAllocationToMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCopyAllocationToMemory
    • HANDLE$vmaCheckCorruption

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCheckCorruption
    • HANDLE$vmaBeginDefragmentation

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBeginDefragmentation
    • HANDLE$vmaEndDefragmentation

      @Nullable public final @Nullable MethodHandle HANDLE$vmaEndDefragmentation
    • HANDLE$vmaBeginDefragmentationPass

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBeginDefragmentationPass
    • HANDLE$vmaEndDefragmentationPass

      @Nullable public final @Nullable MethodHandle HANDLE$vmaEndDefragmentationPass
    • HANDLE$vmaBindBufferMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBindBufferMemory
    • HANDLE$vmaBindBufferMemory2

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBindBufferMemory2
    • HANDLE$vmaBindImageMemory

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBindImageMemory
    • HANDLE$vmaBindImageMemory2

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBindImageMemory2
    • HANDLE$vmaCreateBuffer

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateBuffer
    • HANDLE$vmaCreateBufferWithAlignment

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateBufferWithAlignment
    • HANDLE$vmaCreateAliasingBuffer

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateAliasingBuffer
    • HANDLE$vmaCreateAliasingBuffer2

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateAliasingBuffer2
    • HANDLE$vmaDestroyBuffer

      @Nullable public final @Nullable MethodHandle HANDLE$vmaDestroyBuffer
    • HANDLE$vmaCreateImage

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateImage
    • HANDLE$vmaCreateAliasingImage

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateAliasingImage
    • HANDLE$vmaCreateAliasingImage2

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateAliasingImage2
    • HANDLE$vmaDestroyImage

      @Nullable public final @Nullable MethodHandle HANDLE$vmaDestroyImage
    • HANDLE$vmaCreateVirtualBlock

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCreateVirtualBlock
    • HANDLE$vmaDestroyVirtualBlock

      @Nullable public final @Nullable MethodHandle HANDLE$vmaDestroyVirtualBlock
    • HANDLE$vmaIsVirtualBlockEmpty

      @Nullable public final @Nullable MethodHandle HANDLE$vmaIsVirtualBlockEmpty
    • HANDLE$vmaGetVirtualAllocationInfo

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetVirtualAllocationInfo
    • HANDLE$vmaVirtualAllocate

      @Nullable public final @Nullable MethodHandle HANDLE$vmaVirtualAllocate
    • HANDLE$vmaVirtualFree

      @Nullable public final @Nullable MethodHandle HANDLE$vmaVirtualFree
    • HANDLE$vmaClearVirtualBlock

      @Nullable public final @Nullable MethodHandle HANDLE$vmaClearVirtualBlock
    • HANDLE$vmaSetVirtualAllocationUserData

      @Nullable public final @Nullable MethodHandle HANDLE$vmaSetVirtualAllocationUserData
    • HANDLE$vmaGetVirtualBlockStatistics

      @Nullable public final @Nullable MethodHandle HANDLE$vmaGetVirtualBlockStatistics
    • HANDLE$vmaCalculateVirtualBlockStatistics

      @Nullable public final @Nullable MethodHandle HANDLE$vmaCalculateVirtualBlockStatistics
    • HANDLE$vmaBuildVirtualBlockStatsString

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBuildVirtualBlockStatsString
    • HANDLE$vmaFreeVirtualBlockStatsString

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFreeVirtualBlockStatsString
    • HANDLE$vmaBuildStatsString

      @Nullable public final @Nullable MethodHandle HANDLE$vmaBuildStatsString
    • HANDLE$vmaFreeStatsString

      @Nullable public final @Nullable MethodHandle HANDLE$vmaFreeStatsString
  • Constructor Details

  • Method Details

    • createAllocator

      @EnumType(VkResult.class) public int createAllocator(@Pointer IVmaAllocatorCreateInfo pCreateInfo, @Pointer VmaAllocator.Ptr pAllocator)
      Creates VmaAllocator object.
    • destroyAllocator

      public void destroyAllocator(@Nullable @Nullable VmaAllocator allocator)
      Destroys allocator object.
    • getAllocatorInfo

      public void getAllocatorInfo(VmaAllocator allocator, @Pointer IVmaAllocatorInfo pAllocatorInfo)

      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 to VkPhysicalDevice, 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

      public void setCurrentFrameIndex(VmaAllocator allocator, @Unsigned int frameIndex)
      Sets index of the current frame.
    • calculateStatistics

      public void calculateStatistics(VmaAllocator allocator, @Pointer IVmaTotalStatistics pStats)

      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

      public void getHeapBudgets(VmaAllocator allocator, @Pointer IVmaBudget pBudgets)

      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 creates VmaPool object.
      Parameters:
      allocator - Allocator object.
      pCreateInfo - Parameters of pool to create.
      pPool - Handle to created pool.
    • destroyPool

      public void destroyPool(VmaAllocator allocator, @Nullable @Nullable VmaPool pool)
      Destroys VmaPool 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 existing VmaPool object.
      Parameters:
      allocator - Allocator object.
      pool - Pool object.
      pPoolStats - Statistics of specified pool.
    • checkPoolCorruption

      @EnumType(VkResult.class) public int checkPoolCorruption(VmaAllocator allocator, VmaPool pool)

      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 is HOST_VISIBLE and HOST_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

      public void getPoolName(VmaAllocator allocator, VmaPool pool, PointerPtr ppName)

      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

      public void setPoolName(VmaAllocator allocator, VmaPool pool, @Nullable @Nullable BytePtr pName)

      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 with VK_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

      public void freeMemory(VmaAllocator allocator, @Nullable @Nullable VmaAllocation allocation)

      Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage().

      Passing VK_NULL_HANDLE as allocation 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. Passing VK_NULL_HANDLE as elements of pAllocations 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 structure VmaAllocationInfo2 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's pUserData. 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's pName. 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's pName 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 function vkGetMemoryWin32HandleKHR. 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 using VMA_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 returns
      pHandle - 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 of vkMapMemory, 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 of VkDeviceMemory 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 to VMA_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

      public void unmapMemory(VmaAllocator allocator, VmaAllocation allocation)

      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 not HOST_COHERENT. Unmap operation doesn't do that automatically.

      • offset must be relative to the beginning of allocation.
      • size can be VK_WHOLE_SIZE. It means all memory from offset the the end of given allocation.
      • offset and size don't have to be aligned. They are internally rounded down/up to multiply of nonCoherentAtomSize.
      • If size is 0, this call is ignored.
      • If memory type that the allocation belongs to is not HOST_VISIBLE or it is HOST_COHERENT, this call is ignored.

      Warning! offset and size are relative to the contents of given allocation. If you mean whole allocation, you can pass 0 and VK_WHOLE_SIZE, respectively. Do not pass allocation's offset as offset!!!

      This function returns the VkResult from vkFlushMappedMemoryRanges if it is called, otherwise VK_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 not HOST_COHERENT. Map operation doesn't do that automatically.

      • offset must be relative to the beginning of allocation.
      • size can be VK_WHOLE_SIZE. It means all memory from offset the the end of given allocation.
      • offset and size don't have to be aligned. They are internally rounded down/up to multiply of nonCoherentAtomSize.
      • If size is 0, this call is ignored.
      • If memory type that the allocation belongs to is not HOST_VISIBLE or it is HOST_COHERENT, this call is ignored.

      Warning! offset and size are relative to the contents of given allocation. If you mean whole allocation, you can pass 0 and VK_WHOLE_SIZE, respectively. Do not pass allocation's offset as offset!!!

      This function returns the VkResult from vkInvalidateMappedMemoryRanges if it is called, otherwise VK_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 from vkFlushMappedMemoryRanges if it is called, otherwise VK_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 means VK_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 from vkInvalidateMappedMemoryRanges if it is called, otherwise VK_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 means VK_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 using VMA_MEMORY_USAGE_AUTO and VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT or VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT. Otherwise, the function will fail and generate a Validation Layers error.

      dstAllocationLocalOffset is relative to the contents of given dstAllocation. 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 within dstAllocation 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 and VK_MEMORY_PROPERTY_HOST_CACHED_BIT flag. It can be ensured e.g. by using VMA_MEMORY_USAGE_AUTO and VMA_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 given srcAllocation. 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 within srcAllocation 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 are HOST_VISIBLE and HOST_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
      (@ref 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 or VK_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 had pPassInfo[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 had pPassInfo[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.
    • 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 standard vkBindBufferMemory(), because it ensures proper synchronization so that when a VkDeviceMemory object is used by multiple allocations, calls to vkBind*Memory() or vkMapMemory() 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 with VMA_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 the allocation. Normally it should be 0.
      buffer -
      pNext - A chain of structures to be attached to VkBindBufferMemoryInfoKHR 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 standard vkBindImageMemory(), because it ensures proper synchronization so that when a VkDeviceMemory object is used by multiple allocations, calls to vkBind*Memory() or vkMapMemory() 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 with VMA_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 the allocation. Normally it should be 0.
      image -
      pNext - A chain of structures to be attached to VkBindImageMemoryInfoKHR 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 using VMA_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 new VmaVirtualBlock object.
      Parameters:
      pCreateInfo - Parameters for creation.
      pVirtualBlock - Returned virtual block object or VMA_NULL if creation failed.
    • destroyVirtualBlock

      public void destroyVirtualBlock(@Nullable @Nullable VmaVirtualBlock virtualBlock)

      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

      @NativeType("VkBool32") @Unsigned public int isVirtualBlockEmpty(VmaVirtualBlock virtualBlock)
      Returns true of the VmaVirtualBlock 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 and pUserData 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 to VK_NULL_HANDLE and pOffset, if not null, it set to UINT64_MAX.

      Parameters:
      virtualBlock - Virtual block
      pCreateInfo - Parameters for the allocation
      pAllocation - Returned handle of the new allocation
      pOffset - 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

      public void clearVirtualBlock(VmaVirtualBlock virtualBlock)

      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

      public void getVirtualBlockStatistics(VmaVirtualBlock virtualBlock, @Pointer IVmaStatistics pStats)

      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 - Pass VK_FALSE to only obtain statistics as returned by vmaCalculateVirtualBlockStatistics(). Pass VK_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

      public void freeStatsString(VmaAllocator allocator, @Nullable @Nullable BytePtr pStatsString)