Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
VulkanMemoryAllocator
Synopsis
- createAllocator :: forall io. MonadIO io => AllocatorCreateInfo -> io Allocator
- withAllocator :: forall io r. MonadIO io => AllocatorCreateInfo -> (io Allocator -> (Allocator -> io ()) -> r) -> r
- destroyAllocator :: forall io. MonadIO io => Allocator -> io ()
- getAllocatorInfo :: forall io. MonadIO io => Allocator -> io AllocatorInfo
- getPhysicalDeviceProperties :: forall io. MonadIO io => Allocator -> io (Ptr PhysicalDeviceProperties)
- getMemoryProperties :: forall io. MonadIO io => Allocator -> io (Ptr PhysicalDeviceMemoryProperties)
- getMemoryTypeProperties :: forall io. MonadIO io => Allocator -> ("memoryTypeIndex" ::: Word32) -> io MemoryPropertyFlags
- setCurrentFrameIndex :: forall io. MonadIO io => Allocator -> ("frameIndex" ::: Word32) -> io ()
- calculateStatistics :: forall io. MonadIO io => Allocator -> io ("stats" ::: TotalStatistics)
- getHeapBudgets :: forall io. MonadIO io => Allocator -> ("budgets" ::: Ptr Budget) -> io ()
- findMemoryTypeIndex :: forall io. MonadIO io => Allocator -> ("memoryTypeBits" ::: Word32) -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32)
- findMemoryTypeIndexForBufferInfo :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32)
- findMemoryTypeIndexForImageInfo :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32)
- createPool :: forall io. MonadIO io => Allocator -> PoolCreateInfo -> io Pool
- withPool :: forall io r. MonadIO io => Allocator -> PoolCreateInfo -> (io Pool -> (Pool -> io ()) -> r) -> r
- destroyPool :: forall io. MonadIO io => Allocator -> Pool -> io ()
- getPoolStatistics :: forall io. MonadIO io => Allocator -> Pool -> io ("poolStats" ::: Statistics)
- calculatePoolStatistics :: forall io. MonadIO io => Allocator -> Pool -> io ("poolStats" ::: DetailedStatistics)
- checkPoolCorruption :: forall io. MonadIO io => Allocator -> Pool -> io ()
- getPoolName :: forall io. MonadIO io => Allocator -> Pool -> io ("name" ::: Ptr CChar)
- setPoolName :: forall io. MonadIO io => Allocator -> Pool -> ("name" ::: Maybe ByteString) -> io ()
- allocateMemory :: forall io. MonadIO io => Allocator -> ("vkMemoryRequirements" ::: MemoryRequirements) -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
- withMemory :: forall io r. MonadIO io => Allocator -> MemoryRequirements -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
- allocateMemoryPages :: forall io. MonadIO io => Allocator -> ("vkMemoryRequirements" ::: Vector MemoryRequirements) -> ("createInfo" ::: Vector AllocationCreateInfo) -> io ("allocations" ::: Vector Allocation, "allocationInfo" ::: Vector AllocationInfo)
- withMemoryPages :: forall io r. MonadIO io => Allocator -> Vector MemoryRequirements -> Vector AllocationCreateInfo -> (io (Vector Allocation, Vector AllocationInfo) -> ((Vector Allocation, Vector AllocationInfo) -> io ()) -> r) -> r
- allocateMemoryForBuffer :: forall io. MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
- withMemoryForBuffer :: forall io r. MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
- allocateMemoryForImage :: forall io. MonadIO io => Allocator -> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
- withMemoryForImage :: forall io r. MonadIO io => Allocator -> Image -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
- freeMemory :: forall io. MonadIO io => Allocator -> Allocation -> io ()
- freeMemoryPages :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> io ()
- getAllocationInfo :: forall io. MonadIO io => Allocator -> Allocation -> io AllocationInfo
- setAllocationUserData :: forall io. MonadIO io => Allocator -> Allocation -> ("userData" ::: Ptr ()) -> io ()
- setAllocationName :: forall io. MonadIO io => Allocator -> Allocation -> ("name" ::: Maybe ByteString) -> io ()
- getAllocationMemoryProperties :: forall io. MonadIO io => Allocator -> Allocation -> io MemoryPropertyFlags
- mapMemory :: forall io. MonadIO io => Allocator -> Allocation -> io ("data" ::: Ptr ())
- withMappedMemory :: forall io r. MonadIO io => Allocator -> Allocation -> (io (Ptr ()) -> (Ptr () -> io ()) -> r) -> r
- unmapMemory :: forall io. MonadIO io => Allocator -> Allocation -> io ()
- flushAllocation :: forall io. MonadIO io => Allocator -> Allocation -> ("offset" ::: DeviceSize) -> DeviceSize -> io ()
- invalidateAllocation :: forall io. MonadIO io => Allocator -> Allocation -> ("offset" ::: DeviceSize) -> DeviceSize -> io ()
- flushAllocations :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("offsets" ::: Vector DeviceSize) -> ("sizes" ::: Vector DeviceSize) -> io ()
- invalidateAllocations :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("offsets" ::: Vector DeviceSize) -> ("sizes" ::: Vector DeviceSize) -> io ()
- checkCorruption :: forall io. MonadIO io => Allocator -> ("memoryTypeBits" ::: Word32) -> io ()
- beginDefragmentation :: forall io. MonadIO io => Allocator -> DefragmentationInfo -> io DefragmentationContext
- withDefragmentation :: forall io r. MonadIO io => Allocator -> DefragmentationInfo -> (io DefragmentationContext -> (DefragmentationContext -> io DefragmentationStats) -> r) -> r
- endDefragmentation :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io DefragmentationStats
- beginDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ("passInfo" ::: DefragmentationPassMoveInfo)
- useDefragmentationPass :: forall io r. MonadIO io => Allocator -> DefragmentationContext -> (DefragmentationPassMoveInfo -> io r) -> io ("passInfo" ::: DefragmentationPassMoveInfo, r)
- endDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ("passInfo" ::: DefragmentationPassMoveInfo)
- bindBufferMemory :: forall io. MonadIO io => Allocator -> Allocation -> Buffer -> io ()
- bindBufferMemory2 :: forall io. MonadIO io => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> Buffer -> ("next" ::: Ptr ()) -> io ()
- bindImageMemory :: forall io. MonadIO io => Allocator -> Allocation -> Image -> io ()
- bindImageMemory2 :: forall io. MonadIO io => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> Image -> ("next" ::: Ptr ()) -> io ()
- createBuffer :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> io (Buffer, Allocation, AllocationInfo)
- withBuffer :: forall a io r. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> (io (Buffer, Allocation, AllocationInfo) -> ((Buffer, Allocation, AllocationInfo) -> io ()) -> r) -> r
- createBufferWithAlignment :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> ("minAlignment" ::: DeviceSize) -> io (Buffer, Allocation, AllocationInfo)
- createAliasingBuffer :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> BufferCreateInfo a -> io Buffer
- createAliasingBuffer2 :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> BufferCreateInfo a -> io Buffer
- destroyBuffer :: forall io. MonadIO io => Allocator -> Buffer -> Allocation -> io ()
- createImage :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> io (Image, Allocation, AllocationInfo)
- withImage :: forall a io r. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> (io (Image, Allocation, AllocationInfo) -> ((Image, Allocation, AllocationInfo) -> io ()) -> r) -> r
- createAliasingImage :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ImageCreateInfo a -> io Image
- createAliasingImage2 :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> ImageCreateInfo a -> io Image
- destroyImage :: forall io. MonadIO io => Allocator -> Image -> Allocation -> io ()
- createVirtualBlock :: forall io. MonadIO io => VirtualBlockCreateInfo -> io VirtualBlock
- withVirtualBlock :: forall io r. MonadIO io => VirtualBlockCreateInfo -> (io VirtualBlock -> (VirtualBlock -> io ()) -> r) -> r
- destroyVirtualBlock :: forall io. MonadIO io => VirtualBlock -> io ()
- isVirtualBlockEmpty :: forall io. MonadIO io => VirtualBlock -> io Bool
- getVirtualAllocationInfo :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> io ("virtualAllocInfo" ::: VirtualAllocationInfo)
- virtualAllocate :: forall io. MonadIO io => VirtualBlock -> VirtualAllocationCreateInfo -> io (VirtualAllocation, "offset" ::: DeviceSize)
- withVirtualAllocation :: forall io r. MonadIO io => VirtualBlock -> VirtualAllocationCreateInfo -> (io (VirtualAllocation, DeviceSize) -> ((VirtualAllocation, DeviceSize) -> io ()) -> r) -> r
- virtualFree :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> io ()
- clearVirtualBlock :: forall io. MonadIO io => VirtualBlock -> io ()
- setVirtualAllocationUserData :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> ("userData" ::: Ptr ()) -> io ()
- getVirtualBlockStatistics :: forall io. MonadIO io => VirtualBlock -> io ("stats" ::: Statistics)
- calculateVirtualBlockStatistics :: forall io. MonadIO io => VirtualBlock -> io ("stats" ::: DetailedStatistics)
- buildVirtualBlockStatsString :: forall io. MonadIO io => VirtualBlock -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar)
- freeVirtualBlockStatsString :: forall io. MonadIO io => VirtualBlock -> ("statsString" ::: Ptr CChar) -> io ()
- buildStatsString :: forall io. MonadIO io => Allocator -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar)
- freeStatsString :: forall io. MonadIO io => Allocator -> ("statsString" ::: Ptr CChar) -> io ()
- type AllocatorCreateFlags = AllocatorCreateFlagBits
- newtype AllocatorCreateFlagBits where
- AllocatorCreateFlagBits Flags
- pattern ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT :: AllocatorCreateFlagBits
- pattern ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT :: AllocatorCreateFlagBits
- newtype MemoryUsage where
- MemoryUsage Int32
- pattern MEMORY_USAGE_UNKNOWN :: MemoryUsage
- pattern MEMORY_USAGE_GPU_ONLY :: MemoryUsage
- pattern MEMORY_USAGE_CPU_ONLY :: MemoryUsage
- pattern MEMORY_USAGE_CPU_TO_GPU :: MemoryUsage
- pattern MEMORY_USAGE_GPU_TO_CPU :: MemoryUsage
- pattern MEMORY_USAGE_CPU_COPY :: MemoryUsage
- pattern MEMORY_USAGE_GPU_LAZILY_ALLOCATED :: MemoryUsage
- pattern MEMORY_USAGE_AUTO :: MemoryUsage
- pattern MEMORY_USAGE_AUTO_PREFER_DEVICE :: MemoryUsage
- pattern MEMORY_USAGE_AUTO_PREFER_HOST :: MemoryUsage
- type AllocationCreateFlags = AllocationCreateFlagBits
- newtype AllocationCreateFlagBits where
- AllocationCreateFlagBits Flags
- pattern ALLOCATION_CREATE_DEDICATED_MEMORY_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_NEVER_ALLOCATE_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_MAPPED_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_DONT_BIND_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_WITHIN_BUDGET_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_CAN_ALIAS_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MASK :: AllocationCreateFlagBits
- type PoolCreateFlags = PoolCreateFlagBits
- newtype PoolCreateFlagBits where
- type DefragmentationFlags = DefragmentationFlagBits
- newtype DefragmentationFlagBits where
- DefragmentationFlagBits Flags
- pattern DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT :: DefragmentationFlagBits
- pattern DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT :: DefragmentationFlagBits
- pattern DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT :: DefragmentationFlagBits
- pattern DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT :: DefragmentationFlagBits
- pattern DEFRAGMENTATION_FLAG_ALGORITHM_MASK :: DefragmentationFlagBits
- newtype DefragmentationMoveOperation where
- type VirtualBlockCreateFlags = VirtualBlockCreateFlagBits
- newtype VirtualBlockCreateFlagBits where
- type VirtualAllocationCreateFlags = VirtualAllocationCreateFlagBits
- newtype VirtualAllocationCreateFlagBits where
- VirtualAllocationCreateFlagBits Flags
- pattern VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: VirtualAllocationCreateFlagBits
- pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: VirtualAllocationCreateFlagBits
- pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: VirtualAllocationCreateFlagBits
- pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: VirtualAllocationCreateFlagBits
- pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK :: VirtualAllocationCreateFlagBits
- newtype Allocator = Allocator Word64
- newtype Pool = Pool Word64
- newtype Allocation = Allocation Word64
- newtype DefragmentationContext = DefragmentationContext Word64
- newtype VirtualAllocation = VirtualAllocation Word64
- newtype VirtualBlock = VirtualBlock Word64
- type PFN_vmaAllocateDeviceMemoryFunction = FunPtr FN_vmaAllocateDeviceMemoryFunction
- type FN_vmaAllocateDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO ()
- type PFN_vmaFreeDeviceMemoryFunction = FunPtr FN_vmaFreeDeviceMemoryFunction
- type FN_vmaFreeDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO ()
- data DeviceMemoryCallbacks = DeviceMemoryCallbacks {}
- data VulkanFunctions = VulkanFunctions {
- vkGetInstanceProcAddr :: PFN_vkGetInstanceProcAddr
- vkGetDeviceProcAddr :: PFN_vkGetDeviceProcAddr
- vkGetPhysicalDeviceProperties :: PFN_vkGetPhysicalDeviceProperties
- vkGetPhysicalDeviceMemoryProperties :: PFN_vkGetPhysicalDeviceMemoryProperties
- vkAllocateMemory :: PFN_vkAllocateMemory
- vkFreeMemory :: PFN_vkFreeMemory
- vkMapMemory :: PFN_vkMapMemory
- vkUnmapMemory :: PFN_vkUnmapMemory
- vkFlushMappedMemoryRanges :: PFN_vkFlushMappedMemoryRanges
- vkInvalidateMappedMemoryRanges :: PFN_vkInvalidateMappedMemoryRanges
- vkBindBufferMemory :: PFN_vkBindBufferMemory
- vkBindImageMemory :: PFN_vkBindImageMemory
- vkGetBufferMemoryRequirements :: PFN_vkGetBufferMemoryRequirements
- vkGetImageMemoryRequirements :: PFN_vkGetImageMemoryRequirements
- vkCreateBuffer :: PFN_vkCreateBuffer
- vkDestroyBuffer :: PFN_vkDestroyBuffer
- vkCreateImage :: PFN_vkCreateImage
- vkDestroyImage :: PFN_vkDestroyImage
- vkCmdCopyBuffer :: PFN_vkCmdCopyBuffer
- vkGetBufferMemoryRequirements2KHR :: PFN_vkGetBufferMemoryRequirements2KHR
- vkGetImageMemoryRequirements2KHR :: PFN_vkGetImageMemoryRequirements2KHR
- vkBindBufferMemory2KHR :: PFN_vkBindBufferMemory2KHR
- vkBindImageMemory2KHR :: PFN_vkBindImageMemory2KHR
- vkGetPhysicalDeviceMemoryProperties2KHR :: PFN_vkGetPhysicalDeviceMemoryProperties2KHR
- vkGetDeviceBufferMemoryRequirements :: PFN_vkGetDeviceBufferMemoryRequirements
- vkGetDeviceImageMemoryRequirements :: PFN_vkGetDeviceImageMemoryRequirements
- data AllocatorCreateInfo = AllocatorCreateInfo {
- flags :: AllocatorCreateFlags
- physicalDevice :: Ptr PhysicalDevice_T
- device :: Ptr Device_T
- preferredLargeHeapBlockSize :: DeviceSize
- allocationCallbacks :: Maybe AllocationCallbacks
- deviceMemoryCallbacks :: Maybe DeviceMemoryCallbacks
- heapSizeLimit :: Ptr DeviceSize
- vulkanFunctions :: Maybe VulkanFunctions
- instance' :: Ptr Instance_T
- vulkanApiVersion :: Word32
- typeExternalMemoryHandleTypes :: Ptr ExternalMemoryHandleTypeFlagsKHR
- data AllocatorInfo = AllocatorInfo {}
- data Statistics = Statistics {}
- data DetailedStatistics = DetailedStatistics {}
- data TotalStatistics = TotalStatistics {}
- data Budget = Budget {}
- data AllocationCreateInfo = AllocationCreateInfo {}
- data PoolCreateInfo = PoolCreateInfo {}
- data AllocationInfo = AllocationInfo {
- memoryType :: Word32
- deviceMemory :: DeviceMemory
- offset :: DeviceSize
- size :: DeviceSize
- mappedData :: Ptr ()
- userData :: Ptr ()
- name :: Maybe ByteString
- type PFN_vmaCheckDefragmentationBreakFunction = FunPtr FN_vmaCheckDefragmentationBreakFunction
- type FN_vmaCheckDefragmentationBreakFunction = ("pUserData" ::: Ptr ()) -> IO Bool32
- data DefragmentationInfo = DefragmentationInfo {}
- data DefragmentationMove = DefragmentationMove {}
- data DefragmentationPassMoveInfo = DefragmentationPassMoveInfo {}
- data DefragmentationStats = DefragmentationStats {}
- data VirtualBlockCreateInfo = VirtualBlockCreateInfo {}
- data VirtualAllocationCreateInfo = VirtualAllocationCreateInfo {}
- data VirtualAllocationInfo = VirtualAllocationInfo {
- offset :: DeviceSize
- size :: DeviceSize
- userData :: Ptr ()
Documentation
createAllocator :: forall io. MonadIO io => AllocatorCreateInfo -> io Allocator Source #
Creates Allocator
object.
withAllocator :: forall io r. MonadIO io => AllocatorCreateInfo -> (io Allocator -> (Allocator -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
createAllocator
and destroyAllocator
To ensure that destroyAllocator
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
destroyAllocator :: forall io. MonadIO io => Allocator -> io () Source #
Destroys allocator object.
getAllocatorInfo :: forall io. MonadIO io => Allocator -> io AllocatorInfo Source #
getPhysicalDeviceProperties :: forall io. MonadIO io => Allocator -> io (Ptr PhysicalDeviceProperties) Source #
PhysicalDeviceProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own.
getMemoryProperties :: forall io. MonadIO io => Allocator -> io (Ptr PhysicalDeviceMemoryProperties) Source #
PhysicalDeviceMemoryProperties are fetched from physicalDevice by the allocator. You can access it here, without fetching it again on your own.
getMemoryTypeProperties :: forall io. MonadIO io => Allocator -> ("memoryTypeIndex" ::: Word32) -> io MemoryPropertyFlags Source #
Given Memory Type Index, returns Property Flags of this memory type.
This is just a convenience function. Same information can be obtained
using getMemoryProperties
.
setCurrentFrameIndex :: forall io. MonadIO io => Allocator -> ("frameIndex" ::: Word32) -> io () Source #
Sets index of the current frame.
calculateStatistics :: forall io. MonadIO io => Allocator -> io ("stats" ::: TotalStatistics) Source #
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 getHeapBudgets
.
Note that when using allocator from multiple threads, returned information may immediately become outdated.
getHeapBudgets :: forall io. MonadIO io => Allocator -> ("budgets" ::: Ptr Budget) -> io () Source #
Retrieves information about current memory usage and budget for all memory heaps.
Parameters
allocator | ||
out | pBudgets | Must point to array with number of elements at least equal to number of memory heaps in physical device used. |
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 calculateStatistics
.
Note that when using allocator from multiple threads, returned information may immediately become outdated.
findMemoryTypeIndex :: forall io. MonadIO io => Allocator -> ("memoryTypeBits" ::: Word32) -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32) Source #
Helps to find memoryTypeIndex, given memoryTypeBits and
AllocationCreateInfo
.
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.
Returns
Returns VK_ERROR_FEATURE_NOT_PRESENT if not found. Receiving such result 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.
findMemoryTypeIndexForBufferInfo :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32) Source #
Helps to find memoryTypeIndex, given VkBufferCreateInfo and
AllocationCreateInfo
.
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 :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> io ("memoryTypeIndex" ::: Word32) Source #
Helps to find memoryTypeIndex, given VkImageCreateInfo and
AllocationCreateInfo
.
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 :: forall io. MonadIO io => Allocator -> PoolCreateInfo -> io Pool Source #
Allocates Vulkan device memory and creates Pool
object.
Parameters
allocator | Allocator object. | |
pCreateInfo | Parameters of pool to create. | |
out | pPool | Handle to created pool. |
withPool :: forall io r. MonadIO io => Allocator -> PoolCreateInfo -> (io Pool -> (Pool -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to createPool
and destroyPool
To ensure that destroyPool
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
destroyPool :: forall io. MonadIO io => Allocator -> Pool -> io () Source #
Destroys Pool
object and frees Vulkan device memory.
getPoolStatistics :: forall io. MonadIO io => Allocator -> Pool -> io ("poolStats" ::: Statistics) Source #
Retrieves statistics of existing Pool
object.
Parameters
allocator | Allocator object. | |
pool | Pool object. | |
out | pPoolStats | Statistics of specified pool. |
calculatePoolStatistics :: forall io. MonadIO io => Allocator -> Pool -> io ("poolStats" ::: DetailedStatistics) Source #
Retrieves detailed statistics of existing Pool
object.
Parameters
allocator | Allocator object. | |
pool | Pool object. | |
out | pPoolStats | Statistics of specified pool. |
checkPoolCorruption :: forall io. MonadIO io => Allocator -> Pool -> io () Source #
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.
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 :: forall io. MonadIO io => Allocator -> Pool -> io ("name" ::: Ptr CChar) Source #
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 setPoolName
.
setPoolName :: forall io. MonadIO io => Allocator -> Pool -> ("name" ::: Maybe ByteString) -> io () Source #
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 :: forall io. MonadIO io => Allocator -> ("vkMemoryRequirements" ::: MemoryRequirements) -> AllocationCreateInfo -> io (Allocation, AllocationInfo) Source #
General purpose memory allocation.
Parameters
allocator | ||
pVkMemoryRequirements | ||
pCreateInfo | ||
out | pAllocation | Handle to allocated memory. |
out | pAllocationInfo | Optional. Information about allocated memory.
It can be later fetched using function
getAllocationInfo . |
You should free the memory using freeMemory
or freeMemoryPages
.
It is recommended to use allocateMemoryForBuffer
,
allocateMemoryForImage
, createBuffer
, createImage
instead whenever
possible.
withMemory :: forall io r. MonadIO io => Allocator -> MemoryRequirements -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
allocateMemory
and freeMemory
To ensure that freeMemory
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
allocateMemoryPages :: forall io. MonadIO io => Allocator -> ("vkMemoryRequirements" ::: Vector MemoryRequirements) -> ("createInfo" ::: Vector AllocationCreateInfo) -> io ("allocations" ::: Vector Allocation, "allocationInfo" ::: Vector AllocationInfo) Source #
General purpose memory allocation for multiple allocation objects at once.
Parameters
allocator | Allocator object. | |
pVkMemoryRequirements | Memory requirements for each allocation. | |
pCreateInfo | Creation parameters for each allocation. | |
allocationCount | Number of allocations to make. | |
out | pAllocations | Pointer to array that will be filled with handles to created allocations. |
out | pAllocationInfo | Optional. Pointer to array that will be filled with parameters of created allocations. |
You should free the memory using freeMemory
or freeMemoryPages
.
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 allocateMemory
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
.
withMemoryPages :: forall io r. MonadIO io => Allocator -> Vector MemoryRequirements -> Vector AllocationCreateInfo -> (io (Vector Allocation, Vector AllocationInfo) -> ((Vector Allocation, Vector AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
allocateMemoryPages
and freeMemoryPages
To ensure that freeMemoryPages
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
allocateMemoryForBuffer :: forall io. MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> io (Allocation, AllocationInfo) Source #
Allocates memory suitable for given VkBuffer
.
Parameters
allocator | ||
buffer | ||
pCreateInfo | ||
out | pAllocation | Handle to allocated memory. |
out | pAllocationInfo | Optional. Information about allocated memory.
It can be later fetched using function
getAllocationInfo . |
It only creates Allocation
. To bind the memory to the buffer, use
bindBufferMemory
.
This is a special-purpose function. In most cases you should use
createBuffer
.
You must free the allocation using freeMemory
when no longer needed.
withMemoryForBuffer :: forall io r. MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
allocateMemoryForBuffer
and freeMemory
To ensure that freeMemory
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
allocateMemoryForImage :: forall io. MonadIO io => Allocator -> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo) Source #
Allocates memory suitable for given VkImage
.
Parameters
allocator | ||
image | ||
pCreateInfo | ||
out | pAllocation | Handle to allocated memory. |
out | pAllocationInfo | Optional. Information about allocated memory.
It can be later fetched using function
getAllocationInfo . |
It only creates Allocation
. To bind the memory to the buffer, use
bindImageMemory
.
This is a special-purpose function. In most cases you should use
createImage
.
You must free the allocation using freeMemory
when no longer needed.
withMemoryForImage :: forall io r. MonadIO io => Allocator -> Image -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
allocateMemoryForImage
and freeMemory
To ensure that freeMemory
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
freeMemory :: forall io. MonadIO io => Allocator -> Allocation -> io () Source #
Frees memory previously allocated using allocateMemory
,
allocateMemoryForBuffer
, or allocateMemoryForImage
.
Passing VK_NULL_HANDLE
as allocation
is valid. Such function call is
just skipped.
freeMemoryPages :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> io () Source #
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. allocateMemory
,
allocateMemoryPages
and other functions. It may be internally
optimized to be more efficient than calling freeMemory
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 :: forall io. MonadIO io => Allocator -> Allocation -> io AllocationInfo Source #
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
AllocationInfo
structure while creating your resource, from function
createBuffer
, createImage
. You can remember it if you are sure
parameters don't change (e.g. due to defragmentation).
setAllocationUserData :: forall io. MonadIO io => Allocator -> Allocation -> ("userData" ::: Ptr ()) -> io () Source #
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 :: forall io. MonadIO io => Allocator -> Allocation -> ("name" ::: Maybe ByteString) -> io () Source #
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 :: forall io. MonadIO io => Allocator -> Allocation -> io MemoryPropertyFlags Source #
Given an allocation, returns Property Flags of its memory type.
This is just a convenience function. Same information can be obtained
using getAllocationInfo
+ getMemoryProperties
.
mapMemory :: forall io. MonadIO io => Allocator -> Allocation -> io ("data" ::: Ptr ()) Source #
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 unmapMemory
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 unmapMemory
same number of times as you
called mapMemory
.
It is also safe to call this function on allocation created with
ALLOCATION_CREATE_MAPPED_BIT
flag. Its memory stays mapped all the
time. You must still call unmapMemory
same number of times as you
called mapMemory
. You must not call unmapMemory
additional time to
free the "0-th" mapping made automatically due to
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 invalidateAllocation
/ flushAllocation
, as
required by Vulkan specification.
withMappedMemory :: forall io r. MonadIO io => Allocator -> Allocation -> (io (Ptr ()) -> (Ptr () -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to mapMemory
and unmapMemory
To ensure that unmapMemory
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
unmapMemory :: forall io. MonadIO io => Allocator -> Allocation -> io () Source #
Unmaps memory represented by given allocation, mapped previously using
mapMemory
.
For details, see description of mapMemory
.
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 invalidateAllocation
/ flushAllocation
, as
required by Vulkan specification.
flushAllocation :: forall io. MonadIO io => Allocator -> Allocation -> ("offset" ::: DeviceSize) -> DeviceSize -> io () Source #
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 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
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 :: forall io. MonadIO io => Allocator -> Allocation -> ("offset" ::: DeviceSize) -> DeviceSize -> io () Source #
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 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
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 :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("offsets" ::: Vector DeviceSize) -> ("sizes" ::: Vector DeviceSize) -> io () Source #
Flushes memory of given set of allocations.
Calls vkFlushMappedMemoryRanges()
for memory associated with given
ranges of given allocations. For more information, see documentation of
flushAllocation
.
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 ofsets 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. |
This function returns the VkResult
from vkFlushMappedMemoryRanges
if
it is called, otherwise VK_SUCCESS
.
invalidateAllocations :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("offsets" ::: Vector DeviceSize) -> ("sizes" ::: Vector DeviceSize) -> io () Source #
Invalidates memory of given set of allocations.
Calls vkInvalidateMappedMemoryRanges()
for memory associated with
given ranges of given allocations. For more information, see
documentation of invalidateAllocation
.
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 ofsets 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. |
This function returns the VkResult
from
vkInvalidateMappedMemoryRanges
if it is called, otherwise
VK_SUCCESS
.
checkCorruption :: forall io. MonadIO io => Allocator -> ("memoryTypeBits" ::: Word32) -> io () Source #
Checks magic number in margins around all allocations in given memory types (in both default and custom pools) in search for corruptions.
Parameters
allocator | |
memoryTypeBits | Bit mask, where each bit set means that a memory type with that index should be checked. |
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.
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.
beginDefragmentation :: forall io. MonadIO io => Allocator -> DefragmentationInfo -> io DefragmentationContext Source #
Begins defragmentation process.
Parameters
allocator | Allocator object. | |
pInfo | Structure filled with parameters of defragmentation. | |
out | pContext | Context object that must be passed to
endDefragmentation to finish
defragmentation. |
Returns
VK_SUCCESS
if defragmentation can begin.VK_ERROR_FEATURE_NOT_PRESENT
if defragmentation is not supported.
For more information about defragmentation, see documentation chapter: Defragmentation.
withDefragmentation :: forall io r. MonadIO io => Allocator -> DefragmentationInfo -> (io DefragmentationContext -> (DefragmentationContext -> io DefragmentationStats) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
beginDefragmentation
and endDefragmentation
To ensure that endDefragmentation
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
endDefragmentation :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io DefragmentationStats Source #
Ends defragmentation process.
Parameters
allocator | Allocator object. | |
context | Context object that has been created by
beginDefragmentation . | |
out | pStats | Optional stats for the defragmentation. Can be null. |
Use this function to finish defragmentation started by
beginDefragmentation
.
beginDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ("passInfo" ::: DefragmentationPassMoveInfo) Source #
Starts single defragmentation pass.
Parameters
allocator | Allocator object. | |
context | Context object that has been created by
beginDefragmentation . | |
out | pPassInfo | Computed information for current pass. |
Returns
VK_SUCCESS
if no more moves are possible. Then you can omit call toendDefragmentationPass
and simply end whole defragmentation.VK_INCOMPLETE
if there are pending moves returned inpPassInfo
. You need to perform them, callendDefragmentationPass
, and then preferably try another pass withbeginDefragmentationPass
.
useDefragmentationPass :: forall io r. MonadIO io => Allocator -> DefragmentationContext -> (DefragmentationPassMoveInfo -> io r) -> io ("passInfo" ::: DefragmentationPassMoveInfo, r) Source #
This function will call the supplied action between calls to
beginDefragmentationPass
and endDefragmentationPass
Note that endDefragmentationPass
is *not* called if an exception is
thrown by the inner action.
endDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ("passInfo" ::: DefragmentationPassMoveInfo) Source #
Ends single defragmentation pass.
Parameters
allocator | Allocator object. |
context | Context object that has been created by
beginDefragmentation . |
pPassInfo | Computed information for current pass filled by
beginDefragmentationPass and possibly modified by
you. |
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 hadpPassInfo[i].operation ==
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 ==
DEFRAGMENTATION_MOVE_OPERATION_DESTROY
will be freed.
If no more moves are possible you can end whole defragmentation.
bindBufferMemory :: forall io. MonadIO io => Allocator -> Allocation -> Buffer -> io () Source #
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 createBuffer
instead of this one.
bindBufferMemory2 :: forall io. MonadIO io => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> Buffer -> ("next" ::: Ptr ()) -> io () Source #
Binds buffer to allocation with additional parameters.
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. |
This function is similar to bindBufferMemory
, but it provides
additional parameters.
If pNext
is not null, Allocator
object must have been created with
ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT
flag or with
VmaAllocatorCreateInfo::vulkanApiVersion >= VK_API_VERSION_1_1
.
Otherwise the call fails.
bindImageMemory :: forall io. MonadIO io => Allocator -> Allocation -> Image -> io () Source #
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 createImage
instead of this one.
bindImageMemory2 :: forall io. MonadIO io => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> Image -> ("next" ::: Ptr ()) -> io () Source #
Binds image to allocation with additional parameters.
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. |
This function is similar to bindImageMemory
, but it provides
additional parameters.
If pNext
is not null, Allocator
object must have been created with
ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT
flag or with
VmaAllocatorCreateInfo::vulkanApiVersion >= VK_API_VERSION_1_1
.
Otherwise the call fails.
createBuffer :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> io (Buffer, Allocation, AllocationInfo) Source #
Creates a new VkBuffer
, allocates and binds memory for it.
Parameters
allocator | ||
pBufferCreateInfo | ||
pAllocationCreateInfo | ||
out | pBuffer | Buffer that was created. |
out | pAllocation | Allocation that was created. |
out | pAllocationInfo | Optional. Information about allocated memory.
It can be later fetched using function
getAllocationInfo . |
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
destroyBuffer
or separately, using vkDestroyBuffer()
and
freeMemory
.
If 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
(ALLOCATION_CREATE_NEVER_ALLOCATE_BIT
is not used), it creates
dedicated allocation for this buffer, just like when using
ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
.
Note
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.
withBuffer :: forall a io r. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> (io (Buffer, Allocation, AllocationInfo) -> ((Buffer, Allocation, AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
createBuffer
and destroyBuffer
To ensure that destroyBuffer
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
createBufferWithAlignment :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> BufferCreateInfo a -> AllocationCreateInfo -> ("minAlignment" ::: DeviceSize) -> io (Buffer, Allocation, AllocationInfo) Source #
Creates a buffer with additional minimum alignment.
Similar to createBuffer
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 :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> BufferCreateInfo a -> io Buffer Source #
Creates a new VkBuffer
, binds already created memory for it.
Parameters
allocator | ||
allocation | Allocation that provides memory to be used for binding new buffer to it. | |
pBufferCreateInfo | ||
out | pBuffer | Buffer that was created. |
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
destroyBuffer
.
Note
There is a new version of this function augmented with parameter
allocationLocalOffset
- see createAliasingBuffer2
.
createAliasingBuffer2 :: forall a io. (Extendss BufferCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> BufferCreateInfo a -> io Buffer Source #
Creates a new VkBuffer
, binds already created memory for it.
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 | ||
out | pBuffer | Buffer that was created. |
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
destroyBuffer
.
Note
This is a new version of the function augmented with parameter
allocationLocalOffset
.
destroyBuffer :: forall io. MonadIO io => Allocator -> Buffer -> Allocation -> io () Source #
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 :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> io (Image, Allocation, AllocationInfo) Source #
Function similar to createBuffer
.
withImage :: forall a io r. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> ImageCreateInfo a -> AllocationCreateInfo -> (io (Image, Allocation, AllocationInfo) -> ((Image, Allocation, AllocationInfo) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
createImage
and destroyImage
To ensure that destroyImage
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
createAliasingImage :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ImageCreateInfo a -> io Image Source #
Function similar to createAliasingBuffer
but for images.
createAliasingImage2 :: forall a io. (Extendss ImageCreateInfo a, PokeChain a, MonadIO io) => Allocator -> Allocation -> ("allocationLocalOffset" ::: DeviceSize) -> ImageCreateInfo a -> io Image Source #
Function similar to createAliasingBuffer2
but for images.
destroyImage :: forall io. MonadIO io => Allocator -> Image -> Allocation -> io () Source #
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 :: forall io. MonadIO io => VirtualBlockCreateInfo -> io VirtualBlock Source #
Creates new VirtualBlock
object.
Parameters
pCreateInfo | Parameters for creation. | |
out | pVirtualBlock | Returned virtual block object or VMA_NULL
if creation failed. |
withVirtualBlock :: forall io r. MonadIO io => VirtualBlockCreateInfo -> (io VirtualBlock -> (VirtualBlock -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
createVirtualBlock
and destroyVirtualBlock
To ensure that destroyVirtualBlock
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
destroyVirtualBlock :: forall io. MonadIO io => VirtualBlock -> io () Source #
Destroys VirtualBlock
object.
Please note that you should consciously handle virtual allocations that
could remain unfreed in the block. You should either free them
individually using virtualFree
or call clearVirtualBlock
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 :: forall io. MonadIO io => VirtualBlock -> io Bool Source #
Returns true of the VirtualBlock
is empty - contains 0 virtual
allocations and has all its space available for new allocations.
getVirtualAllocationInfo :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> io ("virtualAllocInfo" ::: VirtualAllocationInfo) Source #
Returns information about a specific virtual allocation within a virtual
block, like its size and pUserData
pointer.
virtualAllocate :: forall io. MonadIO io => VirtualBlock -> VirtualAllocationCreateInfo -> io (VirtualAllocation, "offset" ::: DeviceSize) Source #
Allocates new virtual allocation inside given VirtualBlock
.
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 | |
out | pAllocation | Returned handle of the new allocation |
out | pOffset | Returned offset of the new allocation. Optional, can be null. |
withVirtualAllocation :: forall io r. MonadIO io => VirtualBlock -> VirtualAllocationCreateInfo -> (io (VirtualAllocation, DeviceSize) -> ((VirtualAllocation, DeviceSize) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
virtualAllocate
and virtualFree
To ensure that virtualFree
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the last argument.
To just extract the pair pass (,)
as the last argument.
virtualFree :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> io () Source #
Frees virtual allocation inside given VirtualBlock
.
It is correct to call this function with allocation == VK_NULL_HANDLE
- it does nothing.
clearVirtualBlock :: forall io. MonadIO io => VirtualBlock -> io () Source #
Frees all virtual allocations inside given VirtualBlock
.
You must either call this function or free each virtual allocation
individually with virtualFree
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 :: forall io. MonadIO io => VirtualBlock -> VirtualAllocation -> ("userData" ::: Ptr ()) -> io () Source #
Changes custom pointer associated with given virtual allocation.
getVirtualBlockStatistics :: forall io. MonadIO io => VirtualBlock -> io ("stats" ::: Statistics) Source #
Calculates and returns statistics about virtual allocations and memory
usage in given VirtualBlock
.
This function is fast to call. For more detailed statistics, see
calculateVirtualBlockStatistics
.
calculateVirtualBlockStatistics :: forall io. MonadIO io => VirtualBlock -> io ("stats" ::: DetailedStatistics) Source #
Calculates and returns detailed statistics about virtual allocations and
memory usage in given VirtualBlock
.
This function is slow to call. Use for debugging purposes. For less
detailed statistics, see getVirtualBlockStatistics
.
buildVirtualBlockStatsString :: forall io. MonadIO io => VirtualBlock -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar) Source #
Builds and returns a null-terminated string in JSON format with
information about given VirtualBlock
.
Parameters
virtualBlock | Virtual block. | |
out | ppStatsString | Returned string. |
detailedMap | Pass VK_FALSE to only obtain statistics as
returned by
calculateVirtualBlockStatistics . Pass
VK_TRUE to also obtain full list of
allocations and free spaces. |
Returned string must be freed using freeVirtualBlockStatsString
.
freeVirtualBlockStatsString :: forall io. MonadIO io => VirtualBlock -> ("statsString" ::: Ptr CChar) -> io () Source #
Frees a string returned by buildVirtualBlockStatsString
.
buildStatsString :: forall io. MonadIO io => Allocator -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar) Source #
Builds and returns statistics as a null-terminated string in JSON format.
Parameters
allocator | ||
out | ppStatsString | Must be freed using freeStatsString
function. |
detailedMap |
freeStatsString :: forall io. MonadIO io => Allocator -> ("statsString" ::: Ptr CChar) -> io () Source #
newtype AllocatorCreateFlagBits Source #
Flags for created Allocator
.
Constructors
AllocatorCreateFlagBits Flags |
Bundled Patterns
pattern ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT :: AllocatorCreateFlagBits | Allocator and all objects created from it will not be synchronized internally, so you must guarantee they are used from only one thread at a time or synchronized externally by you. Using this flag may increase performance because internal mutexes are not used. |
pattern ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT :: AllocatorCreateFlagBits | Enables usage of VK_KHR_dedicated_allocation extension. The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion
Using this extension will automatically allocate dedicated blocks of
memory for some buffers and images instead of suballocating place for
them out of bigger memory blocks (as if you explicitly used
You may set this flag only if you found out that following device extensions are supported, you enabled them while creating Vulkan device passed as VmaAllocatorCreateInfo::device, and you want them to be used internally by this library:
When this flag is set, you can experience following warnings reported by Vulkan validation layer. You can ignore them. vkBindBufferMemory(): Binding memory to buffer 0x2d but vkGetBufferMemoryRequirements() has not been called on that buffer. |
pattern ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT :: AllocatorCreateFlagBits | Enables usage of VK_KHR_bind_memory2 extension. The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion
You may set this flag only if you found out that this device extension is supported, you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device, and you want it to be used internally by this library. The extension provides functions |
pattern ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT :: AllocatorCreateFlagBits | Enables usage of VK_EXT_memory_budget extension. You may set this flag only if you found out that this device extension is supported, you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device, and you want it to be used internally by this library, along with another instance extension VK_KHR_get_physical_device_properties2, which is required by it (or Vulkan 1.1, where this extension is promoted). The extension provides query for current memory usage and budget, which will probably be more accurate than an estimation used by the library otherwise. |
pattern ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT :: AllocatorCreateFlagBits | Enables usage of VK_AMD_device_coherent_memory extension. You may set this flag only if you:
The extension and accompanying device feature provide access to memory
types with When the extension is not enabled, such memory types are still
enumerated, but their usage is illegal. To protect from this error, if
you don't create the allocator with this flag, it will refuse to
allocate any memory or create a custom pool in such memory type,
returning |
pattern ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT :: AllocatorCreateFlagBits | Enables usage of "buffer device address" feature, which allows you to
use function You may set this flag only if you:
When this flag is set, you can create buffers with
For more information, see documentation chapter /Enabling buffer device address/. |
pattern ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT :: AllocatorCreateFlagBits | Enables usage of VK_EXT_memory_priority extension in the library. You may set this flag only if you found available and enabled this
device extension, along with
When this flag is used, VmaAllocationCreateInfo::priority and VmaPoolCreateInfo::priority are used to set priorities of allocated Vulkan memory. Without it, these variables are ignored. A priority must be a floating-point value between 0 and 1, indicating
the priority of the allocation relative to other memory allocations.
Larger values are higher priority. The granularity of the priorities is
implementation-dependent. It is automatically passed to every call to
|
Instances
newtype MemoryUsage Source #
Intended usage of the allocated memory.
Constructors
MemoryUsage Int32 |
Bundled Patterns
pattern MEMORY_USAGE_UNKNOWN :: MemoryUsage | No intended memory usage specified. Use other members of
|
pattern MEMORY_USAGE_GPU_ONLY :: MemoryUsage | Deprecated Obsolete, preserved for backward compatibility. Prefers
|
pattern MEMORY_USAGE_CPU_ONLY :: MemoryUsage | Deprecated Obsolete, preserved for backward compatibility. Guarantees
|
pattern MEMORY_USAGE_CPU_TO_GPU :: MemoryUsage | Deprecated Obsolete, preserved for backward compatibility. Guarantees
|
pattern MEMORY_USAGE_GPU_TO_CPU :: MemoryUsage | Deprecated Obsolete, preserved for backward compatibility. Guarantees
|
pattern MEMORY_USAGE_CPU_COPY :: MemoryUsage | Deprecated Obsolete, preserved for backward compatibility. Prefers not
|
pattern MEMORY_USAGE_GPU_LAZILY_ALLOCATED :: MemoryUsage | Lazily allocated GPU memory having
Usage: Memory for transient attachment images (color attachments, depth
attachments etc.), created with
Allocations with this usage are always created as dedicated - it implies
|
pattern MEMORY_USAGE_AUTO :: MemoryUsage | Selects best memory type automatically. This flag is recommended for most common use cases. When using this flag, if you want to map the allocation (using
It can be used only with functions that let the library know
|
pattern MEMORY_USAGE_AUTO_PREFER_DEVICE :: MemoryUsage | Selects best memory type automatically with preference for GPU (device) memory. When using this flag, if you want to map the allocation (using
It can be used only with functions that let the library know
|
pattern MEMORY_USAGE_AUTO_PREFER_HOST :: MemoryUsage | Selects best memory type automatically with preference for CPU (host) memory. When using this flag, if you want to map the allocation (using
It can be used only with functions that let the library know
|
Instances
newtype AllocationCreateFlagBits Source #
Flags to be passed as VmaAllocationCreateInfo::flags.
Constructors
AllocationCreateFlagBits Flags |
Bundled Patterns
pattern ALLOCATION_CREATE_DEDICATED_MEMORY_BIT :: AllocationCreateFlagBits | Set this flag if the allocation should have its own memory block. Use it for special, big resources, like fullscreen images used as attachments. |
pattern ALLOCATION_CREATE_NEVER_ALLOCATE_BIT :: AllocationCreateFlagBits | Set this flag to only try to allocate from existing If new allocation cannot be placed in any of the existing blocks,
allocation fails with You should not use |
pattern ALLOCATION_CREATE_MAPPED_BIT :: AllocationCreateFlagBits | Set this flag to use a memory that will be persistently mapped and retrieve pointer to it. Pointer to mapped memory will be returned through VmaAllocationInfo::pMappedData. It is valid to use this flag for allocation made from memory type that
is not |
pattern ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT :: AllocationCreateFlagBits | Deprecated Preserved for backward compatibility. Consider using Set this flag to treat VmaAllocationCreateInfo::pUserData as pointer
to a null-terminated string. Instead of copying pointer value, a local
copy of the string is made and stored in allocation's |
pattern ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: AllocationCreateFlagBits | Allocation will be created from upper stack in a double stack pool. This flag is only allowed for custom pools created with
|
pattern ALLOCATION_CREATE_DONT_BIND_BIT :: AllocationCreateFlagBits | Create both buffer/image and allocation, but don't bind them together.
It is useful when you want to bind yourself to do some more advanced
binding, e.g. using some extensions. The flag is meaningful only with
functions that bind by default: If you want to make sure the new buffer/image is not tied to the new
memory allocation through |
pattern ALLOCATION_CREATE_WITHIN_BUDGET_BIT :: AllocationCreateFlagBits | Create allocation only if additional device memory required for it, if
any, won't exceed memory budget. Otherwise return
|
pattern ALLOCATION_CREATE_CAN_ALIAS_BIT :: AllocationCreateFlagBits | Set this flag if the allocated memory will have aliasing resources. Usage of this flag prevents supplying |
pattern ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT :: AllocationCreateFlagBits | Requests possibility to map the allocation (using
Declares that mapped memory will only be written sequentially, e.g.
using Warning Violating this declaration may work correctly, but will likely be very
slow. Watch out for implicit reads introduced by doing e.g.
|
pattern ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT :: AllocationCreateFlagBits | Requests possibility to map the allocation (using
Declares that mapped memory can be read, written, and accessed in random
order, so a |
pattern ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT :: AllocationCreateFlagBits | Together with By using this flag, you declare that you will check if the allocation
ended up in a |
pattern ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses smallest possible free range for the allocation to minimize memory usage and fragmentation, possibly at the expense of allocation time. |
pattern ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses first suitable free range for the allocation - not necessarily in terms of the smallest offset but the one that is easiest and fastest to find to minimize allocation time, possibly at the expense of allocation quality. |
pattern ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses always the lowest offset in available space. This is not the most efficient strategy but achieves highly packed data. Used internally by defragmentation, not recommended in typical usage. |
pattern ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT :: AllocationCreateFlagBits | |
pattern ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: AllocationCreateFlagBits | Alias to |
pattern ALLOCATION_CREATE_STRATEGY_MASK :: AllocationCreateFlagBits | A bit mask to extract only |
Instances
type PoolCreateFlags = PoolCreateFlagBits Source #
newtype PoolCreateFlagBits Source #
Flags to be passed as VmaPoolCreateInfo::flags.
Constructors
PoolCreateFlagBits Flags |
Bundled Patterns
pattern POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT :: PoolCreateFlagBits | Use this flag if you always allocate only buffers and linear images or only optimal images out of this pool and so Buffer-Image Granularity can be ignored. This is an optional optimization flag. If you always allocate using If you also allocate using |
pattern POOL_CREATE_LINEAR_ALGORITHM_BIT :: PoolCreateFlagBits | Enables alternative, linear allocation algorithm in this pool. Specify this flag to enable linear allocation algorithm, which always creates new allocations after last one and doesn't reuse space from allocations freed in between. It trades memory consumption for simplified algorithm and data structure, which has better performance and uses less memory for metadata. By using this flag, you can achieve behavior of free-at-once, stack, ring buffer, and double stack. For details, see documentation chapter Linear allocation algorithm. |
pattern POOL_CREATE_ALGORITHM_MASK :: PoolCreateFlagBits | Bit mask to extract only |
Instances
newtype DefragmentationFlagBits Source #
Flags to be passed as VmaDefragmentationInfo::flags.
Constructors
DefragmentationFlagBits Flags |
Bundled Patterns
pattern DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT :: DefragmentationFlagBits | |
pattern DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT :: DefragmentationFlagBits | |
pattern DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT :: DefragmentationFlagBits | |
pattern DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT :: DefragmentationFlagBits | Use the most roboust algorithm at the cost of time to compute and number
of copies to make. Only available when bufferImageGranularity is greater
than 1, since it aims to reduce alignment issues between different types
of resources. Otherwise falls back to same behavior as
|
pattern DEFRAGMENTATION_FLAG_ALGORITHM_MASK :: DefragmentationFlagBits | A bit mask to extract only |
Instances
newtype DefragmentationMoveOperation Source #
Operation performed on single defragmentation move. See structure
DefragmentationMove
.
Constructors
DefragmentationMoveOperation Int32 |
Bundled Patterns
pattern DEFRAGMENTATION_MOVE_OPERATION_COPY :: DefragmentationMoveOperation | Buffer/image has been recreated at |
pattern DEFRAGMENTATION_MOVE_OPERATION_IGNORE :: DefragmentationMoveOperation | Set this value if you cannot move the allocation. New place reserved at
|
pattern DEFRAGMENTATION_MOVE_OPERATION_DESTROY :: DefragmentationMoveOperation | Set this value if you decide to abandon the allocation and you destroyed
the buffer/image. New place reserved at |
Instances
newtype VirtualBlockCreateFlagBits Source #
Flags to be passed as VmaVirtualBlockCreateInfo::flags.
Constructors
VirtualBlockCreateFlagBits Flags |
Bundled Patterns
pattern VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT :: VirtualBlockCreateFlagBits | Enables alternative, linear allocation algorithm in this virtual block. Specify this flag to enable linear allocation algorithm, which always creates new allocations after last one and doesn't reuse space from allocations freed in between. It trades memory consumption for simplified algorithm and data structure, which has better performance and uses less memory for metadata. By using this flag, you can achieve behavior of free-at-once, stack, ring buffer, and double stack. For details, see documentation chapter Linear allocation algorithm. |
pattern VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK :: VirtualBlockCreateFlagBits | Bit mask to extract only |
Instances
newtype VirtualAllocationCreateFlagBits Source #
Flags to be passed as VmaVirtualAllocationCreateInfo::flags.
Constructors
VirtualAllocationCreateFlagBits Flags |
Bundled Patterns
pattern VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: VirtualAllocationCreateFlagBits | Allocation will be created from upper stack in a double stack pool. This flag is only allowed for virtual blocks created with
|
pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: VirtualAllocationCreateFlagBits | Allocation strategy that tries to minimize memory usage. |
pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: VirtualAllocationCreateFlagBits | Allocation strategy that tries to minimize allocation time. |
pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: VirtualAllocationCreateFlagBits | Allocation strategy that chooses always the lowest offset in available space. This is not the most efficient strategy but achieves highly packed data. |
pattern VIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK :: VirtualAllocationCreateFlagBits | A bit mask to extract only These strategy flags are binary compatible with equivalent flags in
|
Instances
VmaAllocator
Represents main object of this library initialized.
Fill structure AllocatorCreateInfo
and call function createAllocator
to create it. Call function destroyAllocator
to destroy it.
It is recommended to create just one object of this type per VkDevice
object, right after Vulkan is initialized and keep it alive until before
Vulkan device is destroyed.
Instances
Storable Allocator Source # | |
Defined in VulkanMemoryAllocator | |
Show Allocator Source # | |
Eq Allocator Source # | |
Ord Allocator Source # | |
IsHandle Allocator Source # | |
Defined in VulkanMemoryAllocator | |
Zero Allocator Source # | |
Defined in VulkanMemoryAllocator |
VmaPool
Represents custom memory pool.
Fill structure PoolCreateInfo
and call function createPool
to create
it. Call function destroyPool
to destroy it.
For more information see Custom memory pools.
newtype Allocation Source #
VmaAllocation
Represents single memory allocation.
It may be either dedicated block of VkDeviceMemory
or a specific
region of a bigger block of this type plus unique offset.
There are multiple ways to create such object. You need to fill
structure AllocationCreateInfo
. For more information see /Choosing
memory type/.
Although the library provides convenience functions that create Vulkan buffer or image, allocate memory for it and bind them together, binding of the allocation to a buffer or an image is out of scope of the allocation itself. Allocation object can exist without buffer/image bound, binding can be done manually by the user, and destruction of it can be done independently of destruction of the allocation.
The object also remembers its size and some other information. To
retrieve this information, use function getAllocationInfo
and inspect
returned structure AllocationInfo
.
Constructors
Allocation Word64 |
Instances
newtype DefragmentationContext Source #
VmaDefragmentationContext
An opaque object that represents started defragmentation process.
Fill structure DefragmentationInfo
and call function
beginDefragmentation
to create it. Call function endDefragmentation
to destroy it.
Constructors
DefragmentationContext Word64 |
Instances
newtype VirtualAllocation Source #
VmaVirtualAllocation
Represents single memory allocation done inside VirtualBlock
.
Use it as a unique identifier to virtual allocation within the single block.
Use value VK_NULL_HANDLE
to represent a null/invalid allocation.
Constructors
VirtualAllocation Word64 |
Instances
newtype VirtualBlock Source #
VmaVirtualBlock
Handle to a virtual block object that allows to use core allocation algorithm without allocating any real GPU memory.
Fill in VirtualBlockCreateInfo
structure and use createVirtualBlock
to create it. Use destroyVirtualBlock
to destroy it. For more
information, see documentation chapter Virtual allocator.
This object is not thread-safe - should not be used from multiple threads simultaneously, must be synchronized externally.
Constructors
VirtualBlock Word64 |
Instances
type FN_vmaAllocateDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO () Source #
type FN_vmaFreeDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO () Source #
data DeviceMemoryCallbacks Source #
VmaDeviceMemoryCallbacks
Set of callbacks that the library will call for vkAllocateMemory
and
vkFreeMemory
.
Provided for informative purpose, e.g. to gather statistics about number of allocations or total amount of memory allocated in Vulkan.
Used in VmaAllocatorCreateInfo::pDeviceMemoryCallbacks.
Constructors
DeviceMemoryCallbacks | |
Fields
|
Instances
data VulkanFunctions Source #
VmaVulkanFunctions
Pointers to some Vulkan functions - a subset used by the library.
Used in VmaAllocatorCreateInfo::pVulkanFunctions.
Constructors
VulkanFunctions | |
Fields
|
Instances
data AllocatorCreateInfo Source #
VmaAllocatorCreateInfo
Description of a Allocator to be created.
Constructors
AllocatorCreateInfo | |
Fields
|
Instances
Show AllocatorCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods showsPrec :: Int -> AllocatorCreateInfo -> ShowS # show :: AllocatorCreateInfo -> String # showList :: [AllocatorCreateInfo] -> ShowS # | |
FromCStruct AllocatorCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods peekCStruct :: Ptr AllocatorCreateInfo -> IO AllocatorCreateInfo # | |
ToCStruct AllocatorCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods withCStruct :: AllocatorCreateInfo -> (Ptr AllocatorCreateInfo -> IO b) -> IO b # pokeCStruct :: Ptr AllocatorCreateInfo -> AllocatorCreateInfo -> IO b -> IO b # withZeroCStruct :: (Ptr AllocatorCreateInfo -> IO b) -> IO b # pokeZeroCStruct :: Ptr AllocatorCreateInfo -> IO b -> IO b # cStructSize :: Int # cStructAlignment :: Int # | |
Zero AllocatorCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods |
data AllocatorInfo Source #
VmaAllocatorInfo
Information about existing Allocator
object.
Constructors
AllocatorInfo | |
Fields
|
Instances
data Statistics Source #
VmaStatistics
Calculated statistics of memory usage e.g. in a specific memory type, heap, custom pool, or total.
These are fast to calculate. See functions: getHeapBudgets
,
getPoolStatistics
.
Constructors
Statistics | |
Fields
|
Instances
data DetailedStatistics Source #
VmaDetailedStatistics
More detailed statistics than Statistics
.
These are slower to calculate. Use for debugging purposes. See
functions: calculateStatistics
, calculatePoolStatistics
.
Previous version of the statistics API provided averages, but they have been removed because they can be easily calculated as:
VkDeviceSize allocationSizeAvg = detailedStats.statistics.allocationBytes / detailedStats.statistics.allocationCount; VkDeviceSize unusedBytes = detailedStats.statistics.blockBytes - detailedStats.statistics.allocationBytes; VkDeviceSize unusedRangeSizeAvg = unusedBytes / detailedStats.unusedRangeCount;
Constructors
DetailedStatistics | |
Fields
|
Instances
data TotalStatistics Source #
VmaTotalStatistics
DetailedStatistics
memoryType [VK_MAX_MEMORY_TYPES]DetailedStatistics
memoryHeap [VK_MAX_MEMORY_HEAPS]DetailedStatistics
total
General statistics from current state of the Allocator - total memory usage across all memory heaps and types.
These are slower to calculate. Use for debugging purposes. See function
calculateStatistics
.
memoryHeap
memoryHeap
VmaTotalStatistics
VmaTotalStatistics
memoryHeap
VmaDetailedStatistics VmaTotalStatistics::memoryHeap[VK_MAX_MEMORY_HEAPS]
memoryType
memoryType
VmaTotalStatistics
VmaTotalStatistics
memoryType
VmaDetailedStatistics VmaTotalStatistics::memoryType[VK_MAX_MEMORY_TYPES]
Constructors
TotalStatistics | |
Instances
VmaBudget
Statistics of current memory usage and available budget for a specific memory heap.
These are fast to calculate. See function getHeapBudgets
.
Constructors
Budget | |
Fields
|
Instances
Storable Budget Source # | |
Show Budget Source # | |
FromCStruct Budget Source # | |
Defined in VulkanMemoryAllocator | |
ToCStruct Budget Source # | |
Defined in VulkanMemoryAllocator | |
Zero Budget Source # | |
Defined in VulkanMemoryAllocator |
data AllocationCreateInfo Source #
VmaAllocationCreateInfo
Parameters of new Allocation
.
To be used with functions like createBuffer
, createImage
, and many
others.
Constructors
AllocationCreateInfo | |
Fields
|
Instances
data PoolCreateInfo Source #
VmaPoolCreateInfo
Describes parameter of created Pool
.
Constructors
PoolCreateInfo | |
Fields
|
Instances
data AllocationInfo Source #
VmaAllocationInfo
Parameters of Allocation
objects, that can be retrieved using function
getAllocationInfo
.
Constructors
AllocationInfo | |
Fields
|
Instances
Show AllocationInfo Source # | |
Defined in VulkanMemoryAllocator Methods showsPrec :: Int -> AllocationInfo -> ShowS # show :: AllocationInfo -> String # showList :: [AllocationInfo] -> ShowS # | |
FromCStruct AllocationInfo Source # | |
Defined in VulkanMemoryAllocator Methods | |
ToCStruct AllocationInfo Source # | |
Defined in VulkanMemoryAllocator Methods withCStruct :: AllocationInfo -> (Ptr AllocationInfo -> IO b) -> IO b # pokeCStruct :: Ptr AllocationInfo -> AllocationInfo -> IO b -> IO b # withZeroCStruct :: (Ptr AllocationInfo -> IO b) -> IO b # pokeZeroCStruct :: Ptr AllocationInfo -> IO b -> IO b # cStructSize :: Int # cStructAlignment :: Int # | |
Zero AllocationInfo Source # | |
Defined in VulkanMemoryAllocator Methods zero :: AllocationInfo # |
type PFN_vmaCheckDefragmentationBreakFunction = FunPtr FN_vmaCheckDefragmentationBreakFunction Source #
data DefragmentationInfo Source #
Constructors
DefragmentationInfo | |
Fields
|
Instances
data DefragmentationMove Source #
VmaDefragmentationMove
Single move of an allocation to be done for defragmentation.
Constructors
DefragmentationMove | |
Fields
|
Instances
data DefragmentationPassMoveInfo Source #
VmaDefragmentationPassMoveInfo
Parameters for incremental defragmentation steps.
To be used with function beginDefragmentationPass
.
Constructors
DefragmentationPassMoveInfo | |
Fields
|
Instances
data DefragmentationStats Source #
VmaDefragmentationStats
Statistics returned for defragmentation process in function
endDefragmentation
.
Constructors
DefragmentationStats | |
Fields
|
Instances
data VirtualBlockCreateInfo Source #
VmaVirtualBlockCreateInfo
Parameters of created VirtualBlock
object to be passed to
createVirtualBlock
.
Constructors
VirtualBlockCreateInfo | |
Fields
|
Instances
Show VirtualBlockCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods showsPrec :: Int -> VirtualBlockCreateInfo -> ShowS # show :: VirtualBlockCreateInfo -> String # showList :: [VirtualBlockCreateInfo] -> ShowS # | |
FromCStruct VirtualBlockCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods peekCStruct :: Ptr VirtualBlockCreateInfo -> IO VirtualBlockCreateInfo # | |
ToCStruct VirtualBlockCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods withCStruct :: VirtualBlockCreateInfo -> (Ptr VirtualBlockCreateInfo -> IO b) -> IO b # pokeCStruct :: Ptr VirtualBlockCreateInfo -> VirtualBlockCreateInfo -> IO b -> IO b # withZeroCStruct :: (Ptr VirtualBlockCreateInfo -> IO b) -> IO b # pokeZeroCStruct :: Ptr VirtualBlockCreateInfo -> IO b -> IO b # cStructSize :: Int # cStructAlignment :: Int # | |
Zero VirtualBlockCreateInfo Source # | |
Defined in VulkanMemoryAllocator Methods |
data VirtualAllocationCreateInfo Source #
VmaVirtualAllocationCreateInfo
Parameters of created virtual allocation to be passed to
virtualAllocate
.
Constructors
VirtualAllocationCreateInfo | |
Fields
|
Instances
data VirtualAllocationInfo Source #
VmaVirtualAllocationInfo
Parameters of an existing virtual allocation, returned by
getVirtualAllocationInfo
.
Constructors
VirtualAllocationInfo | |
Fields
|