Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 ()
- calculateStats :: forall io. MonadIO io => Allocator -> io Stats
- getBudget :: forall io. MonadIO io => Allocator -> io Budget
- buildStatsString :: forall io. MonadIO io => Allocator -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar)
- freeStatsString :: forall io. MonadIO io => Allocator -> ("statsString" ::: Ptr CChar) -> 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 ()
- getPoolStats :: forall io. MonadIO io => Allocator -> Pool -> io PoolStats
- makePoolAllocationsLost :: forall io. MonadIO io => Allocator -> Pool -> io ("lostAllocationCount" ::: Word64)
- 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 ()
- resizeAllocation :: forall io. MonadIO io => Allocator -> Allocation -> ("newSize" ::: DeviceSize) -> io ()
- getAllocationInfo :: forall io. MonadIO io => Allocator -> Allocation -> io AllocationInfo
- touchAllocation :: forall io. MonadIO io => Allocator -> Allocation -> io Bool
- setAllocationUserData :: forall io. MonadIO io => Allocator -> Allocation -> ("userData" ::: Ptr ()) -> io ()
- createLostAllocation :: forall io. MonadIO io => Allocator -> io Allocation
- withLostAllocation :: forall io r. MonadIO io => Allocator -> (io Allocation -> (Allocation -> io ()) -> r) -> r
- 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 ()
- defragmentationBegin :: forall io. MonadIO io => Allocator -> DefragmentationInfo2 -> io (Result, DefragmentationStats, DefragmentationContext)
- withDefragmentation :: forall io r. MonadIO io => Allocator -> DefragmentationInfo2 -> (io (Result, DefragmentationStats, DefragmentationContext) -> ((Result, DefragmentationStats, DefragmentationContext) -> io ()) -> r) -> r
- defragmentationEnd :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ()
- beginDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io DefragmentationPassInfo
- useDefragmentationPass :: forall io r. MonadIO io => Allocator -> DefragmentationContext -> (DefragmentationPassInfo -> io r) -> io r
- endDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io ()
- defragment :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("defragmentationInfo" ::: Maybe DefragmentationInfo) -> io ("allocationsChanged" ::: Vector Bool, DefragmentationStats)
- 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
- 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
- destroyImage :: forall io. MonadIO io => Allocator -> Image -> Allocation -> io ()
- newtype Allocator = Allocator 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 {}
- 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
- type AllocatorCreateFlags = AllocatorCreateFlagBits
- data VulkanFunctions = VulkanFunctions {
- 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
- newtype RecordFlagBits where
- type RecordFlags = RecordFlagBits
- data RecordSettings = RecordSettings {}
- data AllocatorCreateInfo = AllocatorCreateInfo {
- flags :: AllocatorCreateFlags
- physicalDevice :: Ptr PhysicalDevice_T
- device :: Ptr Device_T
- preferredLargeHeapBlockSize :: DeviceSize
- allocationCallbacks :: Maybe AllocationCallbacks
- deviceMemoryCallbacks :: Maybe DeviceMemoryCallbacks
- frameInUseCount :: Word32
- heapSizeLimit :: Ptr DeviceSize
- vulkanFunctions :: Maybe VulkanFunctions
- recordSettings :: Maybe RecordSettings
- instance' :: Ptr Instance_T
- vulkanApiVersion :: Word32
- data AllocatorInfo = AllocatorInfo {}
- data StatInfo = StatInfo {
- blockCount :: Word32
- allocationCount :: Word32
- unusedRangeCount :: Word32
- usedBytes :: DeviceSize
- unusedBytes :: DeviceSize
- allocationSizeMin :: DeviceSize
- allocationSizeAvg :: DeviceSize
- allocationSizeMax :: DeviceSize
- unusedRangeSizeMin :: DeviceSize
- unusedRangeSizeAvg :: DeviceSize
- unusedRangeSizeMax :: DeviceSize
- data Stats = Stats {}
- data Budget = Budget {}
- newtype Pool = Pool Word64
- 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
- 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_CAN_BECOME_LOST_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_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_STRATEGY_BEST_FIT_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT :: AllocationCreateFlagBits
- pattern ALLOCATION_CREATE_STRATEGY_MASK :: AllocationCreateFlagBits
- type AllocationCreateFlags = AllocationCreateFlagBits
- data AllocationCreateInfo = AllocationCreateInfo {}
- newtype PoolCreateFlagBits where
- type PoolCreateFlags = PoolCreateFlagBits
- data PoolCreateInfo = PoolCreateInfo {}
- data PoolStats = PoolStats {}
- newtype Allocation = Allocation Word64
- data AllocationInfo = AllocationInfo {
- memoryType :: Word32
- deviceMemory :: DeviceMemory
- offset :: DeviceSize
- size :: DeviceSize
- mappedData :: Ptr ()
- userData :: Ptr ()
- newtype DefragmentationContext = DefragmentationContext Word64
- newtype DefragmentationFlagBits where
- type DefragmentationFlags = DefragmentationFlagBits
- data DefragmentationInfo2 = DefragmentationInfo2 {}
- data DefragmentationPassMoveInfo = DefragmentationPassMoveInfo {}
- data DefragmentationPassInfo = DefragmentationPassInfo {}
- data DefragmentationInfo = DefragmentationInfo {}
- data DefragmentationStats = DefragmentationStats {}
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 first argument.
To just extract the pair pass (,)
as the first 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.
This function must be used if you make allocations with
ALLOCATION_CREATE_CAN_BECOME_LOST_BIT
and
ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT
flags to inform the
allocator when a new frame begins. Allocations queried using
getAllocationInfo
cannot become lost in the current frame.
calculateStats :: forall io. MonadIO io => Allocator -> io Stats 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. For
faster but more brief statistics suitable to be called every frame or
every allocation, use getBudget
.
Note that when using allocator from multiple threads, returned information may immediately become outdated.
getBudget :: forall io. MonadIO io => Allocator -> io Budget Source #
Retrieves information about current memory budget for all memory heaps.
Parameters.
out | pBudget | 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 calculateStats
.
Note that when using allocator from multiple threads, returned information may immediately become outdated.
buildStatsString :: forall io. MonadIO io => Allocator -> ("detailedMap" ::: Bool) -> io ("statsString" ::: Ptr CChar) Source #
Builds and returns statistics as string in JSON format.
Parameters.
out | ppStatsString | Must be freed using freeStatsString
function. |
freeStatsString :: forall io. MonadIO io => Allocator -> ("statsString" ::: Ptr CChar) -> io () Source #
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. It is just a convenience function, equivalent to calling:
vkCreateBuffer
vkGetBufferMemoryRequirements
findMemoryTypeIndex
vkDestroyBuffer
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. It is just a convenience function, equivalent to calling:
vkCreateImage
vkGetImageMemoryRequirements
findMemoryTypeIndex
vkDestroyImage
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 first argument.
To just extract the pair pass (,)
as the first argument.
destroyPool :: forall io. MonadIO io => Allocator -> Pool -> io () Source #
Destroys Pool
object and frees Vulkan device memory.
getPoolStats :: forall io. MonadIO io => Allocator -> Pool -> io PoolStats Source #
Retrieves statistics of existing Pool
object.
Parameters.
allocator | Allocator object. | |
pool | Pool object. | |
out | pPoolStats | Statistics of specified pool. |
makePoolAllocationsLost :: forall io. MonadIO io => Allocator -> Pool -> io ("lostAllocationCount" ::: Word64) Source #
Marks all allocations in given pool as lost if they are not used in current frame or VmaPoolCreateInfo::frameInUseCount back from now.
Parameters.
allocator | Allocator object. | |
pool | Pool. | |
out | pLostAllocationCount | Number of allocations marked as lost. Optional - pass null if you don't need this information. |
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_VALIDATION_FAILED_EXT
- 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.
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 first argument.
To just extract the pair pass (,)
as the first 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 alloction. | |
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 first argument.
To just extract the pair pass (,)
as the first argument.
allocateMemoryForBuffer :: forall io. MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> io (Allocation, AllocationInfo) Source #
Parameters.
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
.
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 first argument.
To just extract the pair pass (,)
as the first argument.
allocateMemoryForImage :: forall io. MonadIO io => Allocator -> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo) Source #
Function similar to allocateMemoryForBuffer
.
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 first argument.
To just extract the pair pass (,)
as the first 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.
resizeAllocation :: forall io. MonadIO io => Allocator -> Allocation -> ("newSize" ::: DeviceSize) -> io () Source #
Deprecated.
Deprecated
In version 2.2.0 it used to try to change allocation's size without
moving or reallocating it. In current version it returns VK_SUCCESS
only if newSize
equals current allocation's size. Otherwise returns
VK_ERROR_OUT_OF_POOL_MEMORY
, indicating that allocation's size could
not be changed.
getAllocationInfo :: forall io. MonadIO io => Allocator -> Allocation -> io AllocationInfo Source #
Returns current information about specified allocation and atomically marks it as used in current frame.
Current paramters of given allocation are returned in pAllocationInfo
.
This function also atomically "touches" allocation - marks it as used
in current frame, just like touchAllocation
. If the allocation is in
lost state, pAllocationInfo->deviceMemory == VK_NULL_HANDLE
.
Although this function uses atomics and doesn't lock any mutex, so it should be quite efficient, you can avoid calling it too often.
- You can retrieve same
AllocationInfo
structure while creating your resource, from functioncreateBuffer
,createImage
. You can remember it if you are sure parameters don't change (e.g. due to defragmentation or allocation becoming lost). - If you just want to check if allocation is not lost,
touchAllocation
will work faster.
touchAllocation :: forall io. MonadIO io => Allocator -> Allocation -> io Bool Source #
Returns VK_TRUE
if allocation is not lost and atomically marks it as
used in current frame.
If the allocation has been created with
ALLOCATION_CREATE_CAN_BECOME_LOST_BIT
flag, this function returns
VK_TRUE
if it's not in lost state, so it can still be used. It then
also atomically "touches" the allocation - marks it as used in current
frame, so that you can be sure it won't become lost in current frame or
next frameInUseCount
frames.
If the allocation is in lost state, the function returns VK_FALSE
.
Memory of such allocation, as well as buffer or image bound to it,
should not be used. Lost allocation and the buffer/image still need to
be destroyed.
If the allocation has been created without
ALLOCATION_CREATE_CAN_BECOME_LOST_BIT
flag, this function always
returns VK_TRUE
.
setAllocationUserData :: forall io. MonadIO io => Allocator -> Allocation -> ("userData" ::: Ptr ()) -> io () Source #
Sets pUserData in given allocation to new value.
If the allocation was created with
VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT, pUserData 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 pUserData
.
String passed as pUserData 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 pUserData is freed from memory.
If the flag was not used, the value of pointer pUserData
is just
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.
createLostAllocation :: forall io. MonadIO io => Allocator -> io Allocation Source #
Creates new allocation that is in lost state from the beginning.
It can be useful if you need a dummy, non-null allocation.
You still need to destroy created object using freeMemory
.
Returned allocation is not tied to any specific memory pool or memory type and not bound to any image or buffer. It has size = 0. It cannot be turned into a real, non-empty allocation.
withLostAllocation :: forall io r. MonadIO io => Allocator -> (io Allocation -> (Allocation -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
createLostAllocation
and freeMemory
To ensure that freeMemory
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the first argument.
To just extract the pair pass (,)
as the first argument.
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. If the allocation is part of bigger VkDeviceMemory
block, the
pointer is correctly offseted to the beginning of region assigned to
this particular allocation.
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 always fails when called for allocation that was created
with ALLOCATION_CREATE_CAN_BECOME_LOST_BIT
flag. Such allocations
cannot be mapped.
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 first argument.
To just extract the pair pass (,)
as the first 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.
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_VALIDATION_FAILED_EXT
- 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.
defragmentationBegin :: forall io. MonadIO io => Allocator -> DefragmentationInfo2 -> io (Result, DefragmentationStats, DefragmentationContext) Source #
Begins defragmentation process.
Parameters.
allocator | Allocator object. | |
pInfo | Structure filled with parameters of defragmentation. | |
out | pStats | Optional. Statistics of defragmentation. You can pass null if you are not interested in this information. |
out | pContext | Context object that must be passed to
defragmentationEnd to finish
defragmentation. |
Returns.
VK_SUCCESS
and *pContext == null
if defragmentation finished within
this function call. VK_NOT_READY
and *pContext != null
if
defragmentation has been started and you need to call
defragmentationEnd
to finish it. Negative value in case of error.
Use this function instead of old, deprecated defragment
.
Warning! Between the call to defragmentationBegin
and
defragmentationEnd
:
- You should not use any of allocations passed as
pInfo->pAllocations
or any allocations that belong to pools passed aspInfo->pPools
, including callinggetAllocationInfo
,touchAllocation
, or access their data. - Some mutexes protecting internal data structures may be locked, so trying to make or free any allocations, bind buffers or images, map memory, or launch another simultaneous defragmentation in between may cause stall (when done on another thread) or deadlock (when done on the same thread), unless you are 100% sure that defragmented allocations are in different pools.
- Information returned via
pStats
andpInfo->pAllocationsChanged
are undefined. They become valid after call todefragmentationEnd
. - If
pInfo->commandBuffer
is not null, you must submit that command buffer and make sure it finished execution before callingdefragmentationEnd
.
For more information and important limitations regarding defragmentation, see documentation chapter: Defragmentation.
withDefragmentation :: forall io r. MonadIO io => Allocator -> DefragmentationInfo2 -> (io (Result, DefragmentationStats, DefragmentationContext) -> ((Result, DefragmentationStats, DefragmentationContext) -> io ()) -> r) -> r Source #
A convenience wrapper to make a compatible pair of calls to
defragmentationBegin
and defragmentationEnd
To ensure that defragmentationEnd
is always called: pass
bracket
(or the allocate function from your
favourite resource management library) as the first argument.
To just extract the pair pass (,)
as the first argument.
defragmentationEnd :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io () Source #
Ends defragmentation process.
Use this function to finish defragmentation started by
defragmentationBegin
. It is safe to pass context == null
. The
function then does nothing.
beginDefragmentationPass :: forall io. MonadIO io => Allocator -> DefragmentationContext -> io DefragmentationPassInfo Source #
useDefragmentationPass :: forall io r. MonadIO io => Allocator -> DefragmentationContext -> (DefragmentationPassInfo -> io r) -> io 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 () Source #
defragment :: forall io. MonadIO io => Allocator -> ("allocations" ::: Vector Allocation) -> ("defragmentationInfo" ::: Maybe DefragmentationInfo) -> io ("allocationsChanged" ::: Vector Bool, DefragmentationStats) Source #
Deprecated. Compacts memory by moving allocations.
Parameters.
pAllocations | Array of allocations that can be moved during this compation. | |
allocationCount | Number of elements in pAllocations and pAllocationsChanged arrays. | |
out | pAllocationsChanged | Array of boolean values that will indicate whether matching allocation in pAllocations array has been moved. This parameter is optional. Pass null if you don't need this information. |
pDefragmentationInfo | Configuration parameters. Optional - pass null to use default values. | |
out | pDefragmentationStats | Statistics returned by the function. Optional - pass null if you don't need this information. |
Returns.
VK_SUCCESS
if completed, negative error code in case of error.
Deprecated
This is a part of the old interface. It is recommended to use structure
DefragmentationInfo2
and function defragmentationBegin
instead.
This function works by moving allocations to different places (different
VkDeviceMemory
objects and/or different offsets) in order to optimize
memory usage. Only allocations that are in pAllocations
array can be
moved. All other allocations are considered nonmovable in this call.
Basic rules:
- Only allocations made in memory types that have
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
andVK_MEMORY_PROPERTY_HOST_COHERENT_BIT
flags can be compacted. You may pass other allocations but it makes no sense - these will never be moved. - Custom pools created with
POOL_CREATE_LINEAR_ALGORITHM_BIT
orPOOL_CREATE_BUDDY_ALGORITHM_BIT
flag are not defragmented. Allocations passed to this function that come from such pools are ignored. - Allocations created with
ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
or created as dedicated allocations for any other reason are also ignored. - Both allocations made with or without
ALLOCATION_CREATE_MAPPED_BIT
flag can be compacted. If not persistently mapped, memory will be mapped temporarily inside this function if needed. - You must not pass same
Allocation
object multiple times inpAllocations
array.
The function also frees empty VkDeviceMemory
blocks.
Warning: This function may be time-consuming, so you shouldn't call it too often (like after every resource creation/destruction). You can call it on special occasions (like when reloading a game level or when you just destroyed a lot of objects). Calling it every frame may be OK, but you should measure that on your platform.
For more information, see Defragmentation chapter.
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.
allocationLocalOffset | Additional offset to be added while binding, relative
to the beginnig of the allocation . Normally it
should be 0. |
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.
allocationLocalOffset | Additional offset to be added while binding, relative
to the beginnig of the allocation . Normally it
should be 0. |
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 #
Parameters.
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 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 (VmaAllocationCreateInfo::pool is null and 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.
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 first argument.
To just extract the pair pass (,)
as the first argument.
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 it 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 first argument.
To just extract the pair pass (,)
as the first argument.
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 it safe to pass null as image and/or allocation.
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
Eq Allocator Source # | |
Ord Allocator Source # | |
Defined in VulkanMemoryAllocator | |
Show Allocator Source # | |
Storable Allocator Source # | |
Defined in VulkanMemoryAllocator | |
IsHandle Allocator Source # | |
Defined in VulkanMemoryAllocator | |
Zero Allocator Source # | |
Defined in VulkanMemoryAllocator |
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.
DeviceMemoryCallbacks | |
|
Instances
newtype AllocatorCreateFlagBits Source #
Flags for created Allocator
.
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 extenion 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/. |
Instances
data VulkanFunctions Source #
VmaVulkanFunctions
Pointers to some Vulkan functions - a subset used by the library.
Used in VmaAllocatorCreateInfo::pVulkanFunctions.
VulkanFunctions | |
|
Instances
newtype RecordFlagBits Source #
Flags to be used in VmaRecordSettings::flags.
pattern RECORD_FLUSH_AFTER_CALL_BIT :: RecordFlagBits | Enables flush after recording every function call. Enable it if you expect your application to crash, which may leave recording file truncated. It may degrade performance though. |
Instances
type RecordFlags = RecordFlagBits Source #
data RecordSettings Source #
VmaRecordSettings
Parameters for recording calls to VMA functions. To be used in VmaAllocatorCreateInfo::pRecordSettings.
RecordSettings | |
|
Instances
data AllocatorCreateInfo Source #
VmaAllocatorCreateInfo
Description of a Allocator to be created.
AllocatorCreateInfo | |
|
Instances
data AllocatorInfo Source #
VmaAllocatorInfo
Information about existing Allocator
object.
AllocatorInfo | |
|
Instances
VmaStatInfo
Calculated statistics of memory usage in entire allocator.
StatInfo | |
|
Instances
VmaStats
General statistics from current state of Allocator.
memoryHeap
memoryHeap
VmaStats
VmaStats
memoryHeap
VmaStatInfo VmaStats::memoryHeap[VK_MAX_MEMORY_HEAPS]
memoryType
memoryType
VmaStats
VmaStats
memoryType
VmaStatInfo VmaStats::memoryType[VK_MAX_MEMORY_TYPES]
Stats | |
|
Instances
Show Stats Source # | |
Generic Stats Source # | |
Storable Stats Source # | |
Zero Stats Source # | |
Defined in VulkanMemoryAllocator | |
ToCStruct Stats Source # | |
Defined in VulkanMemoryAllocator | |
FromCStruct Stats Source # | |
Defined in VulkanMemoryAllocator | |
type Rep Stats Source # | |
Defined in VulkanMemoryAllocator type Rep Stats = D1 ('MetaData "Stats" "VulkanMemoryAllocator" "VulkanMemoryAllocator-0.3.3-inplace" 'False) (C1 ('MetaCons "Stats" 'PrefixI 'True) (S1 ('MetaSel ('Just "memoryType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector StatInfo)) :*: (S1 ('MetaSel ('Just "memoryHeap") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Vector StatInfo)) :*: S1 ('MetaSel ('Just "total") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 StatInfo)))) |
VmaBudget
Statistics of current memory usage and available budget, in bytes, for specific memory heap.
Budget | |
|
Instances
Eq Budget Source # | |
Show Budget Source # | |
Generic Budget Source # | |
Storable Budget Source # | |
Zero Budget Source # | |
Defined in VulkanMemoryAllocator | |
ToCStruct Budget Source # | |
Defined in VulkanMemoryAllocator | |
FromCStruct Budget Source # | |
Defined in VulkanMemoryAllocator | |
type Rep Budget Source # | |
Defined in VulkanMemoryAllocator type Rep Budget = D1 ('MetaData "Budget" "VulkanMemoryAllocator" "VulkanMemoryAllocator-0.3.3-inplace" 'False) (C1 ('MetaCons "Budget" 'PrefixI 'True) ((S1 ('MetaSel ('Just "blockBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 DeviceSize) :*: S1 ('MetaSel ('Just "allocationBytes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 DeviceSize)) :*: (S1 ('MetaSel ('Just "usage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 DeviceSize) :*: S1 ('MetaSel ('Just "budget") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 DeviceSize)))) |
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 MemoryUsage Source #
pattern MEMORY_USAGE_UNKNOWN :: MemoryUsage | No intended memory usage specified. Use other members of
|
pattern MEMORY_USAGE_GPU_ONLY :: MemoryUsage | Memory will be used on device only, so fast access from the device is
preferred. It usually means device-local GPU (video) memory. No need to
be mappable on host. It is roughly equivalent of
Usage:
Allocation may still end up in |
pattern MEMORY_USAGE_CPU_ONLY :: MemoryUsage | Memory will be mappable on host. It usually means CPU (system) memory.
Guarantees to be Usage: Staging copy of resources used as transfer source. |
pattern MEMORY_USAGE_CPU_TO_GPU :: MemoryUsage | Memory that is both mappable on host (guarantees to be Usage: Resources written frequently by host (dynamic), read by device. E.g. textures (with LINEAR layout), vertex buffers, uniform buffers updated every frame or every draw call. |
pattern MEMORY_USAGE_GPU_TO_CPU :: MemoryUsage | Memory mappable on host (guarantees to be Usage:
|
pattern MEMORY_USAGE_CPU_COPY :: MemoryUsage | CPU memory - memory that is preferably not Usage: Staging copy of resources moved from GPU memory to CPU memory as part of custom paging/residency mechanism, to be moved back to GPU memory when needed. |
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
|
Instances
newtype AllocationCreateFlagBits Source #
Flags to be passed as VmaAllocationCreateInfo::flags.
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. You should not use this flag if VmaAllocationCreateInfo::pool is not null. |
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 If VmaAllocationCreateInfo::pool is not null, this flag is implied and ignored. |
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. Is it valid to use this flag for allocation made from memory type that
is not You should not use this flag together with
|
pattern ALLOCATION_CREATE_CAN_BECOME_LOST_BIT :: AllocationCreateFlagBits | Allocation created with this flag can become lost as a result of another
allocation with To check if allocation is not lost, call For details about supporting lost allocations, see Lost Allocations chapter of User Guide on Main Page. You should not use this flag together with
|
pattern ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT :: AllocationCreateFlagBits | While creating allocation using this flag, other allocations that were
created with flag For details about supporting lost allocations, see Lost Allocations chapter of User Guide on Main Page. |
pattern ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT :: AllocationCreateFlagBits | 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: |
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_STRATEGY_BEST_FIT_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses smallest possible free range for the allocation. |
pattern ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses biggest possible free range for the allocation. |
pattern ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: AllocationCreateFlagBits | Allocation strategy that chooses first suitable free range for the allocation. "First" doesn't necessarily means the one with smallest offset in memory, but rather the one that is easiest and fastest to find. |
pattern ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: AllocationCreateFlagBits | Allocation strategy that tries to minimize memory usage. |
pattern ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: AllocationCreateFlagBits | Allocation strategy that tries to minimize allocation time. |
pattern ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT :: AllocationCreateFlagBits | Allocation strategy that tries to minimize memory fragmentation. |
pattern ALLOCATION_CREATE_STRATEGY_MASK :: AllocationCreateFlagBits | A bit mask to extract only |
Instances
data AllocationCreateInfo Source #
VmaAllocationCreateInfo
AllocationCreateInfo | |
|
Instances
newtype PoolCreateFlagBits Source #
Flags to be passed as VmaPoolCreateInfo::flags.
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. When using this flag, you must specify VmaPoolCreateInfo::maxBlockCount == 1 (or 0 for default). For more details, see Linear allocation algorithm. |
pattern POOL_CREATE_BUDDY_ALGORITHM_BIT :: PoolCreateFlagBits | Enables alternative, buddy allocation algorithm in this pool. It operates on a tree of blocks, each having size that is a power of two and a half of its parent's size. Comparing to default algorithm, this one provides faster allocation and deallocation and decreased external fragmentation, at the expense of more memory wasted (internal fragmentation). For more details, see Buddy allocation algorithm. |
pattern POOL_CREATE_ALGORITHM_MASK :: PoolCreateFlagBits | Bit mask to extract only |
Instances
type PoolCreateFlags = PoolCreateFlagBits Source #
data PoolCreateInfo Source #
VmaPoolCreateInfo
Describes parameter of created Pool
.
PoolCreateInfo | |
|
Instances
VmaPoolStats
Describes parameter of existing Pool
.
PoolStats | |
|
Instances
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
.
Some kinds allocations can be in lost state. For more information, see Lost allocations.
Instances
data AllocationInfo Source #
VmaAllocationInfo
Parameters of Allocation
objects, that can be retrieved using function
getAllocationInfo
.
AllocationInfo | |
|
Instances
newtype DefragmentationContext Source #
VmaDefragmentationContext
Represents Opaque object that represents started defragmentation process.
Fill structure DefragmentationInfo2
and call function
defragmentationBegin
to create it. Call function defragmentationEnd
to destroy it.
Instances
newtype DefragmentationFlagBits Source #
Flags to be used in defragmentationBegin
. None at the moment. Reserved
for future use.
Instances
data DefragmentationInfo2 Source #
VmaDefragmentationInfo2
Parameters for defragmentation.
To be used with function defragmentationBegin
.
DefragmentationInfo2 | |
|
Instances
data DefragmentationPassMoveInfo Source #
VmaDefragmentationPassMoveInfo
Instances
data DefragmentationPassInfo Source #
VmaDefragmentationPassInfo
Parameters for incremental defragmentation steps.
To be used with function beginDefragmentationPass
.
Instances
data DefragmentationInfo Source #
VmaDefragmentationInfo
Deprecated. Optional configuration parameters to be passed to function
defragment
.
Deprecated
This is a part of the old interface. It is recommended to use structure
DefragmentationInfo2
and function defragmentationBegin
instead.
DefragmentationInfo | |
|
Instances
data DefragmentationStats Source #
VmaDefragmentationStats
Statistics returned by function defragment
.
DefragmentationStats | |
|