{-# language CPP #-}
-- No documentation found for Chapter "VulkanMemoryAllocator"
module VulkanMemoryAllocator  ( createAllocator
                              , withAllocator
                              , destroyAllocator
                              , getAllocatorInfo
                              , getPhysicalDeviceProperties
                              , getMemoryProperties
                              , getMemoryTypeProperties
                              , setCurrentFrameIndex
                              , calculateStatistics
                              , getHeapBudgets
                              , findMemoryTypeIndex
                              , findMemoryTypeIndexForBufferInfo
                              , findMemoryTypeIndexForImageInfo
                              , createPool
                              , withPool
                              , destroyPool
                              , getPoolStatistics
                              , calculatePoolStatistics
                              , checkPoolCorruption
                              , getPoolName
                              , setPoolName
                              , allocateMemory
                              , withMemory
                              , allocateMemoryPages
                              , withMemoryPages
                              , allocateMemoryForBuffer
                              , withMemoryForBuffer
                              , allocateMemoryForImage
                              , withMemoryForImage
                              , freeMemory
                              , freeMemoryPages
                              , getAllocationInfo
                              , setAllocationUserData
                              , setAllocationName
                              , getAllocationMemoryProperties
                              , mapMemory
                              , withMappedMemory
                              , unmapMemory
                              , flushAllocation
                              , invalidateAllocation
                              , flushAllocations
                              , invalidateAllocations
                              , checkCorruption
                              , beginDefragmentation
                              , withDefragmentation
                              , endDefragmentation
                              , beginDefragmentationPass
                              , useDefragmentationPass
                              , endDefragmentationPass
                              , bindBufferMemory
                              , bindBufferMemory2
                              , bindImageMemory
                              , bindImageMemory2
                              , createBuffer
                              , withBuffer
                              , createBufferWithAlignment
                              , createAliasingBuffer
                              , createAliasingBuffer2
                              , destroyBuffer
                              , createImage
                              , withImage
                              , createAliasingImage
                              , createAliasingImage2
                              , destroyImage
                              , createVirtualBlock
                              , withVirtualBlock
                              , destroyVirtualBlock
                              , isVirtualBlockEmpty
                              , getVirtualAllocationInfo
                              , virtualAllocate
                              , withVirtualAllocation
                              , virtualFree
                              , clearVirtualBlock
                              , setVirtualAllocationUserData
                              , getVirtualBlockStatistics
                              , calculateVirtualBlockStatistics
                              , buildVirtualBlockStatsString
                              , freeVirtualBlockStatsString
                              , buildStatsString
                              , freeStatsString
                              , AllocatorCreateFlags
                              , AllocatorCreateFlagBits( ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT
                                                       , ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT
                                                       , ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT
                                                       , ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT
                                                       , ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT
                                                       , ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT
                                                       , ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT
                                                       , ..
                                                       )
                              , MemoryUsage( MEMORY_USAGE_UNKNOWN
                                           , MEMORY_USAGE_GPU_ONLY
                                           , MEMORY_USAGE_CPU_ONLY
                                           , MEMORY_USAGE_CPU_TO_GPU
                                           , MEMORY_USAGE_GPU_TO_CPU
                                           , MEMORY_USAGE_CPU_COPY
                                           , MEMORY_USAGE_GPU_LAZILY_ALLOCATED
                                           , MEMORY_USAGE_AUTO
                                           , MEMORY_USAGE_AUTO_PREFER_DEVICE
                                           , MEMORY_USAGE_AUTO_PREFER_HOST
                                           , ..
                                           )
                              , AllocationCreateFlags
                              , AllocationCreateFlagBits( ALLOCATION_CREATE_DEDICATED_MEMORY_BIT
                                                        , ALLOCATION_CREATE_NEVER_ALLOCATE_BIT
                                                        , ALLOCATION_CREATE_MAPPED_BIT
                                                        , ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT
                                                        , ALLOCATION_CREATE_UPPER_ADDRESS_BIT
                                                        , ALLOCATION_CREATE_DONT_BIND_BIT
                                                        , ALLOCATION_CREATE_WITHIN_BUDGET_BIT
                                                        , ALLOCATION_CREATE_CAN_ALIAS_BIT
                                                        , ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT
                                                        , ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT
                                                        , ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT
                                                        , ALLOCATION_CREATE_STRATEGY_MASK
                                                        , ..
                                                        )
                              , PoolCreateFlags
                              , PoolCreateFlagBits( POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT
                                                  , POOL_CREATE_LINEAR_ALGORITHM_BIT
                                                  , POOL_CREATE_ALGORITHM_MASK
                                                  , ..
                                                  )
                              , DefragmentationFlags
                              , DefragmentationFlagBits( DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT
                                                       , DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT
                                                       , DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT
                                                       , DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT
                                                       , DEFRAGMENTATION_FLAG_ALGORITHM_MASK
                                                       , ..
                                                       )
                              , DefragmentationMoveOperation( DEFRAGMENTATION_MOVE_OPERATION_COPY
                                                            , DEFRAGMENTATION_MOVE_OPERATION_IGNORE
                                                            , DEFRAGMENTATION_MOVE_OPERATION_DESTROY
                                                            , ..
                                                            )
                              , VirtualBlockCreateFlags
                              , VirtualBlockCreateFlagBits( VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT
                                                          , VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK
                                                          , ..
                                                          )
                              , VirtualAllocationCreateFlags
                              , VirtualAllocationCreateFlagBits( VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT
                                                               , VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT
                                                               , VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT
                                                               , VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT
                                                               , VIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK
                                                               , ..
                                                               )
                              , Allocator(..)
                              , Pool(..)
                              , Allocation(..)
                              , DefragmentationContext(..)
                              , VirtualAllocation(..)
                              , VirtualBlock(..)
                              , PFN_vmaAllocateDeviceMemoryFunction
                              , FN_vmaAllocateDeviceMemoryFunction
                              , PFN_vmaFreeDeviceMemoryFunction
                              , FN_vmaFreeDeviceMemoryFunction
                              , DeviceMemoryCallbacks(..)
                              , VulkanFunctions(..)
                              , AllocatorCreateInfo(..)
                              , AllocatorInfo(..)
                              , Statistics(..)
                              , DetailedStatistics(..)
                              , TotalStatistics(..)
                              , Budget(..)
                              , AllocationCreateInfo(..)
                              , PoolCreateInfo(..)
                              , AllocationInfo(..)
                              , DefragmentationInfo(..)
                              , DefragmentationMove(..)
                              , DefragmentationPassMoveInfo(..)
                              , DefragmentationStats(..)
                              , VirtualBlockCreateInfo(..)
                              , VirtualAllocationCreateInfo(..)
                              , VirtualAllocationInfo(..)
                              ) where

import Vulkan (AllocationCallbacks)
import Vulkan (BindBufferMemoryInfo)
import Vulkan (BindImageMemoryInfo)
import Vulkan (Bool32)
import Vulkan (Buffer)
import Vulkan (BufferCopy)
import Vulkan (BufferCreateInfo)
import Vulkan (BufferMemoryRequirementsInfo2)
import Vulkan (CommandBuffer_T)
import Vulkan (DeviceMemory)
import Vulkan (DeviceSize)
import Vulkan (Device_T)
import Vulkan (ExternalMemoryHandleTypeFlagsKHR)
import Vulkan (Flags)
import Vulkan (Image)
import Vulkan (ImageCreateInfo)
import Vulkan (ImageMemoryRequirementsInfo2)
import Vulkan (Instance_T)
import Vulkan (MappedMemoryRange)
import Vulkan (MemoryAllocateInfo)
import Vulkan (MemoryMapFlags)
import Vulkan (MemoryPropertyFlags)
import Vulkan (MemoryRequirements)
import Vulkan (MemoryRequirements2)
import Vulkan (PhysicalDeviceMemoryProperties)
import Vulkan (PhysicalDeviceMemoryProperties2)
import Vulkan (PhysicalDeviceProperties)
import Vulkan (PhysicalDevice_T)
import Vulkan (Result)
import Vulkan.CStruct.Utils (FixedArray)
import Vulkan.Internal.Utils (enumReadPrec)
import Vulkan.Internal.Utils (enumShowsPrec)
import Vulkan.Internal.Utils (traceAroundEvent)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.CStruct.Utils (lowerArrayPtr)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import Foreign.Marshal.Utils (maybePeek)
import GHC.Base (when)
import GHC.IO (throwIO)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import GHC.Show (showParen)
import GHC.Show (showString)
import GHC.Show (showsPrec)
import Numeric (showHex)
import Data.ByteString (packCString)
import Data.ByteString (useAsCString)
import Data.Coerce (coerce)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import qualified Data.Vector (null)
import Vulkan.Core10.APIConstants (pattern MAX_MEMORY_HEAPS)
import Vulkan.Core10.APIConstants (pattern MAX_MEMORY_TYPES)
import Vulkan.Core10.Enums.Result (pattern SUCCESS)
import Foreign.C.Types (CChar(..))
import Foreign.C.Types (CSize(..))
import Vulkan (Bool32(..))
import Vulkan (Buffer(..))
import Vulkan (Image(..))
import Vulkan (MemoryPropertyFlagBits(..))
import Vulkan (Result(..))
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.APIConstants (IsHandle)
import Vulkan.Core10.APIConstants (MAX_MEMORY_HEAPS)
import Vulkan.Core10.APIConstants (MAX_MEMORY_TYPES)
import Vulkan.Exception (VulkanException(..))
import Vulkan.NamedType ((:::))
import Vulkan.Zero (Zero)
import Vulkan.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.Bits (Bits)
import Data.Bits (FiniteBits)
import Data.Typeable (Typeable)
import Foreign.C.Types (CChar)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CFloat(..))
import Foreign.C.Types (CFloat(CFloat))
import Foreign.C.Types (CSize)
import Foreign.C.Types (CSize(..))
import Foreign.C.Types (CSize(CSize))
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Data.Int (Int32)
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import GHC.Read (Read(readPrec))
import GHC.Show (Show(showsPrec))
import Data.Word (Word32)
import Data.Word (Word64)
import Data.ByteString (ByteString)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)

foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateAllocator" ffiVmaCreateAllocator
  :: Ptr AllocatorCreateInfo -> Ptr Allocator -> IO Result

-- | Creates 'Allocator' object.
createAllocator :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaCreateAllocator" "pCreateInfo"
                   AllocatorCreateInfo
                -> io (Allocator)
createAllocator :: AllocatorCreateInfo -> io Allocator
createAllocator AllocatorCreateInfo
createInfo = IO Allocator -> io Allocator
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Allocator -> io Allocator)
-> (ContT Allocator IO Allocator -> IO Allocator)
-> ContT Allocator IO Allocator
-> io Allocator
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Allocator IO Allocator -> IO Allocator
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Allocator IO Allocator -> io Allocator)
-> ContT Allocator IO Allocator -> io Allocator
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocatorCreateInfo
pCreateInfo <- ((Ptr AllocatorCreateInfo -> IO Allocator) -> IO Allocator)
-> ContT Allocator IO (Ptr AllocatorCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocatorCreateInfo -> IO Allocator) -> IO Allocator)
 -> ContT Allocator IO (Ptr AllocatorCreateInfo))
-> ((Ptr AllocatorCreateInfo -> IO Allocator) -> IO Allocator)
-> ContT Allocator IO (Ptr AllocatorCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocatorCreateInfo
-> (Ptr AllocatorCreateInfo -> IO Allocator) -> IO Allocator
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocatorCreateInfo
createInfo)
  Ptr Allocator
pPAllocator <- ((Ptr Allocator -> IO Allocator) -> IO Allocator)
-> ContT Allocator IO (Ptr Allocator)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocator -> IO Allocator) -> IO Allocator)
 -> ContT Allocator IO (Ptr Allocator))
-> ((Ptr Allocator -> IO Allocator) -> IO Allocator)
-> ContT Allocator IO (Ptr Allocator)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocator)
-> (Ptr Allocator -> IO ())
-> (Ptr Allocator -> IO Allocator)
-> IO Allocator
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocator)
forall a. Int -> IO (Ptr a)
callocBytes @Allocator Int
8) Ptr Allocator -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Allocator IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Allocator IO Result)
-> IO Result -> ContT Allocator IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateAllocator" ((Ptr AllocatorCreateInfo -> Ptr Allocator -> IO Result
ffiVmaCreateAllocator) Ptr AllocatorCreateInfo
pCreateInfo (Ptr Allocator
pPAllocator))
  IO () -> ContT Allocator IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Allocator IO ()) -> IO () -> ContT Allocator IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Allocator
pAllocator <- IO Allocator -> ContT Allocator IO Allocator
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocator -> ContT Allocator IO Allocator)
-> IO Allocator -> ContT Allocator IO Allocator
forall a b. (a -> b) -> a -> b
$ Ptr Allocator -> IO Allocator
forall a. Storable a => Ptr a -> IO a
peek @Allocator Ptr Allocator
pPAllocator
  Allocator -> ContT Allocator IO Allocator
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Allocator -> ContT Allocator IO Allocator)
-> Allocator -> ContT Allocator IO Allocator
forall a b. (a -> b) -> a -> b
$ (Allocator
pAllocator)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createAllocator' and 'destroyAllocator'
--
-- To ensure that 'destroyAllocator' is always called: pass
-- 'Control.Exception.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.
--
withAllocator :: forall io r . MonadIO io => AllocatorCreateInfo -> (io Allocator -> (Allocator -> io ()) -> r) -> r
withAllocator :: AllocatorCreateInfo
-> (io Allocator -> (Allocator -> io ()) -> r) -> r
withAllocator AllocatorCreateInfo
pCreateInfo io Allocator -> (Allocator -> io ()) -> r
b =
  io Allocator -> (Allocator -> io ()) -> r
b (AllocatorCreateInfo -> io Allocator
forall (io :: * -> *).
MonadIO io =>
AllocatorCreateInfo -> io Allocator
createAllocator AllocatorCreateInfo
pCreateInfo)
    (\(Allocator
o0) -> Allocator -> io ()
forall (io :: * -> *). MonadIO io => Allocator -> io ()
destroyAllocator Allocator
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaDestroyAllocator" ffiVmaDestroyAllocator
  :: Allocator -> IO ()

-- | Destroys allocator object.
destroyAllocator :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaDestroyAllocator" "allocator"
                    Allocator
                 -> io ()
destroyAllocator :: Allocator -> io ()
destroyAllocator Allocator
allocator = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaDestroyAllocator" ((Allocator -> IO ()
ffiVmaDestroyAllocator) (Allocator
allocator))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetAllocatorInfo" ffiVmaGetAllocatorInfo
  :: Allocator -> Ptr AllocatorInfo -> IO ()

-- | Returns information about existing 'Allocator' object - handle to Vulkan
-- device etc.
--
-- It might be useful if you want to keep just the 'Allocator' handle and
-- fetch other required handles to @VkPhysicalDevice@, @VkDevice@ etc.
-- every time using this function.
getAllocatorInfo :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaGetAllocatorInfo" "allocator"
                    Allocator
                 -> io (AllocatorInfo)
getAllocatorInfo :: Allocator -> io AllocatorInfo
getAllocatorInfo Allocator
allocator = IO AllocatorInfo -> io AllocatorInfo
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AllocatorInfo -> io AllocatorInfo)
-> (ContT AllocatorInfo IO AllocatorInfo -> IO AllocatorInfo)
-> ContT AllocatorInfo IO AllocatorInfo
-> io AllocatorInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT AllocatorInfo IO AllocatorInfo -> IO AllocatorInfo
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT AllocatorInfo IO AllocatorInfo -> io AllocatorInfo)
-> ContT AllocatorInfo IO AllocatorInfo -> io AllocatorInfo
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocatorInfo
pPAllocatorInfo <- ((Ptr AllocatorInfo -> IO AllocatorInfo) -> IO AllocatorInfo)
-> ContT AllocatorInfo IO (Ptr AllocatorInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocatorInfo =>
(Ptr AllocatorInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocatorInfo)
  IO () -> ContT AllocatorInfo IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT AllocatorInfo IO ())
-> IO () -> ContT AllocatorInfo IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetAllocatorInfo" ((Allocator -> Ptr AllocatorInfo -> IO ()
ffiVmaGetAllocatorInfo) (Allocator
allocator) (Ptr AllocatorInfo
pPAllocatorInfo))
  AllocatorInfo
pAllocatorInfo <- IO AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo)
-> IO AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocatorInfo -> IO AllocatorInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocatorInfo Ptr AllocatorInfo
pPAllocatorInfo
  AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo)
-> AllocatorInfo -> ContT AllocatorInfo IO AllocatorInfo
forall a b. (a -> b) -> a -> b
$ (AllocatorInfo
pAllocatorInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetPhysicalDeviceProperties" ffiVmaGetPhysicalDeviceProperties
  :: Allocator -> Ptr (Ptr PhysicalDeviceProperties) -> IO ()

-- | PhysicalDeviceProperties are fetched from physicalDevice by the
-- allocator. You can access it here, without fetching it again on your
-- own.
getPhysicalDeviceProperties :: forall io
                             . (MonadIO io)
                            => -- No documentation found for Nested "vmaGetPhysicalDeviceProperties" "allocator"
                               Allocator
                            -> io (Ptr PhysicalDeviceProperties)
getPhysicalDeviceProperties :: Allocator -> io (Ptr PhysicalDeviceProperties)
getPhysicalDeviceProperties Allocator
allocator = IO (Ptr PhysicalDeviceProperties)
-> io (Ptr PhysicalDeviceProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr PhysicalDeviceProperties)
 -> io (Ptr PhysicalDeviceProperties))
-> (ContT
      (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
    -> IO (Ptr PhysicalDeviceProperties))
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
-> io (Ptr PhysicalDeviceProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
-> IO (Ptr PhysicalDeviceProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
 -> io (Ptr PhysicalDeviceProperties))
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
-> io (Ptr PhysicalDeviceProperties)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (Ptr PhysicalDeviceProperties)
pPpPhysicalDeviceProperties <- ((Ptr (Ptr PhysicalDeviceProperties)
  -> IO (Ptr PhysicalDeviceProperties))
 -> IO (Ptr PhysicalDeviceProperties))
-> ContT
     (Ptr PhysicalDeviceProperties)
     IO
     (Ptr (Ptr PhysicalDeviceProperties))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr PhysicalDeviceProperties)
   -> IO (Ptr PhysicalDeviceProperties))
  -> IO (Ptr PhysicalDeviceProperties))
 -> ContT
      (Ptr PhysicalDeviceProperties)
      IO
      (Ptr (Ptr PhysicalDeviceProperties)))
-> ((Ptr (Ptr PhysicalDeviceProperties)
     -> IO (Ptr PhysicalDeviceProperties))
    -> IO (Ptr PhysicalDeviceProperties))
-> ContT
     (Ptr PhysicalDeviceProperties)
     IO
     (Ptr (Ptr PhysicalDeviceProperties))
forall a b. (a -> b) -> a -> b
$ IO (Ptr (Ptr PhysicalDeviceProperties))
-> (Ptr (Ptr PhysicalDeviceProperties) -> IO ())
-> (Ptr (Ptr PhysicalDeviceProperties)
    -> IO (Ptr PhysicalDeviceProperties))
-> IO (Ptr PhysicalDeviceProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr (Ptr PhysicalDeviceProperties))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr PhysicalDeviceProperties) Int
8) Ptr (Ptr PhysicalDeviceProperties) -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT (Ptr PhysicalDeviceProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Ptr PhysicalDeviceProperties) IO ())
-> IO () -> ContT (Ptr PhysicalDeviceProperties) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetPhysicalDeviceProperties" ((Allocator -> Ptr (Ptr PhysicalDeviceProperties) -> IO ()
ffiVmaGetPhysicalDeviceProperties) (Allocator
allocator) (Ptr (Ptr PhysicalDeviceProperties)
pPpPhysicalDeviceProperties))
  Ptr PhysicalDeviceProperties
ppPhysicalDeviceProperties <- IO (Ptr PhysicalDeviceProperties)
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr PhysicalDeviceProperties)
 -> ContT
      (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties))
-> IO (Ptr PhysicalDeviceProperties)
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr PhysicalDeviceProperties)
-> IO (Ptr PhysicalDeviceProperties)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDeviceProperties) Ptr (Ptr PhysicalDeviceProperties)
pPpPhysicalDeviceProperties
  Ptr PhysicalDeviceProperties
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr PhysicalDeviceProperties
 -> ContT
      (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties))
-> Ptr PhysicalDeviceProperties
-> ContT
     (Ptr PhysicalDeviceProperties) IO (Ptr PhysicalDeviceProperties)
forall a b. (a -> b) -> a -> b
$ (Ptr PhysicalDeviceProperties
ppPhysicalDeviceProperties)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetMemoryProperties" ffiVmaGetMemoryProperties
  :: Allocator -> Ptr (Ptr PhysicalDeviceMemoryProperties) -> IO ()

-- | PhysicalDeviceMemoryProperties are fetched from physicalDevice by the
-- allocator. You can access it here, without fetching it again on your
-- own.
getMemoryProperties :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaGetMemoryProperties" "allocator"
                       Allocator
                    -> io (Ptr PhysicalDeviceMemoryProperties)
getMemoryProperties :: Allocator -> io (Ptr PhysicalDeviceMemoryProperties)
getMemoryProperties Allocator
allocator = IO (Ptr PhysicalDeviceMemoryProperties)
-> io (Ptr PhysicalDeviceMemoryProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr PhysicalDeviceMemoryProperties)
 -> io (Ptr PhysicalDeviceMemoryProperties))
-> (ContT
      (Ptr PhysicalDeviceMemoryProperties)
      IO
      (Ptr PhysicalDeviceMemoryProperties)
    -> IO (Ptr PhysicalDeviceMemoryProperties))
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
-> io (Ptr PhysicalDeviceMemoryProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Ptr PhysicalDeviceMemoryProperties)
  IO
  (Ptr PhysicalDeviceMemoryProperties)
-> IO (Ptr PhysicalDeviceMemoryProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Ptr PhysicalDeviceMemoryProperties)
   IO
   (Ptr PhysicalDeviceMemoryProperties)
 -> io (Ptr PhysicalDeviceMemoryProperties))
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
-> io (Ptr PhysicalDeviceMemoryProperties)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (Ptr PhysicalDeviceMemoryProperties)
pPpPhysicalDeviceMemoryProperties <- ((Ptr (Ptr PhysicalDeviceMemoryProperties)
  -> IO (Ptr PhysicalDeviceMemoryProperties))
 -> IO (Ptr PhysicalDeviceMemoryProperties))
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr (Ptr PhysicalDeviceMemoryProperties))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr PhysicalDeviceMemoryProperties)
   -> IO (Ptr PhysicalDeviceMemoryProperties))
  -> IO (Ptr PhysicalDeviceMemoryProperties))
 -> ContT
      (Ptr PhysicalDeviceMemoryProperties)
      IO
      (Ptr (Ptr PhysicalDeviceMemoryProperties)))
-> ((Ptr (Ptr PhysicalDeviceMemoryProperties)
     -> IO (Ptr PhysicalDeviceMemoryProperties))
    -> IO (Ptr PhysicalDeviceMemoryProperties))
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr (Ptr PhysicalDeviceMemoryProperties))
forall a b. (a -> b) -> a -> b
$ IO (Ptr (Ptr PhysicalDeviceMemoryProperties))
-> (Ptr (Ptr PhysicalDeviceMemoryProperties) -> IO ())
-> (Ptr (Ptr PhysicalDeviceMemoryProperties)
    -> IO (Ptr PhysicalDeviceMemoryProperties))
-> IO (Ptr PhysicalDeviceMemoryProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr (Ptr PhysicalDeviceMemoryProperties))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr PhysicalDeviceMemoryProperties) Int
8) Ptr (Ptr PhysicalDeviceMemoryProperties) -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT (Ptr PhysicalDeviceMemoryProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Ptr PhysicalDeviceMemoryProperties) IO ())
-> IO () -> ContT (Ptr PhysicalDeviceMemoryProperties) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetMemoryProperties" ((Allocator -> Ptr (Ptr PhysicalDeviceMemoryProperties) -> IO ()
ffiVmaGetMemoryProperties) (Allocator
allocator) (Ptr (Ptr PhysicalDeviceMemoryProperties)
pPpPhysicalDeviceMemoryProperties))
  Ptr PhysicalDeviceMemoryProperties
ppPhysicalDeviceMemoryProperties <- IO (Ptr PhysicalDeviceMemoryProperties)
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO (Ptr PhysicalDeviceMemoryProperties)
 -> ContT
      (Ptr PhysicalDeviceMemoryProperties)
      IO
      (Ptr PhysicalDeviceMemoryProperties))
-> IO (Ptr PhysicalDeviceMemoryProperties)
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr PhysicalDeviceMemoryProperties)
-> IO (Ptr PhysicalDeviceMemoryProperties)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDeviceMemoryProperties) Ptr (Ptr PhysicalDeviceMemoryProperties)
pPpPhysicalDeviceMemoryProperties
  Ptr PhysicalDeviceMemoryProperties
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr PhysicalDeviceMemoryProperties
 -> ContT
      (Ptr PhysicalDeviceMemoryProperties)
      IO
      (Ptr PhysicalDeviceMemoryProperties))
-> Ptr PhysicalDeviceMemoryProperties
-> ContT
     (Ptr PhysicalDeviceMemoryProperties)
     IO
     (Ptr PhysicalDeviceMemoryProperties)
forall a b. (a -> b) -> a -> b
$ (Ptr PhysicalDeviceMemoryProperties
ppPhysicalDeviceMemoryProperties)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetMemoryTypeProperties" ffiVmaGetMemoryTypeProperties
  :: Allocator -> Word32 -> Ptr MemoryPropertyFlags -> IO ()

-- | Given Memory Type Index, returns Property Flags of this memory type.
--
-- This is just a convenience function. Same information can be obtained
-- using 'getMemoryProperties'.
getMemoryTypeProperties :: forall io
                         . (MonadIO io)
                        => -- No documentation found for Nested "vmaGetMemoryTypeProperties" "allocator"
                           Allocator
                        -> -- No documentation found for Nested "vmaGetMemoryTypeProperties" "memoryTypeIndex"
                           ("memoryTypeIndex" ::: Word32)
                        -> io (MemoryPropertyFlags)
getMemoryTypeProperties :: Allocator
-> ("memoryTypeIndex" ::: Word32) -> io MemoryPropertyFlags
getMemoryTypeProperties Allocator
allocator "memoryTypeIndex" ::: Word32
memoryTypeIndex = IO MemoryPropertyFlags -> io MemoryPropertyFlags
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MemoryPropertyFlags -> io MemoryPropertyFlags)
-> (ContT MemoryPropertyFlags IO MemoryPropertyFlags
    -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> io MemoryPropertyFlags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> IO MemoryPropertyFlags
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT MemoryPropertyFlags IO MemoryPropertyFlags
 -> io MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> io MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ do
  Ptr MemoryPropertyFlags
pPFlags <- ((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
 -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
  -> IO MemoryPropertyFlags)
 -> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags))
-> ((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
    -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags)
forall a b. (a -> b) -> a -> b
$ IO (Ptr MemoryPropertyFlags)
-> (Ptr MemoryPropertyFlags -> IO ())
-> (Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
-> IO MemoryPropertyFlags
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr MemoryPropertyFlags)
forall a. Int -> IO (Ptr a)
callocBytes @MemoryPropertyFlags Int
4) Ptr MemoryPropertyFlags -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT MemoryPropertyFlags IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT MemoryPropertyFlags IO ())
-> IO () -> ContT MemoryPropertyFlags IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetMemoryTypeProperties" ((Allocator
-> ("memoryTypeIndex" ::: Word32)
-> Ptr MemoryPropertyFlags
-> IO ()
ffiVmaGetMemoryTypeProperties) (Allocator
allocator) ("memoryTypeIndex" ::: Word32
memoryTypeIndex) (Ptr MemoryPropertyFlags
pPFlags))
  MemoryPropertyFlags
pFlags <- IO MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO MemoryPropertyFlags
 -> ContT MemoryPropertyFlags IO MemoryPropertyFlags)
-> IO MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags
forall a. Storable a => Ptr a -> IO a
peek @MemoryPropertyFlags Ptr MemoryPropertyFlags
pPFlags
  MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MemoryPropertyFlags
 -> ContT MemoryPropertyFlags IO MemoryPropertyFlags)
-> MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ (MemoryPropertyFlags
pFlags)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaSetCurrentFrameIndex" ffiVmaSetCurrentFrameIndex
  :: Allocator -> Word32 -> IO ()

-- | Sets index of the current frame.
setCurrentFrameIndex :: forall io
                      . (MonadIO io)
                     => -- No documentation found for Nested "vmaSetCurrentFrameIndex" "allocator"
                        Allocator
                     -> -- No documentation found for Nested "vmaSetCurrentFrameIndex" "frameIndex"
                        ("frameIndex" ::: Word32)
                     -> io ()
setCurrentFrameIndex :: Allocator -> ("memoryTypeIndex" ::: Word32) -> io ()
setCurrentFrameIndex Allocator
allocator "memoryTypeIndex" ::: Word32
frameIndex = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaSetCurrentFrameIndex" ((Allocator -> ("memoryTypeIndex" ::: Word32) -> IO ()
ffiVmaSetCurrentFrameIndex) (Allocator
allocator) ("memoryTypeIndex" ::: Word32
frameIndex))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCalculateStatistics" ffiVmaCalculateStatistics
  :: Allocator -> Ptr TotalStatistics -> IO ()

-- | 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.
calculateStatistics :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaCalculateStatistics" "allocator"
                       Allocator
                    -> io (("stats" ::: TotalStatistics))
calculateStatistics :: Allocator -> io ("stats" ::: TotalStatistics)
calculateStatistics Allocator
allocator = IO ("stats" ::: TotalStatistics)
-> io ("stats" ::: TotalStatistics)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("stats" ::: TotalStatistics)
 -> io ("stats" ::: TotalStatistics))
-> (ContT
      ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
    -> IO ("stats" ::: TotalStatistics))
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
-> io ("stats" ::: TotalStatistics)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
 -> io ("stats" ::: TotalStatistics))
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
-> io ("stats" ::: TotalStatistics)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("stats" ::: TotalStatistics)
pPStats <- ((Ptr ("stats" ::: TotalStatistics)
  -> IO ("stats" ::: TotalStatistics))
 -> IO ("stats" ::: TotalStatistics))
-> ContT
     ("stats" ::: TotalStatistics)
     IO
     (Ptr ("stats" ::: TotalStatistics))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("stats" ::: TotalStatistics) =>
(Ptr ("stats" ::: TotalStatistics) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @TotalStatistics)
  IO () -> ContT ("stats" ::: TotalStatistics) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("stats" ::: TotalStatistics) IO ())
-> IO () -> ContT ("stats" ::: TotalStatistics) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCalculateStatistics" ((Allocator -> Ptr ("stats" ::: TotalStatistics) -> IO ()
ffiVmaCalculateStatistics) (Allocator
allocator) (Ptr ("stats" ::: TotalStatistics)
pPStats))
  "stats" ::: TotalStatistics
pStats <- IO ("stats" ::: TotalStatistics)
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("stats" ::: TotalStatistics)
 -> ContT
      ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics))
-> IO ("stats" ::: TotalStatistics)
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
forall a b. (a -> b) -> a -> b
$ Ptr ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @TotalStatistics Ptr ("stats" ::: TotalStatistics)
pPStats
  ("stats" ::: TotalStatistics)
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("stats" ::: TotalStatistics)
 -> ContT
      ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics))
-> ("stats" ::: TotalStatistics)
-> ContT
     ("stats" ::: TotalStatistics) IO ("stats" ::: TotalStatistics)
forall a b. (a -> b) -> a -> b
$ ("stats" ::: TotalStatistics
pStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetHeapBudgets" ffiVmaGetHeapBudgets
  :: Allocator -> Ptr Budget -> IO ()

-- | 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.
getHeapBudgets :: forall io
                . (MonadIO io)
               => -- No documentation found for Nested "vmaGetHeapBudgets" "allocator"
                  Allocator
               -> -- No documentation found for Nested "vmaGetHeapBudgets" "pBudgets"
                  ("budgets" ::: Ptr Budget)
               -> io ()
getHeapBudgets :: Allocator -> ("budgets" ::: Ptr Budget) -> io ()
getHeapBudgets Allocator
allocator "budgets" ::: Ptr Budget
budgets = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetHeapBudgets" ((Allocator -> ("budgets" ::: Ptr Budget) -> IO ()
ffiVmaGetHeapBudgets) (Allocator
allocator) ("budgets" ::: Ptr Budget
budgets))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFindMemoryTypeIndex" ffiVmaFindMemoryTypeIndex
  :: Allocator -> Word32 -> Ptr AllocationCreateInfo -> Ptr Word32 -> IO Result

-- | 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.
findMemoryTypeIndex :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaFindMemoryTypeIndex" "allocator"
                       Allocator
                    -> -- No documentation found for Nested "vmaFindMemoryTypeIndex" "memoryTypeBits"
                       ("memoryTypeBits" ::: Word32)
                    -> -- No documentation found for Nested "vmaFindMemoryTypeIndex" "pAllocationCreateInfo"
                       AllocationCreateInfo
                    -> io (("memoryTypeIndex" ::: Word32))
findMemoryTypeIndex :: Allocator
-> ("memoryTypeIndex" ::: Word32)
-> AllocationCreateInfo
-> io ("memoryTypeIndex" ::: Word32)
findMemoryTypeIndex Allocator
allocator "memoryTypeIndex" ::: Word32
memoryTypeBits AllocationCreateInfo
allocationCreateInfo = IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> (ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex <- ((Ptr ("memoryTypeIndex" ::: Word32)
  -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("memoryTypeIndex" ::: Word32)
   -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32)
      IO
      (Ptr ("memoryTypeIndex" ::: Word32)))
-> ((Ptr ("memoryTypeIndex" ::: Word32)
     -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("memoryTypeIndex" ::: Word32))
-> (Ptr ("memoryTypeIndex" ::: Word32) -> IO ())
-> (Ptr ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("memoryTypeIndex" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 Int
4) Ptr ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result)
-> IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFindMemoryTypeIndex" ((Allocator
-> ("memoryTypeIndex" ::: Word32)
-> Ptr AllocationCreateInfo
-> Ptr ("memoryTypeIndex" ::: Word32)
-> IO Result
ffiVmaFindMemoryTypeIndex) (Allocator
allocator) ("memoryTypeIndex" ::: Word32
memoryTypeBits) Ptr AllocationCreateInfo
pAllocationCreateInfo (Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex))
  IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ())
-> IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "memoryTypeIndex" ::: Word32
pMemoryTypeIndex <- IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex
  ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32
pMemoryTypeIndex)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFindMemoryTypeIndexForBufferInfo" ffiVmaFindMemoryTypeIndexForBufferInfo
  :: Allocator -> Ptr (SomeStruct BufferCreateInfo) -> Ptr AllocationCreateInfo -> Ptr Word32 -> IO Result

-- | 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.
findMemoryTypeIndexForBufferInfo :: forall a io
                                  . (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
                                 => -- No documentation found for Nested "vmaFindMemoryTypeIndexForBufferInfo" "allocator"
                                    Allocator
                                 -> -- No documentation found for Nested "vmaFindMemoryTypeIndexForBufferInfo" "pBufferCreateInfo"
                                    (BufferCreateInfo a)
                                 -> -- No documentation found for Nested "vmaFindMemoryTypeIndexForBufferInfo" "pAllocationCreateInfo"
                                    AllocationCreateInfo
                                 -> io (("memoryTypeIndex" ::: Word32))
findMemoryTypeIndexForBufferInfo :: Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> io ("memoryTypeIndex" ::: Word32)
findMemoryTypeIndexForBufferInfo Allocator
allocator BufferCreateInfo a
bufferCreateInfo AllocationCreateInfo
allocationCreateInfo = IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> (ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (BufferCreateInfo a)
pBufferCreateInfo <- ((Ptr (BufferCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr (BufferCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO (Ptr (BufferCreateInfo a)))
-> ((Ptr (BufferCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr (BufferCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferCreateInfo a
-> (Ptr (BufferCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferCreateInfo a
bufferCreateInfo)
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex <- ((Ptr ("memoryTypeIndex" ::: Word32)
  -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("memoryTypeIndex" ::: Word32)
   -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32)
      IO
      (Ptr ("memoryTypeIndex" ::: Word32)))
-> ((Ptr ("memoryTypeIndex" ::: Word32)
     -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("memoryTypeIndex" ::: Word32))
-> (Ptr ("memoryTypeIndex" ::: Word32) -> IO ())
-> (Ptr ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("memoryTypeIndex" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 Int
4) Ptr ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result)
-> IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFindMemoryTypeIndexForBufferInfo" ((Allocator
-> Ptr (SomeStruct BufferCreateInfo)
-> Ptr AllocationCreateInfo
-> Ptr ("memoryTypeIndex" ::: Word32)
-> IO Result
ffiVmaFindMemoryTypeIndexForBufferInfo) (Allocator
allocator) (Ptr (BufferCreateInfo a) -> Ptr (SomeStruct BufferCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferCreateInfo a)
pBufferCreateInfo) Ptr AllocationCreateInfo
pAllocationCreateInfo (Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex))
  IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ())
-> IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "memoryTypeIndex" ::: Word32
pMemoryTypeIndex <- IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex
  ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32
pMemoryTypeIndex)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFindMemoryTypeIndexForImageInfo" ffiVmaFindMemoryTypeIndexForImageInfo
  :: Allocator -> Ptr (SomeStruct ImageCreateInfo) -> Ptr AllocationCreateInfo -> Ptr Word32 -> IO Result

-- | 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.
findMemoryTypeIndexForImageInfo :: forall a io
                                 . (Extendss ImageCreateInfo a, PokeChain a, MonadIO io)
                                => -- No documentation found for Nested "vmaFindMemoryTypeIndexForImageInfo" "allocator"
                                   Allocator
                                -> -- No documentation found for Nested "vmaFindMemoryTypeIndexForImageInfo" "pImageCreateInfo"
                                   (ImageCreateInfo a)
                                -> -- No documentation found for Nested "vmaFindMemoryTypeIndexForImageInfo" "pAllocationCreateInfo"
                                   AllocationCreateInfo
                                -> io (("memoryTypeIndex" ::: Word32))
findMemoryTypeIndexForImageInfo :: Allocator
-> ImageCreateInfo a
-> AllocationCreateInfo
-> io ("memoryTypeIndex" ::: Word32)
findMemoryTypeIndexForImageInfo Allocator
allocator ImageCreateInfo a
imageCreateInfo AllocationCreateInfo
allocationCreateInfo = IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> (ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
 -> io ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
-> io ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (ImageCreateInfo a)
pImageCreateInfo <- ((Ptr (ImageCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr (ImageCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (ImageCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO (Ptr (ImageCreateInfo a)))
-> ((Ptr (ImageCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr (ImageCreateInfo a))
forall a b. (a -> b) -> a -> b
$ ImageCreateInfo a
-> (Ptr (ImageCreateInfo a) -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImageCreateInfo a
imageCreateInfo)
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex <- ((Ptr ("memoryTypeIndex" ::: Word32)
  -> IO ("memoryTypeIndex" ::: Word32))
 -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("memoryTypeIndex" ::: Word32)
   -> IO ("memoryTypeIndex" ::: Word32))
  -> IO ("memoryTypeIndex" ::: Word32))
 -> ContT
      ("memoryTypeIndex" ::: Word32)
      IO
      (Ptr ("memoryTypeIndex" ::: Word32)))
-> ((Ptr ("memoryTypeIndex" ::: Word32)
     -> IO ("memoryTypeIndex" ::: Word32))
    -> IO ("memoryTypeIndex" ::: Word32))
-> ContT
     ("memoryTypeIndex" ::: Word32)
     IO
     (Ptr ("memoryTypeIndex" ::: Word32))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("memoryTypeIndex" ::: Word32))
-> (Ptr ("memoryTypeIndex" ::: Word32) -> IO ())
-> (Ptr ("memoryTypeIndex" ::: Word32)
    -> IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("memoryTypeIndex" ::: Word32))
forall a. Int -> IO (Ptr a)
callocBytes @Word32 Int
4) Ptr ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result)
-> IO Result -> ContT ("memoryTypeIndex" ::: Word32) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFindMemoryTypeIndexForImageInfo" ((Allocator
-> Ptr (SomeStruct ImageCreateInfo)
-> Ptr AllocationCreateInfo
-> Ptr ("memoryTypeIndex" ::: Word32)
-> IO Result
ffiVmaFindMemoryTypeIndexForImageInfo) (Allocator
allocator) (Ptr (ImageCreateInfo a) -> Ptr (SomeStruct ImageCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (ImageCreateInfo a)
pImageCreateInfo) Ptr AllocationCreateInfo
pAllocationCreateInfo (Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex))
  IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ())
-> IO () -> ContT ("memoryTypeIndex" ::: Word32) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "memoryTypeIndex" ::: Word32
pMemoryTypeIndex <- IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> IO ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 Ptr ("memoryTypeIndex" ::: Word32)
pPMemoryTypeIndex
  ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("memoryTypeIndex" ::: Word32)
 -> ContT
      ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32))
-> ("memoryTypeIndex" ::: Word32)
-> ContT
     ("memoryTypeIndex" ::: Word32) IO ("memoryTypeIndex" ::: Word32)
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32
pMemoryTypeIndex)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreatePool" ffiVmaCreatePool
  :: Allocator -> Ptr PoolCreateInfo -> Ptr Pool -> IO Result

-- | Allocates Vulkan device memory and creates 'Pool' object.
--
-- __Parameters__
--
-- +-----------+-------------+-----------------------------------------------+
-- |           | allocator   | Allocator object.                             |
-- +-----------+-------------+-----------------------------------------------+
-- |           | pCreateInfo | Parameters of pool to create.                 |
-- +-----------+-------------+-----------------------------------------------+
-- | out       | pPool       | Handle to created pool.                       |
-- +-----------+-------------+-----------------------------------------------+
createPool :: forall io
            . (MonadIO io)
           => -- No documentation found for Nested "vmaCreatePool" "allocator"
              Allocator
           -> -- No documentation found for Nested "vmaCreatePool" "pCreateInfo"
              PoolCreateInfo
           -> io (Pool)
createPool :: Allocator -> PoolCreateInfo -> io Pool
createPool Allocator
allocator PoolCreateInfo
createInfo = IO Pool -> io Pool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Pool -> io Pool)
-> (ContT Pool IO Pool -> IO Pool) -> ContT Pool IO Pool -> io Pool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Pool IO Pool -> IO Pool
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Pool IO Pool -> io Pool) -> ContT Pool IO Pool -> io Pool
forall a b. (a -> b) -> a -> b
$ do
  Ptr PoolCreateInfo
pCreateInfo <- ((Ptr PoolCreateInfo -> IO Pool) -> IO Pool)
-> ContT Pool IO (Ptr PoolCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr PoolCreateInfo -> IO Pool) -> IO Pool)
 -> ContT Pool IO (Ptr PoolCreateInfo))
-> ((Ptr PoolCreateInfo -> IO Pool) -> IO Pool)
-> ContT Pool IO (Ptr PoolCreateInfo)
forall a b. (a -> b) -> a -> b
$ PoolCreateInfo -> (Ptr PoolCreateInfo -> IO Pool) -> IO Pool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (PoolCreateInfo
createInfo)
  Ptr Pool
pPPool <- ((Ptr Pool -> IO Pool) -> IO Pool) -> ContT Pool IO (Ptr Pool)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Pool -> IO Pool) -> IO Pool) -> ContT Pool IO (Ptr Pool))
-> ((Ptr Pool -> IO Pool) -> IO Pool) -> ContT Pool IO (Ptr Pool)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Pool)
-> (Ptr Pool -> IO ()) -> (Ptr Pool -> IO Pool) -> IO Pool
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Pool)
forall a. Int -> IO (Ptr a)
callocBytes @Pool Int
8) Ptr Pool -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Pool IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Pool IO Result)
-> IO Result -> ContT Pool IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreatePool" ((Allocator -> Ptr PoolCreateInfo -> Ptr Pool -> IO Result
ffiVmaCreatePool) (Allocator
allocator) Ptr PoolCreateInfo
pCreateInfo (Ptr Pool
pPPool))
  IO () -> ContT Pool IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Pool IO ()) -> IO () -> ContT Pool IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Pool
pPool <- IO Pool -> ContT Pool IO Pool
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Pool -> ContT Pool IO Pool) -> IO Pool -> ContT Pool IO Pool
forall a b. (a -> b) -> a -> b
$ Ptr Pool -> IO Pool
forall a. Storable a => Ptr a -> IO a
peek @Pool Ptr Pool
pPPool
  Pool -> ContT Pool IO Pool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Pool -> ContT Pool IO Pool) -> Pool -> ContT Pool IO Pool
forall a b. (a -> b) -> a -> b
$ (Pool
pPool)

-- | A convenience wrapper to make a compatible pair of calls to 'createPool'
-- and 'destroyPool'
--
-- To ensure that 'destroyPool' is always called: pass
-- 'Control.Exception.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.
--
withPool :: forall io r . MonadIO io => Allocator -> PoolCreateInfo -> (io Pool -> (Pool -> io ()) -> r) -> r
withPool :: Allocator
-> PoolCreateInfo -> (io Pool -> (Pool -> io ()) -> r) -> r
withPool Allocator
allocator PoolCreateInfo
pCreateInfo io Pool -> (Pool -> io ()) -> r
b =
  io Pool -> (Pool -> io ()) -> r
b (Allocator -> PoolCreateInfo -> io Pool
forall (io :: * -> *).
MonadIO io =>
Allocator -> PoolCreateInfo -> io Pool
createPool Allocator
allocator PoolCreateInfo
pCreateInfo)
    (\(Pool
o0) -> Allocator -> Pool -> io ()
forall (io :: * -> *). MonadIO io => Allocator -> Pool -> io ()
destroyPool Allocator
allocator Pool
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaDestroyPool" ffiVmaDestroyPool
  :: Allocator -> Pool -> IO ()

-- | Destroys 'Pool' object and frees Vulkan device memory.
destroyPool :: forall io
             . (MonadIO io)
            => -- No documentation found for Nested "vmaDestroyPool" "allocator"
               Allocator
            -> -- No documentation found for Nested "vmaDestroyPool" "pool"
               Pool
            -> io ()
destroyPool :: Allocator -> Pool -> io ()
destroyPool Allocator
allocator Pool
pool = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaDestroyPool" ((Allocator -> Pool -> IO ()
ffiVmaDestroyPool) (Allocator
allocator) (Pool
pool))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetPoolStatistics" ffiVmaGetPoolStatistics
  :: Allocator -> Pool -> Ptr Statistics -> IO ()

-- | Retrieves statistics of existing 'Pool' object.
--
-- __Parameters__
--
-- +-----------+------------+-----------------------------------------------+
-- |           | allocator  | Allocator object.                             |
-- +-----------+------------+-----------------------------------------------+
-- |           | pool       | Pool object.                                  |
-- +-----------+------------+-----------------------------------------------+
-- | out       | pPoolStats | Statistics of specified pool.                 |
-- +-----------+------------+-----------------------------------------------+
getPoolStatistics :: forall io
                   . (MonadIO io)
                  => -- No documentation found for Nested "vmaGetPoolStatistics" "allocator"
                     Allocator
                  -> -- No documentation found for Nested "vmaGetPoolStatistics" "pool"
                     Pool
                  -> io (("poolStats" ::: Statistics))
getPoolStatistics :: Allocator -> Pool -> io ("poolStats" ::: Statistics)
getPoolStatistics Allocator
allocator Pool
pool = IO ("poolStats" ::: Statistics) -> io ("poolStats" ::: Statistics)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("poolStats" ::: Statistics)
 -> io ("poolStats" ::: Statistics))
-> (ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
    -> IO ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> io ("poolStats" ::: Statistics)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> IO ("poolStats" ::: Statistics)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
 -> io ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> io ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("poolStats" ::: Statistics)
pPPoolStats <- ((Ptr ("poolStats" ::: Statistics)
  -> IO ("poolStats" ::: Statistics))
 -> IO ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO (Ptr ("poolStats" ::: Statistics))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("poolStats" ::: Statistics) =>
(Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @Statistics)
  IO () -> ContT ("poolStats" ::: Statistics) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("poolStats" ::: Statistics) IO ())
-> IO () -> ContT ("poolStats" ::: Statistics) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetPoolStatistics" ((Allocator -> Pool -> Ptr ("poolStats" ::: Statistics) -> IO ()
ffiVmaGetPoolStatistics) (Allocator
allocator) (Pool
pool) (Ptr ("poolStats" ::: Statistics)
pPPoolStats))
  "poolStats" ::: Statistics
pPoolStats <- IO ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("poolStats" ::: Statistics)
 -> ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics))
-> IO ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Statistics Ptr ("poolStats" ::: Statistics)
pPPoolStats
  ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: Statistics)
 -> ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics))
-> ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: Statistics
pPoolStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCalculatePoolStatistics" ffiVmaCalculatePoolStatistics
  :: Allocator -> Pool -> Ptr DetailedStatistics -> IO ()

-- | Retrieves detailed statistics of existing 'Pool' object.
--
-- __Parameters__
--
-- +-----------+------------+-----------------------------------------------+
-- |           | allocator  | Allocator object.                             |
-- +-----------+------------+-----------------------------------------------+
-- |           | pool       | Pool object.                                  |
-- +-----------+------------+-----------------------------------------------+
-- | out       | pPoolStats | Statistics of specified pool.                 |
-- +-----------+------------+-----------------------------------------------+
calculatePoolStatistics :: forall io
                         . (MonadIO io)
                        => -- No documentation found for Nested "vmaCalculatePoolStatistics" "allocator"
                           Allocator
                        -> -- No documentation found for Nested "vmaCalculatePoolStatistics" "pool"
                           Pool
                        -> io (("poolStats" ::: DetailedStatistics))
calculatePoolStatistics :: Allocator -> Pool -> io ("poolStats" ::: DetailedStatistics)
calculatePoolStatistics Allocator
allocator Pool
pool = IO ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("poolStats" ::: DetailedStatistics)
 -> io ("poolStats" ::: DetailedStatistics))
-> (ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics)
    -> IO ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("poolStats" ::: DetailedStatistics)
  IO
  ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("poolStats" ::: DetailedStatistics)
   IO
   ("poolStats" ::: DetailedStatistics)
 -> io ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("poolStats" ::: DetailedStatistics)
pPPoolStats <- ((Ptr ("poolStats" ::: DetailedStatistics)
  -> IO ("poolStats" ::: DetailedStatistics))
 -> IO ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     (Ptr ("poolStats" ::: DetailedStatistics))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("poolStats" ::: DetailedStatistics) =>
(Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @DetailedStatistics)
  IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ())
-> IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCalculatePoolStatistics" ((Allocator
-> Pool -> Ptr ("poolStats" ::: DetailedStatistics) -> IO ()
ffiVmaCalculatePoolStatistics) (Allocator
allocator) (Pool
pool) (Ptr ("poolStats" ::: DetailedStatistics)
pPPoolStats))
  "poolStats" ::: DetailedStatistics
pPoolStats <- IO ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("poolStats" ::: DetailedStatistics)
 -> ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics))
-> IO ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DetailedStatistics Ptr ("poolStats" ::: DetailedStatistics)
pPPoolStats
  ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: DetailedStatistics)
 -> ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics))
-> ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: DetailedStatistics
pPoolStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCheckPoolCorruption" ffiVmaCheckPoolCorruption
  :: Allocator -> Pool -> IO Result

-- | 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.
checkPoolCorruption :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaCheckPoolCorruption" "allocator"
                       Allocator
                    -> -- No documentation found for Nested "vmaCheckPoolCorruption" "pool"
                       Pool
                    -> io ()
checkPoolCorruption :: Allocator -> Pool -> io ()
checkPoolCorruption Allocator
allocator Pool
pool = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCheckPoolCorruption" ((Allocator -> Pool -> IO Result
ffiVmaCheckPoolCorruption) (Allocator
allocator) (Pool
pool))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetPoolName" ffiVmaGetPoolName
  :: Allocator -> Pool -> Ptr (Ptr CChar) -> IO ()

-- | 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'.
getPoolName :: forall io
             . (MonadIO io)
            => -- No documentation found for Nested "vmaGetPoolName" "allocator"
               Allocator
            -> -- No documentation found for Nested "vmaGetPoolName" "pool"
               Pool
            -> io (("name" ::: Ptr CChar))
getPoolName :: Allocator -> Pool -> io ("name" ::: Ptr CChar)
getPoolName Allocator
allocator Pool
pool = IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar))
-> (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> IO ("name" ::: Ptr CChar)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
 -> io ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("name" ::: Ptr CChar)
pPpName <- ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
 -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
  -> IO ("name" ::: Ptr CChar))
 -> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("name" ::: Ptr CChar))
-> (Ptr ("name" ::: Ptr CChar) -> IO ())
-> (Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("name" ::: Ptr CChar))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr CChar) Int
8) Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: Ptr CChar) IO ())
-> IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetPoolName" ((Allocator -> Pool -> Ptr ("name" ::: Ptr CChar) -> IO ()
ffiVmaGetPoolName) (Allocator
allocator) (Pool
pool) (Ptr ("name" ::: Ptr CChar)
pPpName))
  "name" ::: Ptr CChar
ppName <- IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr CChar) Ptr ("name" ::: Ptr CChar)
pPpName
  ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: Ptr CChar
ppName)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaSetPoolName" ffiVmaSetPoolName
  :: Allocator -> Pool -> Ptr CChar -> IO ()

-- | 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.
setPoolName :: forall io
             . (MonadIO io)
            => -- No documentation found for Nested "vmaSetPoolName" "allocator"
               Allocator
            -> -- No documentation found for Nested "vmaSetPoolName" "pool"
               Pool
            -> -- No documentation found for Nested "vmaSetPoolName" "pName"
               ("name" ::: Maybe ByteString)
            -> io ()
setPoolName :: Allocator -> Pool -> ("name" ::: Maybe ByteString) -> io ()
setPoolName Allocator
allocator Pool
pool "name" ::: Maybe ByteString
name = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  "name" ::: Ptr CChar
pName <- case ("name" ::: Maybe ByteString
name) of
    "name" ::: Maybe ByteString
Nothing -> ("name" ::: Ptr CChar) -> ContT () IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "name" ::: Ptr CChar
forall a. Ptr a
nullPtr
    Just ByteString
j -> ((("name" ::: Ptr CChar) -> IO ()) -> IO ())
-> ContT () IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO ()) -> IO ())
 -> ContT () IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO ()) -> IO ())
-> ContT () IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ByteString -> (("name" ::: Ptr CChar) -> IO ()) -> IO ()
forall a. ByteString -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString (ByteString
j)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaSetPoolName" ((Allocator -> Pool -> ("name" ::: Ptr CChar) -> IO ()
ffiVmaSetPoolName) (Allocator
allocator) (Pool
pool) "name" ::: Ptr CChar
pName)
  () -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaAllocateMemory" ffiVmaAllocateMemory
  :: Allocator -> Ptr MemoryRequirements -> Ptr AllocationCreateInfo -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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.
allocateMemory :: forall io
                . (MonadIO io)
               => -- No documentation found for Nested "vmaAllocateMemory" "allocator"
                  Allocator
               -> -- No documentation found for Nested "vmaAllocateMemory" "pVkMemoryRequirements"
                  ("vkMemoryRequirements" ::: MemoryRequirements)
               -> -- No documentation found for Nested "vmaAllocateMemory" "pCreateInfo"
                  AllocationCreateInfo
               -> io (Allocation, AllocationInfo)
allocateMemory :: Allocator
-> ("vkMemoryRequirements" ::: MemoryRequirements)
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
allocateMemory Allocator
allocator "vkMemoryRequirements" ::: MemoryRequirements
vkMemoryRequirements AllocationCreateInfo
createInfo = IO (Allocation, AllocationInfo) -> io (Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> (ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
    -> IO (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> IO (Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
pVkMemoryRequirements <- ((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
  -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo)
     IO
     (Ptr ("vkMemoryRequirements" ::: MemoryRequirements))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
   -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT
      (Allocation, AllocationInfo)
      IO
      (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)))
-> ((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
     -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo)
     IO
     (Ptr ("vkMemoryRequirements" ::: MemoryRequirements))
forall a b. (a -> b) -> a -> b
$ ("vkMemoryRequirements" ::: MemoryRequirements)
-> (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
    -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct ("vkMemoryRequirements" ::: MemoryRequirements
vkMemoryRequirements)
  Ptr AllocationCreateInfo
pCreateInfo <- ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT
      (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
createInfo)
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT (Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Allocation, AllocationInfo) IO Result)
-> IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaAllocateMemory" ((Allocator
-> Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
-> Ptr AllocationCreateInfo
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaAllocateMemory) (Allocator
allocator) Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
pVkMemoryRequirements Ptr AllocationCreateInfo
pCreateInfo (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Allocation
pAllocation <- IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Allocation, AllocationInfo)
 -> ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo))
-> (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Allocation
pAllocation, AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'allocateMemory' and 'freeMemory'
--
-- To ensure that 'freeMemory' is always called: pass
-- 'Control.Exception.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.
--
withMemory :: forall io r . MonadIO io => Allocator -> MemoryRequirements -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
withMemory :: Allocator
-> ("vkMemoryRequirements" ::: MemoryRequirements)
-> AllocationCreateInfo
-> (io (Allocation, AllocationInfo)
    -> ((Allocation, AllocationInfo) -> io ()) -> r)
-> r
withMemory Allocator
allocator "vkMemoryRequirements" ::: MemoryRequirements
pVkMemoryRequirements AllocationCreateInfo
pCreateInfo io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b =
  io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b (Allocator
-> ("vkMemoryRequirements" ::: MemoryRequirements)
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> ("vkMemoryRequirements" ::: MemoryRequirements)
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
allocateMemory Allocator
allocator "vkMemoryRequirements" ::: MemoryRequirements
pVkMemoryRequirements AllocationCreateInfo
pCreateInfo)
    (\(Allocation
o0, AllocationInfo
_) -> Allocator -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Allocation -> io ()
freeMemory Allocator
allocator Allocation
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaAllocateMemoryPages" ffiVmaAllocateMemoryPages
  :: Allocator -> Ptr MemoryRequirements -> Ptr AllocationCreateInfo -> CSize -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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@.
allocateMemoryPages :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaAllocateMemoryPages" "allocator"
                       Allocator
                    -> -- No documentation found for Nested "vmaAllocateMemoryPages" "pVkMemoryRequirements"
                       ("vkMemoryRequirements" ::: Vector MemoryRequirements)
                    -> -- No documentation found for Nested "vmaAllocateMemoryPages" "pCreateInfo"
                       ("createInfo" ::: Vector AllocationCreateInfo)
                    -> io (("allocations" ::: Vector Allocation), ("allocationInfo" ::: Vector AllocationInfo))
allocateMemoryPages :: Allocator
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> ("createInfo" ::: Vector AllocationCreateInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
allocateMemoryPages Allocator
allocator "vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
vkMemoryRequirements "createInfo" ::: Vector AllocationCreateInfo
createInfo = IO
  ("allocations" ::: Vector Allocation,
   "allocationInfo" ::: Vector AllocationInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO
   ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
 -> io
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> (ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("allocations" ::: Vector Allocation,
   "allocationInfo" ::: Vector AllocationInfo)
  IO
  ("allocations" ::: Vector Allocation,
   "allocationInfo" ::: Vector AllocationInfo)
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
   IO
   ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
 -> io
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
pPVkMemoryRequirements <- ((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr ("vkMemoryRequirements" ::: MemoryRequirements))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)))
-> ((Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr ("vkMemoryRequirements" ::: MemoryRequirements))
forall a b. (a -> b) -> a -> b
$ Int
-> (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @MemoryRequirements ((("vkMemoryRequirements"
 ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> Int
forall a. Vector a -> Int
Data.Vector.length ("vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
vkMemoryRequirements)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
24)
  (Int
 -> ("vkMemoryRequirements" ::: MemoryRequirements)
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "vkMemoryRequirements" ::: MemoryRequirements
e -> ((()
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((()
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> ((()
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
-> ("vkMemoryRequirements" ::: MemoryRequirements)
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
pPVkMemoryRequirements Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
-> Int -> Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr MemoryRequirements) ("vkMemoryRequirements" ::: MemoryRequirements
e) (IO
   ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ((()
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> (()
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((()
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ()
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. (a -> b) -> a -> b
$ ())) ("vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
vkMemoryRequirements)
  Ptr AllocationCreateInfo
pPCreateInfo <- ((Ptr AllocationCreateInfo
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ Int
-> (Ptr AllocationCreateInfo
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @AllocationCreateInfo ((("createInfo" ::: Vector AllocationCreateInfo) -> Int
forall a. Vector a -> Int
Data.Vector.length ("createInfo" ::: Vector AllocationCreateInfo
createInfo)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
48)
  IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ (Int -> AllocationCreateInfo -> IO ())
-> ("createInfo" ::: Vector AllocationCreateInfo) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i AllocationCreateInfo
e -> Ptr AllocationCreateInfo -> AllocationCreateInfo -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr AllocationCreateInfo
pPCreateInfo Ptr AllocationCreateInfo -> Int -> Ptr AllocationCreateInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
48 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr AllocationCreateInfo) (AllocationCreateInfo
e)) ("createInfo" ::: Vector AllocationCreateInfo
createInfo)
  let pVkMemoryRequirementsLength :: Int
pVkMemoryRequirementsLength = ("vkMemoryRequirements"
 ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> Int
forall a. Vector a -> Int
Data.Vector.length (("vkMemoryRequirements"
  ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
 -> Int)
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> Int
forall a b. (a -> b) -> a -> b
$ ("vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
vkMemoryRequirements)
  IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((("createInfo" ::: Vector AllocationCreateInfo) -> Int
forall a. Vector a -> Int
Data.Vector.length (("createInfo" ::: Vector AllocationCreateInfo) -> Int)
-> ("createInfo" ::: Vector AllocationCreateInfo) -> Int
forall a b. (a -> b) -> a -> b
$ ("createInfo" ::: Vector AllocationCreateInfo
createInfo)) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
pVkMemoryRequirementsLength) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pCreateInfo and pVkMemoryRequirements must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  Ptr Allocation
pPAllocations <- ((Ptr Allocation
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      (Ptr Allocation))
-> ((Ptr Allocation
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation ((CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationInfo
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      (Ptr AllocationInfo))
-> ((Ptr AllocationInfo
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     (Ptr AllocationInfo)
forall a b. (a -> b) -> a -> b
$ IO (Ptr AllocationInfo)
-> (Ptr AllocationInfo -> IO ())
-> (Ptr AllocationInfo
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr AllocationInfo)
forall a. Int -> IO (Ptr a)
callocBytes @AllocationInfo ((CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
56)) Ptr AllocationInfo -> IO ()
forall a. Ptr a -> IO ()
free
  [()]
_ <- (Int
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> [Int]
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\Int
i -> ((()
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((()
   -> IO
        ("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo))
  -> IO
       ("allocations" ::: Vector Allocation,
        "allocationInfo" ::: Vector AllocationInfo))
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> ((()
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct (Ptr AllocationInfo
pPAllocationInfo Ptr AllocationInfo -> Int -> Ptr AllocationInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
56) :: Ptr AllocationInfo) (IO
   ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ((()
     -> IO
          ("allocations" ::: Vector Allocation,
           "allocationInfo" ::: Vector AllocationInfo))
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> (()
    -> IO
         ("allocations" ::: Vector Allocation,
          "allocationInfo" ::: Vector AllocationInfo))
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((()
 -> IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ()
-> IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. (a -> b) -> a -> b
$ ())) [Int
0..(CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize))) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]
  Result
r <- IO Result
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      Result)
-> IO Result
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaAllocateMemoryPages" ((Allocator
-> Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
-> Ptr AllocationCreateInfo
-> CSize
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaAllocateMemoryPages) (Allocator
allocator) (Ptr ("vkMemoryRequirements" ::: MemoryRequirements)
pPVkMemoryRequirements) (Ptr AllocationCreateInfo
pPCreateInfo) ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize)) (Ptr Allocation
pPAllocations) ((Ptr AllocationInfo
pPAllocationInfo)))
  IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ())
-> IO ()
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "allocations" ::: Vector Allocation
pAllocations <- IO ("allocations" ::: Vector Allocation)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("allocations" ::: Vector Allocation)
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ("allocations" ::: Vector Allocation))
-> IO ("allocations" ::: Vector Allocation)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO Allocation)
-> IO ("allocations" ::: Vector Allocation)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize))) (\Int
i -> Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation ((Ptr Allocation
pPAllocations Ptr Allocation -> Int -> Ptr Allocation
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Allocation)))
  "allocationInfo" ::: Vector AllocationInfo
pAllocationInfo <- IO ("allocationInfo" ::: Vector AllocationInfo)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocationInfo" ::: Vector AllocationInfo)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("allocationInfo" ::: Vector AllocationInfo)
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ("allocationInfo" ::: Vector AllocationInfo))
-> IO ("allocationInfo" ::: Vector AllocationInfo)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocationInfo" ::: Vector AllocationInfo)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO AllocationInfo)
-> IO ("allocationInfo" ::: Vector AllocationInfo)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pVkMemoryRequirementsLength :: CSize))) (\Int
i -> Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo (((Ptr AllocationInfo
pPAllocationInfo) Ptr AllocationInfo -> Int -> Ptr AllocationInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
56 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr AllocationInfo)))
  ("allocations" ::: Vector Allocation,
 "allocationInfo" ::: Vector AllocationInfo)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("allocations" ::: Vector Allocation,
  "allocationInfo" ::: Vector AllocationInfo)
 -> ContT
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
      IO
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo))
-> ("allocations" ::: Vector Allocation,
    "allocationInfo" ::: Vector AllocationInfo)
-> ContT
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
     IO
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall a b. (a -> b) -> a -> b
$ ("allocations" ::: Vector Allocation
pAllocations, "allocationInfo" ::: Vector AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'allocateMemoryPages' and 'freeMemoryPages'
--
-- To ensure that 'freeMemoryPages' is always called: pass
-- 'Control.Exception.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.
--
withMemoryPages :: forall io r . MonadIO io => Allocator -> Vector MemoryRequirements -> Vector AllocationCreateInfo -> (io (Vector Allocation, Vector AllocationInfo) -> ((Vector Allocation, Vector AllocationInfo) -> io ()) -> r) -> r
withMemoryPages :: Allocator
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> ("createInfo" ::: Vector AllocationCreateInfo)
-> (io
      ("allocations" ::: Vector Allocation,
       "allocationInfo" ::: Vector AllocationInfo)
    -> (("allocations" ::: Vector Allocation,
         "allocationInfo" ::: Vector AllocationInfo)
        -> io ())
    -> r)
-> r
withMemoryPages Allocator
allocator "vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
pVkMemoryRequirements "createInfo" ::: Vector AllocationCreateInfo
pCreateInfo io
  ("allocations" ::: Vector Allocation,
   "allocationInfo" ::: Vector AllocationInfo)
-> (("allocations" ::: Vector Allocation,
     "allocationInfo" ::: Vector AllocationInfo)
    -> io ())
-> r
b =
  io
  ("allocations" ::: Vector Allocation,
   "allocationInfo" ::: Vector AllocationInfo)
-> (("allocations" ::: Vector Allocation,
     "allocationInfo" ::: Vector AllocationInfo)
    -> io ())
-> r
b (Allocator
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> ("createInfo" ::: Vector AllocationCreateInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> ("vkMemoryRequirements"
    ::: Vector ("vkMemoryRequirements" ::: MemoryRequirements))
-> ("createInfo" ::: Vector AllocationCreateInfo)
-> io
     ("allocations" ::: Vector Allocation,
      "allocationInfo" ::: Vector AllocationInfo)
allocateMemoryPages Allocator
allocator "vkMemoryRequirements"
::: Vector ("vkMemoryRequirements" ::: MemoryRequirements)
pVkMemoryRequirements "createInfo" ::: Vector AllocationCreateInfo
pCreateInfo)
    (\("allocations" ::: Vector Allocation
o0, "allocationInfo" ::: Vector AllocationInfo
_) -> Allocator -> ("allocations" ::: Vector Allocation) -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> ("allocations" ::: Vector Allocation) -> io ()
freeMemoryPages Allocator
allocator "allocations" ::: Vector Allocation
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaAllocateMemoryForBuffer" ffiVmaAllocateMemoryForBuffer
  :: Allocator -> Buffer -> Ptr AllocationCreateInfo -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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.
allocateMemoryForBuffer :: forall io
                         . (MonadIO io)
                        => -- No documentation found for Nested "vmaAllocateMemoryForBuffer" "allocator"
                           Allocator
                        -> -- No documentation found for Nested "vmaAllocateMemoryForBuffer" "buffer"
                           Buffer
                        -> -- No documentation found for Nested "vmaAllocateMemoryForBuffer" "pCreateInfo"
                           AllocationCreateInfo
                        -> io (Allocation, AllocationInfo)
allocateMemoryForBuffer :: Allocator
-> Buffer
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
allocateMemoryForBuffer Allocator
allocator Buffer
buffer AllocationCreateInfo
createInfo = IO (Allocation, AllocationInfo) -> io (Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> (ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
    -> IO (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> IO (Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocationCreateInfo
pCreateInfo <- ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT
      (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
createInfo)
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT (Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Allocation, AllocationInfo) IO Result)
-> IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaAllocateMemoryForBuffer" ((Allocator
-> Buffer
-> Ptr AllocationCreateInfo
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaAllocateMemoryForBuffer) (Allocator
allocator) (Buffer
buffer) Ptr AllocationCreateInfo
pCreateInfo (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Allocation
pAllocation <- IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Allocation, AllocationInfo)
 -> ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo))
-> (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Allocation
pAllocation, AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'allocateMemoryForBuffer' and 'freeMemory'
--
-- To ensure that 'freeMemory' is always called: pass
-- 'Control.Exception.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.
--
withMemoryForBuffer :: forall io r . MonadIO io => Allocator -> Buffer -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
withMemoryForBuffer :: Allocator
-> Buffer
-> AllocationCreateInfo
-> (io (Allocation, AllocationInfo)
    -> ((Allocation, AllocationInfo) -> io ()) -> r)
-> r
withMemoryForBuffer Allocator
allocator Buffer
buffer AllocationCreateInfo
pCreateInfo io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b =
  io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b (Allocator
-> Buffer
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> Buffer
-> AllocationCreateInfo
-> io (Allocation, AllocationInfo)
allocateMemoryForBuffer Allocator
allocator Buffer
buffer AllocationCreateInfo
pCreateInfo)
    (\(Allocation
o0, AllocationInfo
_) -> Allocator -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Allocation -> io ()
freeMemory Allocator
allocator Allocation
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaAllocateMemoryForImage" ffiVmaAllocateMemoryForImage
  :: Allocator -> Image -> Ptr AllocationCreateInfo -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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.
allocateMemoryForImage :: forall io
                        . (MonadIO io)
                       => -- No documentation found for Nested "vmaAllocateMemoryForImage" "allocator"
                          Allocator
                       -> -- No documentation found for Nested "vmaAllocateMemoryForImage" "image"
                          Image
                       -> -- No documentation found for Nested "vmaAllocateMemoryForImage" "pCreateInfo"
                          AllocationCreateInfo
                       -> io (Allocation, AllocationInfo)
allocateMemoryForImage :: Allocator
-> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
allocateMemoryForImage Allocator
allocator Image
image AllocationCreateInfo
createInfo = IO (Allocation, AllocationInfo) -> io (Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> (ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
    -> IO (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> IO (Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
 -> io (Allocation, AllocationInfo))
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
-> io (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocationCreateInfo
pCreateInfo <- ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT
      (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
createInfo)
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Allocation, AllocationInfo))
  -> IO (Allocation, AllocationInfo))
 -> ContT (Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Allocation, AllocationInfo))
    -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Allocation, AllocationInfo))
-> IO (Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Allocation, AllocationInfo))
 -> IO (Allocation, AllocationInfo))
-> ContT (Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Allocation, AllocationInfo) IO Result)
-> IO Result -> ContT (Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaAllocateMemoryForImage" ((Allocator
-> Image
-> Ptr AllocationCreateInfo
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaAllocateMemoryForImage) (Allocator
allocator) (Image
image) Ptr AllocationCreateInfo
pCreateInfo (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Allocation
pAllocation <- IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation -> ContT (Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Allocation, AllocationInfo)
 -> ContT
      (Allocation, AllocationInfo) IO (Allocation, AllocationInfo))
-> (Allocation, AllocationInfo)
-> ContT
     (Allocation, AllocationInfo) IO (Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Allocation
pAllocation, AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'allocateMemoryForImage' and 'freeMemory'
--
-- To ensure that 'freeMemory' is always called: pass
-- 'Control.Exception.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.
--
withMemoryForImage :: forall io r . MonadIO io => Allocator -> Image -> AllocationCreateInfo -> (io (Allocation, AllocationInfo) -> ((Allocation, AllocationInfo) -> io ()) -> r) -> r
withMemoryForImage :: Allocator
-> Image
-> AllocationCreateInfo
-> (io (Allocation, AllocationInfo)
    -> ((Allocation, AllocationInfo) -> io ()) -> r)
-> r
withMemoryForImage Allocator
allocator Image
image AllocationCreateInfo
pCreateInfo io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b =
  io (Allocation, AllocationInfo)
-> ((Allocation, AllocationInfo) -> io ()) -> r
b (Allocator
-> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> Image -> AllocationCreateInfo -> io (Allocation, AllocationInfo)
allocateMemoryForImage Allocator
allocator Image
image AllocationCreateInfo
pCreateInfo)
    (\(Allocation
o0, AllocationInfo
_) -> Allocator -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Allocation -> io ()
freeMemory Allocator
allocator Allocation
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFreeMemory" ffiVmaFreeMemory
  :: Allocator -> Allocation -> IO ()

-- | Frees memory previously allocated using 'allocateMemory',
-- 'allocateMemoryForBuffer', or 'allocateMemoryForImage'.
--
-- Passing @VK_NULL_HANDLE@ as @allocation@ is valid. Such function call is
-- just skipped.
freeMemory :: forall io
            . (MonadIO io)
           => -- No documentation found for Nested "vmaFreeMemory" "allocator"
              Allocator
           -> -- No documentation found for Nested "vmaFreeMemory" "allocation"
              Allocation
           -> io ()
freeMemory :: Allocator -> Allocation -> io ()
freeMemory Allocator
allocator Allocation
allocation = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFreeMemory" ((Allocator -> Allocation -> IO ()
ffiVmaFreeMemory) (Allocator
allocator) (Allocation
allocation))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFreeMemoryPages" ffiVmaFreeMemoryPages
  :: Allocator -> CSize -> Ptr Allocation -> IO ()

-- | 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.
freeMemoryPages :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaFreeMemoryPages" "allocator"
                   Allocator
                -> -- No documentation found for Nested "vmaFreeMemoryPages" "pAllocations"
                   ("allocations" ::: Vector Allocation)
                -> io ()
freeMemoryPages :: Allocator -> ("allocations" ::: Vector Allocation) -> io ()
freeMemoryPages Allocator
allocator "allocations" ::: Vector Allocation
allocations = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Ptr Allocation
pPAllocations <- ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO ()) -> IO ())
 -> ContT () IO (Ptr Allocation))
-> ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr Allocation -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Allocation ((("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length ("allocations" ::: Vector Allocation
allocations)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Allocation -> IO ())
-> ("allocations" ::: Vector Allocation) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Allocation
e -> Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Allocation
pPAllocations Ptr Allocation -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Allocation) (Allocation
e)) ("allocations" ::: Vector Allocation
allocations)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFreeMemoryPages" ((Allocator -> CSize -> Ptr Allocation -> IO ()
ffiVmaFreeMemoryPages) (Allocator
allocator) ((Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length (("allocations" ::: Vector Allocation) -> Int)
-> ("allocations" ::: Vector Allocation) -> Int
forall a b. (a -> b) -> a -> b
$ ("allocations" ::: Vector Allocation
allocations)) :: CSize)) (Ptr Allocation
pPAllocations))
  () -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetAllocationInfo" ffiVmaGetAllocationInfo
  :: Allocator -> Allocation -> Ptr AllocationInfo -> IO ()

-- | 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).
getAllocationInfo :: forall io
                   . (MonadIO io)
                  => -- No documentation found for Nested "vmaGetAllocationInfo" "allocator"
                     Allocator
                  -> -- No documentation found for Nested "vmaGetAllocationInfo" "allocation"
                     Allocation
                  -> io (AllocationInfo)
getAllocationInfo :: Allocator -> Allocation -> io AllocationInfo
getAllocationInfo Allocator
allocator Allocation
allocation = IO AllocationInfo -> io AllocationInfo
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO AllocationInfo -> io AllocationInfo)
-> (ContT AllocationInfo IO AllocationInfo -> IO AllocationInfo)
-> ContT AllocationInfo IO AllocationInfo
-> io AllocationInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT AllocationInfo IO AllocationInfo -> IO AllocationInfo
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT AllocationInfo IO AllocationInfo -> io AllocationInfo)
-> ContT AllocationInfo IO AllocationInfo -> io AllocationInfo
forall a b. (a -> b) -> a -> b
$ do
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO AllocationInfo) -> IO AllocationInfo)
-> ContT AllocationInfo IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  IO () -> ContT AllocationInfo IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT AllocationInfo IO ())
-> IO () -> ContT AllocationInfo IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetAllocationInfo" ((Allocator -> Allocation -> Ptr AllocationInfo -> IO ()
ffiVmaGetAllocationInfo) (Allocator
allocator) (Allocation
allocation) (Ptr AllocationInfo
pPAllocationInfo))
  AllocationInfo
pAllocationInfo <- IO AllocationInfo -> ContT AllocationInfo IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo -> ContT AllocationInfo IO AllocationInfo)
-> IO AllocationInfo -> ContT AllocationInfo IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  AllocationInfo -> ContT AllocationInfo IO AllocationInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocationInfo -> ContT AllocationInfo IO AllocationInfo)
-> AllocationInfo -> ContT AllocationInfo IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ (AllocationInfo
pAllocationInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaSetAllocationUserData" ffiVmaSetAllocationUserData
  :: Allocator -> Allocation -> Ptr () -> IO ()

-- | 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.
setAllocationUserData :: forall io
                       . (MonadIO io)
                      => -- No documentation found for Nested "vmaSetAllocationUserData" "allocator"
                         Allocator
                      -> -- No documentation found for Nested "vmaSetAllocationUserData" "allocation"
                         Allocation
                      -> -- No documentation found for Nested "vmaSetAllocationUserData" "pUserData"
                         ("userData" ::: Ptr ())
                      -> io ()
setAllocationUserData :: Allocator -> Allocation -> ("userData" ::: Ptr ()) -> io ()
setAllocationUserData Allocator
allocator Allocation
allocation "userData" ::: Ptr ()
userData = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaSetAllocationUserData" ((Allocator -> Allocation -> ("userData" ::: Ptr ()) -> IO ()
ffiVmaSetAllocationUserData) (Allocator
allocator) (Allocation
allocation) ("userData" ::: Ptr ()
userData))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaSetAllocationName" ffiVmaSetAllocationName
  :: Allocator -> Allocation -> Ptr CChar -> IO ()

-- | 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.
setAllocationName :: forall io
                   . (MonadIO io)
                  => -- No documentation found for Nested "vmaSetAllocationName" "allocator"
                     Allocator
                  -> -- No documentation found for Nested "vmaSetAllocationName" "allocation"
                     Allocation
                  -> -- No documentation found for Nested "vmaSetAllocationName" "pName"
                     ("name" ::: Maybe ByteString)
                  -> io ()
setAllocationName :: Allocator -> Allocation -> ("name" ::: Maybe ByteString) -> io ()
setAllocationName Allocator
allocator Allocation
allocation "name" ::: Maybe ByteString
name = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  "name" ::: Ptr CChar
pName <- case ("name" ::: Maybe ByteString
name) of
    "name" ::: Maybe ByteString
Nothing -> ("name" ::: Ptr CChar) -> ContT () IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "name" ::: Ptr CChar
forall a. Ptr a
nullPtr
    Just ByteString
j -> ((("name" ::: Ptr CChar) -> IO ()) -> IO ())
-> ContT () IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO ()) -> IO ())
 -> ContT () IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO ()) -> IO ())
-> ContT () IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ByteString -> (("name" ::: Ptr CChar) -> IO ()) -> IO ()
forall a. ByteString -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString (ByteString
j)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaSetAllocationName" ((Allocator -> Allocation -> ("name" ::: Ptr CChar) -> IO ()
ffiVmaSetAllocationName) (Allocator
allocator) (Allocation
allocation) "name" ::: Ptr CChar
pName)
  () -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetAllocationMemoryProperties" ffiVmaGetAllocationMemoryProperties
  :: Allocator -> Allocation -> Ptr MemoryPropertyFlags -> IO ()

-- | Given an allocation, returns Property Flags of its memory type.
--
-- This is just a convenience function. Same information can be obtained
-- using 'getAllocationInfo' + 'getMemoryProperties'.
getAllocationMemoryProperties :: forall io
                               . (MonadIO io)
                              => -- No documentation found for Nested "vmaGetAllocationMemoryProperties" "allocator"
                                 Allocator
                              -> -- No documentation found for Nested "vmaGetAllocationMemoryProperties" "allocation"
                                 Allocation
                              -> io (MemoryPropertyFlags)
getAllocationMemoryProperties :: Allocator -> Allocation -> io MemoryPropertyFlags
getAllocationMemoryProperties Allocator
allocator Allocation
allocation = IO MemoryPropertyFlags -> io MemoryPropertyFlags
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO MemoryPropertyFlags -> io MemoryPropertyFlags)
-> (ContT MemoryPropertyFlags IO MemoryPropertyFlags
    -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> io MemoryPropertyFlags
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> IO MemoryPropertyFlags
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT MemoryPropertyFlags IO MemoryPropertyFlags
 -> io MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
-> io MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ do
  Ptr MemoryPropertyFlags
pPFlags <- ((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
 -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
  -> IO MemoryPropertyFlags)
 -> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags))
-> ((Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
    -> IO MemoryPropertyFlags)
-> ContT MemoryPropertyFlags IO (Ptr MemoryPropertyFlags)
forall a b. (a -> b) -> a -> b
$ IO (Ptr MemoryPropertyFlags)
-> (Ptr MemoryPropertyFlags -> IO ())
-> (Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags)
-> IO MemoryPropertyFlags
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr MemoryPropertyFlags)
forall a. Int -> IO (Ptr a)
callocBytes @MemoryPropertyFlags Int
4) Ptr MemoryPropertyFlags -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT MemoryPropertyFlags IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT MemoryPropertyFlags IO ())
-> IO () -> ContT MemoryPropertyFlags IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetAllocationMemoryProperties" ((Allocator -> Allocation -> Ptr MemoryPropertyFlags -> IO ()
ffiVmaGetAllocationMemoryProperties) (Allocator
allocator) (Allocation
allocation) (Ptr MemoryPropertyFlags
pPFlags))
  MemoryPropertyFlags
pFlags <- IO MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO MemoryPropertyFlags
 -> ContT MemoryPropertyFlags IO MemoryPropertyFlags)
-> IO MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags
forall a. Storable a => Ptr a -> IO a
peek @MemoryPropertyFlags Ptr MemoryPropertyFlags
pPFlags
  MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MemoryPropertyFlags
 -> ContT MemoryPropertyFlags IO MemoryPropertyFlags)
-> MemoryPropertyFlags
-> ContT MemoryPropertyFlags IO MemoryPropertyFlags
forall a b. (a -> b) -> a -> b
$ (MemoryPropertyFlags
pFlags)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaMapMemory" ffiVmaMapMemory
  :: Allocator -> Allocation -> Ptr (Ptr ()) -> IO Result

-- | 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.
mapMemory :: forall io
           . (MonadIO io)
          => -- No documentation found for Nested "vmaMapMemory" "allocator"
             Allocator
          -> -- No documentation found for Nested "vmaMapMemory" "allocation"
             Allocation
          -> io (("data" ::: Ptr ()))
mapMemory :: Allocator -> Allocation -> io ("userData" ::: Ptr ())
mapMemory Allocator
allocator Allocation
allocation = IO ("userData" ::: Ptr ()) -> io ("userData" ::: Ptr ())
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("userData" ::: Ptr ()) -> io ("userData" ::: Ptr ()))
-> (ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
    -> IO ("userData" ::: Ptr ()))
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
-> io ("userData" ::: Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
-> IO ("userData" ::: Ptr ())
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
 -> io ("userData" ::: Ptr ()))
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
-> io ("userData" ::: Ptr ())
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("userData" ::: Ptr ())
pPpData <- ((Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ()))
 -> IO ("userData" ::: Ptr ()))
-> ContT ("userData" ::: Ptr ()) IO (Ptr ("userData" ::: Ptr ()))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ()))
  -> IO ("userData" ::: Ptr ()))
 -> ContT ("userData" ::: Ptr ()) IO (Ptr ("userData" ::: Ptr ())))
-> ((Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ()))
    -> IO ("userData" ::: Ptr ()))
-> ContT ("userData" ::: Ptr ()) IO (Ptr ("userData" ::: Ptr ()))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("userData" ::: Ptr ()))
-> (Ptr ("userData" ::: Ptr ()) -> IO ())
-> (Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ()))
-> IO ("userData" ::: Ptr ())
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("userData" ::: Ptr ()))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr ()) Int
8) Ptr ("userData" ::: Ptr ()) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("userData" ::: Ptr ()) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("userData" ::: Ptr ()) IO Result)
-> IO Result -> ContT ("userData" ::: Ptr ()) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaMapMemory" ((Allocator -> Allocation -> Ptr ("userData" ::: Ptr ()) -> IO Result
ffiVmaMapMemory) (Allocator
allocator) (Allocation
allocation) (Ptr ("userData" ::: Ptr ())
pPpData))
  IO () -> ContT ("userData" ::: Ptr ()) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("userData" ::: Ptr ()) IO ())
-> IO () -> ContT ("userData" ::: Ptr ()) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "userData" ::: Ptr ()
ppData <- IO ("userData" ::: Ptr ())
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("userData" ::: Ptr ())
 -> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ()))
-> IO ("userData" ::: Ptr ())
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
forall a b. (a -> b) -> a -> b
$ Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) Ptr ("userData" ::: Ptr ())
pPpData
  ("userData" ::: Ptr ())
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("userData" ::: Ptr ())
 -> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ()))
-> ("userData" ::: Ptr ())
-> ContT ("userData" ::: Ptr ()) IO ("userData" ::: Ptr ())
forall a b. (a -> b) -> a -> b
$ ("userData" ::: Ptr ()
ppData)

-- | A convenience wrapper to make a compatible pair of calls to 'mapMemory'
-- and 'unmapMemory'
--
-- To ensure that 'unmapMemory' is always called: pass
-- 'Control.Exception.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.
--
withMappedMemory :: forall io r . MonadIO io => Allocator -> Allocation -> (io (Ptr ()) -> (Ptr () -> io ()) -> r) -> r
withMappedMemory :: Allocator
-> Allocation
-> (io ("userData" ::: Ptr ())
    -> (("userData" ::: Ptr ()) -> io ()) -> r)
-> r
withMappedMemory Allocator
allocator Allocation
allocation io ("userData" ::: Ptr ())
-> (("userData" ::: Ptr ()) -> io ()) -> r
b =
  io ("userData" ::: Ptr ())
-> (("userData" ::: Ptr ()) -> io ()) -> r
b (Allocator -> Allocation -> io ("userData" ::: Ptr ())
forall (io :: * -> *).
MonadIO io =>
Allocator -> Allocation -> io ("userData" ::: Ptr ())
mapMemory Allocator
allocator Allocation
allocation)
    (\("userData" ::: Ptr ()
_) -> Allocator -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Allocation -> io ()
unmapMemory Allocator
allocator Allocation
allocation)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaUnmapMemory" ffiVmaUnmapMemory
  :: Allocator -> Allocation -> IO ()

-- | 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.
unmapMemory :: forall io
             . (MonadIO io)
            => -- No documentation found for Nested "vmaUnmapMemory" "allocator"
               Allocator
            -> -- No documentation found for Nested "vmaUnmapMemory" "allocation"
               Allocation
            -> io ()
unmapMemory :: Allocator -> Allocation -> io ()
unmapMemory Allocator
allocator Allocation
allocation = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaUnmapMemory" ((Allocator -> Allocation -> IO ()
ffiVmaUnmapMemory) (Allocator
allocator) (Allocation
allocation))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFlushAllocation" ffiVmaFlushAllocation
  :: Allocator -> Allocation -> DeviceSize -> DeviceSize -> IO Result

-- | Flushes memory of given allocation.
--
-- Calls @vkFlushMappedMemoryRanges()@ for memory associated with given
-- range of given allocation. It needs to be called after writing to a
-- mapped memory for memory types that are not @HOST_COHERENT@. Unmap
-- operation doesn\'t do that automatically.
--
-- -   @offset@ must be relative to the beginning of allocation.
--
-- -   @size@ can be @VK_WHOLE_SIZE@. It means all memory from @offset@ the
--     the end of given allocation.
--
-- -   @offset@ and @size@ don\'t have to be aligned. They are internally
--     rounded down\/up to multiply of @nonCoherentAtomSize@.
--
-- -   If @size@ is 0, this call is ignored.
--
-- -   If memory type that the @allocation@ belongs to is not
--     @HOST_VISIBLE@ or it is @HOST_COHERENT@, this call is ignored.
--
-- Warning! @offset@ and @size@ are relative to the contents of given
-- @allocation@. If you mean whole allocation, you can pass 0 and
-- @VK_WHOLE_SIZE@, respectively. Do not pass allocation\'s offset as
-- @offset@!!!
--
-- This function returns the @VkResult@ from @vkFlushMappedMemoryRanges@ if
-- it is called, otherwise @VK_SUCCESS@.
flushAllocation :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaFlushAllocation" "allocator"
                   Allocator
                -> -- No documentation found for Nested "vmaFlushAllocation" "allocation"
                   Allocation
                -> -- No documentation found for Nested "vmaFlushAllocation" "offset"
                   ("offset" ::: DeviceSize)
                -> -- No documentation found for Nested "vmaFlushAllocation" "size"
                   DeviceSize
                -> io ()
flushAllocation :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> io ()
flushAllocation Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFlushAllocation" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> IO Result
ffiVmaFlushAllocation) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
offset) ("offset" ::: DeviceSize
size))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaInvalidateAllocation" ffiVmaInvalidateAllocation
  :: Allocator -> Allocation -> DeviceSize -> DeviceSize -> IO Result

-- | Invalidates memory of given allocation.
--
-- Calls @vkInvalidateMappedMemoryRanges()@ for memory associated with
-- given range of given allocation. It needs to be called before reading
-- from a mapped memory for memory types that are not @HOST_COHERENT@. Map
-- operation doesn\'t do that automatically.
--
-- -   @offset@ must be relative to the beginning of allocation.
--
-- -   @size@ can be @VK_WHOLE_SIZE@. It means all memory from @offset@ the
--     the end of given allocation.
--
-- -   @offset@ and @size@ don\'t have to be aligned. They are internally
--     rounded down\/up to multiply of @nonCoherentAtomSize@.
--
-- -   If @size@ is 0, this call is ignored.
--
-- -   If memory type that the @allocation@ belongs to is not
--     @HOST_VISIBLE@ or it is @HOST_COHERENT@, this call is ignored.
--
-- Warning! @offset@ and @size@ are relative to the contents of given
-- @allocation@. If you mean whole allocation, you can pass 0 and
-- @VK_WHOLE_SIZE@, respectively. Do not pass allocation\'s offset as
-- @offset@!!!
--
-- This function returns the @VkResult@ from
-- @vkInvalidateMappedMemoryRanges@ if it is called, otherwise
-- @VK_SUCCESS@.
invalidateAllocation :: forall io
                      . (MonadIO io)
                     => -- No documentation found for Nested "vmaInvalidateAllocation" "allocator"
                        Allocator
                     -> -- No documentation found for Nested "vmaInvalidateAllocation" "allocation"
                        Allocation
                     -> -- No documentation found for Nested "vmaInvalidateAllocation" "offset"
                        ("offset" ::: DeviceSize)
                     -> -- No documentation found for Nested "vmaInvalidateAllocation" "size"
                        DeviceSize
                     -> io ()
invalidateAllocation :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> io ()
invalidateAllocation Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaInvalidateAllocation" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> IO Result
ffiVmaInvalidateAllocation) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
offset) ("offset" ::: DeviceSize
size))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFlushAllocations" ffiVmaFlushAllocations
  :: Allocator -> Word32 -> Ptr Allocation -> Ptr DeviceSize -> Ptr DeviceSize -> IO Result

-- | 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@.
flushAllocations :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaFlushAllocations" "allocator"
                    Allocator
                 -> -- No documentation found for Nested "vmaFlushAllocations" "allocations"
                    ("allocations" ::: Vector Allocation)
                 -> -- No documentation found for Nested "vmaFlushAllocations" "offsets"
                    ("offsets" ::: Vector DeviceSize)
                 -> -- No documentation found for Nested "vmaFlushAllocations" "sizes"
                    ("sizes" ::: Vector DeviceSize)
                 -> io ()
flushAllocations :: Allocator
-> ("allocations" ::: Vector Allocation)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize))
-> ("offsets" ::: Vector ("offset" ::: DeviceSize))
-> io ()
flushAllocations Allocator
allocator "allocations" ::: Vector Allocation
allocations "offsets" ::: Vector ("offset" ::: DeviceSize)
offsets "offsets" ::: Vector ("offset" ::: DeviceSize)
sizes = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let allocationsLength :: Int
allocationsLength = ("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length (("allocations" ::: Vector Allocation) -> Int)
-> ("allocations" ::: Vector Allocation) -> Int
forall a b. (a -> b) -> a -> b
$ ("allocations" ::: Vector Allocation
allocations)
  let offsetsLength :: Int
offsetsLength = ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a b. (a -> b) -> a -> b
$ ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
offsetsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
allocationsLength Bool -> Bool -> Bool
|| Int
offsetsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"offsets and allocations must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let sizesLength :: Int
sizesLength = ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a b. (a -> b) -> a -> b
$ ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sizesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
allocationsLength Bool -> Bool -> Bool
|| Int
sizesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"sizes and allocations must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  Ptr Allocation
pAllocations <- ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO ()) -> IO ())
 -> ContT () IO (Ptr Allocation))
-> ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr Allocation -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Allocation ((("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length ("allocations" ::: Vector Allocation
allocations)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Allocation -> IO ())
-> ("allocations" ::: Vector Allocation) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Allocation
e -> Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Allocation
pAllocations Ptr Allocation -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Allocation) (Allocation
e)) ("allocations" ::: Vector Allocation
allocations)
  Ptr ("offset" ::: DeviceSize)
offsets' <- if ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Bool
forall a. Vector a -> Bool
Data.Vector.null ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets)
    then Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr ("offset" ::: DeviceSize)
forall a. Ptr a
nullPtr
    else do
      Ptr ("offset" ::: DeviceSize)
pOffsets <- ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @DeviceSize (((("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
      IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("offset" ::: DeviceSize) -> IO ())
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "offset" ::: DeviceSize
e -> Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("offset" ::: DeviceSize)
pOffsets Ptr ("offset" ::: DeviceSize)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DeviceSize) ("offset" ::: DeviceSize
e)) (("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets))
      Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr ("offset" ::: DeviceSize)
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize)
pOffsets
  Ptr ("offset" ::: DeviceSize)
sizes' <- if ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Bool
forall a. Vector a -> Bool
Data.Vector.null ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes)
    then Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr ("offset" ::: DeviceSize)
forall a. Ptr a
nullPtr
    else do
      Ptr ("offset" ::: DeviceSize)
pSizes <- ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @DeviceSize (((("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
      IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("offset" ::: DeviceSize) -> IO ())
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "offset" ::: DeviceSize
e -> Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("offset" ::: DeviceSize)
pSizes Ptr ("offset" ::: DeviceSize)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DeviceSize) ("offset" ::: DeviceSize
e)) (("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes))
      Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr ("offset" ::: DeviceSize)
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize)
pSizes
  Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFlushAllocations" ((Allocator
-> ("memoryTypeIndex" ::: Word32)
-> Ptr Allocation
-> Ptr ("offset" ::: DeviceSize)
-> Ptr ("offset" ::: DeviceSize)
-> IO Result
ffiVmaFlushAllocations) (Allocator
allocator) ((Int -> "memoryTypeIndex" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
allocationsLength :: Word32)) (Ptr Allocation
pAllocations) Ptr ("offset" ::: DeviceSize)
offsets' Ptr ("offset" ::: DeviceSize)
sizes')
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaInvalidateAllocations" ffiVmaInvalidateAllocations
  :: Allocator -> Word32 -> Ptr Allocation -> Ptr DeviceSize -> Ptr DeviceSize -> IO Result

-- | 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@.
invalidateAllocations :: forall io
                       . (MonadIO io)
                      => -- No documentation found for Nested "vmaInvalidateAllocations" "allocator"
                         Allocator
                      -> -- No documentation found for Nested "vmaInvalidateAllocations" "allocations"
                         ("allocations" ::: Vector Allocation)
                      -> -- No documentation found for Nested "vmaInvalidateAllocations" "offsets"
                         ("offsets" ::: Vector DeviceSize)
                      -> -- No documentation found for Nested "vmaInvalidateAllocations" "sizes"
                         ("sizes" ::: Vector DeviceSize)
                      -> io ()
invalidateAllocations :: Allocator
-> ("allocations" ::: Vector Allocation)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize))
-> ("offsets" ::: Vector ("offset" ::: DeviceSize))
-> io ()
invalidateAllocations Allocator
allocator "allocations" ::: Vector Allocation
allocations "offsets" ::: Vector ("offset" ::: DeviceSize)
offsets "offsets" ::: Vector ("offset" ::: DeviceSize)
sizes = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let allocationsLength :: Int
allocationsLength = ("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length (("allocations" ::: Vector Allocation) -> Int)
-> ("allocations" ::: Vector Allocation) -> Int
forall a b. (a -> b) -> a -> b
$ ("allocations" ::: Vector Allocation
allocations)
  let offsetsLength :: Int
offsetsLength = ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a b. (a -> b) -> a -> b
$ ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
offsetsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
allocationsLength Bool -> Bool -> Bool
|| Int
offsetsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"offsets and allocations must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let sizesLength :: Int
sizesLength = ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length (("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int)
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a b. (a -> b) -> a -> b
$ ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
sizesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
allocationsLength Bool -> Bool -> Bool
|| Int
sizesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"sizes and allocations must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  Ptr Allocation
pAllocations <- ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO ()) -> IO ())
 -> ContT () IO (Ptr Allocation))
-> ((Ptr Allocation -> IO ()) -> IO ())
-> ContT () IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr Allocation -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Allocation ((("allocations" ::: Vector Allocation) -> Int
forall a. Vector a -> Int
Data.Vector.length ("allocations" ::: Vector Allocation
allocations)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Allocation -> IO ())
-> ("allocations" ::: Vector Allocation) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Allocation
e -> Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Allocation
pAllocations Ptr Allocation -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Allocation) (Allocation
e)) ("allocations" ::: Vector Allocation
allocations)
  Ptr ("offset" ::: DeviceSize)
offsets' <- if ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Bool
forall a. Vector a -> Bool
Data.Vector.null ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets)
    then Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr ("offset" ::: DeviceSize)
forall a. Ptr a
nullPtr
    else do
      Ptr ("offset" ::: DeviceSize)
pOffsets <- ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @DeviceSize (((("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
      IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("offset" ::: DeviceSize) -> IO ())
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "offset" ::: DeviceSize
e -> Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("offset" ::: DeviceSize)
pOffsets Ptr ("offset" ::: DeviceSize)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DeviceSize) ("offset" ::: DeviceSize
e)) (("offsets" ::: Vector ("offset" ::: DeviceSize)
offsets))
      Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr ("offset" ::: DeviceSize)
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize)
pOffsets
  Ptr ("offset" ::: DeviceSize)
sizes' <- if ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Bool
forall a. Vector a -> Bool
Data.Vector.null ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes)
    then Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr ("offset" ::: DeviceSize)
forall a. Ptr a
nullPtr
    else do
      Ptr ("offset" ::: DeviceSize)
pSizes <- ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> ((Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ())
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Int -> (Ptr ("offset" ::: DeviceSize) -> IO ()) -> IO ()
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @DeviceSize (((("offsets" ::: Vector ("offset" ::: DeviceSize)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
      IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("offset" ::: DeviceSize) -> IO ())
-> ("offsets" ::: Vector ("offset" ::: DeviceSize)) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "offset" ::: DeviceSize
e -> Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr ("offset" ::: DeviceSize)
pSizes Ptr ("offset" ::: DeviceSize)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DeviceSize) ("offset" ::: DeviceSize
e)) (("offsets" ::: Vector ("offset" ::: DeviceSize)
sizes))
      Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr ("offset" ::: DeviceSize)
 -> ContT () IO (Ptr ("offset" ::: DeviceSize)))
-> Ptr ("offset" ::: DeviceSize)
-> ContT () IO (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize)
pSizes
  Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaInvalidateAllocations" ((Allocator
-> ("memoryTypeIndex" ::: Word32)
-> Ptr Allocation
-> Ptr ("offset" ::: DeviceSize)
-> Ptr ("offset" ::: DeviceSize)
-> IO Result
ffiVmaInvalidateAllocations) (Allocator
allocator) ((Int -> "memoryTypeIndex" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
allocationsLength :: Word32)) (Ptr Allocation
pAllocations) Ptr ("offset" ::: DeviceSize)
offsets' Ptr ("offset" ::: DeviceSize)
sizes')
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCheckCorruption" ffiVmaCheckCorruption
  :: Allocator -> Word32 -> IO Result

-- | 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.
checkCorruption :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaCheckCorruption" "allocator"
                   Allocator
                -> -- No documentation found for Nested "vmaCheckCorruption" "memoryTypeBits"
                   ("memoryTypeBits" ::: Word32)
                -> io ()
checkCorruption :: Allocator -> ("memoryTypeIndex" ::: Word32) -> io ()
checkCorruption Allocator
allocator "memoryTypeIndex" ::: Word32
memoryTypeBits = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCheckCorruption" ((Allocator -> ("memoryTypeIndex" ::: Word32) -> IO Result
ffiVmaCheckCorruption) (Allocator
allocator) ("memoryTypeIndex" ::: Word32
memoryTypeBits))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBeginDefragmentation" ffiVmaBeginDefragmentation
  :: Allocator -> Ptr DefragmentationInfo -> Ptr DefragmentationContext -> IO Result

-- | 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/.
beginDefragmentation :: forall io
                      . (MonadIO io)
                     => -- No documentation found for Nested "vmaBeginDefragmentation" "allocator"
                        Allocator
                     -> -- No documentation found for Nested "vmaBeginDefragmentation" "pInfo"
                        DefragmentationInfo
                     -> io (DefragmentationContext)
beginDefragmentation :: Allocator -> DefragmentationInfo -> io DefragmentationContext
beginDefragmentation Allocator
allocator DefragmentationInfo
info = IO DefragmentationContext -> io DefragmentationContext
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DefragmentationContext -> io DefragmentationContext)
-> (ContT DefragmentationContext IO DefragmentationContext
    -> IO DefragmentationContext)
-> ContT DefragmentationContext IO DefragmentationContext
-> io DefragmentationContext
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT DefragmentationContext IO DefragmentationContext
-> IO DefragmentationContext
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT DefragmentationContext IO DefragmentationContext
 -> io DefragmentationContext)
-> ContT DefragmentationContext IO DefragmentationContext
-> io DefragmentationContext
forall a b. (a -> b) -> a -> b
$ do
  Ptr DefragmentationInfo
pInfo <- ((Ptr DefragmentationInfo -> IO DefragmentationContext)
 -> IO DefragmentationContext)
-> ContT DefragmentationContext IO (Ptr DefragmentationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DefragmentationInfo -> IO DefragmentationContext)
  -> IO DefragmentationContext)
 -> ContT DefragmentationContext IO (Ptr DefragmentationInfo))
-> ((Ptr DefragmentationInfo -> IO DefragmentationContext)
    -> IO DefragmentationContext)
-> ContT DefragmentationContext IO (Ptr DefragmentationInfo)
forall a b. (a -> b) -> a -> b
$ DefragmentationInfo
-> (Ptr DefragmentationInfo -> IO DefragmentationContext)
-> IO DefragmentationContext
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DefragmentationInfo
info)
  Ptr DefragmentationContext
pPContext <- ((Ptr DefragmentationContext -> IO DefragmentationContext)
 -> IO DefragmentationContext)
-> ContT DefragmentationContext IO (Ptr DefragmentationContext)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DefragmentationContext -> IO DefragmentationContext)
  -> IO DefragmentationContext)
 -> ContT DefragmentationContext IO (Ptr DefragmentationContext))
-> ((Ptr DefragmentationContext -> IO DefragmentationContext)
    -> IO DefragmentationContext)
-> ContT DefragmentationContext IO (Ptr DefragmentationContext)
forall a b. (a -> b) -> a -> b
$ IO (Ptr DefragmentationContext)
-> (Ptr DefragmentationContext -> IO ())
-> (Ptr DefragmentationContext -> IO DefragmentationContext)
-> IO DefragmentationContext
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr DefragmentationContext)
forall a. Int -> IO (Ptr a)
callocBytes @DefragmentationContext Int
8) Ptr DefragmentationContext -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT DefragmentationContext IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT DefragmentationContext IO Result)
-> IO Result -> ContT DefragmentationContext IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBeginDefragmentation" ((Allocator
-> Ptr DefragmentationInfo
-> Ptr DefragmentationContext
-> IO Result
ffiVmaBeginDefragmentation) (Allocator
allocator) Ptr DefragmentationInfo
pInfo (Ptr DefragmentationContext
pPContext))
  IO () -> ContT DefragmentationContext IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DefragmentationContext IO ())
-> IO () -> ContT DefragmentationContext IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  DefragmentationContext
pContext <- IO DefragmentationContext
-> ContT DefragmentationContext IO DefragmentationContext
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO DefragmentationContext
 -> ContT DefragmentationContext IO DefragmentationContext)
-> IO DefragmentationContext
-> ContT DefragmentationContext IO DefragmentationContext
forall a b. (a -> b) -> a -> b
$ Ptr DefragmentationContext -> IO DefragmentationContext
forall a. Storable a => Ptr a -> IO a
peek @DefragmentationContext Ptr DefragmentationContext
pPContext
  DefragmentationContext
-> ContT DefragmentationContext IO DefragmentationContext
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DefragmentationContext
 -> ContT DefragmentationContext IO DefragmentationContext)
-> DefragmentationContext
-> ContT DefragmentationContext IO DefragmentationContext
forall a b. (a -> b) -> a -> b
$ (DefragmentationContext
pContext)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'beginDefragmentation' and 'endDefragmentation'
--
-- To ensure that 'endDefragmentation' is always called: pass
-- 'Control.Exception.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.
--
withDefragmentation :: forall io r . MonadIO io => Allocator -> DefragmentationInfo -> (io DefragmentationContext -> (DefragmentationContext -> io (DefragmentationStats)) -> r) -> r
withDefragmentation :: Allocator
-> DefragmentationInfo
-> (io DefragmentationContext
    -> (DefragmentationContext -> io DefragmentationStats) -> r)
-> r
withDefragmentation Allocator
allocator DefragmentationInfo
pInfo io DefragmentationContext
-> (DefragmentationContext -> io DefragmentationStats) -> r
b =
  io DefragmentationContext
-> (DefragmentationContext -> io DefragmentationStats) -> r
b (Allocator -> DefragmentationInfo -> io DefragmentationContext
forall (io :: * -> *).
MonadIO io =>
Allocator -> DefragmentationInfo -> io DefragmentationContext
beginDefragmentation Allocator
allocator DefragmentationInfo
pInfo)
    (\(DefragmentationContext
o0) -> Allocator -> DefragmentationContext -> io DefragmentationStats
forall (io :: * -> *).
MonadIO io =>
Allocator -> DefragmentationContext -> io DefragmentationStats
endDefragmentation Allocator
allocator DefragmentationContext
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaEndDefragmentation" ffiVmaEndDefragmentation
  :: Allocator -> DefragmentationContext -> Ptr DefragmentationStats -> IO ()

-- | 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'.
endDefragmentation :: forall io
                    . (MonadIO io)
                   => -- No documentation found for Nested "vmaEndDefragmentation" "allocator"
                      Allocator
                   -> -- No documentation found for Nested "vmaEndDefragmentation" "context"
                      DefragmentationContext
                   -> io (DefragmentationStats)
endDefragmentation :: Allocator -> DefragmentationContext -> io DefragmentationStats
endDefragmentation Allocator
allocator DefragmentationContext
context = IO DefragmentationStats -> io DefragmentationStats
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DefragmentationStats -> io DefragmentationStats)
-> (ContT DefragmentationStats IO DefragmentationStats
    -> IO DefragmentationStats)
-> ContT DefragmentationStats IO DefragmentationStats
-> io DefragmentationStats
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT DefragmentationStats IO DefragmentationStats
-> IO DefragmentationStats
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT DefragmentationStats IO DefragmentationStats
 -> io DefragmentationStats)
-> ContT DefragmentationStats IO DefragmentationStats
-> io DefragmentationStats
forall a b. (a -> b) -> a -> b
$ do
  Ptr DefragmentationStats
pPStats <- ((Ptr DefragmentationStats -> IO DefragmentationStats)
 -> IO DefragmentationStats)
-> ContT DefragmentationStats IO (Ptr DefragmentationStats)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct DefragmentationStats =>
(Ptr DefragmentationStats -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @DefragmentationStats)
  IO () -> ContT DefragmentationStats IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DefragmentationStats IO ())
-> IO () -> ContT DefragmentationStats IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaEndDefragmentation" ((Allocator
-> DefragmentationContext -> Ptr DefragmentationStats -> IO ()
ffiVmaEndDefragmentation) (Allocator
allocator) (DefragmentationContext
context) (Ptr DefragmentationStats
pPStats))
  DefragmentationStats
pStats <- IO DefragmentationStats
-> ContT DefragmentationStats IO DefragmentationStats
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO DefragmentationStats
 -> ContT DefragmentationStats IO DefragmentationStats)
-> IO DefragmentationStats
-> ContT DefragmentationStats IO DefragmentationStats
forall a b. (a -> b) -> a -> b
$ Ptr DefragmentationStats -> IO DefragmentationStats
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DefragmentationStats Ptr DefragmentationStats
pPStats
  DefragmentationStats
-> ContT DefragmentationStats IO DefragmentationStats
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DefragmentationStats
 -> ContT DefragmentationStats IO DefragmentationStats)
-> DefragmentationStats
-> ContT DefragmentationStats IO DefragmentationStats
forall a b. (a -> b) -> a -> b
$ (DefragmentationStats
pStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBeginDefragmentationPass" ffiVmaBeginDefragmentationPass
  :: Allocator -> DefragmentationContext -> Ptr DefragmentationPassMoveInfo -> IO Result

-- | 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
--     to 'endDefragmentationPass' and simply end whole defragmentation.
--
-- -   @VK_INCOMPLETE@ if there are pending moves returned in @pPassInfo@.
--     You need to perform them, call 'endDefragmentationPass', and then
--     preferably try another pass with 'beginDefragmentationPass'.
beginDefragmentationPass :: forall io
                          . (MonadIO io)
                         => -- No documentation found for Nested "vmaBeginDefragmentationPass" "allocator"
                            Allocator
                         -> -- No documentation found for Nested "vmaBeginDefragmentationPass" "context"
                            DefragmentationContext
                         -> io (("passInfo" ::: DefragmentationPassMoveInfo))
beginDefragmentationPass :: Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
beginDefragmentationPass Allocator
allocator DefragmentationContext
context = IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("passInfo" ::: DefragmentationPassMoveInfo)
 -> io ("passInfo" ::: DefragmentationPassMoveInfo))
-> (ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo)
    -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("passInfo" ::: DefragmentationPassMoveInfo)
  IO
  ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("passInfo" ::: DefragmentationPassMoveInfo)
   IO
   ("passInfo" ::: DefragmentationPassMoveInfo)
 -> io ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo <- ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
  -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
 -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     (Ptr ("passInfo" ::: DefragmentationPassMoveInfo))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("passInfo" ::: DefragmentationPassMoveInfo) =>
(Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @DefragmentationPassMoveInfo)
  Result
r <- IO Result
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result)
-> IO Result
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBeginDefragmentationPass" ((Allocator
-> DefragmentationContext
-> Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO Result
ffiVmaBeginDefragmentationPass) (Allocator
allocator) (DefragmentationContext
context) (Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo))
  IO () -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ())
-> IO ()
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "passInfo" ::: DefragmentationPassMoveInfo
pPassInfo <- IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("passInfo" ::: DefragmentationPassMoveInfo)
 -> ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo))
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DefragmentationPassMoveInfo Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo
  ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("passInfo" ::: DefragmentationPassMoveInfo)
 -> ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo))
-> ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ ("passInfo" ::: DefragmentationPassMoveInfo
pPassInfo)

-- | 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.
useDefragmentationPass :: forall io r . MonadIO io => Allocator -> DefragmentationContext -> (DefragmentationPassMoveInfo -> io r) -> io (("passInfo" ::: DefragmentationPassMoveInfo), r)
useDefragmentationPass :: Allocator
-> DefragmentationContext
-> (("passInfo" ::: DefragmentationPassMoveInfo) -> io r)
-> io ("passInfo" ::: DefragmentationPassMoveInfo, r)
useDefragmentationPass Allocator
allocator DefragmentationContext
context ("passInfo" ::: DefragmentationPassMoveInfo) -> io r
a =
  do
    "passInfo" ::: DefragmentationPassMoveInfo
x <- Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
beginDefragmentationPass Allocator
allocator DefragmentationContext
context
    r
r <- ("passInfo" ::: DefragmentationPassMoveInfo) -> io r
a "passInfo" ::: DefragmentationPassMoveInfo
x
    "passInfo" ::: DefragmentationPassMoveInfo
d <- (\("passInfo" ::: DefragmentationPassMoveInfo
_) -> Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall (io :: * -> *).
MonadIO io =>
Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
endDefragmentationPass Allocator
allocator DefragmentationContext
context) "passInfo" ::: DefragmentationPassMoveInfo
x
    ("passInfo" ::: DefragmentationPassMoveInfo, r)
-> io ("passInfo" ::: DefragmentationPassMoveInfo, r)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ("passInfo" ::: DefragmentationPassMoveInfo
d, r
r)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaEndDefragmentationPass" ffiVmaEndDefragmentationPass
  :: Allocator -> DefragmentationContext -> Ptr DefragmentationPassMoveInfo -> IO Result

-- | 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 had
--     @pPassInfo[i].operation ==@ 'DEFRAGMENTATION_MOVE_OPERATION_COPY'
--     (which is the default) will be pointing to the new destination
--     place.
--
-- -   Allocation at @pPassInfo[i].srcAllocation@ that had
--     @pPassInfo[i].operation ==@ 'DEFRAGMENTATION_MOVE_OPERATION_DESTROY'
--     will be freed.
--
-- If no more moves are possible you can end whole defragmentation.
endDefragmentationPass :: forall io
                        . (MonadIO io)
                       => -- No documentation found for Nested "vmaEndDefragmentationPass" "allocator"
                          Allocator
                       -> -- No documentation found for Nested "vmaEndDefragmentationPass" "context"
                          DefragmentationContext
                       -> io (("passInfo" ::: DefragmentationPassMoveInfo))
endDefragmentationPass :: Allocator
-> DefragmentationContext
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
endDefragmentationPass Allocator
allocator DefragmentationContext
context = IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("passInfo" ::: DefragmentationPassMoveInfo)
 -> io ("passInfo" ::: DefragmentationPassMoveInfo))
-> (ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo)
    -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("passInfo" ::: DefragmentationPassMoveInfo)
  IO
  ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("passInfo" ::: DefragmentationPassMoveInfo)
   IO
   ("passInfo" ::: DefragmentationPassMoveInfo)
 -> io ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
-> io ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo <- ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
  -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
 -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     (Ptr ("passInfo" ::: DefragmentationPassMoveInfo))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("passInfo" ::: DefragmentationPassMoveInfo) =>
(Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @DefragmentationPassMoveInfo)
  Result
r <- IO Result
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result)
-> IO Result
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaEndDefragmentationPass" ((Allocator
-> DefragmentationContext
-> Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO Result
ffiVmaEndDefragmentationPass) (Allocator
allocator) (DefragmentationContext
context) (Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo))
  IO () -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ())
-> IO ()
-> ContT ("passInfo" ::: DefragmentationPassMoveInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "passInfo" ::: DefragmentationPassMoveInfo
pPassInfo <- IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("passInfo" ::: DefragmentationPassMoveInfo)
 -> ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo))
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DefragmentationPassMoveInfo Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
pPPassInfo
  ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("passInfo" ::: DefragmentationPassMoveInfo)
 -> ContT
      ("passInfo" ::: DefragmentationPassMoveInfo)
      IO
      ("passInfo" ::: DefragmentationPassMoveInfo))
-> ("passInfo" ::: DefragmentationPassMoveInfo)
-> ContT
     ("passInfo" ::: DefragmentationPassMoveInfo)
     IO
     ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ ("passInfo" ::: DefragmentationPassMoveInfo
pPassInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBindBufferMemory" ffiVmaBindBufferMemory
  :: Allocator -> Allocation -> Buffer -> IO Result

-- | 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.
bindBufferMemory :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaBindBufferMemory" "allocator"
                    Allocator
                 -> -- No documentation found for Nested "vmaBindBufferMemory" "allocation"
                    Allocation
                 -> -- No documentation found for Nested "vmaBindBufferMemory" "buffer"
                    Buffer
                 -> io ()
bindBufferMemory :: Allocator -> Allocation -> Buffer -> io ()
bindBufferMemory Allocator
allocator Allocation
allocation Buffer
buffer = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBindBufferMemory" ((Allocator -> Allocation -> Buffer -> IO Result
ffiVmaBindBufferMemory) (Allocator
allocator) (Allocation
allocation) (Buffer
buffer))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBindBufferMemory2" ffiVmaBindBufferMemory2
  :: Allocator -> Allocation -> DeviceSize -> Buffer -> Ptr () -> IO Result

-- | 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.
bindBufferMemory2 :: forall io
                   . (MonadIO io)
                  => -- No documentation found for Nested "vmaBindBufferMemory2" "allocator"
                     Allocator
                  -> -- No documentation found for Nested "vmaBindBufferMemory2" "allocation"
                     Allocation
                  -> -- No documentation found for Nested "vmaBindBufferMemory2" "allocationLocalOffset"
                     ("allocationLocalOffset" ::: DeviceSize)
                  -> -- No documentation found for Nested "vmaBindBufferMemory2" "buffer"
                     Buffer
                  -> -- No documentation found for Nested "vmaBindBufferMemory2" "pNext"
                     ("next" ::: Ptr ())
                  -> io ()
bindBufferMemory2 :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Buffer
-> ("userData" ::: Ptr ())
-> io ()
bindBufferMemory2 Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
allocationLocalOffset Buffer
buffer "userData" ::: Ptr ()
next = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBindBufferMemory2" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Buffer
-> ("userData" ::: Ptr ())
-> IO Result
ffiVmaBindBufferMemory2) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
allocationLocalOffset) (Buffer
buffer) ("userData" ::: Ptr ()
next))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBindImageMemory" ffiVmaBindImageMemory
  :: Allocator -> Allocation -> Image -> IO Result

-- | 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.
bindImageMemory :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaBindImageMemory" "allocator"
                   Allocator
                -> -- No documentation found for Nested "vmaBindImageMemory" "allocation"
                   Allocation
                -> -- No documentation found for Nested "vmaBindImageMemory" "image"
                   Image
                -> io ()
bindImageMemory :: Allocator -> Allocation -> Image -> io ()
bindImageMemory Allocator
allocator Allocation
allocation Image
image = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBindImageMemory" ((Allocator -> Allocation -> Image -> IO Result
ffiVmaBindImageMemory) (Allocator
allocator) (Allocation
allocation) (Image
image))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBindImageMemory2" ffiVmaBindImageMemory2
  :: Allocator -> Allocation -> DeviceSize -> Image -> Ptr () -> IO Result

-- | 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.
bindImageMemory2 :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaBindImageMemory2" "allocator"
                    Allocator
                 -> -- No documentation found for Nested "vmaBindImageMemory2" "allocation"
                    Allocation
                 -> -- No documentation found for Nested "vmaBindImageMemory2" "allocationLocalOffset"
                    ("allocationLocalOffset" ::: DeviceSize)
                 -> -- No documentation found for Nested "vmaBindImageMemory2" "image"
                    Image
                 -> -- No documentation found for Nested "vmaBindImageMemory2" "pNext"
                    ("next" ::: Ptr ())
                 -> io ()
bindImageMemory2 :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Image
-> ("userData" ::: Ptr ())
-> io ()
bindImageMemory2 Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
allocationLocalOffset Image
image "userData" ::: Ptr ()
next = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBindImageMemory2" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Image
-> ("userData" ::: Ptr ())
-> IO Result
ffiVmaBindImageMemory2) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
allocationLocalOffset) (Image
image) ("userData" ::: Ptr ()
next))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateBuffer" ffiVmaCreateBuffer
  :: Allocator -> Ptr (SomeStruct BufferCreateInfo) -> Ptr AllocationCreateInfo -> Ptr Buffer -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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:
--
-- 1.  Creates buffer.
--
-- 2.  Allocates appropriate memory for it.
--
-- 3.  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.
createBuffer :: forall a io
              . (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
             => -- No documentation found for Nested "vmaCreateBuffer" "allocator"
                Allocator
             -> -- No documentation found for Nested "vmaCreateBuffer" "pBufferCreateInfo"
                (BufferCreateInfo a)
             -> -- No documentation found for Nested "vmaCreateBuffer" "pAllocationCreateInfo"
                AllocationCreateInfo
             -> io (Buffer, Allocation, AllocationInfo)
createBuffer :: Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> io (Buffer, Allocation, AllocationInfo)
createBuffer Allocator
allocator BufferCreateInfo a
bufferCreateInfo AllocationCreateInfo
allocationCreateInfo = IO (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Buffer, Allocation, AllocationInfo)
 -> io (Buffer, Allocation, AllocationInfo))
-> (ContT
      (Buffer, Allocation, AllocationInfo)
      IO
      (Buffer, Allocation, AllocationInfo)
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Buffer, Allocation, AllocationInfo)
  IO
  (Buffer, Allocation, AllocationInfo)
-> IO (Buffer, Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Buffer, Allocation, AllocationInfo)
   IO
   (Buffer, Allocation, AllocationInfo)
 -> io (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (BufferCreateInfo a)
pBufferCreateInfo <- ((Ptr (BufferCreateInfo a)
  -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferCreateInfo a)
   -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT
      (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a)))
-> ((Ptr (BufferCreateInfo a)
     -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferCreateInfo a
-> (Ptr (BufferCreateInfo a)
    -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferCreateInfo a
bufferCreateInfo)
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo
  -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo
   -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT
      (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo
     -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo
    -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr Buffer
pPBuffer <- ((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer))
-> ((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Buffer)
-> (Ptr Buffer -> IO ())
-> (Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Buffer)
forall a. Int -> IO (Ptr a)
callocBytes @Buffer Int
8) Ptr Buffer -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Buffer, Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Buffer, Allocation, AllocationInfo) IO Result)
-> IO Result
-> ContT (Buffer, Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateBuffer" ((Allocator
-> Ptr (SomeStruct BufferCreateInfo)
-> Ptr AllocationCreateInfo
-> Ptr Buffer
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaCreateBuffer) (Allocator
allocator) (Ptr (BufferCreateInfo a) -> Ptr (SomeStruct BufferCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferCreateInfo a)
pBufferCreateInfo) Ptr AllocationCreateInfo
pAllocationCreateInfo (Ptr Buffer
pPBuffer) (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Buffer
pBuffer <- IO Buffer -> ContT (Buffer, Allocation, AllocationInfo) IO Buffer
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Buffer -> ContT (Buffer, Allocation, AllocationInfo) IO Buffer)
-> IO Buffer
-> ContT (Buffer, Allocation, AllocationInfo) IO Buffer
forall a b. (a -> b) -> a -> b
$ Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer Ptr Buffer
pPBuffer
  Allocation
pAllocation <- IO Allocation
-> ContT (Buffer, Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation
 -> ContT (Buffer, Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Buffer, Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Buffer, Allocation, AllocationInfo)
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Buffer, Allocation, AllocationInfo)
 -> ContT
      (Buffer, Allocation, AllocationInfo)
      IO
      (Buffer, Allocation, AllocationInfo))
-> (Buffer, Allocation, AllocationInfo)
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Buffer
pBuffer, Allocation
pAllocation, AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createBuffer' and 'destroyBuffer'
--
-- To ensure that 'destroyBuffer' is always called: pass
-- 'Control.Exception.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.
--
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
withBuffer :: Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> (io (Buffer, Allocation, AllocationInfo)
    -> ((Buffer, Allocation, AllocationInfo) -> io ()) -> r)
-> r
withBuffer Allocator
allocator BufferCreateInfo a
pBufferCreateInfo AllocationCreateInfo
pAllocationCreateInfo io (Buffer, Allocation, AllocationInfo)
-> ((Buffer, Allocation, AllocationInfo) -> io ()) -> r
b =
  io (Buffer, Allocation, AllocationInfo)
-> ((Buffer, Allocation, AllocationInfo) -> io ()) -> r
b (Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> io (Buffer, Allocation, AllocationInfo)
forall (a :: [*]) (io :: * -> *).
(Extendss BufferCreateInfo a, PokeChain a, MonadIO io) =>
Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> io (Buffer, Allocation, AllocationInfo)
createBuffer Allocator
allocator BufferCreateInfo a
pBufferCreateInfo AllocationCreateInfo
pAllocationCreateInfo)
    (\(Buffer
o0, Allocation
o1, AllocationInfo
_) -> Allocator -> Buffer -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Buffer -> Allocation -> io ()
destroyBuffer Allocator
allocator Buffer
o0 Allocation
o1)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateBufferWithAlignment" ffiVmaCreateBufferWithAlignment
  :: Allocator -> Ptr (SomeStruct BufferCreateInfo) -> Ptr AllocationCreateInfo -> DeviceSize -> Ptr Buffer -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | 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.
createBufferWithAlignment :: forall a io
                           . (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
                          => -- No documentation found for Nested "vmaCreateBufferWithAlignment" "allocator"
                             Allocator
                          -> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "pBufferCreateInfo"
                             (BufferCreateInfo a)
                          -> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "pAllocationCreateInfo"
                             AllocationCreateInfo
                          -> -- No documentation found for Nested "vmaCreateBufferWithAlignment" "minAlignment"
                             ("minAlignment" ::: DeviceSize)
                          -> io (Buffer, Allocation, AllocationInfo)
createBufferWithAlignment :: Allocator
-> BufferCreateInfo a
-> AllocationCreateInfo
-> ("offset" ::: DeviceSize)
-> io (Buffer, Allocation, AllocationInfo)
createBufferWithAlignment Allocator
allocator BufferCreateInfo a
bufferCreateInfo AllocationCreateInfo
allocationCreateInfo "offset" ::: DeviceSize
minAlignment = IO (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Buffer, Allocation, AllocationInfo)
 -> io (Buffer, Allocation, AllocationInfo))
-> (ContT
      (Buffer, Allocation, AllocationInfo)
      IO
      (Buffer, Allocation, AllocationInfo)
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Buffer, Allocation, AllocationInfo)
  IO
  (Buffer, Allocation, AllocationInfo)
-> IO (Buffer, Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Buffer, Allocation, AllocationInfo)
   IO
   (Buffer, Allocation, AllocationInfo)
 -> io (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
-> io (Buffer, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (BufferCreateInfo a)
pBufferCreateInfo <- ((Ptr (BufferCreateInfo a)
  -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferCreateInfo a)
   -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT
      (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a)))
-> ((Ptr (BufferCreateInfo a)
     -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr (BufferCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferCreateInfo a
-> (Ptr (BufferCreateInfo a)
    -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferCreateInfo a
bufferCreateInfo)
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo
  -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo
   -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT
      (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo
     -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo
    -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr Buffer
pPBuffer <- ((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer))
-> ((Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Buffer)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Buffer)
-> (Ptr Buffer -> IO ())
-> (Ptr Buffer -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Buffer)
forall a. Int -> IO (Ptr a)
callocBytes @Buffer Int
8) Ptr Buffer -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
  -> IO (Buffer, Allocation, AllocationInfo))
 -> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
    -> IO (Buffer, Allocation, AllocationInfo))
-> ContT (Buffer, Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Buffer, Allocation, AllocationInfo))
-> IO (Buffer, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Buffer, Allocation, AllocationInfo))
 -> IO (Buffer, Allocation, AllocationInfo))
-> ContT
     (Buffer, Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Buffer, Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Buffer, Allocation, AllocationInfo) IO Result)
-> IO Result
-> ContT (Buffer, Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateBufferWithAlignment" ((Allocator
-> Ptr (SomeStruct BufferCreateInfo)
-> Ptr AllocationCreateInfo
-> ("offset" ::: DeviceSize)
-> Ptr Buffer
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaCreateBufferWithAlignment) (Allocator
allocator) (Ptr (BufferCreateInfo a) -> Ptr (SomeStruct BufferCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferCreateInfo a)
pBufferCreateInfo) Ptr AllocationCreateInfo
pAllocationCreateInfo ("offset" ::: DeviceSize
minAlignment) (Ptr Buffer
pPBuffer) (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Buffer, Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Buffer
pBuffer <- IO Buffer -> ContT (Buffer, Allocation, AllocationInfo) IO Buffer
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Buffer -> ContT (Buffer, Allocation, AllocationInfo) IO Buffer)
-> IO Buffer
-> ContT (Buffer, Allocation, AllocationInfo) IO Buffer
forall a b. (a -> b) -> a -> b
$ Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer Ptr Buffer
pPBuffer
  Allocation
pAllocation <- IO Allocation
-> ContT (Buffer, Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation
 -> ContT (Buffer, Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Buffer, Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Buffer, Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Buffer, Allocation, AllocationInfo)
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Buffer, Allocation, AllocationInfo)
 -> ContT
      (Buffer, Allocation, AllocationInfo)
      IO
      (Buffer, Allocation, AllocationInfo))
-> (Buffer, Allocation, AllocationInfo)
-> ContT
     (Buffer, Allocation, AllocationInfo)
     IO
     (Buffer, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Buffer
pBuffer, Allocation
pAllocation, AllocationInfo
pAllocationInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateAliasingBuffer" ffiVmaCreateAliasingBuffer
  :: Allocator -> Allocation -> Ptr (SomeStruct BufferCreateInfo) -> Ptr Buffer -> IO Result

-- | 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:
--
-- 1.  Creates buffer.
--
-- 2.  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'.
createAliasingBuffer :: forall a io
                      . (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
                     => -- No documentation found for Nested "vmaCreateAliasingBuffer" "allocator"
                        Allocator
                     -> -- No documentation found for Nested "vmaCreateAliasingBuffer" "allocation"
                        Allocation
                     -> -- No documentation found for Nested "vmaCreateAliasingBuffer" "pBufferCreateInfo"
                        (BufferCreateInfo a)
                     -> io (Buffer)
createAliasingBuffer :: Allocator -> Allocation -> BufferCreateInfo a -> io Buffer
createAliasingBuffer Allocator
allocator Allocation
allocation BufferCreateInfo a
bufferCreateInfo = IO Buffer -> io Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> io Buffer)
-> (ContT Buffer IO Buffer -> IO Buffer)
-> ContT Buffer IO Buffer
-> io Buffer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Buffer IO Buffer -> IO Buffer
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Buffer IO Buffer -> io Buffer)
-> ContT Buffer IO Buffer -> io Buffer
forall a b. (a -> b) -> a -> b
$ do
  Ptr (BufferCreateInfo a)
pBufferCreateInfo <- ((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr (BufferCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
 -> ContT Buffer IO (Ptr (BufferCreateInfo a)))
-> ((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr (BufferCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferCreateInfo a
-> (Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferCreateInfo a
bufferCreateInfo)
  Ptr Buffer
pPBuffer <- ((Ptr Buffer -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr Buffer)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Buffer -> IO Buffer) -> IO Buffer)
 -> ContT Buffer IO (Ptr Buffer))
-> ((Ptr Buffer -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr Buffer)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Buffer)
-> (Ptr Buffer -> IO ()) -> (Ptr Buffer -> IO Buffer) -> IO Buffer
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Buffer)
forall a. Int -> IO (Ptr a)
callocBytes @Buffer Int
8) Ptr Buffer -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Buffer IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Buffer IO Result)
-> IO Result -> ContT Buffer IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateAliasingBuffer" ((Allocator
-> Allocation
-> Ptr (SomeStruct BufferCreateInfo)
-> Ptr Buffer
-> IO Result
ffiVmaCreateAliasingBuffer) (Allocator
allocator) (Allocation
allocation) (Ptr (BufferCreateInfo a) -> Ptr (SomeStruct BufferCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferCreateInfo a)
pBufferCreateInfo) (Ptr Buffer
pPBuffer))
  IO () -> ContT Buffer IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Buffer IO ()) -> IO () -> ContT Buffer IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Buffer
pBuffer <- IO Buffer -> ContT Buffer IO Buffer
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Buffer -> ContT Buffer IO Buffer)
-> IO Buffer -> ContT Buffer IO Buffer
forall a b. (a -> b) -> a -> b
$ Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer Ptr Buffer
pPBuffer
  Buffer -> ContT Buffer IO Buffer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Buffer -> ContT Buffer IO Buffer)
-> Buffer -> ContT Buffer IO Buffer
forall a b. (a -> b) -> a -> b
$ (Buffer
pBuffer)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateAliasingBuffer2" ffiVmaCreateAliasingBuffer2
  :: Allocator -> Allocation -> DeviceSize -> Ptr (SomeStruct BufferCreateInfo) -> Ptr Buffer -> IO Result

-- | 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:
--
-- 1.  Creates buffer.
--
-- 2.  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@.
createAliasingBuffer2 :: forall a io
                       . (Extendss BufferCreateInfo a, PokeChain a, MonadIO io)
                      => -- No documentation found for Nested "vmaCreateAliasingBuffer2" "allocator"
                         Allocator
                      -> -- No documentation found for Nested "vmaCreateAliasingBuffer2" "allocation"
                         Allocation
                      -> -- No documentation found for Nested "vmaCreateAliasingBuffer2" "allocationLocalOffset"
                         ("allocationLocalOffset" ::: DeviceSize)
                      -> -- No documentation found for Nested "vmaCreateAliasingBuffer2" "pBufferCreateInfo"
                         (BufferCreateInfo a)
                      -> io (Buffer)
createAliasingBuffer2 :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> BufferCreateInfo a
-> io Buffer
createAliasingBuffer2 Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
allocationLocalOffset BufferCreateInfo a
bufferCreateInfo = IO Buffer -> io Buffer
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Buffer -> io Buffer)
-> (ContT Buffer IO Buffer -> IO Buffer)
-> ContT Buffer IO Buffer
-> io Buffer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Buffer IO Buffer -> IO Buffer
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Buffer IO Buffer -> io Buffer)
-> ContT Buffer IO Buffer -> io Buffer
forall a b. (a -> b) -> a -> b
$ do
  Ptr (BufferCreateInfo a)
pBufferCreateInfo <- ((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr (BufferCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
 -> ContT Buffer IO (Ptr (BufferCreateInfo a)))
-> ((Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr (BufferCreateInfo a))
forall a b. (a -> b) -> a -> b
$ BufferCreateInfo a
-> (Ptr (BufferCreateInfo a) -> IO Buffer) -> IO Buffer
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (BufferCreateInfo a
bufferCreateInfo)
  Ptr Buffer
pPBuffer <- ((Ptr Buffer -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr Buffer)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Buffer -> IO Buffer) -> IO Buffer)
 -> ContT Buffer IO (Ptr Buffer))
-> ((Ptr Buffer -> IO Buffer) -> IO Buffer)
-> ContT Buffer IO (Ptr Buffer)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Buffer)
-> (Ptr Buffer -> IO ()) -> (Ptr Buffer -> IO Buffer) -> IO Buffer
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Buffer)
forall a. Int -> IO (Ptr a)
callocBytes @Buffer Int
8) Ptr Buffer -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Buffer IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Buffer IO Result)
-> IO Result -> ContT Buffer IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateAliasingBuffer2" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Ptr (SomeStruct BufferCreateInfo)
-> Ptr Buffer
-> IO Result
ffiVmaCreateAliasingBuffer2) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
allocationLocalOffset) (Ptr (BufferCreateInfo a) -> Ptr (SomeStruct BufferCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (BufferCreateInfo a)
pBufferCreateInfo) (Ptr Buffer
pPBuffer))
  IO () -> ContT Buffer IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Buffer IO ()) -> IO () -> ContT Buffer IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Buffer
pBuffer <- IO Buffer -> ContT Buffer IO Buffer
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Buffer -> ContT Buffer IO Buffer)
-> IO Buffer -> ContT Buffer IO Buffer
forall a b. (a -> b) -> a -> b
$ Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer Ptr Buffer
pPBuffer
  Buffer -> ContT Buffer IO Buffer
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Buffer -> ContT Buffer IO Buffer)
-> Buffer -> ContT Buffer IO Buffer
forall a b. (a -> b) -> a -> b
$ (Buffer
pBuffer)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaDestroyBuffer" ffiVmaDestroyBuffer
  :: Allocator -> Buffer -> Allocation -> IO ()

-- | 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.
destroyBuffer :: forall io
               . (MonadIO io)
              => -- No documentation found for Nested "vmaDestroyBuffer" "allocator"
                 Allocator
              -> -- No documentation found for Nested "vmaDestroyBuffer" "buffer"
                 Buffer
              -> -- No documentation found for Nested "vmaDestroyBuffer" "allocation"
                 Allocation
              -> io ()
destroyBuffer :: Allocator -> Buffer -> Allocation -> io ()
destroyBuffer Allocator
allocator Buffer
buffer Allocation
allocation = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaDestroyBuffer" ((Allocator -> Buffer -> Allocation -> IO ()
ffiVmaDestroyBuffer) (Allocator
allocator) (Buffer
buffer) (Allocation
allocation))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateImage" ffiVmaCreateImage
  :: Allocator -> Ptr (SomeStruct ImageCreateInfo) -> Ptr AllocationCreateInfo -> Ptr Image -> Ptr Allocation -> Ptr AllocationInfo -> IO Result

-- | Function similar to 'createBuffer'.
createImage :: forall a io
             . (Extendss ImageCreateInfo a, PokeChain a, MonadIO io)
            => -- No documentation found for Nested "vmaCreateImage" "allocator"
               Allocator
            -> -- No documentation found for Nested "vmaCreateImage" "pImageCreateInfo"
               (ImageCreateInfo a)
            -> -- No documentation found for Nested "vmaCreateImage" "pAllocationCreateInfo"
               AllocationCreateInfo
            -> io (Image, Allocation, AllocationInfo)
createImage :: Allocator
-> ImageCreateInfo a
-> AllocationCreateInfo
-> io (Image, Allocation, AllocationInfo)
createImage Allocator
allocator ImageCreateInfo a
imageCreateInfo AllocationCreateInfo
allocationCreateInfo = IO (Image, Allocation, AllocationInfo)
-> io (Image, Allocation, AllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Image, Allocation, AllocationInfo)
 -> io (Image, Allocation, AllocationInfo))
-> (ContT
      (Image, Allocation, AllocationInfo)
      IO
      (Image, Allocation, AllocationInfo)
    -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo)
     IO
     (Image, Allocation, AllocationInfo)
-> io (Image, Allocation, AllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Image, Allocation, AllocationInfo)
  IO
  (Image, Allocation, AllocationInfo)
-> IO (Image, Allocation, AllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Image, Allocation, AllocationInfo)
   IO
   (Image, Allocation, AllocationInfo)
 -> io (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo)
     IO
     (Image, Allocation, AllocationInfo)
-> io (Image, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr (ImageCreateInfo a)
pImageCreateInfo <- ((Ptr (ImageCreateInfo a)
  -> IO (Image, Allocation, AllocationInfo))
 -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo) IO (Ptr (ImageCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (ImageCreateInfo a)
   -> IO (Image, Allocation, AllocationInfo))
  -> IO (Image, Allocation, AllocationInfo))
 -> ContT
      (Image, Allocation, AllocationInfo) IO (Ptr (ImageCreateInfo a)))
-> ((Ptr (ImageCreateInfo a)
     -> IO (Image, Allocation, AllocationInfo))
    -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo) IO (Ptr (ImageCreateInfo a))
forall a b. (a -> b) -> a -> b
$ ImageCreateInfo a
-> (Ptr (ImageCreateInfo a)
    -> IO (Image, Allocation, AllocationInfo))
-> IO (Image, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImageCreateInfo a
imageCreateInfo)
  Ptr AllocationCreateInfo
pAllocationCreateInfo <- ((Ptr AllocationCreateInfo
  -> IO (Image, Allocation, AllocationInfo))
 -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCreateInfo
   -> IO (Image, Allocation, AllocationInfo))
  -> IO (Image, Allocation, AllocationInfo))
 -> ContT
      (Image, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo))
-> ((Ptr AllocationCreateInfo
     -> IO (Image, Allocation, AllocationInfo))
    -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo) IO (Ptr AllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ AllocationCreateInfo
-> (Ptr AllocationCreateInfo
    -> IO (Image, Allocation, AllocationInfo))
-> IO (Image, Allocation, AllocationInfo)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCreateInfo
allocationCreateInfo)
  Ptr Image
pPImage <- ((Ptr Image -> IO (Image, Allocation, AllocationInfo))
 -> IO (Image, Allocation, AllocationInfo))
-> ContT (Image, Allocation, AllocationInfo) IO (Ptr Image)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Image -> IO (Image, Allocation, AllocationInfo))
  -> IO (Image, Allocation, AllocationInfo))
 -> ContT (Image, Allocation, AllocationInfo) IO (Ptr Image))
-> ((Ptr Image -> IO (Image, Allocation, AllocationInfo))
    -> IO (Image, Allocation, AllocationInfo))
-> ContT (Image, Allocation, AllocationInfo) IO (Ptr Image)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Image)
-> (Ptr Image -> IO ())
-> (Ptr Image -> IO (Image, Allocation, AllocationInfo))
-> IO (Image, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Image)
forall a. Int -> IO (Ptr a)
callocBytes @Image Int
8) Ptr Image -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr Allocation
pPAllocation <- ((Ptr Allocation -> IO (Image, Allocation, AllocationInfo))
 -> IO (Image, Allocation, AllocationInfo))
-> ContT (Image, Allocation, AllocationInfo) IO (Ptr Allocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Allocation -> IO (Image, Allocation, AllocationInfo))
  -> IO (Image, Allocation, AllocationInfo))
 -> ContT (Image, Allocation, AllocationInfo) IO (Ptr Allocation))
-> ((Ptr Allocation -> IO (Image, Allocation, AllocationInfo))
    -> IO (Image, Allocation, AllocationInfo))
-> ContT (Image, Allocation, AllocationInfo) IO (Ptr Allocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Allocation)
-> (Ptr Allocation -> IO ())
-> (Ptr Allocation -> IO (Image, Allocation, AllocationInfo))
-> IO (Image, Allocation, AllocationInfo)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Allocation)
forall a. Int -> IO (Ptr a)
callocBytes @Allocation Int
8) Ptr Allocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr AllocationInfo
pPAllocationInfo <- ((Ptr AllocationInfo -> IO (Image, Allocation, AllocationInfo))
 -> IO (Image, Allocation, AllocationInfo))
-> ContT
     (Image, Allocation, AllocationInfo) IO (Ptr AllocationInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct AllocationInfo =>
(Ptr AllocationInfo -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @AllocationInfo)
  Result
r <- IO Result -> ContT (Image, Allocation, AllocationInfo) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT (Image, Allocation, AllocationInfo) IO Result)
-> IO Result -> ContT (Image, Allocation, AllocationInfo) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateImage" ((Allocator
-> Ptr (SomeStruct ImageCreateInfo)
-> Ptr AllocationCreateInfo
-> Ptr Image
-> Ptr Allocation
-> Ptr AllocationInfo
-> IO Result
ffiVmaCreateImage) (Allocator
allocator) (Ptr (ImageCreateInfo a) -> Ptr (SomeStruct ImageCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (ImageCreateInfo a)
pImageCreateInfo) Ptr AllocationCreateInfo
pAllocationCreateInfo (Ptr Image
pPImage) (Ptr Allocation
pPAllocation) (Ptr AllocationInfo
pPAllocationInfo))
  IO () -> ContT (Image, Allocation, AllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (Image, Allocation, AllocationInfo) IO ())
-> IO () -> ContT (Image, Allocation, AllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Image
pImage <- IO Image -> ContT (Image, Allocation, AllocationInfo) IO Image
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Image -> ContT (Image, Allocation, AllocationInfo) IO Image)
-> IO Image -> ContT (Image, Allocation, AllocationInfo) IO Image
forall a b. (a -> b) -> a -> b
$ Ptr Image -> IO Image
forall a. Storable a => Ptr a -> IO a
peek @Image Ptr Image
pPImage
  Allocation
pAllocation <- IO Allocation
-> ContT (Image, Allocation, AllocationInfo) IO Allocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Allocation
 -> ContT (Image, Allocation, AllocationInfo) IO Allocation)
-> IO Allocation
-> ContT (Image, Allocation, AllocationInfo) IO Allocation
forall a b. (a -> b) -> a -> b
$ Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation Ptr Allocation
pPAllocation
  AllocationInfo
pAllocationInfo <- IO AllocationInfo
-> ContT (Image, Allocation, AllocationInfo) IO AllocationInfo
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO AllocationInfo
 -> ContT (Image, Allocation, AllocationInfo) IO AllocationInfo)
-> IO AllocationInfo
-> ContT (Image, Allocation, AllocationInfo) IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ Ptr AllocationInfo -> IO AllocationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationInfo Ptr AllocationInfo
pPAllocationInfo
  (Image, Allocation, AllocationInfo)
-> ContT
     (Image, Allocation, AllocationInfo)
     IO
     (Image, Allocation, AllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Image, Allocation, AllocationInfo)
 -> ContT
      (Image, Allocation, AllocationInfo)
      IO
      (Image, Allocation, AllocationInfo))
-> (Image, Allocation, AllocationInfo)
-> ContT
     (Image, Allocation, AllocationInfo)
     IO
     (Image, Allocation, AllocationInfo)
forall a b. (a -> b) -> a -> b
$ (Image
pImage, Allocation
pAllocation, AllocationInfo
pAllocationInfo)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createImage' and 'destroyImage'
--
-- To ensure that 'destroyImage' is always called: pass
-- 'Control.Exception.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.
--
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
withImage :: Allocator
-> ImageCreateInfo a
-> AllocationCreateInfo
-> (io (Image, Allocation, AllocationInfo)
    -> ((Image, Allocation, AllocationInfo) -> io ()) -> r)
-> r
withImage Allocator
allocator ImageCreateInfo a
pImageCreateInfo AllocationCreateInfo
pAllocationCreateInfo io (Image, Allocation, AllocationInfo)
-> ((Image, Allocation, AllocationInfo) -> io ()) -> r
b =
  io (Image, Allocation, AllocationInfo)
-> ((Image, Allocation, AllocationInfo) -> io ()) -> r
b (Allocator
-> ImageCreateInfo a
-> AllocationCreateInfo
-> io (Image, Allocation, AllocationInfo)
forall (a :: [*]) (io :: * -> *).
(Extendss ImageCreateInfo a, PokeChain a, MonadIO io) =>
Allocator
-> ImageCreateInfo a
-> AllocationCreateInfo
-> io (Image, Allocation, AllocationInfo)
createImage Allocator
allocator ImageCreateInfo a
pImageCreateInfo AllocationCreateInfo
pAllocationCreateInfo)
    (\(Image
o0, Allocation
o1, AllocationInfo
_) -> Allocator -> Image -> Allocation -> io ()
forall (io :: * -> *).
MonadIO io =>
Allocator -> Image -> Allocation -> io ()
destroyImage Allocator
allocator Image
o0 Allocation
o1)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateAliasingImage" ffiVmaCreateAliasingImage
  :: Allocator -> Allocation -> Ptr (SomeStruct ImageCreateInfo) -> Ptr Image -> IO Result

-- | Function similar to 'createAliasingBuffer' but for images.
createAliasingImage :: forall a io
                     . (Extendss ImageCreateInfo a, PokeChain a, MonadIO io)
                    => -- No documentation found for Nested "vmaCreateAliasingImage" "allocator"
                       Allocator
                    -> -- No documentation found for Nested "vmaCreateAliasingImage" "allocation"
                       Allocation
                    -> -- No documentation found for Nested "vmaCreateAliasingImage" "pImageCreateInfo"
                       (ImageCreateInfo a)
                    -> io (Image)
createAliasingImage :: Allocator -> Allocation -> ImageCreateInfo a -> io Image
createAliasingImage Allocator
allocator Allocation
allocation ImageCreateInfo a
imageCreateInfo = IO Image -> io Image
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Image -> io Image)
-> (ContT Image IO Image -> IO Image)
-> ContT Image IO Image
-> io Image
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Image IO Image -> IO Image
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Image IO Image -> io Image)
-> ContT Image IO Image -> io Image
forall a b. (a -> b) -> a -> b
$ do
  Ptr (ImageCreateInfo a)
pImageCreateInfo <- ((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
-> ContT Image IO (Ptr (ImageCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
 -> ContT Image IO (Ptr (ImageCreateInfo a)))
-> ((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
-> ContT Image IO (Ptr (ImageCreateInfo a))
forall a b. (a -> b) -> a -> b
$ ImageCreateInfo a
-> (Ptr (ImageCreateInfo a) -> IO Image) -> IO Image
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImageCreateInfo a
imageCreateInfo)
  Ptr Image
pPImage <- ((Ptr Image -> IO Image) -> IO Image) -> ContT Image IO (Ptr Image)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Image -> IO Image) -> IO Image)
 -> ContT Image IO (Ptr Image))
-> ((Ptr Image -> IO Image) -> IO Image)
-> ContT Image IO (Ptr Image)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Image)
-> (Ptr Image -> IO ()) -> (Ptr Image -> IO Image) -> IO Image
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Image)
forall a. Int -> IO (Ptr a)
callocBytes @Image Int
8) Ptr Image -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Image IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Image IO Result)
-> IO Result -> ContT Image IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateAliasingImage" ((Allocator
-> Allocation
-> Ptr (SomeStruct ImageCreateInfo)
-> Ptr Image
-> IO Result
ffiVmaCreateAliasingImage) (Allocator
allocator) (Allocation
allocation) (Ptr (ImageCreateInfo a) -> Ptr (SomeStruct ImageCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (ImageCreateInfo a)
pImageCreateInfo) (Ptr Image
pPImage))
  IO () -> ContT Image IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Image IO ()) -> IO () -> ContT Image IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Image
pImage <- IO Image -> ContT Image IO Image
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Image -> ContT Image IO Image)
-> IO Image -> ContT Image IO Image
forall a b. (a -> b) -> a -> b
$ Ptr Image -> IO Image
forall a. Storable a => Ptr a -> IO a
peek @Image Ptr Image
pPImage
  Image -> ContT Image IO Image
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Image -> ContT Image IO Image) -> Image -> ContT Image IO Image
forall a b. (a -> b) -> a -> b
$ (Image
pImage)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateAliasingImage2" ffiVmaCreateAliasingImage2
  :: Allocator -> Allocation -> DeviceSize -> Ptr (SomeStruct ImageCreateInfo) -> Ptr Image -> IO Result

-- | Function similar to 'createAliasingBuffer2' but for images.
createAliasingImage2 :: forall a io
                      . (Extendss ImageCreateInfo a, PokeChain a, MonadIO io)
                     => -- No documentation found for Nested "vmaCreateAliasingImage2" "allocator"
                        Allocator
                     -> -- No documentation found for Nested "vmaCreateAliasingImage2" "allocation"
                        Allocation
                     -> -- No documentation found for Nested "vmaCreateAliasingImage2" "allocationLocalOffset"
                        ("allocationLocalOffset" ::: DeviceSize)
                     -> -- No documentation found for Nested "vmaCreateAliasingImage2" "pImageCreateInfo"
                        (ImageCreateInfo a)
                     -> io (Image)
createAliasingImage2 :: Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> ImageCreateInfo a
-> io Image
createAliasingImage2 Allocator
allocator Allocation
allocation "offset" ::: DeviceSize
allocationLocalOffset ImageCreateInfo a
imageCreateInfo = IO Image -> io Image
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Image -> io Image)
-> (ContT Image IO Image -> IO Image)
-> ContT Image IO Image
-> io Image
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Image IO Image -> IO Image
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Image IO Image -> io Image)
-> ContT Image IO Image -> io Image
forall a b. (a -> b) -> a -> b
$ do
  Ptr (ImageCreateInfo a)
pImageCreateInfo <- ((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
-> ContT Image IO (Ptr (ImageCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
 -> ContT Image IO (Ptr (ImageCreateInfo a)))
-> ((Ptr (ImageCreateInfo a) -> IO Image) -> IO Image)
-> ContT Image IO (Ptr (ImageCreateInfo a))
forall a b. (a -> b) -> a -> b
$ ImageCreateInfo a
-> (Ptr (ImageCreateInfo a) -> IO Image) -> IO Image
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (ImageCreateInfo a
imageCreateInfo)
  Ptr Image
pPImage <- ((Ptr Image -> IO Image) -> IO Image) -> ContT Image IO (Ptr Image)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Image -> IO Image) -> IO Image)
 -> ContT Image IO (Ptr Image))
-> ((Ptr Image -> IO Image) -> IO Image)
-> ContT Image IO (Ptr Image)
forall a b. (a -> b) -> a -> b
$ IO (Ptr Image)
-> (Ptr Image -> IO ()) -> (Ptr Image -> IO Image) -> IO Image
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr Image)
forall a. Int -> IO (Ptr a)
callocBytes @Image Int
8) Ptr Image -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT Image IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Image IO Result)
-> IO Result -> ContT Image IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateAliasingImage2" ((Allocator
-> Allocation
-> ("offset" ::: DeviceSize)
-> Ptr (SomeStruct ImageCreateInfo)
-> Ptr Image
-> IO Result
ffiVmaCreateAliasingImage2) (Allocator
allocator) (Allocation
allocation) ("offset" ::: DeviceSize
allocationLocalOffset) (Ptr (ImageCreateInfo a) -> Ptr (SomeStruct ImageCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (ImageCreateInfo a)
pImageCreateInfo) (Ptr Image
pPImage))
  IO () -> ContT Image IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Image IO ()) -> IO () -> ContT Image IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Image
pImage <- IO Image -> ContT Image IO Image
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Image -> ContT Image IO Image)
-> IO Image -> ContT Image IO Image
forall a b. (a -> b) -> a -> b
$ Ptr Image -> IO Image
forall a. Storable a => Ptr a -> IO a
peek @Image Ptr Image
pPImage
  Image -> ContT Image IO Image
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Image -> ContT Image IO Image) -> Image -> ContT Image IO Image
forall a b. (a -> b) -> a -> b
$ (Image
pImage)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaDestroyImage" ffiVmaDestroyImage
  :: Allocator -> Image -> Allocation -> IO ()

-- | 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.
destroyImage :: forall io
              . (MonadIO io)
             => -- No documentation found for Nested "vmaDestroyImage" "allocator"
                Allocator
             -> -- No documentation found for Nested "vmaDestroyImage" "image"
                Image
             -> -- No documentation found for Nested "vmaDestroyImage" "allocation"
                Allocation
             -> io ()
destroyImage :: Allocator -> Image -> Allocation -> io ()
destroyImage Allocator
allocator Image
image Allocation
allocation = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaDestroyImage" ((Allocator -> Image -> Allocation -> IO ()
ffiVmaDestroyImage) (Allocator
allocator) (Image
image) (Allocation
allocation))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCreateVirtualBlock" ffiVmaCreateVirtualBlock
  :: Ptr VirtualBlockCreateInfo -> Ptr VirtualBlock -> IO Result

-- | Creates new 'VirtualBlock' object.
--
-- __Parameters__
--
-- +-----------+---------------+-----------------------------------------------+
-- |           | pCreateInfo   | Parameters for creation.                      |
-- +-----------+---------------+-----------------------------------------------+
-- | out       | pVirtualBlock | Returned virtual block object or @VMA_NULL@   |
-- |           |               | if creation failed.                           |
-- +-----------+---------------+-----------------------------------------------+
createVirtualBlock :: forall io
                    . (MonadIO io)
                   => -- No documentation found for Nested "vmaCreateVirtualBlock" "pCreateInfo"
                      VirtualBlockCreateInfo
                   -> io (VirtualBlock)
createVirtualBlock :: VirtualBlockCreateInfo -> io VirtualBlock
createVirtualBlock VirtualBlockCreateInfo
createInfo = IO VirtualBlock -> io VirtualBlock
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO VirtualBlock -> io VirtualBlock)
-> (ContT VirtualBlock IO VirtualBlock -> IO VirtualBlock)
-> ContT VirtualBlock IO VirtualBlock
-> io VirtualBlock
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT VirtualBlock IO VirtualBlock -> IO VirtualBlock
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT VirtualBlock IO VirtualBlock -> io VirtualBlock)
-> ContT VirtualBlock IO VirtualBlock -> io VirtualBlock
forall a b. (a -> b) -> a -> b
$ do
  Ptr VirtualBlockCreateInfo
pCreateInfo <- ((Ptr VirtualBlockCreateInfo -> IO VirtualBlock)
 -> IO VirtualBlock)
-> ContT VirtualBlock IO (Ptr VirtualBlockCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr VirtualBlockCreateInfo -> IO VirtualBlock)
  -> IO VirtualBlock)
 -> ContT VirtualBlock IO (Ptr VirtualBlockCreateInfo))
-> ((Ptr VirtualBlockCreateInfo -> IO VirtualBlock)
    -> IO VirtualBlock)
-> ContT VirtualBlock IO (Ptr VirtualBlockCreateInfo)
forall a b. (a -> b) -> a -> b
$ VirtualBlockCreateInfo
-> (Ptr VirtualBlockCreateInfo -> IO VirtualBlock)
-> IO VirtualBlock
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (VirtualBlockCreateInfo
createInfo)
  Ptr VirtualBlock
pPVirtualBlock <- ((Ptr VirtualBlock -> IO VirtualBlock) -> IO VirtualBlock)
-> ContT VirtualBlock IO (Ptr VirtualBlock)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr VirtualBlock -> IO VirtualBlock) -> IO VirtualBlock)
 -> ContT VirtualBlock IO (Ptr VirtualBlock))
-> ((Ptr VirtualBlock -> IO VirtualBlock) -> IO VirtualBlock)
-> ContT VirtualBlock IO (Ptr VirtualBlock)
forall a b. (a -> b) -> a -> b
$ IO (Ptr VirtualBlock)
-> (Ptr VirtualBlock -> IO ())
-> (Ptr VirtualBlock -> IO VirtualBlock)
-> IO VirtualBlock
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr VirtualBlock)
forall a. Int -> IO (Ptr a)
callocBytes @VirtualBlock Int
8) Ptr VirtualBlock -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT VirtualBlock IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT VirtualBlock IO Result)
-> IO Result -> ContT VirtualBlock IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCreateVirtualBlock" ((Ptr VirtualBlockCreateInfo -> Ptr VirtualBlock -> IO Result
ffiVmaCreateVirtualBlock) Ptr VirtualBlockCreateInfo
pCreateInfo (Ptr VirtualBlock
pPVirtualBlock))
  IO () -> ContT VirtualBlock IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT VirtualBlock IO ())
-> IO () -> ContT VirtualBlock IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  VirtualBlock
pVirtualBlock <- IO VirtualBlock -> ContT VirtualBlock IO VirtualBlock
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO VirtualBlock -> ContT VirtualBlock IO VirtualBlock)
-> IO VirtualBlock -> ContT VirtualBlock IO VirtualBlock
forall a b. (a -> b) -> a -> b
$ Ptr VirtualBlock -> IO VirtualBlock
forall a. Storable a => Ptr a -> IO a
peek @VirtualBlock Ptr VirtualBlock
pPVirtualBlock
  VirtualBlock -> ContT VirtualBlock IO VirtualBlock
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VirtualBlock -> ContT VirtualBlock IO VirtualBlock)
-> VirtualBlock -> ContT VirtualBlock IO VirtualBlock
forall a b. (a -> b) -> a -> b
$ (VirtualBlock
pVirtualBlock)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createVirtualBlock' and 'destroyVirtualBlock'
--
-- To ensure that 'destroyVirtualBlock' is always called: pass
-- 'Control.Exception.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.
--
withVirtualBlock :: forall io r . MonadIO io => VirtualBlockCreateInfo -> (io VirtualBlock -> (VirtualBlock -> io ()) -> r) -> r
withVirtualBlock :: VirtualBlockCreateInfo
-> (io VirtualBlock -> (VirtualBlock -> io ()) -> r) -> r
withVirtualBlock VirtualBlockCreateInfo
pCreateInfo io VirtualBlock -> (VirtualBlock -> io ()) -> r
b =
  io VirtualBlock -> (VirtualBlock -> io ()) -> r
b (VirtualBlockCreateInfo -> io VirtualBlock
forall (io :: * -> *).
MonadIO io =>
VirtualBlockCreateInfo -> io VirtualBlock
createVirtualBlock VirtualBlockCreateInfo
pCreateInfo)
    (\(VirtualBlock
o0) -> VirtualBlock -> io ()
forall (io :: * -> *). MonadIO io => VirtualBlock -> io ()
destroyVirtualBlock VirtualBlock
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaDestroyVirtualBlock" ffiVmaDestroyVirtualBlock
  :: VirtualBlock -> IO ()

-- | 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.
destroyVirtualBlock :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaDestroyVirtualBlock" "virtualBlock"
                       VirtualBlock
                    -> io ()
destroyVirtualBlock :: VirtualBlock -> io ()
destroyVirtualBlock VirtualBlock
virtualBlock = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaDestroyVirtualBlock" ((VirtualBlock -> IO ()
ffiVmaDestroyVirtualBlock) (VirtualBlock
virtualBlock))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaIsVirtualBlockEmpty" ffiVmaIsVirtualBlockEmpty
  :: VirtualBlock -> IO Bool32

-- | Returns true of the 'VirtualBlock' is empty - contains 0 virtual
-- allocations and has all its space available for new allocations.
isVirtualBlockEmpty :: forall io
                     . (MonadIO io)
                    => -- No documentation found for Nested "vmaIsVirtualBlockEmpty" "virtualBlock"
                       VirtualBlock
                    -> io (Bool)
isVirtualBlockEmpty :: VirtualBlock -> io Bool
isVirtualBlockEmpty VirtualBlock
virtualBlock = IO Bool -> io Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> io Bool) -> IO Bool -> io Bool
forall a b. (a -> b) -> a -> b
$ do
  Bool32
r <- String -> IO Bool32 -> IO Bool32
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaIsVirtualBlockEmpty" ((VirtualBlock -> IO Bool32
ffiVmaIsVirtualBlockEmpty) (VirtualBlock
virtualBlock))
  Bool -> IO Bool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Bool -> IO Bool) -> Bool -> IO Bool
forall a b. (a -> b) -> a -> b
$ ((Bool32 -> Bool
bool32ToBool Bool32
r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetVirtualAllocationInfo" ffiVmaGetVirtualAllocationInfo
  :: VirtualBlock -> VirtualAllocation -> Ptr VirtualAllocationInfo -> IO ()

-- | Returns information about a specific virtual allocation within a virtual
-- block, like its size and @pUserData@ pointer.
getVirtualAllocationInfo :: forall io
                          . (MonadIO io)
                         => -- No documentation found for Nested "vmaGetVirtualAllocationInfo" "virtualBlock"
                            VirtualBlock
                         -> -- No documentation found for Nested "vmaGetVirtualAllocationInfo" "allocation"
                            VirtualAllocation
                         -> io (("virtualAllocInfo" ::: VirtualAllocationInfo))
getVirtualAllocationInfo :: VirtualBlock
-> VirtualAllocation
-> io ("virtualAllocInfo" ::: VirtualAllocationInfo)
getVirtualAllocationInfo VirtualBlock
virtualBlock VirtualAllocation
allocation = IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> io ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
 -> io ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> (ContT
      ("virtualAllocInfo" ::: VirtualAllocationInfo)
      IO
      ("virtualAllocInfo" ::: VirtualAllocationInfo)
    -> IO ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> io ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("virtualAllocInfo" ::: VirtualAllocationInfo)
  IO
  ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("virtualAllocInfo" ::: VirtualAllocationInfo)
   IO
   ("virtualAllocInfo" ::: VirtualAllocationInfo)
 -> io ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> io ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
pPVirtualAllocInfo <- ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
  -> IO ("virtualAllocInfo" ::: VirtualAllocationInfo))
 -> IO ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("virtualAllocInfo" ::: VirtualAllocationInfo) =>
(Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b)
-> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @VirtualAllocationInfo)
  IO () -> ContT ("virtualAllocInfo" ::: VirtualAllocationInfo) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT ("virtualAllocInfo" ::: VirtualAllocationInfo) IO ())
-> IO ()
-> ContT ("virtualAllocInfo" ::: VirtualAllocationInfo) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetVirtualAllocationInfo" ((VirtualBlock
-> VirtualAllocation
-> Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ()
ffiVmaGetVirtualAllocationInfo) (VirtualBlock
virtualBlock) (VirtualAllocation
allocation) (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
pPVirtualAllocInfo))
  "virtualAllocInfo" ::: VirtualAllocationInfo
pVirtualAllocInfo <- IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
 -> ContT
      ("virtualAllocInfo" ::: VirtualAllocationInfo)
      IO
      ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a b. (a -> b) -> a -> b
$ Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @VirtualAllocationInfo Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
pPVirtualAllocInfo
  ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("virtualAllocInfo" ::: VirtualAllocationInfo)
 -> ContT
      ("virtualAllocInfo" ::: VirtualAllocationInfo)
      IO
      ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ContT
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
     IO
     ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a b. (a -> b) -> a -> b
$ ("virtualAllocInfo" ::: VirtualAllocationInfo
pVirtualAllocInfo)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaVirtualAllocate" ffiVmaVirtualAllocate
  :: VirtualBlock -> Ptr VirtualAllocationCreateInfo -> Ptr VirtualAllocation -> Ptr DeviceSize -> IO Result

-- | 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.                        |
-- +-----------+--------------+-----------------------------------------------+
virtualAllocate :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaVirtualAllocate" "virtualBlock"
                   VirtualBlock
                -> -- No documentation found for Nested "vmaVirtualAllocate" "pCreateInfo"
                   VirtualAllocationCreateInfo
                -> io (VirtualAllocation, ("offset" ::: DeviceSize))
virtualAllocate :: VirtualBlock
-> VirtualAllocationCreateInfo
-> io (VirtualAllocation, "offset" ::: DeviceSize)
virtualAllocate VirtualBlock
virtualBlock VirtualAllocationCreateInfo
createInfo = IO (VirtualAllocation, "offset" ::: DeviceSize)
-> io (VirtualAllocation, "offset" ::: DeviceSize)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (VirtualAllocation, "offset" ::: DeviceSize)
 -> io (VirtualAllocation, "offset" ::: DeviceSize))
-> (ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      (VirtualAllocation, "offset" ::: DeviceSize)
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (VirtualAllocation, "offset" ::: DeviceSize)
-> io (VirtualAllocation, "offset" ::: DeviceSize)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (VirtualAllocation, "offset" ::: DeviceSize)
  IO
  (VirtualAllocation, "offset" ::: DeviceSize)
-> IO (VirtualAllocation, "offset" ::: DeviceSize)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (VirtualAllocation, "offset" ::: DeviceSize)
   IO
   (VirtualAllocation, "offset" ::: DeviceSize)
 -> io (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (VirtualAllocation, "offset" ::: DeviceSize)
-> io (VirtualAllocation, "offset" ::: DeviceSize)
forall a b. (a -> b) -> a -> b
$ do
  Ptr VirtualAllocationCreateInfo
pCreateInfo <- ((Ptr VirtualAllocationCreateInfo
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr VirtualAllocationCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr VirtualAllocationCreateInfo
   -> IO (VirtualAllocation, "offset" ::: DeviceSize))
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      (Ptr VirtualAllocationCreateInfo))
-> ((Ptr VirtualAllocationCreateInfo
     -> IO (VirtualAllocation, "offset" ::: DeviceSize))
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr VirtualAllocationCreateInfo)
forall a b. (a -> b) -> a -> b
$ VirtualAllocationCreateInfo
-> (Ptr VirtualAllocationCreateInfo
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> IO (VirtualAllocation, "offset" ::: DeviceSize)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (VirtualAllocationCreateInfo
createInfo)
  Ptr VirtualAllocation
pPAllocation <- ((Ptr VirtualAllocation
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr VirtualAllocation)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr VirtualAllocation
   -> IO (VirtualAllocation, "offset" ::: DeviceSize))
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      (Ptr VirtualAllocation))
-> ((Ptr VirtualAllocation
     -> IO (VirtualAllocation, "offset" ::: DeviceSize))
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr VirtualAllocation)
forall a b. (a -> b) -> a -> b
$ IO (Ptr VirtualAllocation)
-> (Ptr VirtualAllocation -> IO ())
-> (Ptr VirtualAllocation
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> IO (VirtualAllocation, "offset" ::: DeviceSize)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr VirtualAllocation)
forall a. Int -> IO (Ptr a)
callocBytes @VirtualAllocation Int
8) Ptr VirtualAllocation -> IO ()
forall a. Ptr a -> IO ()
free
  Ptr ("offset" ::: DeviceSize)
pPOffset <- ((Ptr ("offset" ::: DeviceSize)
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr ("offset" ::: DeviceSize))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("offset" ::: DeviceSize)
   -> IO (VirtualAllocation, "offset" ::: DeviceSize))
  -> IO (VirtualAllocation, "offset" ::: DeviceSize))
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      (Ptr ("offset" ::: DeviceSize)))
-> ((Ptr ("offset" ::: DeviceSize)
     -> IO (VirtualAllocation, "offset" ::: DeviceSize))
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (Ptr ("offset" ::: DeviceSize))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("offset" ::: DeviceSize))
-> (Ptr ("offset" ::: DeviceSize) -> IO ())
-> (Ptr ("offset" ::: DeviceSize)
    -> IO (VirtualAllocation, "offset" ::: DeviceSize))
-> IO (VirtualAllocation, "offset" ::: DeviceSize)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("offset" ::: DeviceSize))
forall a. Int -> IO (Ptr a)
callocBytes @DeviceSize Int
8) Ptr ("offset" ::: DeviceSize) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO Result)
-> IO Result
-> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaVirtualAllocate" ((VirtualBlock
-> Ptr VirtualAllocationCreateInfo
-> Ptr VirtualAllocation
-> Ptr ("offset" ::: DeviceSize)
-> IO Result
ffiVmaVirtualAllocate) (VirtualBlock
virtualBlock) Ptr VirtualAllocationCreateInfo
pCreateInfo (Ptr VirtualAllocation
pPAllocation) (Ptr ("offset" ::: DeviceSize)
pPOffset))
  IO () -> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO ())
-> IO ()
-> ContT (VirtualAllocation, "offset" ::: DeviceSize) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  VirtualAllocation
pAllocation <- IO VirtualAllocation
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize) IO VirtualAllocation
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO VirtualAllocation
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize) IO VirtualAllocation)
-> IO VirtualAllocation
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize) IO VirtualAllocation
forall a b. (a -> b) -> a -> b
$ Ptr VirtualAllocation -> IO VirtualAllocation
forall a. Storable a => Ptr a -> IO a
peek @VirtualAllocation Ptr VirtualAllocation
pPAllocation
  "offset" ::: DeviceSize
pOffset <- IO ("offset" ::: DeviceSize)
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     ("offset" ::: DeviceSize)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("offset" ::: DeviceSize)
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      ("offset" ::: DeviceSize))
-> IO ("offset" ::: DeviceSize)
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     ("offset" ::: DeviceSize)
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize Ptr ("offset" ::: DeviceSize)
pPOffset
  (VirtualAllocation, "offset" ::: DeviceSize)
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (VirtualAllocation, "offset" ::: DeviceSize)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((VirtualAllocation, "offset" ::: DeviceSize)
 -> ContT
      (VirtualAllocation, "offset" ::: DeviceSize)
      IO
      (VirtualAllocation, "offset" ::: DeviceSize))
-> (VirtualAllocation, "offset" ::: DeviceSize)
-> ContT
     (VirtualAllocation, "offset" ::: DeviceSize)
     IO
     (VirtualAllocation, "offset" ::: DeviceSize)
forall a b. (a -> b) -> a -> b
$ (VirtualAllocation
pAllocation, "offset" ::: DeviceSize
pOffset)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'virtualAllocate' and 'virtualFree'
--
-- To ensure that 'virtualFree' is always called: pass
-- 'Control.Exception.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.
--
withVirtualAllocation :: forall io r . MonadIO io => VirtualBlock -> VirtualAllocationCreateInfo -> (io (VirtualAllocation, DeviceSize) -> ((VirtualAllocation, DeviceSize) -> io ()) -> r) -> r
withVirtualAllocation :: VirtualBlock
-> VirtualAllocationCreateInfo
-> (io (VirtualAllocation, "offset" ::: DeviceSize)
    -> ((VirtualAllocation, "offset" ::: DeviceSize) -> io ()) -> r)
-> r
withVirtualAllocation VirtualBlock
virtualBlock VirtualAllocationCreateInfo
pCreateInfo io (VirtualAllocation, "offset" ::: DeviceSize)
-> ((VirtualAllocation, "offset" ::: DeviceSize) -> io ()) -> r
b =
  io (VirtualAllocation, "offset" ::: DeviceSize)
-> ((VirtualAllocation, "offset" ::: DeviceSize) -> io ()) -> r
b (VirtualBlock
-> VirtualAllocationCreateInfo
-> io (VirtualAllocation, "offset" ::: DeviceSize)
forall (io :: * -> *).
MonadIO io =>
VirtualBlock
-> VirtualAllocationCreateInfo
-> io (VirtualAllocation, "offset" ::: DeviceSize)
virtualAllocate VirtualBlock
virtualBlock VirtualAllocationCreateInfo
pCreateInfo)
    (\(VirtualAllocation
o0, "offset" ::: DeviceSize
_) -> VirtualBlock -> VirtualAllocation -> io ()
forall (io :: * -> *).
MonadIO io =>
VirtualBlock -> VirtualAllocation -> io ()
virtualFree VirtualBlock
virtualBlock VirtualAllocation
o0)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaVirtualFree" ffiVmaVirtualFree
  :: VirtualBlock -> VirtualAllocation -> IO ()

-- | Frees virtual allocation inside given 'VirtualBlock'.
--
-- It is correct to call this function with @allocation == VK_NULL_HANDLE@
-- - it does nothing.
virtualFree :: forall io
             . (MonadIO io)
            => -- No documentation found for Nested "vmaVirtualFree" "virtualBlock"
               VirtualBlock
            -> -- No documentation found for Nested "vmaVirtualFree" "allocation"
               VirtualAllocation
            -> io ()
virtualFree :: VirtualBlock -> VirtualAllocation -> io ()
virtualFree VirtualBlock
virtualBlock VirtualAllocation
allocation = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaVirtualFree" ((VirtualBlock -> VirtualAllocation -> IO ()
ffiVmaVirtualFree) (VirtualBlock
virtualBlock) (VirtualAllocation
allocation))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaClearVirtualBlock" ffiVmaClearVirtualBlock
  :: VirtualBlock -> IO ()

-- | 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.
clearVirtualBlock :: forall io
                   . (MonadIO io)
                  => -- No documentation found for Nested "vmaClearVirtualBlock" "virtualBlock"
                     VirtualBlock
                  -> io ()
clearVirtualBlock :: VirtualBlock -> io ()
clearVirtualBlock VirtualBlock
virtualBlock = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaClearVirtualBlock" ((VirtualBlock -> IO ()
ffiVmaClearVirtualBlock) (VirtualBlock
virtualBlock))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaSetVirtualAllocationUserData" ffiVmaSetVirtualAllocationUserData
  :: VirtualBlock -> VirtualAllocation -> Ptr () -> IO ()

-- | Changes custom pointer associated with given virtual allocation.
setVirtualAllocationUserData :: forall io
                              . (MonadIO io)
                             => -- No documentation found for Nested "vmaSetVirtualAllocationUserData" "virtualBlock"
                                VirtualBlock
                             -> -- No documentation found for Nested "vmaSetVirtualAllocationUserData" "allocation"
                                VirtualAllocation
                             -> -- No documentation found for Nested "vmaSetVirtualAllocationUserData" "pUserData"
                                ("userData" ::: Ptr ())
                             -> io ()
setVirtualAllocationUserData :: VirtualBlock
-> VirtualAllocation -> ("userData" ::: Ptr ()) -> io ()
setVirtualAllocationUserData VirtualBlock
virtualBlock VirtualAllocation
allocation "userData" ::: Ptr ()
userData = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaSetVirtualAllocationUserData" ((VirtualBlock
-> VirtualAllocation -> ("userData" ::: Ptr ()) -> IO ()
ffiVmaSetVirtualAllocationUserData) (VirtualBlock
virtualBlock) (VirtualAllocation
allocation) ("userData" ::: Ptr ()
userData))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaGetVirtualBlockStatistics" ffiVmaGetVirtualBlockStatistics
  :: VirtualBlock -> Ptr Statistics -> IO ()

-- | 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'.
getVirtualBlockStatistics :: forall io
                           . (MonadIO io)
                          => -- No documentation found for Nested "vmaGetVirtualBlockStatistics" "virtualBlock"
                             VirtualBlock
                          -> io (("stats" ::: Statistics))
getVirtualBlockStatistics :: VirtualBlock -> io ("poolStats" ::: Statistics)
getVirtualBlockStatistics VirtualBlock
virtualBlock = IO ("poolStats" ::: Statistics) -> io ("poolStats" ::: Statistics)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("poolStats" ::: Statistics)
 -> io ("poolStats" ::: Statistics))
-> (ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
    -> IO ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> io ("poolStats" ::: Statistics)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> IO ("poolStats" ::: Statistics)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
 -> io ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
-> io ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("poolStats" ::: Statistics)
pPStats <- ((Ptr ("poolStats" ::: Statistics)
  -> IO ("poolStats" ::: Statistics))
 -> IO ("poolStats" ::: Statistics))
-> ContT
     ("poolStats" ::: Statistics) IO (Ptr ("poolStats" ::: Statistics))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("poolStats" ::: Statistics) =>
(Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @Statistics)
  IO () -> ContT ("poolStats" ::: Statistics) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("poolStats" ::: Statistics) IO ())
-> IO () -> ContT ("poolStats" ::: Statistics) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaGetVirtualBlockStatistics" ((VirtualBlock -> Ptr ("poolStats" ::: Statistics) -> IO ()
ffiVmaGetVirtualBlockStatistics) (VirtualBlock
virtualBlock) (Ptr ("poolStats" ::: Statistics)
pPStats))
  "poolStats" ::: Statistics
pStats <- IO ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("poolStats" ::: Statistics)
 -> ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics))
-> IO ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Statistics Ptr ("poolStats" ::: Statistics)
pPStats
  ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: Statistics)
 -> ContT
      ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics))
-> ("poolStats" ::: Statistics)
-> ContT
     ("poolStats" ::: Statistics) IO ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: Statistics
pStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaCalculateVirtualBlockStatistics" ffiVmaCalculateVirtualBlockStatistics
  :: VirtualBlock -> Ptr DetailedStatistics -> IO ()

-- | 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'.
calculateVirtualBlockStatistics :: forall io
                                 . (MonadIO io)
                                => -- No documentation found for Nested "vmaCalculateVirtualBlockStatistics" "virtualBlock"
                                   VirtualBlock
                                -> io (("stats" ::: DetailedStatistics))
calculateVirtualBlockStatistics :: VirtualBlock -> io ("poolStats" ::: DetailedStatistics)
calculateVirtualBlockStatistics VirtualBlock
virtualBlock = IO ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("poolStats" ::: DetailedStatistics)
 -> io ("poolStats" ::: DetailedStatistics))
-> (ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics)
    -> IO ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("poolStats" ::: DetailedStatistics)
  IO
  ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("poolStats" ::: DetailedStatistics)
   IO
   ("poolStats" ::: DetailedStatistics)
 -> io ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
-> io ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("poolStats" ::: DetailedStatistics)
pPStats <- ((Ptr ("poolStats" ::: DetailedStatistics)
  -> IO ("poolStats" ::: DetailedStatistics))
 -> IO ("poolStats" ::: DetailedStatistics))
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     (Ptr ("poolStats" ::: DetailedStatistics))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall b.
ToCStruct ("poolStats" ::: DetailedStatistics) =>
(Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b
forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @DetailedStatistics)
  IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ())
-> IO () -> ContT ("poolStats" ::: DetailedStatistics) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaCalculateVirtualBlockStatistics" ((VirtualBlock -> Ptr ("poolStats" ::: DetailedStatistics) -> IO ()
ffiVmaCalculateVirtualBlockStatistics) (VirtualBlock
virtualBlock) (Ptr ("poolStats" ::: DetailedStatistics)
pPStats))
  "poolStats" ::: DetailedStatistics
pStats <- IO ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("poolStats" ::: DetailedStatistics)
 -> ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics))
-> IO ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DetailedStatistics Ptr ("poolStats" ::: DetailedStatistics)
pPStats
  ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: DetailedStatistics)
 -> ContT
      ("poolStats" ::: DetailedStatistics)
      IO
      ("poolStats" ::: DetailedStatistics))
-> ("poolStats" ::: DetailedStatistics)
-> ContT
     ("poolStats" ::: DetailedStatistics)
     IO
     ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: DetailedStatistics
pStats)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBuildVirtualBlockStatsString" ffiVmaBuildVirtualBlockStatsString
  :: VirtualBlock -> Ptr (Ptr CChar) -> Bool32 -> IO ()

-- | 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'.
buildVirtualBlockStatsString :: forall io
                              . (MonadIO io)
                             => -- No documentation found for Nested "vmaBuildVirtualBlockStatsString" "virtualBlock"
                                VirtualBlock
                             -> -- No documentation found for Nested "vmaBuildVirtualBlockStatsString" "detailedMap"
                                ("detailedMap" ::: Bool)
                             -> io (("statsString" ::: Ptr CChar))
buildVirtualBlockStatsString :: VirtualBlock -> Bool -> io ("name" ::: Ptr CChar)
buildVirtualBlockStatsString VirtualBlock
virtualBlock Bool
detailedMap = IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar))
-> (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> IO ("name" ::: Ptr CChar)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
 -> io ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("name" ::: Ptr CChar)
pPpStatsString <- ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
 -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
  -> IO ("name" ::: Ptr CChar))
 -> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("name" ::: Ptr CChar))
-> (Ptr ("name" ::: Ptr CChar) -> IO ())
-> (Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("name" ::: Ptr CChar))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr CChar) Int
8) Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: Ptr CChar) IO ())
-> IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBuildVirtualBlockStatsString" ((VirtualBlock -> Ptr ("name" ::: Ptr CChar) -> Bool32 -> IO ()
ffiVmaBuildVirtualBlockStatsString) (VirtualBlock
virtualBlock) (Ptr ("name" ::: Ptr CChar)
pPpStatsString) (Bool -> Bool32
boolToBool32 (Bool
detailedMap)))
  "name" ::: Ptr CChar
ppStatsString <- IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr CChar) Ptr ("name" ::: Ptr CChar)
pPpStatsString
  ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: Ptr CChar
ppStatsString)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFreeVirtualBlockStatsString" ffiVmaFreeVirtualBlockStatsString
  :: VirtualBlock -> Ptr CChar -> IO ()

-- | Frees a string returned by 'buildVirtualBlockStatsString'.
freeVirtualBlockStatsString :: forall io
                             . (MonadIO io)
                            => -- No documentation found for Nested "vmaFreeVirtualBlockStatsString" "virtualBlock"
                               VirtualBlock
                            -> -- No documentation found for Nested "vmaFreeVirtualBlockStatsString" "pStatsString"
                               ("statsString" ::: Ptr CChar)
                            -> io ()
freeVirtualBlockStatsString :: VirtualBlock -> ("name" ::: Ptr CChar) -> io ()
freeVirtualBlockStatsString VirtualBlock
virtualBlock "name" ::: Ptr CChar
statsString = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFreeVirtualBlockStatsString" ((VirtualBlock -> ("name" ::: Ptr CChar) -> IO ()
ffiVmaFreeVirtualBlockStatsString) (VirtualBlock
virtualBlock) ("name" ::: Ptr CChar
statsString))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaBuildStatsString" ffiVmaBuildStatsString
  :: Allocator -> Ptr (Ptr CChar) -> Bool32 -> IO ()

-- | Builds and returns statistics as a null-terminated string in JSON
-- format.
--
-- __Parameters__
--
-- +-----------+---------------+-----------------------------------------------+
-- |           | allocator     |                                               |
-- +-----------+---------------+-----------------------------------------------+
-- | out       | ppStatsString | Must be freed using 'freeStatsString'         |
-- |           |               | function.                                     |
-- +-----------+---------------+-----------------------------------------------+
-- |           | detailedMap   |                                               |
-- +-----------+---------------+-----------------------------------------------+
buildStatsString :: forall io
                  . (MonadIO io)
                 => -- No documentation found for Nested "vmaBuildStatsString" "allocator"
                    Allocator
                 -> -- No documentation found for Nested "vmaBuildStatsString" "detailedMap"
                    ("detailedMap" ::: Bool)
                 -> io (("statsString" ::: Ptr CChar))
buildStatsString :: Allocator -> Bool -> io ("name" ::: Ptr CChar)
buildStatsString Allocator
allocator Bool
detailedMap = IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("name" ::: Ptr CChar) -> io ("name" ::: Ptr CChar))
-> (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> IO ("name" ::: Ptr CChar)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
 -> io ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
-> io ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ do
  Ptr ("name" ::: Ptr CChar)
pPpStatsString <- ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
 -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
  -> IO ("name" ::: Ptr CChar))
 -> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar)))
-> ((Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
    -> IO ("name" ::: Ptr CChar))
-> ContT ("name" ::: Ptr CChar) IO (Ptr ("name" ::: Ptr CChar))
forall a b. (a -> b) -> a -> b
$ IO (Ptr ("name" ::: Ptr CChar))
-> (Ptr ("name" ::: Ptr CChar) -> IO ())
-> (Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO (Ptr ("name" ::: Ptr CChar))
forall a. Int -> IO (Ptr a)
callocBytes @(Ptr CChar) Int
8) Ptr ("name" ::: Ptr CChar) -> IO ()
forall a. Ptr a -> IO ()
free
  IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("name" ::: Ptr CChar) IO ())
-> IO () -> ContT ("name" ::: Ptr CChar) IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaBuildStatsString" ((Allocator -> Ptr ("name" ::: Ptr CChar) -> Bool32 -> IO ()
ffiVmaBuildStatsString) (Allocator
allocator) (Ptr ("name" ::: Ptr CChar)
pPpStatsString) (Bool -> Bool32
boolToBool32 (Bool
detailedMap)))
  "name" ::: Ptr CChar
ppStatsString <- IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> IO ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr CChar) Ptr ("name" ::: Ptr CChar)
pPpStatsString
  ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("name" ::: Ptr CChar)
 -> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar))
-> ("name" ::: Ptr CChar)
-> ContT ("name" ::: Ptr CChar) IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ("name" ::: Ptr CChar
ppStatsString)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "vmaFreeStatsString" ffiVmaFreeStatsString
  :: Allocator -> Ptr CChar -> IO ()


freeStatsString :: forall io
                 . (MonadIO io)
                => -- No documentation found for Nested "vmaFreeStatsString" "allocator"
                   Allocator
                -> -- No documentation found for Nested "vmaFreeStatsString" "pStatsString"
                   ("statsString" ::: Ptr CChar)
                -> io ()
freeStatsString :: Allocator -> ("name" ::: Ptr CChar) -> io ()
freeStatsString Allocator
allocator "name" ::: Ptr CChar
statsString = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent String
"vmaFreeStatsString" ((Allocator -> ("name" ::: Ptr CChar) -> IO ()
ffiVmaFreeStatsString) (Allocator
allocator) ("name" ::: Ptr CChar
statsString))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


type FN_vkAllocateMemory = Ptr Device_T -> ("pAllocateInfo" ::: Ptr (SomeStruct MemoryAllocateInfo)) -> ("pAllocator" ::: Ptr AllocationCallbacks) -> ("pMemory" ::: Ptr DeviceMemory) -> IO Result
-- No documentation found for TopLevel "PFN_vkAllocateMemory"
type PFN_vkAllocateMemory = FunPtr FN_vkAllocateMemory


type FN_vkBindBufferMemory = Ptr Device_T -> Buffer -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result
-- No documentation found for TopLevel "PFN_vkBindBufferMemory"
type PFN_vkBindBufferMemory = FunPtr FN_vkBindBufferMemory


type FN_vkBindBufferMemory2KHR = Ptr Device_T -> ("bindInfoCount" ::: Word32) -> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo)) -> IO Result
-- No documentation found for TopLevel "PFN_vkBindBufferMemory2KHR"
type PFN_vkBindBufferMemory2KHR = FunPtr FN_vkBindBufferMemory2KHR


type FN_vkBindImageMemory = Ptr Device_T -> Image -> DeviceMemory -> ("memoryOffset" ::: DeviceSize) -> IO Result
-- No documentation found for TopLevel "PFN_vkBindImageMemory"
type PFN_vkBindImageMemory = FunPtr FN_vkBindImageMemory


type FN_vkBindImageMemory2KHR = Ptr Device_T -> ("bindInfoCount" ::: Word32) -> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo)) -> IO Result
-- No documentation found for TopLevel "PFN_vkBindImageMemory2KHR"
type PFN_vkBindImageMemory2KHR = FunPtr FN_vkBindImageMemory2KHR


type FN_vkCmdCopyBuffer = Ptr CommandBuffer_T -> ("srcBuffer" ::: Buffer) -> ("dstBuffer" ::: Buffer) -> ("regionCount" ::: Word32) -> ("pRegions" ::: Ptr BufferCopy) -> IO ()
-- No documentation found for TopLevel "PFN_vkCmdCopyBuffer"
type PFN_vkCmdCopyBuffer = FunPtr FN_vkCmdCopyBuffer


type FN_vkCreateBuffer = Ptr Device_T -> ("pCreateInfo" ::: Ptr (SomeStruct BufferCreateInfo)) -> ("pAllocator" ::: Ptr AllocationCallbacks) -> ("pBuffer" ::: Ptr Buffer) -> IO Result
-- No documentation found for TopLevel "PFN_vkCreateBuffer"
type PFN_vkCreateBuffer = FunPtr FN_vkCreateBuffer


type FN_vkCreateImage = Ptr Device_T -> ("pCreateInfo" ::: Ptr (SomeStruct ImageCreateInfo)) -> ("pAllocator" ::: Ptr AllocationCallbacks) -> ("pImage" ::: Ptr Image) -> IO Result
-- No documentation found for TopLevel "PFN_vkCreateImage"
type PFN_vkCreateImage = FunPtr FN_vkCreateImage


type FN_vkDestroyBuffer = Ptr Device_T -> Buffer -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()
-- No documentation found for TopLevel "PFN_vkDestroyBuffer"
type PFN_vkDestroyBuffer = FunPtr FN_vkDestroyBuffer


type FN_vkDestroyImage = Ptr Device_T -> Image -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()
-- No documentation found for TopLevel "PFN_vkDestroyImage"
type PFN_vkDestroyImage = FunPtr FN_vkDestroyImage


type FN_vkFlushMappedMemoryRanges = Ptr Device_T -> ("memoryRangeCount" ::: Word32) -> ("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO Result
-- No documentation found for TopLevel "PFN_vkFlushMappedMemoryRanges"
type PFN_vkFlushMappedMemoryRanges = FunPtr FN_vkFlushMappedMemoryRanges


type FN_vkFreeMemory = Ptr Device_T -> DeviceMemory -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()
-- No documentation found for TopLevel "PFN_vkFreeMemory"
type PFN_vkFreeMemory = FunPtr FN_vkFreeMemory


type FN_vkGetBufferMemoryRequirements = Ptr Device_T -> Buffer -> ("pMemoryRequirements" ::: Ptr MemoryRequirements) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetBufferMemoryRequirements"
type PFN_vkGetBufferMemoryRequirements = FunPtr FN_vkGetBufferMemoryRequirements


type FN_vkGetBufferMemoryRequirements2KHR = Ptr Device_T -> ("pInfo" ::: Ptr BufferMemoryRequirementsInfo2) -> ("pMemoryRequirements" ::: Ptr (SomeStruct MemoryRequirements2)) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetBufferMemoryRequirements2KHR"
type PFN_vkGetBufferMemoryRequirements2KHR = FunPtr FN_vkGetBufferMemoryRequirements2KHR


type FN_vkGetImageMemoryRequirements = Ptr Device_T -> Image -> ("pMemoryRequirements" ::: Ptr MemoryRequirements) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetImageMemoryRequirements"
type PFN_vkGetImageMemoryRequirements = FunPtr FN_vkGetImageMemoryRequirements


type FN_vkGetImageMemoryRequirements2KHR = Ptr Device_T -> ("pInfo" ::: Ptr (SomeStruct ImageMemoryRequirementsInfo2)) -> ("pMemoryRequirements" ::: Ptr (SomeStruct MemoryRequirements2)) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetImageMemoryRequirements2KHR"
type PFN_vkGetImageMemoryRequirements2KHR = FunPtr FN_vkGetImageMemoryRequirements2KHR


type FN_vkGetPhysicalDeviceMemoryProperties = Ptr PhysicalDevice_T -> ("pMemoryProperties" ::: Ptr PhysicalDeviceMemoryProperties) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetPhysicalDeviceMemoryProperties"
type PFN_vkGetPhysicalDeviceMemoryProperties = FunPtr FN_vkGetPhysicalDeviceMemoryProperties


type FN_vkGetPhysicalDeviceMemoryProperties2KHR = Ptr PhysicalDevice_T -> ("pMemoryProperties" ::: Ptr (SomeStruct PhysicalDeviceMemoryProperties2)) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetPhysicalDeviceMemoryProperties2KHR"
type PFN_vkGetPhysicalDeviceMemoryProperties2KHR = FunPtr FN_vkGetPhysicalDeviceMemoryProperties2KHR


type FN_vkGetPhysicalDeviceProperties = Ptr PhysicalDevice_T -> ("pProperties" ::: Ptr PhysicalDeviceProperties) -> IO ()
-- No documentation found for TopLevel "PFN_vkGetPhysicalDeviceProperties"
type PFN_vkGetPhysicalDeviceProperties = FunPtr FN_vkGetPhysicalDeviceProperties


type FN_vkGetDeviceProcAddr = Ptr Device_T -> ("pName" ::: Ptr CChar) -> IO PFN_vkVoidFunction
-- No documentation found for TopLevel "PFN_vkGetDeviceProcAddr"
type PFN_vkGetDeviceProcAddr = FunPtr FN_vkGetDeviceProcAddr


type FN_vkGetInstanceProcAddr = Ptr Instance_T -> ("pName" ::: Ptr CChar) -> IO PFN_vkVoidFunction
-- No documentation found for TopLevel "PFN_vkGetInstanceProcAddr"
type PFN_vkGetInstanceProcAddr = FunPtr FN_vkGetInstanceProcAddr


type FN_vkInvalidateMappedMemoryRanges = Ptr Device_T -> ("memoryRangeCount" ::: Word32) -> ("pMemoryRanges" ::: Ptr MappedMemoryRange) -> IO Result
-- No documentation found for TopLevel "PFN_vkInvalidateMappedMemoryRanges"
type PFN_vkInvalidateMappedMemoryRanges = FunPtr FN_vkInvalidateMappedMemoryRanges


type FN_vkVoidFunction = IO ()
-- No documentation found for TopLevel "PFN_vkVoidFunction"
type PFN_vkVoidFunction = FunPtr FN_vkVoidFunction


type FN_vkMapMemory = Ptr Device_T -> DeviceMemory -> ("offset" ::: DeviceSize) -> DeviceSize -> MemoryMapFlags -> ("ppData" ::: Ptr (Ptr ())) -> IO Result
-- No documentation found for TopLevel "PFN_vkMapMemory"
type PFN_vkMapMemory = FunPtr FN_vkMapMemory


type FN_vkUnmapMemory = Ptr Device_T -> DeviceMemory -> IO ()
-- No documentation found for TopLevel "PFN_vkUnmapMemory"
type PFN_vkUnmapMemory = FunPtr FN_vkUnmapMemory


type AllocatorCreateFlags = AllocatorCreateFlagBits

-- | Flags for created 'Allocator'.
newtype AllocatorCreateFlagBits = AllocatorCreateFlagBits Flags
  deriving newtype (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
(AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> Eq AllocatorCreateFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c/= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
== :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c== :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
Eq, Eq AllocatorCreateFlagBits
Eq AllocatorCreateFlagBits
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Ordering)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> Ord AllocatorCreateFlagBits
AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Ordering
AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$cmin :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
max :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$cmax :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
>= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c>= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
> :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c> :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
<= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c<= :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
< :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
$c< :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Bool
compare :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Ordering
$ccompare :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> Ordering
$cp1Ord :: Eq AllocatorCreateFlagBits
Ord, Ptr b -> Int -> IO AllocatorCreateFlagBits
Ptr b -> Int -> AllocatorCreateFlagBits -> IO ()
Ptr AllocatorCreateFlagBits -> IO AllocatorCreateFlagBits
Ptr AllocatorCreateFlagBits -> Int -> IO AllocatorCreateFlagBits
Ptr AllocatorCreateFlagBits
-> Int -> AllocatorCreateFlagBits -> IO ()
Ptr AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> IO ()
AllocatorCreateFlagBits -> Int
(AllocatorCreateFlagBits -> Int)
-> (AllocatorCreateFlagBits -> Int)
-> (Ptr AllocatorCreateFlagBits
    -> Int -> IO AllocatorCreateFlagBits)
-> (Ptr AllocatorCreateFlagBits
    -> Int -> AllocatorCreateFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO AllocatorCreateFlagBits)
-> (forall b. Ptr b -> Int -> AllocatorCreateFlagBits -> IO ())
-> (Ptr AllocatorCreateFlagBits -> IO AllocatorCreateFlagBits)
-> (Ptr AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> IO ())
-> Storable AllocatorCreateFlagBits
forall b. Ptr b -> Int -> IO AllocatorCreateFlagBits
forall b. Ptr b -> Int -> AllocatorCreateFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> IO ()
$cpoke :: Ptr AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> IO ()
peek :: Ptr AllocatorCreateFlagBits -> IO AllocatorCreateFlagBits
$cpeek :: Ptr AllocatorCreateFlagBits -> IO AllocatorCreateFlagBits
pokeByteOff :: Ptr b -> Int -> AllocatorCreateFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> AllocatorCreateFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO AllocatorCreateFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AllocatorCreateFlagBits
pokeElemOff :: Ptr AllocatorCreateFlagBits
-> Int -> AllocatorCreateFlagBits -> IO ()
$cpokeElemOff :: Ptr AllocatorCreateFlagBits
-> Int -> AllocatorCreateFlagBits -> IO ()
peekElemOff :: Ptr AllocatorCreateFlagBits -> Int -> IO AllocatorCreateFlagBits
$cpeekElemOff :: Ptr AllocatorCreateFlagBits -> Int -> IO AllocatorCreateFlagBits
alignment :: AllocatorCreateFlagBits -> Int
$calignment :: AllocatorCreateFlagBits -> Int
sizeOf :: AllocatorCreateFlagBits -> Int
$csizeOf :: AllocatorCreateFlagBits -> Int
Storable, AllocatorCreateFlagBits
AllocatorCreateFlagBits -> Zero AllocatorCreateFlagBits
forall a. a -> Zero a
zero :: AllocatorCreateFlagBits
$czero :: AllocatorCreateFlagBits
Zero, Eq AllocatorCreateFlagBits
AllocatorCreateFlagBits
Eq AllocatorCreateFlagBits
-> (AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits
    -> AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> AllocatorCreateFlagBits
-> (Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> Bool)
-> (AllocatorCreateFlagBits -> Maybe Int)
-> (AllocatorCreateFlagBits -> Int)
-> (AllocatorCreateFlagBits -> Bool)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits)
-> (AllocatorCreateFlagBits -> Int)
-> Bits AllocatorCreateFlagBits
Int -> AllocatorCreateFlagBits
AllocatorCreateFlagBits -> Bool
AllocatorCreateFlagBits -> Int
AllocatorCreateFlagBits -> Maybe Int
AllocatorCreateFlagBits -> AllocatorCreateFlagBits
AllocatorCreateFlagBits -> Int -> Bool
AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: AllocatorCreateFlagBits -> Int
$cpopCount :: AllocatorCreateFlagBits -> Int
rotateR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$crotateR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
rotateL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$crotateL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
unsafeShiftR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cunsafeShiftR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
shiftR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cshiftR :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
unsafeShiftL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cunsafeShiftL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
shiftL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cshiftL :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
isSigned :: AllocatorCreateFlagBits -> Bool
$cisSigned :: AllocatorCreateFlagBits -> Bool
bitSize :: AllocatorCreateFlagBits -> Int
$cbitSize :: AllocatorCreateFlagBits -> Int
bitSizeMaybe :: AllocatorCreateFlagBits -> Maybe Int
$cbitSizeMaybe :: AllocatorCreateFlagBits -> Maybe Int
testBit :: AllocatorCreateFlagBits -> Int -> Bool
$ctestBit :: AllocatorCreateFlagBits -> Int -> Bool
complementBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$ccomplementBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
clearBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cclearBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
setBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$csetBit :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
bit :: Int -> AllocatorCreateFlagBits
$cbit :: Int -> AllocatorCreateFlagBits
zeroBits :: AllocatorCreateFlagBits
$czeroBits :: AllocatorCreateFlagBits
rotate :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$crotate :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
shift :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
$cshift :: AllocatorCreateFlagBits -> Int -> AllocatorCreateFlagBits
complement :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$ccomplement :: AllocatorCreateFlagBits -> AllocatorCreateFlagBits
xor :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$cxor :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
.|. :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$c.|. :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
.&. :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$c.&. :: AllocatorCreateFlagBits
-> AllocatorCreateFlagBits -> AllocatorCreateFlagBits
$cp1Bits :: Eq AllocatorCreateFlagBits
Bits, Bits AllocatorCreateFlagBits
Bits AllocatorCreateFlagBits
-> (AllocatorCreateFlagBits -> Int)
-> (AllocatorCreateFlagBits -> Int)
-> (AllocatorCreateFlagBits -> Int)
-> FiniteBits AllocatorCreateFlagBits
AllocatorCreateFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: AllocatorCreateFlagBits -> Int
$ccountTrailingZeros :: AllocatorCreateFlagBits -> Int
countLeadingZeros :: AllocatorCreateFlagBits -> Int
$ccountLeadingZeros :: AllocatorCreateFlagBits -> Int
finiteBitSize :: AllocatorCreateFlagBits -> Int
$cfiniteBitSize :: AllocatorCreateFlagBits -> Int
$cp1FiniteBits :: Bits AllocatorCreateFlagBits
FiniteBits)

-- | 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 $bALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT    = AllocatorCreateFlagBits 0x00000001
-- | Enables usage of VK_KHR_dedicated_allocation extension.
--
-- The flag works only if /VmaAllocatorCreateInfo::vulkanApiVersion/
-- @== VK_API_VERSION_1_0@. When it is @VK_API_VERSION_1_1@, the flag is
-- ignored because the extension has been promoted to Vulkan 1.1.
--
-- 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
-- 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT' flag) when it is recommended by
-- the driver. It may improve performance on some GPUs.
--
-- 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:
--
-- -   VK_KHR_get_memory_requirements2 (device extension)
--
-- -   VK_KHR_dedicated_allocation (device extension)
--
-- 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 $bALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT   = AllocatorCreateFlagBits 0x00000002
-- | Enables usage of VK_KHR_bind_memory2 extension.
--
-- The flag works only if /VmaAllocatorCreateInfo::vulkanApiVersion/
-- @== VK_API_VERSION_1_0@. When it is @VK_API_VERSION_1_1@, the flag is
-- ignored because the extension has been promoted to Vulkan 1.1.
--
-- 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 @vkBindBufferMemory2KHR@ and
-- @vkBindImageMemory2KHR@, which allow to pass a chain of @pNext@
-- structures while binding. This flag is required if you use @pNext@
-- parameter in 'bindBufferMemory2' or 'bindImageMemory2'.
pattern $bALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT           = AllocatorCreateFlagBits 0x00000004
-- | 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 $bALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT          = AllocatorCreateFlagBits 0x00000008
-- | Enables usage of VK_AMD_device_coherent_memory extension.
--
-- You may set this flag only if you:
--
-- -   found out that this device extension is supported and enabled it
--     while creating Vulkan device passed as
--     /VmaAllocatorCreateInfo::device/,
--
-- -   checked that
--     @VkPhysicalDeviceCoherentMemoryFeaturesAMD::deviceCoherentMemory@ is
--     true and set it while creating the Vulkan device,
--
-- -   want it to be used internally by this library.
--
-- The extension and accompanying device feature provide access to memory
-- types with @VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD@ and
-- @VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD@ flags. They are useful
-- mostly for writing breadcrumb markers - a common method for debugging
-- GPU crash\/hang\/TDR.
--
-- 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 @VK_ERROR_FEATURE_NOT_PRESENT@.
pattern $bALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT = AllocatorCreateFlagBits 0x00000010
-- | Enables usage of \"buffer device address\" feature, which allows you to
-- use function @vkGetBufferDeviceAddress*@ to get raw GPU pointer to a
-- buffer and pass it for usage inside a shader.
--
-- You may set this flag only if you:
--
-- 1.  (For Vulkan version \< 1.2) Found as available and enabled device
--     extension VK_KHR_buffer_device_address. This extension is promoted
--     to core Vulkan 1.2.
--
-- 2.  Found as available and enabled device feature
--     @VkPhysicalDeviceBufferDeviceAddressFeatures::bufferDeviceAddress@.
--
-- When this flag is set, you can create buffers with
-- @VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT@ using VMA. The library
-- automatically adds @VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT@ to allocated
-- memory blocks wherever it might be needed.
--
-- For more information, see documentation chapter /Enabling buffer device
-- address/.
pattern $bALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT      = AllocatorCreateFlagBits 0x00000020
-- | 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
-- @VkPhysicalDeviceMemoryPriorityFeaturesEXT::memoryPriority == VK_TRUE@,
-- while creating Vulkan device passed as /VmaAllocatorCreateInfo::device/.
--
-- 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
-- @vkAllocateMemory@ done by the library using structure
-- @VkMemoryPriorityAllocateInfoEXT@. The value to be used for default
-- priority is 0.5. For more details, see the documentation of the
-- VK_EXT_memory_priority extension.
pattern $bALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT :: AllocatorCreateFlagBits
$mALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT :: forall r.
AllocatorCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT        = AllocatorCreateFlagBits 0x00000040

conNameAllocatorCreateFlagBits :: String
conNameAllocatorCreateFlagBits :: String
conNameAllocatorCreateFlagBits = String
"AllocatorCreateFlagBits"

enumPrefixAllocatorCreateFlagBits :: String
enumPrefixAllocatorCreateFlagBits :: String
enumPrefixAllocatorCreateFlagBits = String
"ALLOCATOR_CREATE_"

showTableAllocatorCreateFlagBits :: [(AllocatorCreateFlagBits, String)]
showTableAllocatorCreateFlagBits :: [(AllocatorCreateFlagBits, String)]
showTableAllocatorCreateFlagBits =
  [ (AllocatorCreateFlagBits
ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT   , String
"EXTERNALLY_SYNCHRONIZED_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT  , String
"KHR_DEDICATED_ALLOCATION_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT          , String
"KHR_BIND_MEMORY2_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT         , String
"EXT_MEMORY_BUDGET_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT, String
"AMD_DEVICE_COHERENT_MEMORY_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT     , String
"BUFFER_DEVICE_ADDRESS_BIT")
  , (AllocatorCreateFlagBits
ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT       , String
"EXT_MEMORY_PRIORITY_BIT")
  ]

instance Show AllocatorCreateFlagBits where
  showsPrec :: Int -> AllocatorCreateFlagBits -> ShowS
showsPrec = String
-> [(AllocatorCreateFlagBits, String)]
-> String
-> (AllocatorCreateFlagBits -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> AllocatorCreateFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixAllocatorCreateFlagBits
                            [(AllocatorCreateFlagBits, String)]
showTableAllocatorCreateFlagBits
                            String
conNameAllocatorCreateFlagBits
                            (\(AllocatorCreateFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read AllocatorCreateFlagBits where
  readPrec :: ReadPrec AllocatorCreateFlagBits
readPrec = String
-> [(AllocatorCreateFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32) -> AllocatorCreateFlagBits)
-> ReadPrec AllocatorCreateFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixAllocatorCreateFlagBits
                          [(AllocatorCreateFlagBits, String)]
showTableAllocatorCreateFlagBits
                          String
conNameAllocatorCreateFlagBits
                          ("memoryTypeIndex" ::: Word32) -> AllocatorCreateFlagBits
AllocatorCreateFlagBits


-- | Intended usage of the allocated memory.
newtype MemoryUsage = MemoryUsage Int32
  deriving newtype (MemoryUsage -> MemoryUsage -> Bool
(MemoryUsage -> MemoryUsage -> Bool)
-> (MemoryUsage -> MemoryUsage -> Bool) -> Eq MemoryUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MemoryUsage -> MemoryUsage -> Bool
$c/= :: MemoryUsage -> MemoryUsage -> Bool
== :: MemoryUsage -> MemoryUsage -> Bool
$c== :: MemoryUsage -> MemoryUsage -> Bool
Eq, Eq MemoryUsage
Eq MemoryUsage
-> (MemoryUsage -> MemoryUsage -> Ordering)
-> (MemoryUsage -> MemoryUsage -> Bool)
-> (MemoryUsage -> MemoryUsage -> Bool)
-> (MemoryUsage -> MemoryUsage -> Bool)
-> (MemoryUsage -> MemoryUsage -> Bool)
-> (MemoryUsage -> MemoryUsage -> MemoryUsage)
-> (MemoryUsage -> MemoryUsage -> MemoryUsage)
-> Ord MemoryUsage
MemoryUsage -> MemoryUsage -> Bool
MemoryUsage -> MemoryUsage -> Ordering
MemoryUsage -> MemoryUsage -> MemoryUsage
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: MemoryUsage -> MemoryUsage -> MemoryUsage
$cmin :: MemoryUsage -> MemoryUsage -> MemoryUsage
max :: MemoryUsage -> MemoryUsage -> MemoryUsage
$cmax :: MemoryUsage -> MemoryUsage -> MemoryUsage
>= :: MemoryUsage -> MemoryUsage -> Bool
$c>= :: MemoryUsage -> MemoryUsage -> Bool
> :: MemoryUsage -> MemoryUsage -> Bool
$c> :: MemoryUsage -> MemoryUsage -> Bool
<= :: MemoryUsage -> MemoryUsage -> Bool
$c<= :: MemoryUsage -> MemoryUsage -> Bool
< :: MemoryUsage -> MemoryUsage -> Bool
$c< :: MemoryUsage -> MemoryUsage -> Bool
compare :: MemoryUsage -> MemoryUsage -> Ordering
$ccompare :: MemoryUsage -> MemoryUsage -> Ordering
$cp1Ord :: Eq MemoryUsage
Ord, Ptr b -> Int -> IO MemoryUsage
Ptr b -> Int -> MemoryUsage -> IO ()
Ptr MemoryUsage -> IO MemoryUsage
Ptr MemoryUsage -> Int -> IO MemoryUsage
Ptr MemoryUsage -> Int -> MemoryUsage -> IO ()
Ptr MemoryUsage -> MemoryUsage -> IO ()
MemoryUsage -> Int
(MemoryUsage -> Int)
-> (MemoryUsage -> Int)
-> (Ptr MemoryUsage -> Int -> IO MemoryUsage)
-> (Ptr MemoryUsage -> Int -> MemoryUsage -> IO ())
-> (forall b. Ptr b -> Int -> IO MemoryUsage)
-> (forall b. Ptr b -> Int -> MemoryUsage -> IO ())
-> (Ptr MemoryUsage -> IO MemoryUsage)
-> (Ptr MemoryUsage -> MemoryUsage -> IO ())
-> Storable MemoryUsage
forall b. Ptr b -> Int -> IO MemoryUsage
forall b. Ptr b -> Int -> MemoryUsage -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr MemoryUsage -> MemoryUsage -> IO ()
$cpoke :: Ptr MemoryUsage -> MemoryUsage -> IO ()
peek :: Ptr MemoryUsage -> IO MemoryUsage
$cpeek :: Ptr MemoryUsage -> IO MemoryUsage
pokeByteOff :: Ptr b -> Int -> MemoryUsage -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> MemoryUsage -> IO ()
peekByteOff :: Ptr b -> Int -> IO MemoryUsage
$cpeekByteOff :: forall b. Ptr b -> Int -> IO MemoryUsage
pokeElemOff :: Ptr MemoryUsage -> Int -> MemoryUsage -> IO ()
$cpokeElemOff :: Ptr MemoryUsage -> Int -> MemoryUsage -> IO ()
peekElemOff :: Ptr MemoryUsage -> Int -> IO MemoryUsage
$cpeekElemOff :: Ptr MemoryUsage -> Int -> IO MemoryUsage
alignment :: MemoryUsage -> Int
$calignment :: MemoryUsage -> Int
sizeOf :: MemoryUsage -> Int
$csizeOf :: MemoryUsage -> Int
Storable, MemoryUsage
MemoryUsage -> Zero MemoryUsage
forall a. a -> Zero a
zero :: MemoryUsage
$czero :: MemoryUsage
Zero)

-- | No intended memory usage specified. Use other members of
-- 'AllocationCreateInfo' to specify your requirements.
pattern $bMEMORY_USAGE_UNKNOWN :: MemoryUsage
$mMEMORY_USAGE_UNKNOWN :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_UNKNOWN              = MemoryUsage 0
-- | /Deprecated/
--
-- Obsolete, preserved for backward compatibility. Prefers
-- @VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT@.
pattern $bMEMORY_USAGE_GPU_ONLY :: MemoryUsage
$mMEMORY_USAGE_GPU_ONLY :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_GPU_ONLY             = MemoryUsage 1
-- | /Deprecated/
--
-- Obsolete, preserved for backward compatibility. Guarantees
-- @VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT@ and
-- @VK_MEMORY_PROPERTY_HOST_COHERENT_BIT@.
pattern $bMEMORY_USAGE_CPU_ONLY :: MemoryUsage
$mMEMORY_USAGE_CPU_ONLY :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_CPU_ONLY             = MemoryUsage 2
-- | /Deprecated/
--
-- Obsolete, preserved for backward compatibility. Guarantees
-- @VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT@, prefers
-- @VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT@.
pattern $bMEMORY_USAGE_CPU_TO_GPU :: MemoryUsage
$mMEMORY_USAGE_CPU_TO_GPU :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_CPU_TO_GPU           = MemoryUsage 3
-- | /Deprecated/
--
-- Obsolete, preserved for backward compatibility. Guarantees
-- @VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT@, prefers
-- @VK_MEMORY_PROPERTY_HOST_CACHED_BIT@.
pattern $bMEMORY_USAGE_GPU_TO_CPU :: MemoryUsage
$mMEMORY_USAGE_GPU_TO_CPU :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_GPU_TO_CPU           = MemoryUsage 4
-- | /Deprecated/
--
-- Obsolete, preserved for backward compatibility. Prefers not
-- @VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT@.
pattern $bMEMORY_USAGE_CPU_COPY :: MemoryUsage
$mMEMORY_USAGE_CPU_COPY :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_CPU_COPY             = MemoryUsage 5
-- | Lazily allocated GPU memory having
-- @VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT@. Exists mostly on mobile
-- platforms. Using it on desktop PC or other GPUs with no such memory type
-- present will fail the allocation.
--
-- Usage: Memory for transient attachment images (color attachments, depth
-- attachments etc.), created with
-- @VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT@.
--
-- Allocations with this usage are always created as dedicated - it implies
-- 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT'.
pattern $bMEMORY_USAGE_GPU_LAZILY_ALLOCATED :: MemoryUsage
$mMEMORY_USAGE_GPU_LAZILY_ALLOCATED :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_GPU_LAZILY_ALLOCATED = MemoryUsage 6
-- | 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
-- 'mapMemory' or 'ALLOCATION_CREATE_MAPPED_BIT'), you must pass one of the
-- flags: 'ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT' or
-- 'ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT' in
-- /VmaAllocationCreateInfo::flags/.
--
-- It can be used only with functions that let the library know
-- @VkBufferCreateInfo@ or @VkImageCreateInfo@, e.g. 'createBuffer',
-- 'createImage', 'findMemoryTypeIndexForBufferInfo',
-- 'findMemoryTypeIndexForImageInfo' and not with generic memory allocation
-- functions.
pattern $bMEMORY_USAGE_AUTO :: MemoryUsage
$mMEMORY_USAGE_AUTO :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_AUTO                 = MemoryUsage 7
-- | Selects best memory type automatically with preference for GPU (device)
-- memory.
--
-- When using this flag, if you want to map the allocation (using
-- 'mapMemory' or 'ALLOCATION_CREATE_MAPPED_BIT'), you must pass one of the
-- flags: 'ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT' or
-- 'ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT' in
-- /VmaAllocationCreateInfo::flags/.
--
-- It can be used only with functions that let the library know
-- @VkBufferCreateInfo@ or @VkImageCreateInfo@, e.g. 'createBuffer',
-- 'createImage', 'findMemoryTypeIndexForBufferInfo',
-- 'findMemoryTypeIndexForImageInfo' and not with generic memory allocation
-- functions.
pattern $bMEMORY_USAGE_AUTO_PREFER_DEVICE :: MemoryUsage
$mMEMORY_USAGE_AUTO_PREFER_DEVICE :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_AUTO_PREFER_DEVICE   = MemoryUsage 8
-- | Selects best memory type automatically with preference for CPU (host)
-- memory.
--
-- When using this flag, if you want to map the allocation (using
-- 'mapMemory' or 'ALLOCATION_CREATE_MAPPED_BIT'), you must pass one of the
-- flags: 'ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT' or
-- 'ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT' in
-- /VmaAllocationCreateInfo::flags/.
--
-- It can be used only with functions that let the library know
-- @VkBufferCreateInfo@ or @VkImageCreateInfo@, e.g. 'createBuffer',
-- 'createImage', 'findMemoryTypeIndexForBufferInfo',
-- 'findMemoryTypeIndexForImageInfo' and not with generic memory allocation
-- functions.
pattern $bMEMORY_USAGE_AUTO_PREFER_HOST :: MemoryUsage
$mMEMORY_USAGE_AUTO_PREFER_HOST :: forall r. MemoryUsage -> (Void# -> r) -> (Void# -> r) -> r
MEMORY_USAGE_AUTO_PREFER_HOST     = MemoryUsage 9
{-# complete MEMORY_USAGE_UNKNOWN,
             MEMORY_USAGE_GPU_ONLY,
             MEMORY_USAGE_CPU_ONLY,
             MEMORY_USAGE_CPU_TO_GPU,
             MEMORY_USAGE_GPU_TO_CPU,
             MEMORY_USAGE_CPU_COPY,
             MEMORY_USAGE_GPU_LAZILY_ALLOCATED,
             MEMORY_USAGE_AUTO,
             MEMORY_USAGE_AUTO_PREFER_DEVICE,
             MEMORY_USAGE_AUTO_PREFER_HOST :: MemoryUsage #-}

conNameMemoryUsage :: String
conNameMemoryUsage :: String
conNameMemoryUsage = String
"MemoryUsage"

enumPrefixMemoryUsage :: String
enumPrefixMemoryUsage :: String
enumPrefixMemoryUsage = String
"MEMORY_USAGE_"

showTableMemoryUsage :: [(MemoryUsage, String)]
showTableMemoryUsage :: [(MemoryUsage, String)]
showTableMemoryUsage =
  [ (MemoryUsage
MEMORY_USAGE_UNKNOWN             , String
"UNKNOWN")
  , (MemoryUsage
MEMORY_USAGE_GPU_ONLY            , String
"GPU_ONLY")
  , (MemoryUsage
MEMORY_USAGE_CPU_ONLY            , String
"CPU_ONLY")
  , (MemoryUsage
MEMORY_USAGE_CPU_TO_GPU          , String
"CPU_TO_GPU")
  , (MemoryUsage
MEMORY_USAGE_GPU_TO_CPU          , String
"GPU_TO_CPU")
  , (MemoryUsage
MEMORY_USAGE_CPU_COPY            , String
"CPU_COPY")
  , (MemoryUsage
MEMORY_USAGE_GPU_LAZILY_ALLOCATED, String
"GPU_LAZILY_ALLOCATED")
  , (MemoryUsage
MEMORY_USAGE_AUTO                , String
"AUTO")
  , (MemoryUsage
MEMORY_USAGE_AUTO_PREFER_DEVICE  , String
"AUTO_PREFER_DEVICE")
  , (MemoryUsage
MEMORY_USAGE_AUTO_PREFER_HOST    , String
"AUTO_PREFER_HOST")
  ]

instance Show MemoryUsage where
  showsPrec :: Int -> MemoryUsage -> ShowS
showsPrec =
    String
-> [(MemoryUsage, String)]
-> String
-> (MemoryUsage -> Int32)
-> (Int32 -> ShowS)
-> Int
-> MemoryUsage
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixMemoryUsage [(MemoryUsage, String)]
showTableMemoryUsage String
conNameMemoryUsage (\(MemoryUsage Int32
x) -> Int32
x) (Int -> Int32 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11)

instance Read MemoryUsage where
  readPrec :: ReadPrec MemoryUsage
readPrec = String
-> [(MemoryUsage, String)]
-> String
-> (Int32 -> MemoryUsage)
-> ReadPrec MemoryUsage
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixMemoryUsage [(MemoryUsage, String)]
showTableMemoryUsage String
conNameMemoryUsage Int32 -> MemoryUsage
MemoryUsage


type AllocationCreateFlags = AllocationCreateFlagBits

-- | Flags to be passed as /VmaAllocationCreateInfo::flags/.
newtype AllocationCreateFlagBits = AllocationCreateFlagBits Flags
  deriving newtype (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
(AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> Eq AllocationCreateFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c/= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
== :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c== :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
Eq, Eq AllocationCreateFlagBits
Eq AllocationCreateFlagBits
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> Ordering)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> Ord AllocationCreateFlagBits
AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
AllocationCreateFlagBits -> AllocationCreateFlagBits -> Ordering
AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$cmin :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
max :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$cmax :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
>= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c>= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
> :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c> :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
<= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c<= :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
< :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
$c< :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Bool
compare :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Ordering
$ccompare :: AllocationCreateFlagBits -> AllocationCreateFlagBits -> Ordering
$cp1Ord :: Eq AllocationCreateFlagBits
Ord, Ptr b -> Int -> IO AllocationCreateFlagBits
Ptr b -> Int -> AllocationCreateFlagBits -> IO ()
Ptr AllocationCreateFlagBits -> IO AllocationCreateFlagBits
Ptr AllocationCreateFlagBits -> Int -> IO AllocationCreateFlagBits
Ptr AllocationCreateFlagBits
-> Int -> AllocationCreateFlagBits -> IO ()
Ptr AllocationCreateFlagBits -> AllocationCreateFlagBits -> IO ()
AllocationCreateFlagBits -> Int
(AllocationCreateFlagBits -> Int)
-> (AllocationCreateFlagBits -> Int)
-> (Ptr AllocationCreateFlagBits
    -> Int -> IO AllocationCreateFlagBits)
-> (Ptr AllocationCreateFlagBits
    -> Int -> AllocationCreateFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO AllocationCreateFlagBits)
-> (forall b. Ptr b -> Int -> AllocationCreateFlagBits -> IO ())
-> (Ptr AllocationCreateFlagBits -> IO AllocationCreateFlagBits)
-> (Ptr AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> IO ())
-> Storable AllocationCreateFlagBits
forall b. Ptr b -> Int -> IO AllocationCreateFlagBits
forall b. Ptr b -> Int -> AllocationCreateFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr AllocationCreateFlagBits -> AllocationCreateFlagBits -> IO ()
$cpoke :: Ptr AllocationCreateFlagBits -> AllocationCreateFlagBits -> IO ()
peek :: Ptr AllocationCreateFlagBits -> IO AllocationCreateFlagBits
$cpeek :: Ptr AllocationCreateFlagBits -> IO AllocationCreateFlagBits
pokeByteOff :: Ptr b -> Int -> AllocationCreateFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> AllocationCreateFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO AllocationCreateFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO AllocationCreateFlagBits
pokeElemOff :: Ptr AllocationCreateFlagBits
-> Int -> AllocationCreateFlagBits -> IO ()
$cpokeElemOff :: Ptr AllocationCreateFlagBits
-> Int -> AllocationCreateFlagBits -> IO ()
peekElemOff :: Ptr AllocationCreateFlagBits -> Int -> IO AllocationCreateFlagBits
$cpeekElemOff :: Ptr AllocationCreateFlagBits -> Int -> IO AllocationCreateFlagBits
alignment :: AllocationCreateFlagBits -> Int
$calignment :: AllocationCreateFlagBits -> Int
sizeOf :: AllocationCreateFlagBits -> Int
$csizeOf :: AllocationCreateFlagBits -> Int
Storable, AllocationCreateFlagBits
AllocationCreateFlagBits -> Zero AllocationCreateFlagBits
forall a. a -> Zero a
zero :: AllocationCreateFlagBits
$czero :: AllocationCreateFlagBits
Zero, Eq AllocationCreateFlagBits
AllocationCreateFlagBits
Eq AllocationCreateFlagBits
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits
    -> AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> AllocationCreateFlagBits
-> (Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> Bool)
-> (AllocationCreateFlagBits -> Maybe Int)
-> (AllocationCreateFlagBits -> Int)
-> (AllocationCreateFlagBits -> Bool)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits)
-> (AllocationCreateFlagBits -> Int)
-> Bits AllocationCreateFlagBits
Int -> AllocationCreateFlagBits
AllocationCreateFlagBits -> Bool
AllocationCreateFlagBits -> Int
AllocationCreateFlagBits -> Maybe Int
AllocationCreateFlagBits -> AllocationCreateFlagBits
AllocationCreateFlagBits -> Int -> Bool
AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: AllocationCreateFlagBits -> Int
$cpopCount :: AllocationCreateFlagBits -> Int
rotateR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$crotateR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
rotateL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$crotateL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
unsafeShiftR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cunsafeShiftR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
shiftR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cshiftR :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
unsafeShiftL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cunsafeShiftL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
shiftL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cshiftL :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
isSigned :: AllocationCreateFlagBits -> Bool
$cisSigned :: AllocationCreateFlagBits -> Bool
bitSize :: AllocationCreateFlagBits -> Int
$cbitSize :: AllocationCreateFlagBits -> Int
bitSizeMaybe :: AllocationCreateFlagBits -> Maybe Int
$cbitSizeMaybe :: AllocationCreateFlagBits -> Maybe Int
testBit :: AllocationCreateFlagBits -> Int -> Bool
$ctestBit :: AllocationCreateFlagBits -> Int -> Bool
complementBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$ccomplementBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
clearBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cclearBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
setBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$csetBit :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
bit :: Int -> AllocationCreateFlagBits
$cbit :: Int -> AllocationCreateFlagBits
zeroBits :: AllocationCreateFlagBits
$czeroBits :: AllocationCreateFlagBits
rotate :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$crotate :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
shift :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
$cshift :: AllocationCreateFlagBits -> Int -> AllocationCreateFlagBits
complement :: AllocationCreateFlagBits -> AllocationCreateFlagBits
$ccomplement :: AllocationCreateFlagBits -> AllocationCreateFlagBits
xor :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$cxor :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
.|. :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$c.|. :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
.&. :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$c.&. :: AllocationCreateFlagBits
-> AllocationCreateFlagBits -> AllocationCreateFlagBits
$cp1Bits :: Eq AllocationCreateFlagBits
Bits, Bits AllocationCreateFlagBits
Bits AllocationCreateFlagBits
-> (AllocationCreateFlagBits -> Int)
-> (AllocationCreateFlagBits -> Int)
-> (AllocationCreateFlagBits -> Int)
-> FiniteBits AllocationCreateFlagBits
AllocationCreateFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: AllocationCreateFlagBits -> Int
$ccountTrailingZeros :: AllocationCreateFlagBits -> Int
countLeadingZeros :: AllocationCreateFlagBits -> Int
$ccountLeadingZeros :: AllocationCreateFlagBits -> Int
finiteBitSize :: AllocationCreateFlagBits -> Int
$cfiniteBitSize :: AllocationCreateFlagBits -> Int
$cp1FiniteBits :: Bits AllocationCreateFlagBits
FiniteBits)

-- | 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 $bALLOCATION_CREATE_DEDICATED_MEMORY_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_DEDICATED_MEMORY_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_DEDICATED_MEMORY_BIT                   = AllocationCreateFlagBits 0x00000001
-- | Set this flag to only try to allocate from existing @VkDeviceMemory@
-- blocks and never create new such block.
--
-- If new allocation cannot be placed in any of the existing blocks,
-- allocation fails with @VK_ERROR_OUT_OF_DEVICE_MEMORY@ error.
--
-- You should not use 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT' and
-- 'ALLOCATION_CREATE_NEVER_ALLOCATE_BIT' at the same time. It makes no
-- sense.
pattern $bALLOCATION_CREATE_NEVER_ALLOCATE_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_NEVER_ALLOCATE_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_NEVER_ALLOCATE_BIT                     = AllocationCreateFlagBits 0x00000002
-- | 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 @HOST_VISIBLE@. This flag is then ignored and memory is not
-- mapped. This is useful if you need an allocation that is efficient to
-- use on GPU (@DEVICE_LOCAL@) and still want to map it directly if
-- possible on platforms that support it (e.g. Intel GPU).
pattern $bALLOCATION_CREATE_MAPPED_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_MAPPED_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_MAPPED_BIT                             = AllocationCreateFlagBits 0x00000004
-- | /Deprecated/
--
-- Preserved for backward compatibility. Consider using 'setAllocationName'
-- instead.
--
-- 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 @pName@. The
-- string is automatically freed together with the allocation. It is also
-- used in 'buildStatsString'.
pattern $bALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT              = AllocationCreateFlagBits 0x00000020
-- | Allocation will be created from upper stack in a double stack pool.
--
-- This flag is only allowed for custom pools created with
-- 'POOL_CREATE_LINEAR_ALGORITHM_BIT' flag.
pattern $bALLOCATION_CREATE_UPPER_ADDRESS_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_UPPER_ADDRESS_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_UPPER_ADDRESS_BIT                      = AllocationCreateFlagBits 0x00000040
-- | 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: 'createBuffer', 'createImage'. Otherwise
-- it is ignored.
--
-- If you want to make sure the new buffer\/image is not tied to the new
-- memory allocation through @VkMemoryDedicatedAllocateInfoKHR@ structure
-- in case the allocation ends up in its own memory block, use also flag
-- 'ALLOCATION_CREATE_CAN_ALIAS_BIT'.
pattern $bALLOCATION_CREATE_DONT_BIND_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_DONT_BIND_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_DONT_BIND_BIT                          = AllocationCreateFlagBits 0x00000080
-- | Create allocation only if additional device memory required for it, if
-- any, won\'t exceed memory budget. Otherwise return
-- @VK_ERROR_OUT_OF_DEVICE_MEMORY@.
pattern $bALLOCATION_CREATE_WITHIN_BUDGET_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_WITHIN_BUDGET_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_WITHIN_BUDGET_BIT                      = AllocationCreateFlagBits 0x00000100
-- | Set this flag if the allocated memory will have aliasing resources.
--
-- Usage of this flag prevents supplying @VkMemoryDedicatedAllocateInfoKHR@
-- when 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT' is specified. Otherwise
-- created dedicated memory will not be suitable for aliasing resources,
-- resulting in Vulkan Validation Layer errors.
pattern $bALLOCATION_CREATE_CAN_ALIAS_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_CAN_ALIAS_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_CAN_ALIAS_BIT                          = AllocationCreateFlagBits 0x00000200
-- | Requests possibility to map the allocation (using 'mapMemory' or
-- 'ALLOCATION_CREATE_MAPPED_BIT').
--
-- -   If you use 'MEMORY_USAGE_AUTO' or other @VMA_MEMORY_USAGE_AUTO*@
--     value, you must use this flag to be able to map the allocation.
--     Otherwise, mapping is incorrect.
--
-- -   If you use other value of 'MemoryUsage', this flag is ignored and
--     mapping is always possible in memory types that are @HOST_VISIBLE@.
--     This includes allocations created in /Custom memory pools/.
--
-- Declares that mapped memory will only be written sequentially, e.g.
-- using @memcpy()@ or a loop writing number-by-number, never read or
-- accessed randomly, so a memory type can be selected that is uncached and
-- write-combined.
--
-- Warning
--
-- Violating this declaration may work correctly, but will likely be very
-- slow. Watch out for implicit reads introduced by doing e.g.
-- @pMappedData[i] += x;@ Better prepare your data in a local variable and
-- @memcpy()@ it to the mapped pointer all at once.
pattern $bALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT       = AllocationCreateFlagBits 0x00000400
-- | Requests possibility to map the allocation (using 'mapMemory' or
-- 'ALLOCATION_CREATE_MAPPED_BIT').
--
-- -   If you use 'MEMORY_USAGE_AUTO' or other @VMA_MEMORY_USAGE_AUTO*@
--     value, you must use this flag to be able to map the allocation.
--     Otherwise, mapping is incorrect.
--
-- -   If you use other value of 'MemoryUsage', this flag is ignored and
--     mapping is always possible in memory types that are @HOST_VISIBLE@.
--     This includes allocations created in /Custom memory pools/.
--
-- Declares that mapped memory can be read, written, and accessed in random
-- order, so a @HOST_CACHED@ memory type is required.
pattern $bALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT                 = AllocationCreateFlagBits 0x00000800
-- | Together with 'ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT' or
-- 'ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT', it says that despite request
-- for host access, a not-@HOST_VISIBLE@ memory type can be selected if it
-- may improve performance.
--
-- By using this flag, you declare that you will check if the allocation
-- ended up in a @HOST_VISIBLE@ memory type (e.g. using
-- 'getAllocationMemoryProperties') and if not, you will create some
-- \"staging\" buffer and issue an explicit transfer to write\/read your
-- data. To prepare for this possibility, don\'t forget to add appropriate
-- flags like @VK_BUFFER_USAGE_TRANSFER_DST_BIT@,
-- @VK_BUFFER_USAGE_TRANSFER_SRC_BIT@ to the parameters of created buffer
-- or image.
pattern $bALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT = AllocationCreateFlagBits 0x00001000
-- | 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 $bALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT                = AllocationCreateFlagBits 0x00010000
-- | 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 $bALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT                  = AllocationCreateFlagBits 0x00020000
-- | 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 $bALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT                = AllocationCreateFlagBits 0x00040000
-- | Alias to 'ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT'.
pattern $bALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT                  = AllocationCreateFlagBits 0x00010000
-- | Alias to 'ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT'.
pattern $bALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT                 = AllocationCreateFlagBits 0x00020000
-- | A bit mask to extract only @STRATEGY@ bits from entire set of flags.
pattern $bALLOCATION_CREATE_STRATEGY_MASK :: AllocationCreateFlagBits
$mALLOCATION_CREATE_STRATEGY_MASK :: forall r.
AllocationCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
ALLOCATION_CREATE_STRATEGY_MASK                          = AllocationCreateFlagBits 0x00070000

conNameAllocationCreateFlagBits :: String
conNameAllocationCreateFlagBits :: String
conNameAllocationCreateFlagBits = String
"AllocationCreateFlagBits"

enumPrefixAllocationCreateFlagBits :: String
enumPrefixAllocationCreateFlagBits :: String
enumPrefixAllocationCreateFlagBits = String
"ALLOCATION_CREATE_"

showTableAllocationCreateFlagBits :: [(AllocationCreateFlagBits, String)]
showTableAllocationCreateFlagBits :: [(AllocationCreateFlagBits, String)]
showTableAllocationCreateFlagBits =
  [ (AllocationCreateFlagBits
ALLOCATION_CREATE_DEDICATED_MEMORY_BIT                  , String
"DEDICATED_MEMORY_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_NEVER_ALLOCATE_BIT                    , String
"NEVER_ALLOCATE_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_MAPPED_BIT                            , String
"MAPPED_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT             , String
"USER_DATA_COPY_STRING_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_UPPER_ADDRESS_BIT                     , String
"UPPER_ADDRESS_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_DONT_BIND_BIT                         , String
"DONT_BIND_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_WITHIN_BUDGET_BIT                     , String
"WITHIN_BUDGET_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_CAN_ALIAS_BIT                         , String
"CAN_ALIAS_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT      , String
"HOST_ACCESS_SEQUENTIAL_WRITE_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT                , String
"HOST_ACCESS_RANDOM_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT, String
"HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT               , String
"STRATEGY_MIN_MEMORY_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT                 , String
"STRATEGY_MIN_TIME_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT               , String
"STRATEGY_MIN_OFFSET_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT                 , String
"STRATEGY_BEST_FIT_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT                , String
"STRATEGY_FIRST_FIT_BIT")
  , (AllocationCreateFlagBits
ALLOCATION_CREATE_STRATEGY_MASK                         , String
"STRATEGY_MASK")
  ]

instance Show AllocationCreateFlagBits where
  showsPrec :: Int -> AllocationCreateFlagBits -> ShowS
showsPrec = String
-> [(AllocationCreateFlagBits, String)]
-> String
-> (AllocationCreateFlagBits -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> AllocationCreateFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixAllocationCreateFlagBits
                            [(AllocationCreateFlagBits, String)]
showTableAllocationCreateFlagBits
                            String
conNameAllocationCreateFlagBits
                            (\(AllocationCreateFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read AllocationCreateFlagBits where
  readPrec :: ReadPrec AllocationCreateFlagBits
readPrec = String
-> [(AllocationCreateFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32) -> AllocationCreateFlagBits)
-> ReadPrec AllocationCreateFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixAllocationCreateFlagBits
                          [(AllocationCreateFlagBits, String)]
showTableAllocationCreateFlagBits
                          String
conNameAllocationCreateFlagBits
                          ("memoryTypeIndex" ::: Word32) -> AllocationCreateFlagBits
AllocationCreateFlagBits


type PoolCreateFlags = PoolCreateFlagBits

-- | Flags to be passed as /VmaPoolCreateInfo::flags/.
newtype PoolCreateFlagBits = PoolCreateFlagBits Flags
  deriving newtype (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
(PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> Eq PoolCreateFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c/= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
== :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c== :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
Eq, Eq PoolCreateFlagBits
Eq PoolCreateFlagBits
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Ordering)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits)
-> Ord PoolCreateFlagBits
PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
PoolCreateFlagBits -> PoolCreateFlagBits -> Ordering
PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$cmin :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
max :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$cmax :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
>= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c>= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
> :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c> :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
<= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c<= :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
< :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
$c< :: PoolCreateFlagBits -> PoolCreateFlagBits -> Bool
compare :: PoolCreateFlagBits -> PoolCreateFlagBits -> Ordering
$ccompare :: PoolCreateFlagBits -> PoolCreateFlagBits -> Ordering
$cp1Ord :: Eq PoolCreateFlagBits
Ord, Ptr b -> Int -> IO PoolCreateFlagBits
Ptr b -> Int -> PoolCreateFlagBits -> IO ()
Ptr PoolCreateFlagBits -> IO PoolCreateFlagBits
Ptr PoolCreateFlagBits -> Int -> IO PoolCreateFlagBits
Ptr PoolCreateFlagBits -> Int -> PoolCreateFlagBits -> IO ()
Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ()
PoolCreateFlagBits -> Int
(PoolCreateFlagBits -> Int)
-> (PoolCreateFlagBits -> Int)
-> (Ptr PoolCreateFlagBits -> Int -> IO PoolCreateFlagBits)
-> (Ptr PoolCreateFlagBits -> Int -> PoolCreateFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO PoolCreateFlagBits)
-> (forall b. Ptr b -> Int -> PoolCreateFlagBits -> IO ())
-> (Ptr PoolCreateFlagBits -> IO PoolCreateFlagBits)
-> (Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ())
-> Storable PoolCreateFlagBits
forall b. Ptr b -> Int -> IO PoolCreateFlagBits
forall b. Ptr b -> Int -> PoolCreateFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ()
$cpoke :: Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ()
peek :: Ptr PoolCreateFlagBits -> IO PoolCreateFlagBits
$cpeek :: Ptr PoolCreateFlagBits -> IO PoolCreateFlagBits
pokeByteOff :: Ptr b -> Int -> PoolCreateFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> PoolCreateFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO PoolCreateFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO PoolCreateFlagBits
pokeElemOff :: Ptr PoolCreateFlagBits -> Int -> PoolCreateFlagBits -> IO ()
$cpokeElemOff :: Ptr PoolCreateFlagBits -> Int -> PoolCreateFlagBits -> IO ()
peekElemOff :: Ptr PoolCreateFlagBits -> Int -> IO PoolCreateFlagBits
$cpeekElemOff :: Ptr PoolCreateFlagBits -> Int -> IO PoolCreateFlagBits
alignment :: PoolCreateFlagBits -> Int
$calignment :: PoolCreateFlagBits -> Int
sizeOf :: PoolCreateFlagBits -> Int
$csizeOf :: PoolCreateFlagBits -> Int
Storable, PoolCreateFlagBits
PoolCreateFlagBits -> Zero PoolCreateFlagBits
forall a. a -> Zero a
zero :: PoolCreateFlagBits
$czero :: PoolCreateFlagBits
Zero, Eq PoolCreateFlagBits
PoolCreateFlagBits
Eq PoolCreateFlagBits
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> PoolCreateFlagBits
-> (Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> Bool)
-> (PoolCreateFlagBits -> Maybe Int)
-> (PoolCreateFlagBits -> Int)
-> (PoolCreateFlagBits -> Bool)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int -> PoolCreateFlagBits)
-> (PoolCreateFlagBits -> Int)
-> Bits PoolCreateFlagBits
Int -> PoolCreateFlagBits
PoolCreateFlagBits -> Bool
PoolCreateFlagBits -> Int
PoolCreateFlagBits -> Maybe Int
PoolCreateFlagBits -> PoolCreateFlagBits
PoolCreateFlagBits -> Int -> Bool
PoolCreateFlagBits -> Int -> PoolCreateFlagBits
PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: PoolCreateFlagBits -> Int
$cpopCount :: PoolCreateFlagBits -> Int
rotateR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$crotateR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
rotateL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$crotateL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
unsafeShiftR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cunsafeShiftR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
shiftR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cshiftR :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
unsafeShiftL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cunsafeShiftL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
shiftL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cshiftL :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
isSigned :: PoolCreateFlagBits -> Bool
$cisSigned :: PoolCreateFlagBits -> Bool
bitSize :: PoolCreateFlagBits -> Int
$cbitSize :: PoolCreateFlagBits -> Int
bitSizeMaybe :: PoolCreateFlagBits -> Maybe Int
$cbitSizeMaybe :: PoolCreateFlagBits -> Maybe Int
testBit :: PoolCreateFlagBits -> Int -> Bool
$ctestBit :: PoolCreateFlagBits -> Int -> Bool
complementBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$ccomplementBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
clearBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cclearBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
setBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$csetBit :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
bit :: Int -> PoolCreateFlagBits
$cbit :: Int -> PoolCreateFlagBits
zeroBits :: PoolCreateFlagBits
$czeroBits :: PoolCreateFlagBits
rotate :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$crotate :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
shift :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
$cshift :: PoolCreateFlagBits -> Int -> PoolCreateFlagBits
complement :: PoolCreateFlagBits -> PoolCreateFlagBits
$ccomplement :: PoolCreateFlagBits -> PoolCreateFlagBits
xor :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$cxor :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
.|. :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$c.|. :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
.&. :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$c.&. :: PoolCreateFlagBits -> PoolCreateFlagBits -> PoolCreateFlagBits
$cp1Bits :: Eq PoolCreateFlagBits
Bits, Bits PoolCreateFlagBits
Bits PoolCreateFlagBits
-> (PoolCreateFlagBits -> Int)
-> (PoolCreateFlagBits -> Int)
-> (PoolCreateFlagBits -> Int)
-> FiniteBits PoolCreateFlagBits
PoolCreateFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: PoolCreateFlagBits -> Int
$ccountTrailingZeros :: PoolCreateFlagBits -> Int
countLeadingZeros :: PoolCreateFlagBits -> Int
$ccountLeadingZeros :: PoolCreateFlagBits -> Int
finiteBitSize :: PoolCreateFlagBits -> Int
$cfiniteBitSize :: PoolCreateFlagBits -> Int
$cp1FiniteBits :: Bits PoolCreateFlagBits
FiniteBits)

-- | 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 'createBuffer', 'createImage',
-- 'allocateMemoryForBuffer', then you don\'t need to use it because
-- allocator knows exact type of your allocations so it can handle
-- Buffer-Image Granularity in the optimal way.
--
-- If you also allocate using 'allocateMemoryForImage' or 'allocateMemory',
-- exact type of such allocations is not known, so allocator must be
-- conservative in handling Buffer-Image Granularity, which can lead to
-- suboptimal allocation (wasted memory). In that case, if you can make
-- sure you always allocate only buffers and linear images or only optimal
-- images out of this pool, use this flag to make allocator disregard
-- Buffer-Image Granularity and so make allocations faster and more
-- optimal.
pattern $bPOOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT :: PoolCreateFlagBits
$mPOOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT :: forall r. PoolCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT = PoolCreateFlagBits 0x00000002
-- | 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 $bPOOL_CREATE_LINEAR_ALGORITHM_BIT :: PoolCreateFlagBits
$mPOOL_CREATE_LINEAR_ALGORITHM_BIT :: forall r. PoolCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
POOL_CREATE_LINEAR_ALGORITHM_BIT                = PoolCreateFlagBits 0x00000004
-- | Bit mask to extract only @ALGORITHM@ bits from entire set of flags.
pattern $bPOOL_CREATE_ALGORITHM_MASK :: PoolCreateFlagBits
$mPOOL_CREATE_ALGORITHM_MASK :: forall r. PoolCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
POOL_CREATE_ALGORITHM_MASK                      = PoolCreateFlagBits 0x00000004

conNamePoolCreateFlagBits :: String
conNamePoolCreateFlagBits :: String
conNamePoolCreateFlagBits = String
"PoolCreateFlagBits"

enumPrefixPoolCreateFlagBits :: String
enumPrefixPoolCreateFlagBits :: String
enumPrefixPoolCreateFlagBits = String
"POOL_CREATE_"

showTablePoolCreateFlagBits :: [(PoolCreateFlagBits, String)]
showTablePoolCreateFlagBits :: [(PoolCreateFlagBits, String)]
showTablePoolCreateFlagBits =
  [ (PoolCreateFlagBits
POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT, String
"IGNORE_BUFFER_IMAGE_GRANULARITY_BIT")
  , (PoolCreateFlagBits
POOL_CREATE_LINEAR_ALGORITHM_BIT               , String
"LINEAR_ALGORITHM_BIT")
  , (PoolCreateFlagBits
POOL_CREATE_ALGORITHM_MASK                     , String
"ALGORITHM_MASK")
  ]

instance Show PoolCreateFlagBits where
  showsPrec :: Int -> PoolCreateFlagBits -> ShowS
showsPrec = String
-> [(PoolCreateFlagBits, String)]
-> String
-> (PoolCreateFlagBits -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> PoolCreateFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixPoolCreateFlagBits
                            [(PoolCreateFlagBits, String)]
showTablePoolCreateFlagBits
                            String
conNamePoolCreateFlagBits
                            (\(PoolCreateFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read PoolCreateFlagBits where
  readPrec :: ReadPrec PoolCreateFlagBits
readPrec =
    String
-> [(PoolCreateFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32) -> PoolCreateFlagBits)
-> ReadPrec PoolCreateFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixPoolCreateFlagBits [(PoolCreateFlagBits, String)]
showTablePoolCreateFlagBits String
conNamePoolCreateFlagBits ("memoryTypeIndex" ::: Word32) -> PoolCreateFlagBits
PoolCreateFlagBits


type DefragmentationFlags = DefragmentationFlagBits

-- | Flags to be passed as /VmaDefragmentationInfo::flags/.
newtype DefragmentationFlagBits = DefragmentationFlagBits Flags
  deriving newtype (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
(DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> Eq DefragmentationFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c/= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
== :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c== :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
Eq, Eq DefragmentationFlagBits
Eq DefragmentationFlagBits
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Ordering)
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits -> DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits
    -> DefragmentationFlagBits -> DefragmentationFlagBits)
-> (DefragmentationFlagBits
    -> DefragmentationFlagBits -> DefragmentationFlagBits)
-> Ord DefragmentationFlagBits
DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
DefragmentationFlagBits -> DefragmentationFlagBits -> Ordering
DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$cmin :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
max :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$cmax :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
>= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c>= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
> :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c> :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
<= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c<= :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
< :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
$c< :: DefragmentationFlagBits -> DefragmentationFlagBits -> Bool
compare :: DefragmentationFlagBits -> DefragmentationFlagBits -> Ordering
$ccompare :: DefragmentationFlagBits -> DefragmentationFlagBits -> Ordering
$cp1Ord :: Eq DefragmentationFlagBits
Ord, Ptr b -> Int -> IO DefragmentationFlagBits
Ptr b -> Int -> DefragmentationFlagBits -> IO ()
Ptr DefragmentationFlagBits -> IO DefragmentationFlagBits
Ptr DefragmentationFlagBits -> Int -> IO DefragmentationFlagBits
Ptr DefragmentationFlagBits
-> Int -> DefragmentationFlagBits -> IO ()
Ptr DefragmentationFlagBits -> DefragmentationFlagBits -> IO ()
DefragmentationFlagBits -> Int
(DefragmentationFlagBits -> Int)
-> (DefragmentationFlagBits -> Int)
-> (Ptr DefragmentationFlagBits
    -> Int -> IO DefragmentationFlagBits)
-> (Ptr DefragmentationFlagBits
    -> Int -> DefragmentationFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO DefragmentationFlagBits)
-> (forall b. Ptr b -> Int -> DefragmentationFlagBits -> IO ())
-> (Ptr DefragmentationFlagBits -> IO DefragmentationFlagBits)
-> (Ptr DefragmentationFlagBits
    -> DefragmentationFlagBits -> IO ())
-> Storable DefragmentationFlagBits
forall b. Ptr b -> Int -> IO DefragmentationFlagBits
forall b. Ptr b -> Int -> DefragmentationFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr DefragmentationFlagBits -> DefragmentationFlagBits -> IO ()
$cpoke :: Ptr DefragmentationFlagBits -> DefragmentationFlagBits -> IO ()
peek :: Ptr DefragmentationFlagBits -> IO DefragmentationFlagBits
$cpeek :: Ptr DefragmentationFlagBits -> IO DefragmentationFlagBits
pokeByteOff :: Ptr b -> Int -> DefragmentationFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> DefragmentationFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO DefragmentationFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO DefragmentationFlagBits
pokeElemOff :: Ptr DefragmentationFlagBits
-> Int -> DefragmentationFlagBits -> IO ()
$cpokeElemOff :: Ptr DefragmentationFlagBits
-> Int -> DefragmentationFlagBits -> IO ()
peekElemOff :: Ptr DefragmentationFlagBits -> Int -> IO DefragmentationFlagBits
$cpeekElemOff :: Ptr DefragmentationFlagBits -> Int -> IO DefragmentationFlagBits
alignment :: DefragmentationFlagBits -> Int
$calignment :: DefragmentationFlagBits -> Int
sizeOf :: DefragmentationFlagBits -> Int
$csizeOf :: DefragmentationFlagBits -> Int
Storable, DefragmentationFlagBits
DefragmentationFlagBits -> Zero DefragmentationFlagBits
forall a. a -> Zero a
zero :: DefragmentationFlagBits
$czero :: DefragmentationFlagBits
Zero, Eq DefragmentationFlagBits
DefragmentationFlagBits
Eq DefragmentationFlagBits
-> (DefragmentationFlagBits
    -> DefragmentationFlagBits -> DefragmentationFlagBits)
-> (DefragmentationFlagBits
    -> DefragmentationFlagBits -> DefragmentationFlagBits)
-> (DefragmentationFlagBits
    -> DefragmentationFlagBits -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> DefragmentationFlagBits
-> (Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> Bool)
-> (DefragmentationFlagBits -> Maybe Int)
-> (DefragmentationFlagBits -> Int)
-> (DefragmentationFlagBits -> Bool)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int -> DefragmentationFlagBits)
-> (DefragmentationFlagBits -> Int)
-> Bits DefragmentationFlagBits
Int -> DefragmentationFlagBits
DefragmentationFlagBits -> Bool
DefragmentationFlagBits -> Int
DefragmentationFlagBits -> Maybe Int
DefragmentationFlagBits -> DefragmentationFlagBits
DefragmentationFlagBits -> Int -> Bool
DefragmentationFlagBits -> Int -> DefragmentationFlagBits
DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: DefragmentationFlagBits -> Int
$cpopCount :: DefragmentationFlagBits -> Int
rotateR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$crotateR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
rotateL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$crotateL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
unsafeShiftR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cunsafeShiftR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
shiftR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cshiftR :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
unsafeShiftL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cunsafeShiftL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
shiftL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cshiftL :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
isSigned :: DefragmentationFlagBits -> Bool
$cisSigned :: DefragmentationFlagBits -> Bool
bitSize :: DefragmentationFlagBits -> Int
$cbitSize :: DefragmentationFlagBits -> Int
bitSizeMaybe :: DefragmentationFlagBits -> Maybe Int
$cbitSizeMaybe :: DefragmentationFlagBits -> Maybe Int
testBit :: DefragmentationFlagBits -> Int -> Bool
$ctestBit :: DefragmentationFlagBits -> Int -> Bool
complementBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$ccomplementBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
clearBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cclearBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
setBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$csetBit :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
bit :: Int -> DefragmentationFlagBits
$cbit :: Int -> DefragmentationFlagBits
zeroBits :: DefragmentationFlagBits
$czeroBits :: DefragmentationFlagBits
rotate :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$crotate :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
shift :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
$cshift :: DefragmentationFlagBits -> Int -> DefragmentationFlagBits
complement :: DefragmentationFlagBits -> DefragmentationFlagBits
$ccomplement :: DefragmentationFlagBits -> DefragmentationFlagBits
xor :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$cxor :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
.|. :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$c.|. :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
.&. :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$c.&. :: DefragmentationFlagBits
-> DefragmentationFlagBits -> DefragmentationFlagBits
$cp1Bits :: Eq DefragmentationFlagBits
Bits, Bits DefragmentationFlagBits
Bits DefragmentationFlagBits
-> (DefragmentationFlagBits -> Int)
-> (DefragmentationFlagBits -> Int)
-> (DefragmentationFlagBits -> Int)
-> FiniteBits DefragmentationFlagBits
DefragmentationFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: DefragmentationFlagBits -> Int
$ccountTrailingZeros :: DefragmentationFlagBits -> Int
countLeadingZeros :: DefragmentationFlagBits -> Int
$ccountLeadingZeros :: DefragmentationFlagBits -> Int
finiteBitSize :: DefragmentationFlagBits -> Int
$cfiniteBitSize :: DefragmentationFlagBits -> Int
$cp1FiniteBits :: Bits DefragmentationFlagBits
FiniteBits)


pattern $bDEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT :: DefragmentationFlagBits
$mDEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT :: forall r.
DefragmentationFlagBits -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT      = DefragmentationFlagBits 0x00000001

pattern $bDEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT :: DefragmentationFlagBits
$mDEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT :: forall r.
DefragmentationFlagBits -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT  = DefragmentationFlagBits 0x00000002

pattern $bDEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT :: DefragmentationFlagBits
$mDEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT :: forall r.
DefragmentationFlagBits -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT      = DefragmentationFlagBits 0x00000004
-- | 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
-- 'DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT'.
pattern $bDEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT :: DefragmentationFlagBits
$mDEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT :: forall r.
DefragmentationFlagBits -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT = DefragmentationFlagBits 0x00000008
-- | A bit mask to extract only @ALGORITHM@ bits from entire set of flags.
pattern $bDEFRAGMENTATION_FLAG_ALGORITHM_MASK :: DefragmentationFlagBits
$mDEFRAGMENTATION_FLAG_ALGORITHM_MASK :: forall r.
DefragmentationFlagBits -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_FLAG_ALGORITHM_MASK          = DefragmentationFlagBits 0x0000000f

conNameDefragmentationFlagBits :: String
conNameDefragmentationFlagBits :: String
conNameDefragmentationFlagBits = String
"DefragmentationFlagBits"

enumPrefixDefragmentationFlagBits :: String
enumPrefixDefragmentationFlagBits :: String
enumPrefixDefragmentationFlagBits = String
"DEFRAGMENTATION_FLAG_ALGORITHM_"

showTableDefragmentationFlagBits :: [(DefragmentationFlagBits, String)]
showTableDefragmentationFlagBits :: [(DefragmentationFlagBits, String)]
showTableDefragmentationFlagBits =
  [ (DefragmentationFlagBits
DEFRAGMENTATION_FLAG_ALGORITHM_FAST_BIT     , String
"FAST_BIT")
  , (DefragmentationFlagBits
DEFRAGMENTATION_FLAG_ALGORITHM_BALANCED_BIT , String
"BALANCED_BIT")
  , (DefragmentationFlagBits
DEFRAGMENTATION_FLAG_ALGORITHM_FULL_BIT     , String
"FULL_BIT")
  , (DefragmentationFlagBits
DEFRAGMENTATION_FLAG_ALGORITHM_EXTENSIVE_BIT, String
"EXTENSIVE_BIT")
  , (DefragmentationFlagBits
DEFRAGMENTATION_FLAG_ALGORITHM_MASK         , String
"MASK")
  ]

instance Show DefragmentationFlagBits where
  showsPrec :: Int -> DefragmentationFlagBits -> ShowS
showsPrec = String
-> [(DefragmentationFlagBits, String)]
-> String
-> (DefragmentationFlagBits -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> DefragmentationFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixDefragmentationFlagBits
                            [(DefragmentationFlagBits, String)]
showTableDefragmentationFlagBits
                            String
conNameDefragmentationFlagBits
                            (\(DefragmentationFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read DefragmentationFlagBits where
  readPrec :: ReadPrec DefragmentationFlagBits
readPrec = String
-> [(DefragmentationFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32) -> DefragmentationFlagBits)
-> ReadPrec DefragmentationFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixDefragmentationFlagBits
                          [(DefragmentationFlagBits, String)]
showTableDefragmentationFlagBits
                          String
conNameDefragmentationFlagBits
                          ("memoryTypeIndex" ::: Word32) -> DefragmentationFlagBits
DefragmentationFlagBits


-- | Operation performed on single defragmentation move. See structure
-- 'DefragmentationMove'.
newtype DefragmentationMoveOperation = DefragmentationMoveOperation Int32
  deriving newtype (DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
(DefragmentationMoveOperation
 -> DefragmentationMoveOperation -> Bool)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Bool)
-> Eq DefragmentationMoveOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c/= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
== :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c== :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
Eq, Eq DefragmentationMoveOperation
Eq DefragmentationMoveOperation
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Ordering)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Bool)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Bool)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Bool)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> Bool)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> DefragmentationMoveOperation)
-> (DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> DefragmentationMoveOperation)
-> Ord DefragmentationMoveOperation
DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Ordering
DefragmentationMoveOperation
-> DefragmentationMoveOperation -> DefragmentationMoveOperation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> DefragmentationMoveOperation
$cmin :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> DefragmentationMoveOperation
max :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> DefragmentationMoveOperation
$cmax :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> DefragmentationMoveOperation
>= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c>= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
> :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c> :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
<= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c<= :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
< :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
$c< :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Bool
compare :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Ordering
$ccompare :: DefragmentationMoveOperation
-> DefragmentationMoveOperation -> Ordering
$cp1Ord :: Eq DefragmentationMoveOperation
Ord, Ptr b -> Int -> IO DefragmentationMoveOperation
Ptr b -> Int -> DefragmentationMoveOperation -> IO ()
Ptr DefragmentationMoveOperation -> IO DefragmentationMoveOperation
Ptr DefragmentationMoveOperation
-> Int -> IO DefragmentationMoveOperation
Ptr DefragmentationMoveOperation
-> Int -> DefragmentationMoveOperation -> IO ()
Ptr DefragmentationMoveOperation
-> DefragmentationMoveOperation -> IO ()
DefragmentationMoveOperation -> Int
(DefragmentationMoveOperation -> Int)
-> (DefragmentationMoveOperation -> Int)
-> (Ptr DefragmentationMoveOperation
    -> Int -> IO DefragmentationMoveOperation)
-> (Ptr DefragmentationMoveOperation
    -> Int -> DefragmentationMoveOperation -> IO ())
-> (forall b. Ptr b -> Int -> IO DefragmentationMoveOperation)
-> (forall b.
    Ptr b -> Int -> DefragmentationMoveOperation -> IO ())
-> (Ptr DefragmentationMoveOperation
    -> IO DefragmentationMoveOperation)
-> (Ptr DefragmentationMoveOperation
    -> DefragmentationMoveOperation -> IO ())
-> Storable DefragmentationMoveOperation
forall b. Ptr b -> Int -> IO DefragmentationMoveOperation
forall b. Ptr b -> Int -> DefragmentationMoveOperation -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr DefragmentationMoveOperation
-> DefragmentationMoveOperation -> IO ()
$cpoke :: Ptr DefragmentationMoveOperation
-> DefragmentationMoveOperation -> IO ()
peek :: Ptr DefragmentationMoveOperation -> IO DefragmentationMoveOperation
$cpeek :: Ptr DefragmentationMoveOperation -> IO DefragmentationMoveOperation
pokeByteOff :: Ptr b -> Int -> DefragmentationMoveOperation -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> DefragmentationMoveOperation -> IO ()
peekByteOff :: Ptr b -> Int -> IO DefragmentationMoveOperation
$cpeekByteOff :: forall b. Ptr b -> Int -> IO DefragmentationMoveOperation
pokeElemOff :: Ptr DefragmentationMoveOperation
-> Int -> DefragmentationMoveOperation -> IO ()
$cpokeElemOff :: Ptr DefragmentationMoveOperation
-> Int -> DefragmentationMoveOperation -> IO ()
peekElemOff :: Ptr DefragmentationMoveOperation
-> Int -> IO DefragmentationMoveOperation
$cpeekElemOff :: Ptr DefragmentationMoveOperation
-> Int -> IO DefragmentationMoveOperation
alignment :: DefragmentationMoveOperation -> Int
$calignment :: DefragmentationMoveOperation -> Int
sizeOf :: DefragmentationMoveOperation -> Int
$csizeOf :: DefragmentationMoveOperation -> Int
Storable, DefragmentationMoveOperation
DefragmentationMoveOperation -> Zero DefragmentationMoveOperation
forall a. a -> Zero a
zero :: DefragmentationMoveOperation
$czero :: DefragmentationMoveOperation
Zero)

-- | Buffer\/image has been recreated at @dstTmpAllocation@, data has been
-- copied, old buffer\/image has been destroyed. @srcAllocation@ should be
-- changed to point to the new place. This is the default value set by
-- 'beginDefragmentationPass'.
pattern $bDEFRAGMENTATION_MOVE_OPERATION_COPY :: DefragmentationMoveOperation
$mDEFRAGMENTATION_MOVE_OPERATION_COPY :: forall r.
DefragmentationMoveOperation -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_MOVE_OPERATION_COPY    = DefragmentationMoveOperation 0
-- | Set this value if you cannot move the allocation. New place reserved at
-- @dstTmpAllocation@ will be freed. @srcAllocation@ will remain unchanged.
pattern $bDEFRAGMENTATION_MOVE_OPERATION_IGNORE :: DefragmentationMoveOperation
$mDEFRAGMENTATION_MOVE_OPERATION_IGNORE :: forall r.
DefragmentationMoveOperation -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_MOVE_OPERATION_IGNORE  = DefragmentationMoveOperation 1
-- | Set this value if you decide to abandon the allocation and you destroyed
-- the buffer\/image. New place reserved at @dstTmpAllocation@ will be
-- freed, along with @srcAllocation@, which will be destroyed.
pattern $bDEFRAGMENTATION_MOVE_OPERATION_DESTROY :: DefragmentationMoveOperation
$mDEFRAGMENTATION_MOVE_OPERATION_DESTROY :: forall r.
DefragmentationMoveOperation -> (Void# -> r) -> (Void# -> r) -> r
DEFRAGMENTATION_MOVE_OPERATION_DESTROY = DefragmentationMoveOperation 2
{-# complete DEFRAGMENTATION_MOVE_OPERATION_COPY,
             DEFRAGMENTATION_MOVE_OPERATION_IGNORE,
             DEFRAGMENTATION_MOVE_OPERATION_DESTROY :: DefragmentationMoveOperation #-}

conNameDefragmentationMoveOperation :: String
conNameDefragmentationMoveOperation :: String
conNameDefragmentationMoveOperation = String
"DefragmentationMoveOperation"

enumPrefixDefragmentationMoveOperation :: String
enumPrefixDefragmentationMoveOperation :: String
enumPrefixDefragmentationMoveOperation = String
"DEFRAGMENTATION_MOVE_OPERATION_"

showTableDefragmentationMoveOperation :: [(DefragmentationMoveOperation, String)]
showTableDefragmentationMoveOperation :: [(DefragmentationMoveOperation, String)]
showTableDefragmentationMoveOperation =
  [ (DefragmentationMoveOperation
DEFRAGMENTATION_MOVE_OPERATION_COPY   , String
"COPY")
  , (DefragmentationMoveOperation
DEFRAGMENTATION_MOVE_OPERATION_IGNORE , String
"IGNORE")
  , (DefragmentationMoveOperation
DEFRAGMENTATION_MOVE_OPERATION_DESTROY, String
"DESTROY")
  ]

instance Show DefragmentationMoveOperation where
  showsPrec :: Int -> DefragmentationMoveOperation -> ShowS
showsPrec = String
-> [(DefragmentationMoveOperation, String)]
-> String
-> (DefragmentationMoveOperation -> Int32)
-> (Int32 -> ShowS)
-> Int
-> DefragmentationMoveOperation
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixDefragmentationMoveOperation
                            [(DefragmentationMoveOperation, String)]
showTableDefragmentationMoveOperation
                            String
conNameDefragmentationMoveOperation
                            (\(DefragmentationMoveOperation Int32
x) -> Int32
x)
                            (Int -> Int32 -> ShowS
forall a. Show a => Int -> a -> ShowS
showsPrec Int
11)

instance Read DefragmentationMoveOperation where
  readPrec :: ReadPrec DefragmentationMoveOperation
readPrec = String
-> [(DefragmentationMoveOperation, String)]
-> String
-> (Int32 -> DefragmentationMoveOperation)
-> ReadPrec DefragmentationMoveOperation
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixDefragmentationMoveOperation
                          [(DefragmentationMoveOperation, String)]
showTableDefragmentationMoveOperation
                          String
conNameDefragmentationMoveOperation
                          Int32 -> DefragmentationMoveOperation
DefragmentationMoveOperation


type VirtualBlockCreateFlags = VirtualBlockCreateFlagBits

-- | Flags to be passed as /VmaVirtualBlockCreateInfo::flags/.
newtype VirtualBlockCreateFlagBits = VirtualBlockCreateFlagBits Flags
  deriving newtype (VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
(VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Bool)
-> Eq VirtualBlockCreateFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c/= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
== :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c== :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
Eq, Eq VirtualBlockCreateFlagBits
Eq VirtualBlockCreateFlagBits
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Ordering)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> Ord VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> Ordering
VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$cmin :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
max :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$cmax :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
>= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c>= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
> :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c> :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
<= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c<= :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
< :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
$c< :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits -> Bool
compare :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> Ordering
$ccompare :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> Ordering
$cp1Ord :: Eq VirtualBlockCreateFlagBits
Ord, Ptr b -> Int -> IO VirtualBlockCreateFlagBits
Ptr b -> Int -> VirtualBlockCreateFlagBits -> IO ()
Ptr VirtualBlockCreateFlagBits -> IO VirtualBlockCreateFlagBits
Ptr VirtualBlockCreateFlagBits
-> Int -> IO VirtualBlockCreateFlagBits
Ptr VirtualBlockCreateFlagBits
-> Int -> VirtualBlockCreateFlagBits -> IO ()
Ptr VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> IO ()
VirtualBlockCreateFlagBits -> Int
(VirtualBlockCreateFlagBits -> Int)
-> (VirtualBlockCreateFlagBits -> Int)
-> (Ptr VirtualBlockCreateFlagBits
    -> Int -> IO VirtualBlockCreateFlagBits)
-> (Ptr VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO VirtualBlockCreateFlagBits)
-> (forall b. Ptr b -> Int -> VirtualBlockCreateFlagBits -> IO ())
-> (Ptr VirtualBlockCreateFlagBits
    -> IO VirtualBlockCreateFlagBits)
-> (Ptr VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> IO ())
-> Storable VirtualBlockCreateFlagBits
forall b. Ptr b -> Int -> IO VirtualBlockCreateFlagBits
forall b. Ptr b -> Int -> VirtualBlockCreateFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> IO ()
$cpoke :: Ptr VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> IO ()
peek :: Ptr VirtualBlockCreateFlagBits -> IO VirtualBlockCreateFlagBits
$cpeek :: Ptr VirtualBlockCreateFlagBits -> IO VirtualBlockCreateFlagBits
pokeByteOff :: Ptr b -> Int -> VirtualBlockCreateFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> VirtualBlockCreateFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO VirtualBlockCreateFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO VirtualBlockCreateFlagBits
pokeElemOff :: Ptr VirtualBlockCreateFlagBits
-> Int -> VirtualBlockCreateFlagBits -> IO ()
$cpokeElemOff :: Ptr VirtualBlockCreateFlagBits
-> Int -> VirtualBlockCreateFlagBits -> IO ()
peekElemOff :: Ptr VirtualBlockCreateFlagBits
-> Int -> IO VirtualBlockCreateFlagBits
$cpeekElemOff :: Ptr VirtualBlockCreateFlagBits
-> Int -> IO VirtualBlockCreateFlagBits
alignment :: VirtualBlockCreateFlagBits -> Int
$calignment :: VirtualBlockCreateFlagBits -> Int
sizeOf :: VirtualBlockCreateFlagBits -> Int
$csizeOf :: VirtualBlockCreateFlagBits -> Int
Storable, VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits -> Zero VirtualBlockCreateFlagBits
forall a. a -> Zero a
zero :: VirtualBlockCreateFlagBits
$czero :: VirtualBlockCreateFlagBits
Zero, Eq VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits
Eq VirtualBlockCreateFlagBits
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> VirtualBlockCreateFlagBits
-> (Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits -> Int -> Bool)
-> (VirtualBlockCreateFlagBits -> Maybe Int)
-> (VirtualBlockCreateFlagBits -> Int)
-> (VirtualBlockCreateFlagBits -> Bool)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits
    -> Int -> VirtualBlockCreateFlagBits)
-> (VirtualBlockCreateFlagBits -> Int)
-> Bits VirtualBlockCreateFlagBits
Int -> VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits -> Bool
VirtualBlockCreateFlagBits -> Int
VirtualBlockCreateFlagBits -> Maybe Int
VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits -> Int -> Bool
VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: VirtualBlockCreateFlagBits -> Int
$cpopCount :: VirtualBlockCreateFlagBits -> Int
rotateR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$crotateR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
rotateL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$crotateL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
unsafeShiftR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cunsafeShiftR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
shiftR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cshiftR :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
unsafeShiftL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cunsafeShiftL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
shiftL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cshiftL :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
isSigned :: VirtualBlockCreateFlagBits -> Bool
$cisSigned :: VirtualBlockCreateFlagBits -> Bool
bitSize :: VirtualBlockCreateFlagBits -> Int
$cbitSize :: VirtualBlockCreateFlagBits -> Int
bitSizeMaybe :: VirtualBlockCreateFlagBits -> Maybe Int
$cbitSizeMaybe :: VirtualBlockCreateFlagBits -> Maybe Int
testBit :: VirtualBlockCreateFlagBits -> Int -> Bool
$ctestBit :: VirtualBlockCreateFlagBits -> Int -> Bool
complementBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$ccomplementBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
clearBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cclearBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
setBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$csetBit :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
bit :: Int -> VirtualBlockCreateFlagBits
$cbit :: Int -> VirtualBlockCreateFlagBits
zeroBits :: VirtualBlockCreateFlagBits
$czeroBits :: VirtualBlockCreateFlagBits
rotate :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$crotate :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
shift :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
$cshift :: VirtualBlockCreateFlagBits -> Int -> VirtualBlockCreateFlagBits
complement :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$ccomplement :: VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
xor :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$cxor :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
.|. :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$c.|. :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
.&. :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$c.&. :: VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> VirtualBlockCreateFlagBits
$cp1Bits :: Eq VirtualBlockCreateFlagBits
Bits, Bits VirtualBlockCreateFlagBits
Bits VirtualBlockCreateFlagBits
-> (VirtualBlockCreateFlagBits -> Int)
-> (VirtualBlockCreateFlagBits -> Int)
-> (VirtualBlockCreateFlagBits -> Int)
-> FiniteBits VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: VirtualBlockCreateFlagBits -> Int
$ccountTrailingZeros :: VirtualBlockCreateFlagBits -> Int
countLeadingZeros :: VirtualBlockCreateFlagBits -> Int
$ccountLeadingZeros :: VirtualBlockCreateFlagBits -> Int
finiteBitSize :: VirtualBlockCreateFlagBits -> Int
$cfiniteBitSize :: VirtualBlockCreateFlagBits -> Int
$cp1FiniteBits :: Bits VirtualBlockCreateFlagBits
FiniteBits)

-- | 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 $bVIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT :: VirtualBlockCreateFlagBits
$mVIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT :: forall r.
VirtualBlockCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT = VirtualBlockCreateFlagBits 0x00000001
-- | Bit mask to extract only @ALGORITHM@ bits from entire set of flags.
pattern $bVIRTUAL_BLOCK_CREATE_ALGORITHM_MASK :: VirtualBlockCreateFlagBits
$mVIRTUAL_BLOCK_CREATE_ALGORITHM_MASK :: forall r.
VirtualBlockCreateFlagBits -> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK       = VirtualBlockCreateFlagBits 0x00000001

conNameVirtualBlockCreateFlagBits :: String
conNameVirtualBlockCreateFlagBits :: String
conNameVirtualBlockCreateFlagBits = String
"VirtualBlockCreateFlagBits"

enumPrefixVirtualBlockCreateFlagBits :: String
enumPrefixVirtualBlockCreateFlagBits :: String
enumPrefixVirtualBlockCreateFlagBits = String
"VIRTUAL_BLOCK_CREATE_"

showTableVirtualBlockCreateFlagBits :: [(VirtualBlockCreateFlagBits, String)]
showTableVirtualBlockCreateFlagBits :: [(VirtualBlockCreateFlagBits, String)]
showTableVirtualBlockCreateFlagBits =
  [ (VirtualBlockCreateFlagBits
VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT, String
"LINEAR_ALGORITHM_BIT")
  , (VirtualBlockCreateFlagBits
VIRTUAL_BLOCK_CREATE_ALGORITHM_MASK      , String
"ALGORITHM_MASK")
  ]

instance Show VirtualBlockCreateFlagBits where
  showsPrec :: Int -> VirtualBlockCreateFlagBits -> ShowS
showsPrec = String
-> [(VirtualBlockCreateFlagBits, String)]
-> String
-> (VirtualBlockCreateFlagBits -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> VirtualBlockCreateFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixVirtualBlockCreateFlagBits
                            [(VirtualBlockCreateFlagBits, String)]
showTableVirtualBlockCreateFlagBits
                            String
conNameVirtualBlockCreateFlagBits
                            (\(VirtualBlockCreateFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read VirtualBlockCreateFlagBits where
  readPrec :: ReadPrec VirtualBlockCreateFlagBits
readPrec = String
-> [(VirtualBlockCreateFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32) -> VirtualBlockCreateFlagBits)
-> ReadPrec VirtualBlockCreateFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixVirtualBlockCreateFlagBits
                          [(VirtualBlockCreateFlagBits, String)]
showTableVirtualBlockCreateFlagBits
                          String
conNameVirtualBlockCreateFlagBits
                          ("memoryTypeIndex" ::: Word32) -> VirtualBlockCreateFlagBits
VirtualBlockCreateFlagBits


type VirtualAllocationCreateFlags = VirtualAllocationCreateFlagBits

-- | Flags to be passed as /VmaVirtualAllocationCreateInfo::flags/.
newtype VirtualAllocationCreateFlagBits = VirtualAllocationCreateFlagBits Flags
  deriving newtype (VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
(VirtualAllocationCreateFlagBits
 -> VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Bool)
-> Eq VirtualAllocationCreateFlagBits
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c/= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
== :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c== :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
Eq, Eq VirtualAllocationCreateFlagBits
Eq VirtualAllocationCreateFlagBits
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Ordering)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> Ord VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Ordering
VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$cmin :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
max :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$cmax :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
>= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c>= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
> :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c> :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
<= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c<= :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
< :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
$c< :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Bool
compare :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Ordering
$ccompare :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> Ordering
$cp1Ord :: Eq VirtualAllocationCreateFlagBits
Ord, Ptr b -> Int -> IO VirtualAllocationCreateFlagBits
Ptr b -> Int -> VirtualAllocationCreateFlagBits -> IO ()
Ptr VirtualAllocationCreateFlagBits
-> IO VirtualAllocationCreateFlagBits
Ptr VirtualAllocationCreateFlagBits
-> Int -> IO VirtualAllocationCreateFlagBits
Ptr VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits -> IO ()
Ptr VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> IO ()
VirtualAllocationCreateFlagBits -> Int
(VirtualAllocationCreateFlagBits -> Int)
-> (VirtualAllocationCreateFlagBits -> Int)
-> (Ptr VirtualAllocationCreateFlagBits
    -> Int -> IO VirtualAllocationCreateFlagBits)
-> (Ptr VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits -> IO ())
-> (forall b. Ptr b -> Int -> IO VirtualAllocationCreateFlagBits)
-> (forall b.
    Ptr b -> Int -> VirtualAllocationCreateFlagBits -> IO ())
-> (Ptr VirtualAllocationCreateFlagBits
    -> IO VirtualAllocationCreateFlagBits)
-> (Ptr VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits -> IO ())
-> Storable VirtualAllocationCreateFlagBits
forall b. Ptr b -> Int -> IO VirtualAllocationCreateFlagBits
forall b. Ptr b -> Int -> VirtualAllocationCreateFlagBits -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> IO ()
$cpoke :: Ptr VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> IO ()
peek :: Ptr VirtualAllocationCreateFlagBits
-> IO VirtualAllocationCreateFlagBits
$cpeek :: Ptr VirtualAllocationCreateFlagBits
-> IO VirtualAllocationCreateFlagBits
pokeByteOff :: Ptr b -> Int -> VirtualAllocationCreateFlagBits -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> VirtualAllocationCreateFlagBits -> IO ()
peekByteOff :: Ptr b -> Int -> IO VirtualAllocationCreateFlagBits
$cpeekByteOff :: forall b. Ptr b -> Int -> IO VirtualAllocationCreateFlagBits
pokeElemOff :: Ptr VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits -> IO ()
$cpokeElemOff :: Ptr VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits -> IO ()
peekElemOff :: Ptr VirtualAllocationCreateFlagBits
-> Int -> IO VirtualAllocationCreateFlagBits
$cpeekElemOff :: Ptr VirtualAllocationCreateFlagBits
-> Int -> IO VirtualAllocationCreateFlagBits
alignment :: VirtualAllocationCreateFlagBits -> Int
$calignment :: VirtualAllocationCreateFlagBits -> Int
sizeOf :: VirtualAllocationCreateFlagBits -> Int
$csizeOf :: VirtualAllocationCreateFlagBits -> Int
Storable, VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits
-> Zero VirtualAllocationCreateFlagBits
forall a. a -> Zero a
zero :: VirtualAllocationCreateFlagBits
$czero :: VirtualAllocationCreateFlagBits
Zero, Eq VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits
Eq VirtualAllocationCreateFlagBits
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> VirtualAllocationCreateFlagBits
-> (Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits -> Int -> Bool)
-> (VirtualAllocationCreateFlagBits -> Maybe Int)
-> (VirtualAllocationCreateFlagBits -> Int)
-> (VirtualAllocationCreateFlagBits -> Bool)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits
    -> Int -> VirtualAllocationCreateFlagBits)
-> (VirtualAllocationCreateFlagBits -> Int)
-> Bits VirtualAllocationCreateFlagBits
Int -> VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits -> Bool
VirtualAllocationCreateFlagBits -> Int
VirtualAllocationCreateFlagBits -> Maybe Int
VirtualAllocationCreateFlagBits -> VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits -> Int -> Bool
VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
popCount :: VirtualAllocationCreateFlagBits -> Int
$cpopCount :: VirtualAllocationCreateFlagBits -> Int
rotateR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$crotateR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
rotateL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$crotateL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
unsafeShiftR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cunsafeShiftR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
shiftR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cshiftR :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
unsafeShiftL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cunsafeShiftL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
shiftL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cshiftL :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
isSigned :: VirtualAllocationCreateFlagBits -> Bool
$cisSigned :: VirtualAllocationCreateFlagBits -> Bool
bitSize :: VirtualAllocationCreateFlagBits -> Int
$cbitSize :: VirtualAllocationCreateFlagBits -> Int
bitSizeMaybe :: VirtualAllocationCreateFlagBits -> Maybe Int
$cbitSizeMaybe :: VirtualAllocationCreateFlagBits -> Maybe Int
testBit :: VirtualAllocationCreateFlagBits -> Int -> Bool
$ctestBit :: VirtualAllocationCreateFlagBits -> Int -> Bool
complementBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$ccomplementBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
clearBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cclearBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
setBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$csetBit :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
bit :: Int -> VirtualAllocationCreateFlagBits
$cbit :: Int -> VirtualAllocationCreateFlagBits
zeroBits :: VirtualAllocationCreateFlagBits
$czeroBits :: VirtualAllocationCreateFlagBits
rotate :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$crotate :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
shift :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
$cshift :: VirtualAllocationCreateFlagBits
-> Int -> VirtualAllocationCreateFlagBits
complement :: VirtualAllocationCreateFlagBits -> VirtualAllocationCreateFlagBits
$ccomplement :: VirtualAllocationCreateFlagBits -> VirtualAllocationCreateFlagBits
xor :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$cxor :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
.|. :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$c.|. :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
.&. :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$c.&. :: VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits
$cp1Bits :: Eq VirtualAllocationCreateFlagBits
Bits, Bits VirtualAllocationCreateFlagBits
Bits VirtualAllocationCreateFlagBits
-> (VirtualAllocationCreateFlagBits -> Int)
-> (VirtualAllocationCreateFlagBits -> Int)
-> (VirtualAllocationCreateFlagBits -> Int)
-> FiniteBits VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits -> Int
forall b.
Bits b -> (b -> Int) -> (b -> Int) -> (b -> Int) -> FiniteBits b
countTrailingZeros :: VirtualAllocationCreateFlagBits -> Int
$ccountTrailingZeros :: VirtualAllocationCreateFlagBits -> Int
countLeadingZeros :: VirtualAllocationCreateFlagBits -> Int
$ccountLeadingZeros :: VirtualAllocationCreateFlagBits -> Int
finiteBitSize :: VirtualAllocationCreateFlagBits -> Int
$cfiniteBitSize :: VirtualAllocationCreateFlagBits -> Int
$cp1FiniteBits :: Bits VirtualAllocationCreateFlagBits
FiniteBits)

-- | Allocation will be created from upper stack in a double stack pool.
--
-- This flag is only allowed for virtual blocks created with
-- 'VIRTUAL_BLOCK_CREATE_LINEAR_ALGORITHM_BIT' flag.
pattern $bVIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: VirtualAllocationCreateFlagBits
$mVIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT :: forall r.
VirtualAllocationCreateFlagBits
-> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT       = VirtualAllocationCreateFlagBits 0x00000040
-- | Allocation strategy that tries to minimize memory usage.
pattern $bVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: VirtualAllocationCreateFlagBits
$mVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT :: forall r.
VirtualAllocationCreateFlagBits
-> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT = VirtualAllocationCreateFlagBits 0x00010000
-- | Allocation strategy that tries to minimize allocation time.
pattern $bVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: VirtualAllocationCreateFlagBits
$mVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT :: forall r.
VirtualAllocationCreateFlagBits
-> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT   = VirtualAllocationCreateFlagBits 0x00020000
-- | Allocation strategy that chooses always the lowest offset in available
-- space. This is not the most efficient strategy but achieves highly
-- packed data.
pattern $bVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: VirtualAllocationCreateFlagBits
$mVIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT :: forall r.
VirtualAllocationCreateFlagBits
-> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT = VirtualAllocationCreateFlagBits 0x00040000
-- | A bit mask to extract only @STRATEGY@ bits from entire set of flags.
--
-- These strategy flags are binary compatible with equivalent flags in
-- 'AllocationCreateFlagBits'.
pattern $bVIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK :: VirtualAllocationCreateFlagBits
$mVIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK :: forall r.
VirtualAllocationCreateFlagBits
-> (Void# -> r) -> (Void# -> r) -> r
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK           = VirtualAllocationCreateFlagBits 0x00070000

conNameVirtualAllocationCreateFlagBits :: String
conNameVirtualAllocationCreateFlagBits :: String
conNameVirtualAllocationCreateFlagBits = String
"VirtualAllocationCreateFlagBits"

enumPrefixVirtualAllocationCreateFlagBits :: String
enumPrefixVirtualAllocationCreateFlagBits :: String
enumPrefixVirtualAllocationCreateFlagBits = String
"VIRTUAL_ALLOCATION_CREATE_"

showTableVirtualAllocationCreateFlagBits :: [(VirtualAllocationCreateFlagBits, String)]
showTableVirtualAllocationCreateFlagBits :: [(VirtualAllocationCreateFlagBits, String)]
showTableVirtualAllocationCreateFlagBits =
  [ (VirtualAllocationCreateFlagBits
VIRTUAL_ALLOCATION_CREATE_UPPER_ADDRESS_BIT      , String
"UPPER_ADDRESS_BIT")
  , (VirtualAllocationCreateFlagBits
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT, String
"STRATEGY_MIN_MEMORY_BIT")
  , (VirtualAllocationCreateFlagBits
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT  , String
"STRATEGY_MIN_TIME_BIT")
  , (VirtualAllocationCreateFlagBits
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MIN_OFFSET_BIT, String
"STRATEGY_MIN_OFFSET_BIT")
  , (VirtualAllocationCreateFlagBits
VIRTUAL_ALLOCATION_CREATE_STRATEGY_MASK          , String
"STRATEGY_MASK")
  ]

instance Show VirtualAllocationCreateFlagBits where
  showsPrec :: Int -> VirtualAllocationCreateFlagBits -> ShowS
showsPrec = String
-> [(VirtualAllocationCreateFlagBits, String)]
-> String
-> (VirtualAllocationCreateFlagBits
    -> "memoryTypeIndex" ::: Word32)
-> (("memoryTypeIndex" ::: Word32) -> ShowS)
-> Int
-> VirtualAllocationCreateFlagBits
-> ShowS
forall a i.
Eq a =>
String
-> [(a, String)]
-> String
-> (a -> i)
-> (i -> ShowS)
-> Int
-> a
-> ShowS
enumShowsPrec String
enumPrefixVirtualAllocationCreateFlagBits
                            [(VirtualAllocationCreateFlagBits, String)]
showTableVirtualAllocationCreateFlagBits
                            String
conNameVirtualAllocationCreateFlagBits
                            (\(VirtualAllocationCreateFlagBits "memoryTypeIndex" ::: Word32
x) -> "memoryTypeIndex" ::: Word32
x)
                            (\"memoryTypeIndex" ::: Word32
x -> String -> ShowS
showString String
"0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("memoryTypeIndex" ::: Word32) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "memoryTypeIndex" ::: Word32
x)

instance Read VirtualAllocationCreateFlagBits where
  readPrec :: ReadPrec VirtualAllocationCreateFlagBits
readPrec = String
-> [(VirtualAllocationCreateFlagBits, String)]
-> String
-> (("memoryTypeIndex" ::: Word32)
    -> VirtualAllocationCreateFlagBits)
-> ReadPrec VirtualAllocationCreateFlagBits
forall i a.
Read i =>
String -> [(a, String)] -> String -> (i -> a) -> ReadPrec a
enumReadPrec String
enumPrefixVirtualAllocationCreateFlagBits
                          [(VirtualAllocationCreateFlagBits, String)]
showTableVirtualAllocationCreateFlagBits
                          String
conNameVirtualAllocationCreateFlagBits
                          ("memoryTypeIndex" ::: Word32) -> VirtualAllocationCreateFlagBits
VirtualAllocationCreateFlagBits


-- | 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.
newtype Allocator = Allocator Word64
  deriving newtype (Allocator -> Allocator -> Bool
(Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Bool) -> Eq Allocator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Allocator -> Allocator -> Bool
$c/= :: Allocator -> Allocator -> Bool
== :: Allocator -> Allocator -> Bool
$c== :: Allocator -> Allocator -> Bool
Eq, Eq Allocator
Eq Allocator
-> (Allocator -> Allocator -> Ordering)
-> (Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Bool)
-> (Allocator -> Allocator -> Allocator)
-> (Allocator -> Allocator -> Allocator)
-> Ord Allocator
Allocator -> Allocator -> Bool
Allocator -> Allocator -> Ordering
Allocator -> Allocator -> Allocator
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Allocator -> Allocator -> Allocator
$cmin :: Allocator -> Allocator -> Allocator
max :: Allocator -> Allocator -> Allocator
$cmax :: Allocator -> Allocator -> Allocator
>= :: Allocator -> Allocator -> Bool
$c>= :: Allocator -> Allocator -> Bool
> :: Allocator -> Allocator -> Bool
$c> :: Allocator -> Allocator -> Bool
<= :: Allocator -> Allocator -> Bool
$c<= :: Allocator -> Allocator -> Bool
< :: Allocator -> Allocator -> Bool
$c< :: Allocator -> Allocator -> Bool
compare :: Allocator -> Allocator -> Ordering
$ccompare :: Allocator -> Allocator -> Ordering
$cp1Ord :: Eq Allocator
Ord, Ptr b -> Int -> IO Allocator
Ptr b -> Int -> Allocator -> IO ()
Ptr Allocator -> IO Allocator
Ptr Allocator -> Int -> IO Allocator
Ptr Allocator -> Int -> Allocator -> IO ()
Ptr Allocator -> Allocator -> IO ()
Allocator -> Int
(Allocator -> Int)
-> (Allocator -> Int)
-> (Ptr Allocator -> Int -> IO Allocator)
-> (Ptr Allocator -> Int -> Allocator -> IO ())
-> (forall b. Ptr b -> Int -> IO Allocator)
-> (forall b. Ptr b -> Int -> Allocator -> IO ())
-> (Ptr Allocator -> IO Allocator)
-> (Ptr Allocator -> Allocator -> IO ())
-> Storable Allocator
forall b. Ptr b -> Int -> IO Allocator
forall b. Ptr b -> Int -> Allocator -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr Allocator -> Allocator -> IO ()
$cpoke :: Ptr Allocator -> Allocator -> IO ()
peek :: Ptr Allocator -> IO Allocator
$cpeek :: Ptr Allocator -> IO Allocator
pokeByteOff :: Ptr b -> Int -> Allocator -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> Allocator -> IO ()
peekByteOff :: Ptr b -> Int -> IO Allocator
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Allocator
pokeElemOff :: Ptr Allocator -> Int -> Allocator -> IO ()
$cpokeElemOff :: Ptr Allocator -> Int -> Allocator -> IO ()
peekElemOff :: Ptr Allocator -> Int -> IO Allocator
$cpeekElemOff :: Ptr Allocator -> Int -> IO Allocator
alignment :: Allocator -> Int
$calignment :: Allocator -> Int
sizeOf :: Allocator -> Int
$csizeOf :: Allocator -> Int
Storable, Allocator
Allocator -> Zero Allocator
forall a. a -> Zero a
zero :: Allocator
$czero :: Allocator
Zero)
  deriving anyclass (Eq Allocator
Zero Allocator
Eq Allocator -> Zero Allocator -> IsHandle Allocator
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero Allocator
$cp1IsHandle :: Eq Allocator
IsHandle)
instance Show Allocator where
  showsPrec :: Int -> Allocator -> ShowS
showsPrec Int
p (Allocator "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"Allocator 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


-- | 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 Pool = Pool Word64
  deriving newtype (Pool -> Pool -> Bool
(Pool -> Pool -> Bool) -> (Pool -> Pool -> Bool) -> Eq Pool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pool -> Pool -> Bool
$c/= :: Pool -> Pool -> Bool
== :: Pool -> Pool -> Bool
$c== :: Pool -> Pool -> Bool
Eq, Eq Pool
Eq Pool
-> (Pool -> Pool -> Ordering)
-> (Pool -> Pool -> Bool)
-> (Pool -> Pool -> Bool)
-> (Pool -> Pool -> Bool)
-> (Pool -> Pool -> Bool)
-> (Pool -> Pool -> Pool)
-> (Pool -> Pool -> Pool)
-> Ord Pool
Pool -> Pool -> Bool
Pool -> Pool -> Ordering
Pool -> Pool -> Pool
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Pool -> Pool -> Pool
$cmin :: Pool -> Pool -> Pool
max :: Pool -> Pool -> Pool
$cmax :: Pool -> Pool -> Pool
>= :: Pool -> Pool -> Bool
$c>= :: Pool -> Pool -> Bool
> :: Pool -> Pool -> Bool
$c> :: Pool -> Pool -> Bool
<= :: Pool -> Pool -> Bool
$c<= :: Pool -> Pool -> Bool
< :: Pool -> Pool -> Bool
$c< :: Pool -> Pool -> Bool
compare :: Pool -> Pool -> Ordering
$ccompare :: Pool -> Pool -> Ordering
$cp1Ord :: Eq Pool
Ord, Ptr b -> Int -> IO Pool
Ptr b -> Int -> Pool -> IO ()
Ptr Pool -> IO Pool
Ptr Pool -> Int -> IO Pool
Ptr Pool -> Int -> Pool -> IO ()
Ptr Pool -> Pool -> IO ()
Pool -> Int
(Pool -> Int)
-> (Pool -> Int)
-> (Ptr Pool -> Int -> IO Pool)
-> (Ptr Pool -> Int -> Pool -> IO ())
-> (forall b. Ptr b -> Int -> IO Pool)
-> (forall b. Ptr b -> Int -> Pool -> IO ())
-> (Ptr Pool -> IO Pool)
-> (Ptr Pool -> Pool -> IO ())
-> Storable Pool
forall b. Ptr b -> Int -> IO Pool
forall b. Ptr b -> Int -> Pool -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr Pool -> Pool -> IO ()
$cpoke :: Ptr Pool -> Pool -> IO ()
peek :: Ptr Pool -> IO Pool
$cpeek :: Ptr Pool -> IO Pool
pokeByteOff :: Ptr b -> Int -> Pool -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> Pool -> IO ()
peekByteOff :: Ptr b -> Int -> IO Pool
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Pool
pokeElemOff :: Ptr Pool -> Int -> Pool -> IO ()
$cpokeElemOff :: Ptr Pool -> Int -> Pool -> IO ()
peekElemOff :: Ptr Pool -> Int -> IO Pool
$cpeekElemOff :: Ptr Pool -> Int -> IO Pool
alignment :: Pool -> Int
$calignment :: Pool -> Int
sizeOf :: Pool -> Int
$csizeOf :: Pool -> Int
Storable, Pool
Pool -> Zero Pool
forall a. a -> Zero a
zero :: Pool
$czero :: Pool
Zero)
  deriving anyclass (Eq Pool
Zero Pool
Eq Pool -> Zero Pool -> IsHandle Pool
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero Pool
$cp1IsHandle :: Eq Pool
IsHandle)
instance Show Pool where
  showsPrec :: Int -> Pool -> ShowS
showsPrec Int
p (Pool "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"Pool 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


-- | 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'.
newtype Allocation = Allocation Word64
  deriving newtype (Allocation -> Allocation -> Bool
(Allocation -> Allocation -> Bool)
-> (Allocation -> Allocation -> Bool) -> Eq Allocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Allocation -> Allocation -> Bool
$c/= :: Allocation -> Allocation -> Bool
== :: Allocation -> Allocation -> Bool
$c== :: Allocation -> Allocation -> Bool
Eq, Eq Allocation
Eq Allocation
-> (Allocation -> Allocation -> Ordering)
-> (Allocation -> Allocation -> Bool)
-> (Allocation -> Allocation -> Bool)
-> (Allocation -> Allocation -> Bool)
-> (Allocation -> Allocation -> Bool)
-> (Allocation -> Allocation -> Allocation)
-> (Allocation -> Allocation -> Allocation)
-> Ord Allocation
Allocation -> Allocation -> Bool
Allocation -> Allocation -> Ordering
Allocation -> Allocation -> Allocation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Allocation -> Allocation -> Allocation
$cmin :: Allocation -> Allocation -> Allocation
max :: Allocation -> Allocation -> Allocation
$cmax :: Allocation -> Allocation -> Allocation
>= :: Allocation -> Allocation -> Bool
$c>= :: Allocation -> Allocation -> Bool
> :: Allocation -> Allocation -> Bool
$c> :: Allocation -> Allocation -> Bool
<= :: Allocation -> Allocation -> Bool
$c<= :: Allocation -> Allocation -> Bool
< :: Allocation -> Allocation -> Bool
$c< :: Allocation -> Allocation -> Bool
compare :: Allocation -> Allocation -> Ordering
$ccompare :: Allocation -> Allocation -> Ordering
$cp1Ord :: Eq Allocation
Ord, Ptr b -> Int -> IO Allocation
Ptr b -> Int -> Allocation -> IO ()
Ptr Allocation -> IO Allocation
Ptr Allocation -> Int -> IO Allocation
Ptr Allocation -> Int -> Allocation -> IO ()
Ptr Allocation -> Allocation -> IO ()
Allocation -> Int
(Allocation -> Int)
-> (Allocation -> Int)
-> (Ptr Allocation -> Int -> IO Allocation)
-> (Ptr Allocation -> Int -> Allocation -> IO ())
-> (forall b. Ptr b -> Int -> IO Allocation)
-> (forall b. Ptr b -> Int -> Allocation -> IO ())
-> (Ptr Allocation -> IO Allocation)
-> (Ptr Allocation -> Allocation -> IO ())
-> Storable Allocation
forall b. Ptr b -> Int -> IO Allocation
forall b. Ptr b -> Int -> Allocation -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr Allocation -> Allocation -> IO ()
$cpoke :: Ptr Allocation -> Allocation -> IO ()
peek :: Ptr Allocation -> IO Allocation
$cpeek :: Ptr Allocation -> IO Allocation
pokeByteOff :: Ptr b -> Int -> Allocation -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> Allocation -> IO ()
peekByteOff :: Ptr b -> Int -> IO Allocation
$cpeekByteOff :: forall b. Ptr b -> Int -> IO Allocation
pokeElemOff :: Ptr Allocation -> Int -> Allocation -> IO ()
$cpokeElemOff :: Ptr Allocation -> Int -> Allocation -> IO ()
peekElemOff :: Ptr Allocation -> Int -> IO Allocation
$cpeekElemOff :: Ptr Allocation -> Int -> IO Allocation
alignment :: Allocation -> Int
$calignment :: Allocation -> Int
sizeOf :: Allocation -> Int
$csizeOf :: Allocation -> Int
Storable, Allocation
Allocation -> Zero Allocation
forall a. a -> Zero a
zero :: Allocation
$czero :: Allocation
Zero)
  deriving anyclass (Eq Allocation
Zero Allocation
Eq Allocation -> Zero Allocation -> IsHandle Allocation
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero Allocation
$cp1IsHandle :: Eq Allocation
IsHandle)
instance Show Allocation where
  showsPrec :: Int -> Allocation -> ShowS
showsPrec Int
p (Allocation "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"Allocation 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


-- | 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.
newtype DefragmentationContext = DefragmentationContext Word64
  deriving newtype (DefragmentationContext -> DefragmentationContext -> Bool
(DefragmentationContext -> DefragmentationContext -> Bool)
-> (DefragmentationContext -> DefragmentationContext -> Bool)
-> Eq DefragmentationContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationContext -> DefragmentationContext -> Bool
$c/= :: DefragmentationContext -> DefragmentationContext -> Bool
== :: DefragmentationContext -> DefragmentationContext -> Bool
$c== :: DefragmentationContext -> DefragmentationContext -> Bool
Eq, Eq DefragmentationContext
Eq DefragmentationContext
-> (DefragmentationContext -> DefragmentationContext -> Ordering)
-> (DefragmentationContext -> DefragmentationContext -> Bool)
-> (DefragmentationContext -> DefragmentationContext -> Bool)
-> (DefragmentationContext -> DefragmentationContext -> Bool)
-> (DefragmentationContext -> DefragmentationContext -> Bool)
-> (DefragmentationContext
    -> DefragmentationContext -> DefragmentationContext)
-> (DefragmentationContext
    -> DefragmentationContext -> DefragmentationContext)
-> Ord DefragmentationContext
DefragmentationContext -> DefragmentationContext -> Bool
DefragmentationContext -> DefragmentationContext -> Ordering
DefragmentationContext
-> DefragmentationContext -> DefragmentationContext
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DefragmentationContext
-> DefragmentationContext -> DefragmentationContext
$cmin :: DefragmentationContext
-> DefragmentationContext -> DefragmentationContext
max :: DefragmentationContext
-> DefragmentationContext -> DefragmentationContext
$cmax :: DefragmentationContext
-> DefragmentationContext -> DefragmentationContext
>= :: DefragmentationContext -> DefragmentationContext -> Bool
$c>= :: DefragmentationContext -> DefragmentationContext -> Bool
> :: DefragmentationContext -> DefragmentationContext -> Bool
$c> :: DefragmentationContext -> DefragmentationContext -> Bool
<= :: DefragmentationContext -> DefragmentationContext -> Bool
$c<= :: DefragmentationContext -> DefragmentationContext -> Bool
< :: DefragmentationContext -> DefragmentationContext -> Bool
$c< :: DefragmentationContext -> DefragmentationContext -> Bool
compare :: DefragmentationContext -> DefragmentationContext -> Ordering
$ccompare :: DefragmentationContext -> DefragmentationContext -> Ordering
$cp1Ord :: Eq DefragmentationContext
Ord, Ptr b -> Int -> IO DefragmentationContext
Ptr b -> Int -> DefragmentationContext -> IO ()
Ptr DefragmentationContext -> IO DefragmentationContext
Ptr DefragmentationContext -> Int -> IO DefragmentationContext
Ptr DefragmentationContext
-> Int -> DefragmentationContext -> IO ()
Ptr DefragmentationContext -> DefragmentationContext -> IO ()
DefragmentationContext -> Int
(DefragmentationContext -> Int)
-> (DefragmentationContext -> Int)
-> (Ptr DefragmentationContext -> Int -> IO DefragmentationContext)
-> (Ptr DefragmentationContext
    -> Int -> DefragmentationContext -> IO ())
-> (forall b. Ptr b -> Int -> IO DefragmentationContext)
-> (forall b. Ptr b -> Int -> DefragmentationContext -> IO ())
-> (Ptr DefragmentationContext -> IO DefragmentationContext)
-> (Ptr DefragmentationContext -> DefragmentationContext -> IO ())
-> Storable DefragmentationContext
forall b. Ptr b -> Int -> IO DefragmentationContext
forall b. Ptr b -> Int -> DefragmentationContext -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr DefragmentationContext -> DefragmentationContext -> IO ()
$cpoke :: Ptr DefragmentationContext -> DefragmentationContext -> IO ()
peek :: Ptr DefragmentationContext -> IO DefragmentationContext
$cpeek :: Ptr DefragmentationContext -> IO DefragmentationContext
pokeByteOff :: Ptr b -> Int -> DefragmentationContext -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> DefragmentationContext -> IO ()
peekByteOff :: Ptr b -> Int -> IO DefragmentationContext
$cpeekByteOff :: forall b. Ptr b -> Int -> IO DefragmentationContext
pokeElemOff :: Ptr DefragmentationContext
-> Int -> DefragmentationContext -> IO ()
$cpokeElemOff :: Ptr DefragmentationContext
-> Int -> DefragmentationContext -> IO ()
peekElemOff :: Ptr DefragmentationContext -> Int -> IO DefragmentationContext
$cpeekElemOff :: Ptr DefragmentationContext -> Int -> IO DefragmentationContext
alignment :: DefragmentationContext -> Int
$calignment :: DefragmentationContext -> Int
sizeOf :: DefragmentationContext -> Int
$csizeOf :: DefragmentationContext -> Int
Storable, DefragmentationContext
DefragmentationContext -> Zero DefragmentationContext
forall a. a -> Zero a
zero :: DefragmentationContext
$czero :: DefragmentationContext
Zero)
  deriving anyclass (Eq DefragmentationContext
Zero DefragmentationContext
Eq DefragmentationContext
-> Zero DefragmentationContext -> IsHandle DefragmentationContext
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero DefragmentationContext
$cp1IsHandle :: Eq DefragmentationContext
IsHandle)
instance Show DefragmentationContext where
  showsPrec :: Int -> DefragmentationContext -> ShowS
showsPrec Int
p (DefragmentationContext "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"DefragmentationContext 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


-- | 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.
newtype VirtualAllocation = VirtualAllocation Word64
  deriving newtype (VirtualAllocation -> VirtualAllocation -> Bool
(VirtualAllocation -> VirtualAllocation -> Bool)
-> (VirtualAllocation -> VirtualAllocation -> Bool)
-> Eq VirtualAllocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualAllocation -> VirtualAllocation -> Bool
$c/= :: VirtualAllocation -> VirtualAllocation -> Bool
== :: VirtualAllocation -> VirtualAllocation -> Bool
$c== :: VirtualAllocation -> VirtualAllocation -> Bool
Eq, Eq VirtualAllocation
Eq VirtualAllocation
-> (VirtualAllocation -> VirtualAllocation -> Ordering)
-> (VirtualAllocation -> VirtualAllocation -> Bool)
-> (VirtualAllocation -> VirtualAllocation -> Bool)
-> (VirtualAllocation -> VirtualAllocation -> Bool)
-> (VirtualAllocation -> VirtualAllocation -> Bool)
-> (VirtualAllocation -> VirtualAllocation -> VirtualAllocation)
-> (VirtualAllocation -> VirtualAllocation -> VirtualAllocation)
-> Ord VirtualAllocation
VirtualAllocation -> VirtualAllocation -> Bool
VirtualAllocation -> VirtualAllocation -> Ordering
VirtualAllocation -> VirtualAllocation -> VirtualAllocation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: VirtualAllocation -> VirtualAllocation -> VirtualAllocation
$cmin :: VirtualAllocation -> VirtualAllocation -> VirtualAllocation
max :: VirtualAllocation -> VirtualAllocation -> VirtualAllocation
$cmax :: VirtualAllocation -> VirtualAllocation -> VirtualAllocation
>= :: VirtualAllocation -> VirtualAllocation -> Bool
$c>= :: VirtualAllocation -> VirtualAllocation -> Bool
> :: VirtualAllocation -> VirtualAllocation -> Bool
$c> :: VirtualAllocation -> VirtualAllocation -> Bool
<= :: VirtualAllocation -> VirtualAllocation -> Bool
$c<= :: VirtualAllocation -> VirtualAllocation -> Bool
< :: VirtualAllocation -> VirtualAllocation -> Bool
$c< :: VirtualAllocation -> VirtualAllocation -> Bool
compare :: VirtualAllocation -> VirtualAllocation -> Ordering
$ccompare :: VirtualAllocation -> VirtualAllocation -> Ordering
$cp1Ord :: Eq VirtualAllocation
Ord, Ptr b -> Int -> IO VirtualAllocation
Ptr b -> Int -> VirtualAllocation -> IO ()
Ptr VirtualAllocation -> IO VirtualAllocation
Ptr VirtualAllocation -> Int -> IO VirtualAllocation
Ptr VirtualAllocation -> Int -> VirtualAllocation -> IO ()
Ptr VirtualAllocation -> VirtualAllocation -> IO ()
VirtualAllocation -> Int
(VirtualAllocation -> Int)
-> (VirtualAllocation -> Int)
-> (Ptr VirtualAllocation -> Int -> IO VirtualAllocation)
-> (Ptr VirtualAllocation -> Int -> VirtualAllocation -> IO ())
-> (forall b. Ptr b -> Int -> IO VirtualAllocation)
-> (forall b. Ptr b -> Int -> VirtualAllocation -> IO ())
-> (Ptr VirtualAllocation -> IO VirtualAllocation)
-> (Ptr VirtualAllocation -> VirtualAllocation -> IO ())
-> Storable VirtualAllocation
forall b. Ptr b -> Int -> IO VirtualAllocation
forall b. Ptr b -> Int -> VirtualAllocation -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr VirtualAllocation -> VirtualAllocation -> IO ()
$cpoke :: Ptr VirtualAllocation -> VirtualAllocation -> IO ()
peek :: Ptr VirtualAllocation -> IO VirtualAllocation
$cpeek :: Ptr VirtualAllocation -> IO VirtualAllocation
pokeByteOff :: Ptr b -> Int -> VirtualAllocation -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> VirtualAllocation -> IO ()
peekByteOff :: Ptr b -> Int -> IO VirtualAllocation
$cpeekByteOff :: forall b. Ptr b -> Int -> IO VirtualAllocation
pokeElemOff :: Ptr VirtualAllocation -> Int -> VirtualAllocation -> IO ()
$cpokeElemOff :: Ptr VirtualAllocation -> Int -> VirtualAllocation -> IO ()
peekElemOff :: Ptr VirtualAllocation -> Int -> IO VirtualAllocation
$cpeekElemOff :: Ptr VirtualAllocation -> Int -> IO VirtualAllocation
alignment :: VirtualAllocation -> Int
$calignment :: VirtualAllocation -> Int
sizeOf :: VirtualAllocation -> Int
$csizeOf :: VirtualAllocation -> Int
Storable, VirtualAllocation
VirtualAllocation -> Zero VirtualAllocation
forall a. a -> Zero a
zero :: VirtualAllocation
$czero :: VirtualAllocation
Zero)
  deriving anyclass (Eq VirtualAllocation
Zero VirtualAllocation
Eq VirtualAllocation
-> Zero VirtualAllocation -> IsHandle VirtualAllocation
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero VirtualAllocation
$cp1IsHandle :: Eq VirtualAllocation
IsHandle)
instance Show VirtualAllocation where
  showsPrec :: Int -> VirtualAllocation -> ShowS
showsPrec Int
p (VirtualAllocation "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"VirtualAllocation 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


-- | 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.
newtype VirtualBlock = VirtualBlock Word64
  deriving newtype (VirtualBlock -> VirtualBlock -> Bool
(VirtualBlock -> VirtualBlock -> Bool)
-> (VirtualBlock -> VirtualBlock -> Bool) -> Eq VirtualBlock
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualBlock -> VirtualBlock -> Bool
$c/= :: VirtualBlock -> VirtualBlock -> Bool
== :: VirtualBlock -> VirtualBlock -> Bool
$c== :: VirtualBlock -> VirtualBlock -> Bool
Eq, Eq VirtualBlock
Eq VirtualBlock
-> (VirtualBlock -> VirtualBlock -> Ordering)
-> (VirtualBlock -> VirtualBlock -> Bool)
-> (VirtualBlock -> VirtualBlock -> Bool)
-> (VirtualBlock -> VirtualBlock -> Bool)
-> (VirtualBlock -> VirtualBlock -> Bool)
-> (VirtualBlock -> VirtualBlock -> VirtualBlock)
-> (VirtualBlock -> VirtualBlock -> VirtualBlock)
-> Ord VirtualBlock
VirtualBlock -> VirtualBlock -> Bool
VirtualBlock -> VirtualBlock -> Ordering
VirtualBlock -> VirtualBlock -> VirtualBlock
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: VirtualBlock -> VirtualBlock -> VirtualBlock
$cmin :: VirtualBlock -> VirtualBlock -> VirtualBlock
max :: VirtualBlock -> VirtualBlock -> VirtualBlock
$cmax :: VirtualBlock -> VirtualBlock -> VirtualBlock
>= :: VirtualBlock -> VirtualBlock -> Bool
$c>= :: VirtualBlock -> VirtualBlock -> Bool
> :: VirtualBlock -> VirtualBlock -> Bool
$c> :: VirtualBlock -> VirtualBlock -> Bool
<= :: VirtualBlock -> VirtualBlock -> Bool
$c<= :: VirtualBlock -> VirtualBlock -> Bool
< :: VirtualBlock -> VirtualBlock -> Bool
$c< :: VirtualBlock -> VirtualBlock -> Bool
compare :: VirtualBlock -> VirtualBlock -> Ordering
$ccompare :: VirtualBlock -> VirtualBlock -> Ordering
$cp1Ord :: Eq VirtualBlock
Ord, Ptr b -> Int -> IO VirtualBlock
Ptr b -> Int -> VirtualBlock -> IO ()
Ptr VirtualBlock -> IO VirtualBlock
Ptr VirtualBlock -> Int -> IO VirtualBlock
Ptr VirtualBlock -> Int -> VirtualBlock -> IO ()
Ptr VirtualBlock -> VirtualBlock -> IO ()
VirtualBlock -> Int
(VirtualBlock -> Int)
-> (VirtualBlock -> Int)
-> (Ptr VirtualBlock -> Int -> IO VirtualBlock)
-> (Ptr VirtualBlock -> Int -> VirtualBlock -> IO ())
-> (forall b. Ptr b -> Int -> IO VirtualBlock)
-> (forall b. Ptr b -> Int -> VirtualBlock -> IO ())
-> (Ptr VirtualBlock -> IO VirtualBlock)
-> (Ptr VirtualBlock -> VirtualBlock -> IO ())
-> Storable VirtualBlock
forall b. Ptr b -> Int -> IO VirtualBlock
forall b. Ptr b -> Int -> VirtualBlock -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr VirtualBlock -> VirtualBlock -> IO ()
$cpoke :: Ptr VirtualBlock -> VirtualBlock -> IO ()
peek :: Ptr VirtualBlock -> IO VirtualBlock
$cpeek :: Ptr VirtualBlock -> IO VirtualBlock
pokeByteOff :: Ptr b -> Int -> VirtualBlock -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> VirtualBlock -> IO ()
peekByteOff :: Ptr b -> Int -> IO VirtualBlock
$cpeekByteOff :: forall b. Ptr b -> Int -> IO VirtualBlock
pokeElemOff :: Ptr VirtualBlock -> Int -> VirtualBlock -> IO ()
$cpokeElemOff :: Ptr VirtualBlock -> Int -> VirtualBlock -> IO ()
peekElemOff :: Ptr VirtualBlock -> Int -> IO VirtualBlock
$cpeekElemOff :: Ptr VirtualBlock -> Int -> IO VirtualBlock
alignment :: VirtualBlock -> Int
$calignment :: VirtualBlock -> Int
sizeOf :: VirtualBlock -> Int
$csizeOf :: VirtualBlock -> Int
Storable, VirtualBlock
VirtualBlock -> Zero VirtualBlock
forall a. a -> Zero a
zero :: VirtualBlock
$czero :: VirtualBlock
Zero)
  deriving anyclass (Eq VirtualBlock
Zero VirtualBlock
Eq VirtualBlock -> Zero VirtualBlock -> IsHandle VirtualBlock
forall a. Eq a -> Zero a -> IsHandle a
$cp2IsHandle :: Zero VirtualBlock
$cp1IsHandle :: Eq VirtualBlock
IsHandle)
instance Show VirtualBlock where
  showsPrec :: Int -> VirtualBlock -> ShowS
showsPrec Int
p (VirtualBlock "offset" ::: DeviceSize
x) = Bool -> ShowS -> ShowS
showParen (Int
p Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
11) (String -> ShowS
showString String
"VirtualBlock 0x" ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ("offset" ::: DeviceSize) -> ShowS
forall a. (Integral a, Show a) => a -> ShowS
showHex "offset" ::: DeviceSize
x)


type FN_vmaAllocateDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO ()
-- No documentation found for TopLevel "PFN_vmaAllocateDeviceMemoryFunction"
type PFN_vmaAllocateDeviceMemoryFunction = FunPtr FN_vmaAllocateDeviceMemoryFunction


type FN_vmaFreeDeviceMemoryFunction = Allocator -> ("memoryType" ::: Word32) -> DeviceMemory -> DeviceSize -> ("pUserData" ::: Ptr ()) -> IO ()
-- No documentation found for TopLevel "PFN_vmaFreeDeviceMemoryFunction"
type PFN_vmaFreeDeviceMemoryFunction = FunPtr FN_vmaFreeDeviceMemoryFunction


-- | 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/.
data DeviceMemoryCallbacks = DeviceMemoryCallbacks
  { -- | Optional, can be null.
    DeviceMemoryCallbacks -> PFN_vmaAllocateDeviceMemoryFunction
pfnAllocate :: PFN_vmaAllocateDeviceMemoryFunction
  , -- | Optional, can be null.
    DeviceMemoryCallbacks -> PFN_vmaAllocateDeviceMemoryFunction
pfnFree :: PFN_vmaFreeDeviceMemoryFunction
  , -- | Optional, can be null.
    DeviceMemoryCallbacks -> "userData" ::: Ptr ()
userData :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DeviceMemoryCallbacks)
#endif
deriving instance Show DeviceMemoryCallbacks

instance ToCStruct DeviceMemoryCallbacks where
  withCStruct :: DeviceMemoryCallbacks
-> (Ptr DeviceMemoryCallbacks -> IO b) -> IO b
withCStruct DeviceMemoryCallbacks
x Ptr DeviceMemoryCallbacks -> IO b
f = Int -> (Ptr DeviceMemoryCallbacks -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr DeviceMemoryCallbacks -> IO b) -> IO b)
-> (Ptr DeviceMemoryCallbacks -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr DeviceMemoryCallbacks
p -> Ptr DeviceMemoryCallbacks -> DeviceMemoryCallbacks -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DeviceMemoryCallbacks
p DeviceMemoryCallbacks
x (Ptr DeviceMemoryCallbacks -> IO b
f Ptr DeviceMemoryCallbacks
p)
  pokeCStruct :: Ptr DeviceMemoryCallbacks -> DeviceMemoryCallbacks -> IO b -> IO b
pokeCStruct Ptr DeviceMemoryCallbacks
p DeviceMemoryCallbacks{"userData" ::: Ptr ()
PFN_vmaAllocateDeviceMemoryFunction
userData :: "userData" ::: Ptr ()
pfnFree :: PFN_vmaAllocateDeviceMemoryFunction
pfnAllocate :: PFN_vmaAllocateDeviceMemoryFunction
$sel:userData:DeviceMemoryCallbacks :: DeviceMemoryCallbacks -> "userData" ::: Ptr ()
$sel:pfnFree:DeviceMemoryCallbacks :: DeviceMemoryCallbacks -> PFN_vmaAllocateDeviceMemoryFunction
$sel:pfnAllocate:DeviceMemoryCallbacks :: DeviceMemoryCallbacks -> PFN_vmaAllocateDeviceMemoryFunction
..} IO b
f = do
    Ptr PFN_vmaAllocateDeviceMemoryFunction
-> PFN_vmaAllocateDeviceMemoryFunction -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks
-> Int -> Ptr PFN_vmaAllocateDeviceMemoryFunction
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr PFN_vmaAllocateDeviceMemoryFunction)) (PFN_vmaAllocateDeviceMemoryFunction
pfnAllocate)
    Ptr PFN_vmaAllocateDeviceMemoryFunction
-> PFN_vmaAllocateDeviceMemoryFunction -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks
-> Int -> Ptr PFN_vmaAllocateDeviceMemoryFunction
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr PFN_vmaFreeDeviceMemoryFunction)) (PFN_vmaAllocateDeviceMemoryFunction
pfnFree)
    Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
userData)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr DeviceMemoryCallbacks -> IO b -> IO b
pokeZeroCStruct Ptr DeviceMemoryCallbacks
_ IO b
f = IO b
f

instance FromCStruct DeviceMemoryCallbacks where
  peekCStruct :: Ptr DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
peekCStruct Ptr DeviceMemoryCallbacks
p = do
    PFN_vmaAllocateDeviceMemoryFunction
pfnAllocate <- Ptr PFN_vmaAllocateDeviceMemoryFunction
-> IO PFN_vmaAllocateDeviceMemoryFunction
forall a. Storable a => Ptr a -> IO a
peek @PFN_vmaAllocateDeviceMemoryFunction ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks
-> Int -> Ptr PFN_vmaAllocateDeviceMemoryFunction
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr PFN_vmaAllocateDeviceMemoryFunction))
    PFN_vmaAllocateDeviceMemoryFunction
pfnFree <- Ptr PFN_vmaAllocateDeviceMemoryFunction
-> IO PFN_vmaAllocateDeviceMemoryFunction
forall a. Storable a => Ptr a -> IO a
peek @PFN_vmaFreeDeviceMemoryFunction ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks
-> Int -> Ptr PFN_vmaAllocateDeviceMemoryFunction
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr PFN_vmaFreeDeviceMemoryFunction))
    "userData" ::: Ptr ()
pUserData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr DeviceMemoryCallbacks
p Ptr DeviceMemoryCallbacks -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr ())))
    DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks)
-> DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
forall a b. (a -> b) -> a -> b
$ PFN_vmaAllocateDeviceMemoryFunction
-> PFN_vmaAllocateDeviceMemoryFunction
-> ("userData" ::: Ptr ())
-> DeviceMemoryCallbacks
DeviceMemoryCallbacks
             PFN_vmaAllocateDeviceMemoryFunction
pfnAllocate PFN_vmaAllocateDeviceMemoryFunction
pfnFree "userData" ::: Ptr ()
pUserData

instance Storable DeviceMemoryCallbacks where
  sizeOf :: DeviceMemoryCallbacks -> Int
sizeOf ~DeviceMemoryCallbacks
_ = Int
24
  alignment :: DeviceMemoryCallbacks -> Int
alignment ~DeviceMemoryCallbacks
_ = Int
8
  peek :: Ptr DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
peek = Ptr DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr DeviceMemoryCallbacks -> DeviceMemoryCallbacks -> IO ()
poke Ptr DeviceMemoryCallbacks
ptr DeviceMemoryCallbacks
poked = Ptr DeviceMemoryCallbacks
-> DeviceMemoryCallbacks -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DeviceMemoryCallbacks
ptr DeviceMemoryCallbacks
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DeviceMemoryCallbacks where
  zero :: DeviceMemoryCallbacks
zero = PFN_vmaAllocateDeviceMemoryFunction
-> PFN_vmaAllocateDeviceMemoryFunction
-> ("userData" ::: Ptr ())
-> DeviceMemoryCallbacks
DeviceMemoryCallbacks
           PFN_vmaAllocateDeviceMemoryFunction
forall a. Zero a => a
zero
           PFN_vmaAllocateDeviceMemoryFunction
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero


-- | VmaVulkanFunctions
--
-- Pointers to some Vulkan functions - a subset used by the library.
--
-- Used in /VmaAllocatorCreateInfo::pVulkanFunctions/.
data VulkanFunctions = VulkanFunctions
  { -- | Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.
    VulkanFunctions -> PFN_vkGetInstanceProcAddr
vkGetInstanceProcAddr :: PFN_vkGetInstanceProcAddr
  , -- | Required when using VMA_DYNAMIC_VULKAN_FUNCTIONS.
    VulkanFunctions -> PFN_vkGetDeviceProcAddr
vkGetDeviceProcAddr :: PFN_vkGetDeviceProcAddr
  , 
    VulkanFunctions -> PFN_vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceProperties :: PFN_vkGetPhysicalDeviceProperties
  , 
    VulkanFunctions -> PFN_vkGetPhysicalDeviceMemoryProperties
vkGetPhysicalDeviceMemoryProperties :: PFN_vkGetPhysicalDeviceMemoryProperties
  , 
    VulkanFunctions -> PFN_vkAllocateMemory
vkAllocateMemory :: PFN_vkAllocateMemory
  , 
    VulkanFunctions -> PFN_vkFreeMemory
vkFreeMemory :: PFN_vkFreeMemory
  , 
    VulkanFunctions -> PFN_vkMapMemory
vkMapMemory :: PFN_vkMapMemory
  , 
    VulkanFunctions -> PFN_vkUnmapMemory
vkUnmapMemory :: PFN_vkUnmapMemory
  , 
    VulkanFunctions -> PFN_vkFlushMappedMemoryRanges
vkFlushMappedMemoryRanges :: PFN_vkFlushMappedMemoryRanges
  , 
    VulkanFunctions -> PFN_vkFlushMappedMemoryRanges
vkInvalidateMappedMemoryRanges :: PFN_vkInvalidateMappedMemoryRanges
  , 
    VulkanFunctions -> PFN_vkBindBufferMemory
vkBindBufferMemory :: PFN_vkBindBufferMemory
  , 
    VulkanFunctions -> PFN_vkBindImageMemory
vkBindImageMemory :: PFN_vkBindImageMemory
  , 
    VulkanFunctions -> PFN_vkGetBufferMemoryRequirements
vkGetBufferMemoryRequirements :: PFN_vkGetBufferMemoryRequirements
  , 
    VulkanFunctions -> PFN_vkGetImageMemoryRequirements
vkGetImageMemoryRequirements :: PFN_vkGetImageMemoryRequirements
  , 
    VulkanFunctions -> PFN_vkCreateBuffer
vkCreateBuffer :: PFN_vkCreateBuffer
  , 
    VulkanFunctions -> PFN_vkDestroyBuffer
vkDestroyBuffer :: PFN_vkDestroyBuffer
  , 
    VulkanFunctions -> PFN_vkCreateImage
vkCreateImage :: PFN_vkCreateImage
  , 
    VulkanFunctions -> PFN_vkDestroyImage
vkDestroyImage :: PFN_vkDestroyImage
  , 
    VulkanFunctions -> PFN_vkCmdCopyBuffer
vkCmdCopyBuffer :: PFN_vkCmdCopyBuffer
  , -- | Fetch \"vkGetBufferMemoryRequirements2\" on Vulkan >= 1.1, fetch
    -- \"vkGetBufferMemoryRequirements2KHR\" when using
    -- VK_KHR_dedicated_allocation extension.
    VulkanFunctions -> PFN_vkGetBufferMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR :: PFN_vkGetBufferMemoryRequirements2KHR
  , -- | Fetch \"vkGetImageMemoryRequirements2\" on Vulkan >= 1.1, fetch
    -- \"vkGetImageMemoryRequirements2KHR\" when using
    -- VK_KHR_dedicated_allocation extension.
    VulkanFunctions -> PFN_vkGetImageMemoryRequirements2KHR
vkGetImageMemoryRequirements2KHR :: PFN_vkGetImageMemoryRequirements2KHR
  , -- | Fetch \"vkBindBufferMemory2\" on Vulkan >= 1.1, fetch
    -- \"vkBindBufferMemory2KHR\" when using VK_KHR_bind_memory2 extension.
    VulkanFunctions -> PFN_vkBindBufferMemory2KHR
vkBindBufferMemory2KHR :: PFN_vkBindBufferMemory2KHR
  , -- | Fetch \"vkBindImageMemory2\" on Vulkan >= 1.1, fetch
    -- \"vkBindImageMemory2KHR\" when using VK_KHR_bind_memory2 extension.
    VulkanFunctions -> PFN_vkBindImageMemory2KHR
vkBindImageMemory2KHR :: PFN_vkBindImageMemory2KHR
  , 
    VulkanFunctions -> PFN_vkGetPhysicalDeviceMemoryProperties2KHR
vkGetPhysicalDeviceMemoryProperties2KHR :: PFN_vkGetPhysicalDeviceMemoryProperties2KHR
  }
  deriving (Typeable, VulkanFunctions -> VulkanFunctions -> Bool
(VulkanFunctions -> VulkanFunctions -> Bool)
-> (VulkanFunctions -> VulkanFunctions -> Bool)
-> Eq VulkanFunctions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VulkanFunctions -> VulkanFunctions -> Bool
$c/= :: VulkanFunctions -> VulkanFunctions -> Bool
== :: VulkanFunctions -> VulkanFunctions -> Bool
$c== :: VulkanFunctions -> VulkanFunctions -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (VulkanFunctions)
#endif
deriving instance Show VulkanFunctions

instance ToCStruct VulkanFunctions where
  withCStruct :: VulkanFunctions -> (Ptr VulkanFunctions -> IO b) -> IO b
withCStruct VulkanFunctions
x Ptr VulkanFunctions -> IO b
f = Int -> (Ptr VulkanFunctions -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
192 ((Ptr VulkanFunctions -> IO b) -> IO b)
-> (Ptr VulkanFunctions -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr VulkanFunctions
p -> Ptr VulkanFunctions -> VulkanFunctions -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr VulkanFunctions
p VulkanFunctions
x (Ptr VulkanFunctions -> IO b
f Ptr VulkanFunctions
p)
  pokeCStruct :: Ptr VulkanFunctions -> VulkanFunctions -> IO b -> IO b
pokeCStruct Ptr VulkanFunctions
p VulkanFunctions{PFN_vkCmdCopyBuffer
PFN_vkBindBufferMemory2KHR
PFN_vkBindImageMemory2KHR
PFN_vkFlushMappedMemoryRanges
PFN_vkGetDeviceProcAddr
PFN_vkGetImageMemoryRequirements2KHR
PFN_vkAllocateMemory
PFN_vkCreateImage
PFN_vkCreateBuffer
PFN_vkGetBufferMemoryRequirements2KHR
PFN_vkGetBufferMemoryRequirements
PFN_vkDestroyBuffer
PFN_vkBindBufferMemory
PFN_vkUnmapMemory
PFN_vkMapMemory
PFN_vkFreeMemory
PFN_vkGetImageMemoryRequirements
PFN_vkDestroyImage
PFN_vkBindImageMemory
PFN_vkGetInstanceProcAddr
PFN_vkGetPhysicalDeviceMemoryProperties2KHR
PFN_vkGetPhysicalDeviceMemoryProperties
PFN_vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceMemoryProperties2KHR :: PFN_vkGetPhysicalDeviceMemoryProperties2KHR
vkBindImageMemory2KHR :: PFN_vkBindImageMemory2KHR
vkBindBufferMemory2KHR :: PFN_vkBindBufferMemory2KHR
vkGetImageMemoryRequirements2KHR :: PFN_vkGetImageMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR :: PFN_vkGetBufferMemoryRequirements2KHR
vkCmdCopyBuffer :: PFN_vkCmdCopyBuffer
vkDestroyImage :: PFN_vkDestroyImage
vkCreateImage :: PFN_vkCreateImage
vkDestroyBuffer :: PFN_vkDestroyBuffer
vkCreateBuffer :: PFN_vkCreateBuffer
vkGetImageMemoryRequirements :: PFN_vkGetImageMemoryRequirements
vkGetBufferMemoryRequirements :: PFN_vkGetBufferMemoryRequirements
vkBindImageMemory :: PFN_vkBindImageMemory
vkBindBufferMemory :: PFN_vkBindBufferMemory
vkInvalidateMappedMemoryRanges :: PFN_vkFlushMappedMemoryRanges
vkFlushMappedMemoryRanges :: PFN_vkFlushMappedMemoryRanges
vkUnmapMemory :: PFN_vkUnmapMemory
vkMapMemory :: PFN_vkMapMemory
vkFreeMemory :: PFN_vkFreeMemory
vkAllocateMemory :: PFN_vkAllocateMemory
vkGetPhysicalDeviceMemoryProperties :: PFN_vkGetPhysicalDeviceMemoryProperties
vkGetPhysicalDeviceProperties :: PFN_vkGetPhysicalDeviceProperties
vkGetDeviceProcAddr :: PFN_vkGetDeviceProcAddr
vkGetInstanceProcAddr :: PFN_vkGetInstanceProcAddr
$sel:vkGetPhysicalDeviceMemoryProperties2KHR:VulkanFunctions :: VulkanFunctions -> PFN_vkGetPhysicalDeviceMemoryProperties2KHR
$sel:vkBindImageMemory2KHR:VulkanFunctions :: VulkanFunctions -> PFN_vkBindImageMemory2KHR
$sel:vkBindBufferMemory2KHR:VulkanFunctions :: VulkanFunctions -> PFN_vkBindBufferMemory2KHR
$sel:vkGetImageMemoryRequirements2KHR:VulkanFunctions :: VulkanFunctions -> PFN_vkGetImageMemoryRequirements2KHR
$sel:vkGetBufferMemoryRequirements2KHR:VulkanFunctions :: VulkanFunctions -> PFN_vkGetBufferMemoryRequirements2KHR
$sel:vkCmdCopyBuffer:VulkanFunctions :: VulkanFunctions -> PFN_vkCmdCopyBuffer
$sel:vkDestroyImage:VulkanFunctions :: VulkanFunctions -> PFN_vkDestroyImage
$sel:vkCreateImage:VulkanFunctions :: VulkanFunctions -> PFN_vkCreateImage
$sel:vkDestroyBuffer:VulkanFunctions :: VulkanFunctions -> PFN_vkDestroyBuffer
$sel:vkCreateBuffer:VulkanFunctions :: VulkanFunctions -> PFN_vkCreateBuffer
$sel:vkGetImageMemoryRequirements:VulkanFunctions :: VulkanFunctions -> PFN_vkGetImageMemoryRequirements
$sel:vkGetBufferMemoryRequirements:VulkanFunctions :: VulkanFunctions -> PFN_vkGetBufferMemoryRequirements
$sel:vkBindImageMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkBindImageMemory
$sel:vkBindBufferMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkBindBufferMemory
$sel:vkInvalidateMappedMemoryRanges:VulkanFunctions :: VulkanFunctions -> PFN_vkFlushMappedMemoryRanges
$sel:vkFlushMappedMemoryRanges:VulkanFunctions :: VulkanFunctions -> PFN_vkFlushMappedMemoryRanges
$sel:vkUnmapMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkUnmapMemory
$sel:vkMapMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkMapMemory
$sel:vkFreeMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkFreeMemory
$sel:vkAllocateMemory:VulkanFunctions :: VulkanFunctions -> PFN_vkAllocateMemory
$sel:vkGetPhysicalDeviceMemoryProperties:VulkanFunctions :: VulkanFunctions -> PFN_vkGetPhysicalDeviceMemoryProperties
$sel:vkGetPhysicalDeviceProperties:VulkanFunctions :: VulkanFunctions -> PFN_vkGetPhysicalDeviceProperties
$sel:vkGetDeviceProcAddr:VulkanFunctions :: VulkanFunctions -> PFN_vkGetDeviceProcAddr
$sel:vkGetInstanceProcAddr:VulkanFunctions :: VulkanFunctions -> PFN_vkGetInstanceProcAddr
..} IO b
f = do
    Ptr PFN_vkGetInstanceProcAddr -> PFN_vkGetInstanceProcAddr -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetInstanceProcAddr
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr PFN_vkGetInstanceProcAddr)) (PFN_vkGetInstanceProcAddr
vkGetInstanceProcAddr)
    Ptr PFN_vkGetDeviceProcAddr -> PFN_vkGetDeviceProcAddr -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetDeviceProcAddr
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr PFN_vkGetDeviceProcAddr)) (PFN_vkGetDeviceProcAddr
vkGetDeviceProcAddr)
    Ptr PFN_vkGetPhysicalDeviceProperties
-> PFN_vkGetPhysicalDeviceProperties -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetPhysicalDeviceProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr PFN_vkGetPhysicalDeviceProperties)) (PFN_vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceProperties)
    Ptr PFN_vkGetPhysicalDeviceMemoryProperties
-> PFN_vkGetPhysicalDeviceMemoryProperties -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetPhysicalDeviceMemoryProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr PFN_vkGetPhysicalDeviceMemoryProperties)) (PFN_vkGetPhysicalDeviceMemoryProperties
vkGetPhysicalDeviceMemoryProperties)
    Ptr PFN_vkAllocateMemory -> PFN_vkAllocateMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkAllocateMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr PFN_vkAllocateMemory)) (PFN_vkAllocateMemory
vkAllocateMemory)
    Ptr PFN_vkFreeMemory -> PFN_vkFreeMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFreeMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr PFN_vkFreeMemory)) (PFN_vkFreeMemory
vkFreeMemory)
    Ptr PFN_vkMapMemory -> PFN_vkMapMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkMapMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr PFN_vkMapMemory)) (PFN_vkMapMemory
vkMapMemory)
    Ptr PFN_vkUnmapMemory -> PFN_vkUnmapMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkUnmapMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr PFN_vkUnmapMemory)) (PFN_vkUnmapMemory
vkUnmapMemory)
    Ptr PFN_vkFlushMappedMemoryRanges
-> PFN_vkFlushMappedMemoryRanges -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFlushMappedMemoryRanges
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr PFN_vkFlushMappedMemoryRanges)) (PFN_vkFlushMappedMemoryRanges
vkFlushMappedMemoryRanges)
    Ptr PFN_vkFlushMappedMemoryRanges
-> PFN_vkFlushMappedMemoryRanges -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFlushMappedMemoryRanges
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
72 :: Ptr PFN_vkInvalidateMappedMemoryRanges)) (PFN_vkFlushMappedMemoryRanges
vkInvalidateMappedMemoryRanges)
    Ptr PFN_vkBindBufferMemory -> PFN_vkBindBufferMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindBufferMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
80 :: Ptr PFN_vkBindBufferMemory)) (PFN_vkBindBufferMemory
vkBindBufferMemory)
    Ptr PFN_vkBindImageMemory -> PFN_vkBindImageMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindImageMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
88 :: Ptr PFN_vkBindImageMemory)) (PFN_vkBindImageMemory
vkBindImageMemory)
    Ptr PFN_vkGetBufferMemoryRequirements
-> PFN_vkGetBufferMemoryRequirements -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetBufferMemoryRequirements
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
96 :: Ptr PFN_vkGetBufferMemoryRequirements)) (PFN_vkGetBufferMemoryRequirements
vkGetBufferMemoryRequirements)
    Ptr PFN_vkGetImageMemoryRequirements
-> PFN_vkGetImageMemoryRequirements -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetImageMemoryRequirements
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
104 :: Ptr PFN_vkGetImageMemoryRequirements)) (PFN_vkGetImageMemoryRequirements
vkGetImageMemoryRequirements)
    Ptr PFN_vkCreateBuffer -> PFN_vkCreateBuffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCreateBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
112 :: Ptr PFN_vkCreateBuffer)) (PFN_vkCreateBuffer
vkCreateBuffer)
    Ptr PFN_vkDestroyBuffer -> PFN_vkDestroyBuffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkDestroyBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
120 :: Ptr PFN_vkDestroyBuffer)) (PFN_vkDestroyBuffer
vkDestroyBuffer)
    Ptr PFN_vkCreateImage -> PFN_vkCreateImage -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCreateImage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
128 :: Ptr PFN_vkCreateImage)) (PFN_vkCreateImage
vkCreateImage)
    Ptr PFN_vkDestroyImage -> PFN_vkDestroyImage -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkDestroyImage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
136 :: Ptr PFN_vkDestroyImage)) (PFN_vkDestroyImage
vkDestroyImage)
    Ptr PFN_vkCmdCopyBuffer -> PFN_vkCmdCopyBuffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCmdCopyBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
144 :: Ptr PFN_vkCmdCopyBuffer)) (PFN_vkCmdCopyBuffer
vkCmdCopyBuffer)
    Ptr PFN_vkGetBufferMemoryRequirements2KHR
-> PFN_vkGetBufferMemoryRequirements2KHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetBufferMemoryRequirements2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
152 :: Ptr PFN_vkGetBufferMemoryRequirements2KHR)) (PFN_vkGetBufferMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR)
    Ptr PFN_vkGetImageMemoryRequirements2KHR
-> PFN_vkGetImageMemoryRequirements2KHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetImageMemoryRequirements2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
160 :: Ptr PFN_vkGetImageMemoryRequirements2KHR)) (PFN_vkGetImageMemoryRequirements2KHR
vkGetImageMemoryRequirements2KHR)
    Ptr PFN_vkBindBufferMemory2KHR
-> PFN_vkBindBufferMemory2KHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindBufferMemory2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
168 :: Ptr PFN_vkBindBufferMemory2KHR)) (PFN_vkBindBufferMemory2KHR
vkBindBufferMemory2KHR)
    Ptr PFN_vkBindImageMemory2KHR -> PFN_vkBindImageMemory2KHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindImageMemory2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
176 :: Ptr PFN_vkBindImageMemory2KHR)) (PFN_vkBindImageMemory2KHR
vkBindImageMemory2KHR)
    Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR
-> PFN_vkGetPhysicalDeviceMemoryProperties2KHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
184 :: Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR)) (PFN_vkGetPhysicalDeviceMemoryProperties2KHR
vkGetPhysicalDeviceMemoryProperties2KHR)
    IO b
f
  cStructSize :: Int
cStructSize = Int
192
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr VulkanFunctions -> IO b -> IO b
pokeZeroCStruct Ptr VulkanFunctions
_ IO b
f = IO b
f

instance FromCStruct VulkanFunctions where
  peekCStruct :: Ptr VulkanFunctions -> IO VulkanFunctions
peekCStruct Ptr VulkanFunctions
p = do
    PFN_vkGetInstanceProcAddr
vkGetInstanceProcAddr <- Ptr PFN_vkGetInstanceProcAddr -> IO PFN_vkGetInstanceProcAddr
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetInstanceProcAddr ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetInstanceProcAddr
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr PFN_vkGetInstanceProcAddr))
    PFN_vkGetDeviceProcAddr
vkGetDeviceProcAddr <- Ptr PFN_vkGetDeviceProcAddr -> IO PFN_vkGetDeviceProcAddr
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetDeviceProcAddr ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetDeviceProcAddr
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr PFN_vkGetDeviceProcAddr))
    PFN_vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceProperties <- Ptr PFN_vkGetPhysicalDeviceProperties
-> IO PFN_vkGetPhysicalDeviceProperties
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetPhysicalDeviceProperties ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetPhysicalDeviceProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr PFN_vkGetPhysicalDeviceProperties))
    PFN_vkGetPhysicalDeviceMemoryProperties
vkGetPhysicalDeviceMemoryProperties <- Ptr PFN_vkGetPhysicalDeviceMemoryProperties
-> IO PFN_vkGetPhysicalDeviceMemoryProperties
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetPhysicalDeviceMemoryProperties ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetPhysicalDeviceMemoryProperties
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr PFN_vkGetPhysicalDeviceMemoryProperties))
    PFN_vkAllocateMemory
vkAllocateMemory <- Ptr PFN_vkAllocateMemory -> IO PFN_vkAllocateMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkAllocateMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkAllocateMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr PFN_vkAllocateMemory))
    PFN_vkFreeMemory
vkFreeMemory <- Ptr PFN_vkFreeMemory -> IO PFN_vkFreeMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkFreeMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFreeMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr PFN_vkFreeMemory))
    PFN_vkMapMemory
vkMapMemory <- Ptr PFN_vkMapMemory -> IO PFN_vkMapMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkMapMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkMapMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr PFN_vkMapMemory))
    PFN_vkUnmapMemory
vkUnmapMemory <- Ptr PFN_vkUnmapMemory -> IO PFN_vkUnmapMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkUnmapMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkUnmapMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr PFN_vkUnmapMemory))
    PFN_vkFlushMappedMemoryRanges
vkFlushMappedMemoryRanges <- Ptr PFN_vkFlushMappedMemoryRanges
-> IO PFN_vkFlushMappedMemoryRanges
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkFlushMappedMemoryRanges ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFlushMappedMemoryRanges
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr PFN_vkFlushMappedMemoryRanges))
    PFN_vkFlushMappedMemoryRanges
vkInvalidateMappedMemoryRanges <- Ptr PFN_vkFlushMappedMemoryRanges
-> IO PFN_vkFlushMappedMemoryRanges
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkInvalidateMappedMemoryRanges ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkFlushMappedMemoryRanges
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
72 :: Ptr PFN_vkInvalidateMappedMemoryRanges))
    PFN_vkBindBufferMemory
vkBindBufferMemory <- Ptr PFN_vkBindBufferMemory -> IO PFN_vkBindBufferMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkBindBufferMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindBufferMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
80 :: Ptr PFN_vkBindBufferMemory))
    PFN_vkBindImageMemory
vkBindImageMemory <- Ptr PFN_vkBindImageMemory -> IO PFN_vkBindImageMemory
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkBindImageMemory ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindImageMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
88 :: Ptr PFN_vkBindImageMemory))
    PFN_vkGetBufferMemoryRequirements
vkGetBufferMemoryRequirements <- Ptr PFN_vkGetBufferMemoryRequirements
-> IO PFN_vkGetBufferMemoryRequirements
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetBufferMemoryRequirements ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetBufferMemoryRequirements
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
96 :: Ptr PFN_vkGetBufferMemoryRequirements))
    PFN_vkGetImageMemoryRequirements
vkGetImageMemoryRequirements <- Ptr PFN_vkGetImageMemoryRequirements
-> IO PFN_vkGetImageMemoryRequirements
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetImageMemoryRequirements ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkGetImageMemoryRequirements
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
104 :: Ptr PFN_vkGetImageMemoryRequirements))
    PFN_vkCreateBuffer
vkCreateBuffer <- Ptr PFN_vkCreateBuffer -> IO PFN_vkCreateBuffer
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkCreateBuffer ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCreateBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
112 :: Ptr PFN_vkCreateBuffer))
    PFN_vkDestroyBuffer
vkDestroyBuffer <- Ptr PFN_vkDestroyBuffer -> IO PFN_vkDestroyBuffer
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkDestroyBuffer ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkDestroyBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
120 :: Ptr PFN_vkDestroyBuffer))
    PFN_vkCreateImage
vkCreateImage <- Ptr PFN_vkCreateImage -> IO PFN_vkCreateImage
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkCreateImage ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCreateImage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
128 :: Ptr PFN_vkCreateImage))
    PFN_vkDestroyImage
vkDestroyImage <- Ptr PFN_vkDestroyImage -> IO PFN_vkDestroyImage
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkDestroyImage ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkDestroyImage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
136 :: Ptr PFN_vkDestroyImage))
    PFN_vkCmdCopyBuffer
vkCmdCopyBuffer <- Ptr PFN_vkCmdCopyBuffer -> IO PFN_vkCmdCopyBuffer
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkCmdCopyBuffer ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkCmdCopyBuffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
144 :: Ptr PFN_vkCmdCopyBuffer))
    PFN_vkGetBufferMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR <- Ptr PFN_vkGetBufferMemoryRequirements2KHR
-> IO PFN_vkGetBufferMemoryRequirements2KHR
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetBufferMemoryRequirements2KHR ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetBufferMemoryRequirements2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
152 :: Ptr PFN_vkGetBufferMemoryRequirements2KHR))
    PFN_vkGetImageMemoryRequirements2KHR
vkGetImageMemoryRequirements2KHR <- Ptr PFN_vkGetImageMemoryRequirements2KHR
-> IO PFN_vkGetImageMemoryRequirements2KHR
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetImageMemoryRequirements2KHR ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetImageMemoryRequirements2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
160 :: Ptr PFN_vkGetImageMemoryRequirements2KHR))
    PFN_vkBindBufferMemory2KHR
vkBindBufferMemory2KHR <- Ptr PFN_vkBindBufferMemory2KHR -> IO PFN_vkBindBufferMemory2KHR
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkBindBufferMemory2KHR ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindBufferMemory2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
168 :: Ptr PFN_vkBindBufferMemory2KHR))
    PFN_vkBindImageMemory2KHR
vkBindImageMemory2KHR <- Ptr PFN_vkBindImageMemory2KHR -> IO PFN_vkBindImageMemory2KHR
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkBindImageMemory2KHR ((Ptr VulkanFunctions
p Ptr VulkanFunctions -> Int -> Ptr PFN_vkBindImageMemory2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
176 :: Ptr PFN_vkBindImageMemory2KHR))
    PFN_vkGetPhysicalDeviceMemoryProperties2KHR
vkGetPhysicalDeviceMemoryProperties2KHR <- Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR
-> IO PFN_vkGetPhysicalDeviceMemoryProperties2KHR
forall a. Storable a => Ptr a -> IO a
peek @PFN_vkGetPhysicalDeviceMemoryProperties2KHR ((Ptr VulkanFunctions
p Ptr VulkanFunctions
-> Int -> Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
184 :: Ptr PFN_vkGetPhysicalDeviceMemoryProperties2KHR))
    VulkanFunctions -> IO VulkanFunctions
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VulkanFunctions -> IO VulkanFunctions)
-> VulkanFunctions -> IO VulkanFunctions
forall a b. (a -> b) -> a -> b
$ PFN_vkGetInstanceProcAddr
-> PFN_vkGetDeviceProcAddr
-> PFN_vkGetPhysicalDeviceProperties
-> PFN_vkGetPhysicalDeviceMemoryProperties
-> PFN_vkAllocateMemory
-> PFN_vkFreeMemory
-> PFN_vkMapMemory
-> PFN_vkUnmapMemory
-> PFN_vkFlushMappedMemoryRanges
-> PFN_vkFlushMappedMemoryRanges
-> PFN_vkBindBufferMemory
-> PFN_vkBindImageMemory
-> PFN_vkGetBufferMemoryRequirements
-> PFN_vkGetImageMemoryRequirements
-> PFN_vkCreateBuffer
-> PFN_vkDestroyBuffer
-> PFN_vkCreateImage
-> PFN_vkDestroyImage
-> PFN_vkCmdCopyBuffer
-> PFN_vkGetBufferMemoryRequirements2KHR
-> PFN_vkGetImageMemoryRequirements2KHR
-> PFN_vkBindBufferMemory2KHR
-> PFN_vkBindImageMemory2KHR
-> PFN_vkGetPhysicalDeviceMemoryProperties2KHR
-> VulkanFunctions
VulkanFunctions
             PFN_vkGetInstanceProcAddr
vkGetInstanceProcAddr PFN_vkGetDeviceProcAddr
vkGetDeviceProcAddr PFN_vkGetPhysicalDeviceProperties
vkGetPhysicalDeviceProperties PFN_vkGetPhysicalDeviceMemoryProperties
vkGetPhysicalDeviceMemoryProperties PFN_vkAllocateMemory
vkAllocateMemory PFN_vkFreeMemory
vkFreeMemory PFN_vkMapMemory
vkMapMemory PFN_vkUnmapMemory
vkUnmapMemory PFN_vkFlushMappedMemoryRanges
vkFlushMappedMemoryRanges PFN_vkFlushMappedMemoryRanges
vkInvalidateMappedMemoryRanges PFN_vkBindBufferMemory
vkBindBufferMemory PFN_vkBindImageMemory
vkBindImageMemory PFN_vkGetBufferMemoryRequirements
vkGetBufferMemoryRequirements PFN_vkGetImageMemoryRequirements
vkGetImageMemoryRequirements PFN_vkCreateBuffer
vkCreateBuffer PFN_vkDestroyBuffer
vkDestroyBuffer PFN_vkCreateImage
vkCreateImage PFN_vkDestroyImage
vkDestroyImage PFN_vkCmdCopyBuffer
vkCmdCopyBuffer PFN_vkGetBufferMemoryRequirements2KHR
vkGetBufferMemoryRequirements2KHR PFN_vkGetImageMemoryRequirements2KHR
vkGetImageMemoryRequirements2KHR PFN_vkBindBufferMemory2KHR
vkBindBufferMemory2KHR PFN_vkBindImageMemory2KHR
vkBindImageMemory2KHR PFN_vkGetPhysicalDeviceMemoryProperties2KHR
vkGetPhysicalDeviceMemoryProperties2KHR

instance Storable VulkanFunctions where
  sizeOf :: VulkanFunctions -> Int
sizeOf ~VulkanFunctions
_ = Int
192
  alignment :: VulkanFunctions -> Int
alignment ~VulkanFunctions
_ = Int
8
  peek :: Ptr VulkanFunctions -> IO VulkanFunctions
peek = Ptr VulkanFunctions -> IO VulkanFunctions
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr VulkanFunctions -> VulkanFunctions -> IO ()
poke Ptr VulkanFunctions
ptr VulkanFunctions
poked = Ptr VulkanFunctions -> VulkanFunctions -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr VulkanFunctions
ptr VulkanFunctions
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero VulkanFunctions where
  zero :: VulkanFunctions
zero = PFN_vkGetInstanceProcAddr
-> PFN_vkGetDeviceProcAddr
-> PFN_vkGetPhysicalDeviceProperties
-> PFN_vkGetPhysicalDeviceMemoryProperties
-> PFN_vkAllocateMemory
-> PFN_vkFreeMemory
-> PFN_vkMapMemory
-> PFN_vkUnmapMemory
-> PFN_vkFlushMappedMemoryRanges
-> PFN_vkFlushMappedMemoryRanges
-> PFN_vkBindBufferMemory
-> PFN_vkBindImageMemory
-> PFN_vkGetBufferMemoryRequirements
-> PFN_vkGetImageMemoryRequirements
-> PFN_vkCreateBuffer
-> PFN_vkDestroyBuffer
-> PFN_vkCreateImage
-> PFN_vkDestroyImage
-> PFN_vkCmdCopyBuffer
-> PFN_vkGetBufferMemoryRequirements2KHR
-> PFN_vkGetImageMemoryRequirements2KHR
-> PFN_vkBindBufferMemory2KHR
-> PFN_vkBindImageMemory2KHR
-> PFN_vkGetPhysicalDeviceMemoryProperties2KHR
-> VulkanFunctions
VulkanFunctions
           PFN_vkGetInstanceProcAddr
forall a. Zero a => a
zero
           PFN_vkGetDeviceProcAddr
forall a. Zero a => a
zero
           PFN_vkGetPhysicalDeviceProperties
forall a. Zero a => a
zero
           PFN_vkGetPhysicalDeviceMemoryProperties
forall a. Zero a => a
zero
           PFN_vkAllocateMemory
forall a. Zero a => a
zero
           PFN_vkFreeMemory
forall a. Zero a => a
zero
           PFN_vkMapMemory
forall a. Zero a => a
zero
           PFN_vkUnmapMemory
forall a. Zero a => a
zero
           PFN_vkFlushMappedMemoryRanges
forall a. Zero a => a
zero
           PFN_vkFlushMappedMemoryRanges
forall a. Zero a => a
zero
           PFN_vkBindBufferMemory
forall a. Zero a => a
zero
           PFN_vkBindImageMemory
forall a. Zero a => a
zero
           PFN_vkGetBufferMemoryRequirements
forall a. Zero a => a
zero
           PFN_vkGetImageMemoryRequirements
forall a. Zero a => a
zero
           PFN_vkCreateBuffer
forall a. Zero a => a
zero
           PFN_vkDestroyBuffer
forall a. Zero a => a
zero
           PFN_vkCreateImage
forall a. Zero a => a
zero
           PFN_vkDestroyImage
forall a. Zero a => a
zero
           PFN_vkCmdCopyBuffer
forall a. Zero a => a
zero
           PFN_vkGetBufferMemoryRequirements2KHR
forall a. Zero a => a
zero
           PFN_vkGetImageMemoryRequirements2KHR
forall a. Zero a => a
zero
           PFN_vkBindBufferMemory2KHR
forall a. Zero a => a
zero
           PFN_vkBindImageMemory2KHR
forall a. Zero a => a
zero
           PFN_vkGetPhysicalDeviceMemoryProperties2KHR
forall a. Zero a => a
zero


-- | VmaAllocatorCreateInfo
--
-- Description of a Allocator to be created.
data AllocatorCreateInfo = AllocatorCreateInfo
  { -- | Flags for created allocator. Use 'AllocatorCreateFlagBits' enum.
    AllocatorCreateInfo -> AllocatorCreateFlagBits
flags :: AllocatorCreateFlags
  , -- | Vulkan physical device.
    --
    -- It must be valid throughout whole lifetime of created allocator.
    AllocatorCreateInfo -> Ptr PhysicalDevice_T
physicalDevice :: Ptr PhysicalDevice_T
  , -- | Vulkan device.
    --
    -- It must be valid throughout whole lifetime of created allocator.
    AllocatorCreateInfo -> Ptr Device_T
device :: Ptr Device_T
  , -- | Preferred size of a single @VkDeviceMemory@ block to be allocated from
    -- large heaps > 1 GiB. Optional.
    --
    -- Set to 0 to use default, which is currently 256 MiB.
    AllocatorCreateInfo -> "offset" ::: DeviceSize
preferredLargeHeapBlockSize :: DeviceSize
  , -- | Custom CPU memory allocation callbacks. Optional.
    --
    -- Optional, can be null. When specified, will also be used for all
    -- CPU-side memory allocations.
    AllocatorCreateInfo -> Maybe AllocationCallbacks
allocationCallbacks :: Maybe AllocationCallbacks
  , -- | Informative callbacks for @vkAllocateMemory@, @vkFreeMemory@. Optional.
    --
    -- Optional, can be null.
    AllocatorCreateInfo -> Maybe DeviceMemoryCallbacks
deviceMemoryCallbacks :: Maybe DeviceMemoryCallbacks
  , -- | Either null or a pointer to an array of limits on maximum number of
    -- bytes that can be allocated out of particular Vulkan memory heap.
    --
    -- If not NULL, it must be a pointer to an array of
    -- @VkPhysicalDeviceMemoryProperties::memoryHeapCount@ elements, defining
    -- limit on maximum number of bytes that can be allocated out of particular
    -- Vulkan memory heap.
    --
    -- Any of the elements may be equal to @VK_WHOLE_SIZE@, which means no
    -- limit on that heap. This is also the default in case of @pHeapSizeLimit@
    -- = NULL.
    --
    -- If there is a limit defined for a heap:
    --
    -- -   If user tries to allocate more memory from that heap using this
    --     allocator, the allocation fails with
    --     @VK_ERROR_OUT_OF_DEVICE_MEMORY@.
    --
    -- -   If the limit is smaller than heap size reported in
    --     @VkMemoryHeap::size@, the value of this limit will be reported
    --     instead when using 'getMemoryProperties'.
    --
    -- Warning! Using this feature may not be equivalent to installing a GPU
    -- with smaller amount of memory, because graphics driver doesn\'t
    -- necessary fail new allocations with @VK_ERROR_OUT_OF_DEVICE_MEMORY@
    -- result when memory capacity is exceeded. It may return success and just
    -- silently migrate some device memory blocks to system RAM. This driver
    -- behavior can also be controlled using
    -- VK_AMD_memory_overallocation_behavior extension.
    AllocatorCreateInfo -> Ptr ("offset" ::: DeviceSize)
heapSizeLimit :: Ptr DeviceSize
  , -- | Pointers to Vulkan functions. Can be null.
    --
    -- For details see /Pointers to Vulkan functions/.
    AllocatorCreateInfo -> Maybe VulkanFunctions
vulkanFunctions :: Maybe VulkanFunctions
  , -- | Handle to Vulkan instance object.
    --
    -- Starting from version 3.0.0 this member is no longer optional, it must
    -- be set!
    AllocatorCreateInfo -> Ptr Instance_T
instance' :: Ptr Instance_T
  , -- | Optional. The highest version of Vulkan that the application is designed
    -- to use.
    --
    -- It must be a value in the format as created by macro @VK_MAKE_VERSION@
    -- or a constant like: @VK_API_VERSION_1_1@, @VK_API_VERSION_1_0@. The
    -- patch version number specified is ignored. Only the major and minor
    -- versions are considered. It must be less or equal (preferably equal) to
    -- value as passed to @vkCreateInstance@ as
    -- @VkApplicationInfo::apiVersion@. Only versions 1.0, 1.1, 1.2, 1.3 are
    -- supported by the current implementation. Leaving it initialized to zero
    -- is equivalent to @VK_API_VERSION_1_0@.
    AllocatorCreateInfo -> "memoryTypeIndex" ::: Word32
vulkanApiVersion :: Word32
  , -- | Either null or a pointer to an array of external memory handle types for
    -- each Vulkan memory type.
    --
    -- If not NULL, it must be a pointer to an array of
    -- @VkPhysicalDeviceMemoryProperties::memoryTypeCount@ elements, defining
    -- external memory handle types of particular Vulkan memory type, to be
    -- passed using @VkExportMemoryAllocateInfoKHR@.
    --
    -- Any of the elements may be equal to 0, which means not to use
    -- @VkExportMemoryAllocateInfoKHR@ on this memory type. This is also the
    -- default in case of @pTypeExternalMemoryHandleTypes@ = NULL.
    AllocatorCreateInfo -> Ptr ExternalMemoryHandleTypeFlagsKHR
typeExternalMemoryHandleTypes :: Ptr ExternalMemoryHandleTypeFlagsKHR
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (AllocatorCreateInfo)
#endif
deriving instance Show AllocatorCreateInfo

instance ToCStruct AllocatorCreateInfo where
  withCStruct :: AllocatorCreateInfo -> (Ptr AllocatorCreateInfo -> IO b) -> IO b
withCStruct AllocatorCreateInfo
x Ptr AllocatorCreateInfo -> IO b
f = Int -> (Ptr AllocatorCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
88 ((Ptr AllocatorCreateInfo -> IO b) -> IO b)
-> (Ptr AllocatorCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr AllocatorCreateInfo
p -> Ptr AllocatorCreateInfo -> AllocatorCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocatorCreateInfo
p AllocatorCreateInfo
x (Ptr AllocatorCreateInfo -> IO b
f Ptr AllocatorCreateInfo
p)
  pokeCStruct :: Ptr AllocatorCreateInfo -> AllocatorCreateInfo -> IO b -> IO b
pokeCStruct Ptr AllocatorCreateInfo
p AllocatorCreateInfo{Maybe AllocationCallbacks
Maybe VulkanFunctions
Maybe DeviceMemoryCallbacks
"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
Ptr ("offset" ::: DeviceSize)
Ptr ExternalMemoryHandleTypeFlagsKHR
Ptr Device_T
Ptr Instance_T
Ptr PhysicalDevice_T
AllocatorCreateFlagBits
typeExternalMemoryHandleTypes :: Ptr ExternalMemoryHandleTypeFlagsKHR
vulkanApiVersion :: "memoryTypeIndex" ::: Word32
instance' :: Ptr Instance_T
vulkanFunctions :: Maybe VulkanFunctions
heapSizeLimit :: Ptr ("offset" ::: DeviceSize)
deviceMemoryCallbacks :: Maybe DeviceMemoryCallbacks
allocationCallbacks :: Maybe AllocationCallbacks
preferredLargeHeapBlockSize :: "offset" ::: DeviceSize
device :: Ptr Device_T
physicalDevice :: Ptr PhysicalDevice_T
flags :: AllocatorCreateFlagBits
$sel:typeExternalMemoryHandleTypes:AllocatorCreateInfo :: AllocatorCreateInfo -> Ptr ExternalMemoryHandleTypeFlagsKHR
$sel:vulkanApiVersion:AllocatorCreateInfo :: AllocatorCreateInfo -> "memoryTypeIndex" ::: Word32
$sel:instance':AllocatorCreateInfo :: AllocatorCreateInfo -> Ptr Instance_T
$sel:vulkanFunctions:AllocatorCreateInfo :: AllocatorCreateInfo -> Maybe VulkanFunctions
$sel:heapSizeLimit:AllocatorCreateInfo :: AllocatorCreateInfo -> Ptr ("offset" ::: DeviceSize)
$sel:deviceMemoryCallbacks:AllocatorCreateInfo :: AllocatorCreateInfo -> Maybe DeviceMemoryCallbacks
$sel:allocationCallbacks:AllocatorCreateInfo :: AllocatorCreateInfo -> Maybe AllocationCallbacks
$sel:preferredLargeHeapBlockSize:AllocatorCreateInfo :: AllocatorCreateInfo -> "offset" ::: DeviceSize
$sel:device:AllocatorCreateInfo :: AllocatorCreateInfo -> Ptr Device_T
$sel:physicalDevice:AllocatorCreateInfo :: AllocatorCreateInfo -> Ptr PhysicalDevice_T
$sel:flags:AllocatorCreateInfo :: AllocatorCreateInfo -> AllocatorCreateFlagBits
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr AllocatorCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocatorCreateFlags)) (AllocatorCreateFlagBits
flags)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T))) (Ptr PhysicalDevice_T
physicalDevice)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr Device_T) -> Ptr Device_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T))) (Ptr Device_T
device)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
preferredLargeHeapBlockSize)
    Ptr AllocationCallbacks
pAllocationCallbacks'' <- case (Maybe AllocationCallbacks
allocationCallbacks) of
      Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks -> ContT b IO (Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
      Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO b) -> IO b)
 -> ContT b IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr AllocationCallbacks) -> Ptr AllocationCallbacks -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr AllocationCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr AllocationCallbacks))) Ptr AllocationCallbacks
pAllocationCallbacks''
    Ptr DeviceMemoryCallbacks
pDeviceMemoryCallbacks'' <- case (Maybe DeviceMemoryCallbacks
deviceMemoryCallbacks) of
      Maybe DeviceMemoryCallbacks
Nothing -> Ptr DeviceMemoryCallbacks -> ContT b IO (Ptr DeviceMemoryCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr DeviceMemoryCallbacks
forall a. Ptr a
nullPtr
      Just DeviceMemoryCallbacks
j -> ((Ptr DeviceMemoryCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr DeviceMemoryCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DeviceMemoryCallbacks -> IO b) -> IO b)
 -> ContT b IO (Ptr DeviceMemoryCallbacks))
-> ((Ptr DeviceMemoryCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr DeviceMemoryCallbacks)
forall a b. (a -> b) -> a -> b
$ DeviceMemoryCallbacks
-> (Ptr DeviceMemoryCallbacks -> IO b) -> IO b
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DeviceMemoryCallbacks
j)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr DeviceMemoryCallbacks)
-> Ptr DeviceMemoryCallbacks -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr DeviceMemoryCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr DeviceMemoryCallbacks))) Ptr DeviceMemoryCallbacks
pDeviceMemoryCallbacks''
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ("offset" ::: DeviceSize))
-> Ptr ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr (Ptr ("offset" ::: DeviceSize))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr DeviceSize))) (Ptr ("offset" ::: DeviceSize)
heapSizeLimit)
    Ptr VulkanFunctions
pVulkanFunctions'' <- case (Maybe VulkanFunctions
vulkanFunctions) of
      Maybe VulkanFunctions
Nothing -> Ptr VulkanFunctions -> ContT b IO (Ptr VulkanFunctions)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr VulkanFunctions
forall a. Ptr a
nullPtr
      Just VulkanFunctions
j -> ((Ptr VulkanFunctions -> IO b) -> IO b)
-> ContT b IO (Ptr VulkanFunctions)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr VulkanFunctions -> IO b) -> IO b)
 -> ContT b IO (Ptr VulkanFunctions))
-> ((Ptr VulkanFunctions -> IO b) -> IO b)
-> ContT b IO (Ptr VulkanFunctions)
forall a b. (a -> b) -> a -> b
$ VulkanFunctions -> (Ptr VulkanFunctions -> IO b) -> IO b
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (VulkanFunctions
j)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr VulkanFunctions) -> Ptr VulkanFunctions -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr VulkanFunctions)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr (Ptr VulkanFunctions))) Ptr VulkanFunctions
pVulkanFunctions''
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr Instance_T) -> Ptr Instance_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr (Ptr Instance_T))) (Ptr Instance_T
instance')
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
72 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
vulkanApiVersion)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)
-> Ptr ExternalMemoryHandleTypeFlagsKHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
80 :: Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR))) (Ptr ExternalMemoryHandleTypeFlagsKHR
typeExternalMemoryHandleTypes)
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = Int
88
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr AllocatorCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr AllocatorCreateInfo
p IO b
f = do
    Ptr AllocatorCreateFlagBits -> AllocatorCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr AllocatorCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocatorCreateFlags)) (AllocatorCreateFlagBits
forall a. Zero a => a
zero)
    Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T))) (Ptr PhysicalDevice_T
forall a. Zero a => a
zero)
    Ptr (Ptr Device_T) -> Ptr Device_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T))) (Ptr Device_T
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr (Ptr Instance_T) -> Ptr Instance_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr (Ptr Instance_T))) (Ptr Instance_T
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
72 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct AllocatorCreateInfo where
  peekCStruct :: Ptr AllocatorCreateInfo -> IO AllocatorCreateInfo
peekCStruct Ptr AllocatorCreateInfo
p = do
    AllocatorCreateFlagBits
flags <- Ptr AllocatorCreateFlagBits -> IO AllocatorCreateFlagBits
forall a. Storable a => Ptr a -> IO a
peek @AllocatorCreateFlags ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr AllocatorCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocatorCreateFlags))
    Ptr PhysicalDevice_T
physicalDevice <- Ptr (Ptr PhysicalDevice_T) -> IO (Ptr PhysicalDevice_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDevice_T) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T)))
    Ptr Device_T
device <- Ptr (Ptr Device_T) -> IO (Ptr Device_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Device_T) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T)))
    "offset" ::: DeviceSize
preferredLargeHeapBlockSize <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize))
    Ptr AllocationCallbacks
pAllocationCallbacks <- Ptr (Ptr AllocationCallbacks) -> IO (Ptr AllocationCallbacks)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr AllocationCallbacks) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr AllocationCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr AllocationCallbacks)))
    Maybe AllocationCallbacks
pAllocationCallbacks' <- (Ptr AllocationCallbacks -> IO AllocationCallbacks)
-> Ptr AllocationCallbacks -> IO (Maybe AllocationCallbacks)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek (\Ptr AllocationCallbacks
j -> Ptr AllocationCallbacks -> IO AllocationCallbacks
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationCallbacks (Ptr AllocationCallbacks
j)) Ptr AllocationCallbacks
pAllocationCallbacks
    Ptr DeviceMemoryCallbacks
pDeviceMemoryCallbacks <- Ptr (Ptr DeviceMemoryCallbacks) -> IO (Ptr DeviceMemoryCallbacks)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DeviceMemoryCallbacks) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr DeviceMemoryCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr DeviceMemoryCallbacks)))
    Maybe DeviceMemoryCallbacks
pDeviceMemoryCallbacks' <- (Ptr DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks)
-> Ptr DeviceMemoryCallbacks -> IO (Maybe DeviceMemoryCallbacks)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek (\Ptr DeviceMemoryCallbacks
j -> Ptr DeviceMemoryCallbacks -> IO DeviceMemoryCallbacks
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DeviceMemoryCallbacks (Ptr DeviceMemoryCallbacks
j)) Ptr DeviceMemoryCallbacks
pDeviceMemoryCallbacks
    Ptr ("offset" ::: DeviceSize)
pHeapSizeLimit <- Ptr (Ptr ("offset" ::: DeviceSize))
-> IO (Ptr ("offset" ::: DeviceSize))
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DeviceSize) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr (Ptr ("offset" ::: DeviceSize))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr DeviceSize)))
    Ptr VulkanFunctions
pVulkanFunctions <- Ptr (Ptr VulkanFunctions) -> IO (Ptr VulkanFunctions)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr VulkanFunctions) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr VulkanFunctions)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr (Ptr VulkanFunctions)))
    Maybe VulkanFunctions
pVulkanFunctions' <- (Ptr VulkanFunctions -> IO VulkanFunctions)
-> Ptr VulkanFunctions -> IO (Maybe VulkanFunctions)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek (\Ptr VulkanFunctions
j -> Ptr VulkanFunctions -> IO VulkanFunctions
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @VulkanFunctions (Ptr VulkanFunctions
j)) Ptr VulkanFunctions
pVulkanFunctions
    Ptr Instance_T
instance' <- Ptr (Ptr Instance_T) -> IO (Ptr Instance_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Instance_T) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr (Ptr Instance_T)))
    "memoryTypeIndex" ::: Word32
vulkanApiVersion <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
72 :: Ptr Word32))
    Ptr ExternalMemoryHandleTypeFlagsKHR
pTypeExternalMemoryHandleTypes <- Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)
-> IO (Ptr ExternalMemoryHandleTypeFlagsKHR)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ExternalMemoryHandleTypeFlagsKHR) ((Ptr AllocatorCreateInfo
p Ptr AllocatorCreateInfo
-> Int -> Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
80 :: Ptr (Ptr ExternalMemoryHandleTypeFlagsKHR)))
    AllocatorCreateInfo -> IO AllocatorCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocatorCreateInfo -> IO AllocatorCreateInfo)
-> AllocatorCreateInfo -> IO AllocatorCreateInfo
forall a b. (a -> b) -> a -> b
$ AllocatorCreateFlagBits
-> Ptr PhysicalDevice_T
-> Ptr Device_T
-> ("offset" ::: DeviceSize)
-> Maybe AllocationCallbacks
-> Maybe DeviceMemoryCallbacks
-> Ptr ("offset" ::: DeviceSize)
-> Maybe VulkanFunctions
-> Ptr Instance_T
-> ("memoryTypeIndex" ::: Word32)
-> Ptr ExternalMemoryHandleTypeFlagsKHR
-> AllocatorCreateInfo
AllocatorCreateInfo
             AllocatorCreateFlagBits
flags Ptr PhysicalDevice_T
physicalDevice Ptr Device_T
device "offset" ::: DeviceSize
preferredLargeHeapBlockSize Maybe AllocationCallbacks
pAllocationCallbacks' Maybe DeviceMemoryCallbacks
pDeviceMemoryCallbacks' Ptr ("offset" ::: DeviceSize)
pHeapSizeLimit Maybe VulkanFunctions
pVulkanFunctions' Ptr Instance_T
instance' "memoryTypeIndex" ::: Word32
vulkanApiVersion Ptr ExternalMemoryHandleTypeFlagsKHR
pTypeExternalMemoryHandleTypes

instance Zero AllocatorCreateInfo where
  zero :: AllocatorCreateInfo
zero = AllocatorCreateFlagBits
-> Ptr PhysicalDevice_T
-> Ptr Device_T
-> ("offset" ::: DeviceSize)
-> Maybe AllocationCallbacks
-> Maybe DeviceMemoryCallbacks
-> Ptr ("offset" ::: DeviceSize)
-> Maybe VulkanFunctions
-> Ptr Instance_T
-> ("memoryTypeIndex" ::: Word32)
-> Ptr ExternalMemoryHandleTypeFlagsKHR
-> AllocatorCreateInfo
AllocatorCreateInfo
           AllocatorCreateFlagBits
forall a. Zero a => a
zero
           Ptr PhysicalDevice_T
forall a. Zero a => a
zero
           Ptr Device_T
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           Maybe AllocationCallbacks
forall a. Maybe a
Nothing
           Maybe DeviceMemoryCallbacks
forall a. Maybe a
Nothing
           Ptr ("offset" ::: DeviceSize)
forall a. Zero a => a
zero
           Maybe VulkanFunctions
forall a. Maybe a
Nothing
           Ptr Instance_T
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           Ptr ExternalMemoryHandleTypeFlagsKHR
forall a. Zero a => a
zero


-- | VmaAllocatorInfo
--
-- Information about existing 'Allocator' object.
data AllocatorInfo = AllocatorInfo
  { -- | Handle to Vulkan instance object.
    --
    -- This is the same value as has been passed through
    -- /VmaAllocatorCreateInfo::instance/.
    AllocatorInfo -> Ptr Instance_T
instance' :: Ptr Instance_T
  , -- | Handle to Vulkan physical device object.
    --
    -- This is the same value as has been passed through
    -- /VmaAllocatorCreateInfo::physicalDevice/.
    AllocatorInfo -> Ptr PhysicalDevice_T
physicalDevice :: Ptr PhysicalDevice_T
  , -- | Handle to Vulkan device object.
    --
    -- This is the same value as has been passed through
    -- /VmaAllocatorCreateInfo::device/.
    AllocatorInfo -> Ptr Device_T
device :: Ptr Device_T
  }
  deriving (Typeable, AllocatorInfo -> AllocatorInfo -> Bool
(AllocatorInfo -> AllocatorInfo -> Bool)
-> (AllocatorInfo -> AllocatorInfo -> Bool) -> Eq AllocatorInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllocatorInfo -> AllocatorInfo -> Bool
$c/= :: AllocatorInfo -> AllocatorInfo -> Bool
== :: AllocatorInfo -> AllocatorInfo -> Bool
$c== :: AllocatorInfo -> AllocatorInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (AllocatorInfo)
#endif
deriving instance Show AllocatorInfo

instance ToCStruct AllocatorInfo where
  withCStruct :: AllocatorInfo -> (Ptr AllocatorInfo -> IO b) -> IO b
withCStruct AllocatorInfo
x Ptr AllocatorInfo -> IO b
f = Int -> (Ptr AllocatorInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr AllocatorInfo -> IO b) -> IO b)
-> (Ptr AllocatorInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr AllocatorInfo
p -> Ptr AllocatorInfo -> AllocatorInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocatorInfo
p AllocatorInfo
x (Ptr AllocatorInfo -> IO b
f Ptr AllocatorInfo
p)
  pokeCStruct :: Ptr AllocatorInfo -> AllocatorInfo -> IO b -> IO b
pokeCStruct Ptr AllocatorInfo
p AllocatorInfo{Ptr Device_T
Ptr Instance_T
Ptr PhysicalDevice_T
device :: Ptr Device_T
physicalDevice :: Ptr PhysicalDevice_T
instance' :: Ptr Instance_T
$sel:device:AllocatorInfo :: AllocatorInfo -> Ptr Device_T
$sel:physicalDevice:AllocatorInfo :: AllocatorInfo -> Ptr PhysicalDevice_T
$sel:instance':AllocatorInfo :: AllocatorInfo -> Ptr Instance_T
..} IO b
f = do
    Ptr (Ptr Instance_T) -> Ptr Instance_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr (Ptr Instance_T))) (Ptr Instance_T
instance')
    Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T))) (Ptr PhysicalDevice_T
physicalDevice)
    Ptr (Ptr Device_T) -> Ptr Device_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T))) (Ptr Device_T
device)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr AllocatorInfo -> IO b -> IO b
pokeZeroCStruct Ptr AllocatorInfo
p IO b
f = do
    Ptr (Ptr Instance_T) -> Ptr Instance_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr (Ptr Instance_T))) (Ptr Instance_T
forall a. Zero a => a
zero)
    Ptr (Ptr PhysicalDevice_T) -> Ptr PhysicalDevice_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T))) (Ptr PhysicalDevice_T
forall a. Zero a => a
zero)
    Ptr (Ptr Device_T) -> Ptr Device_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T))) (Ptr Device_T
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct AllocatorInfo where
  peekCStruct :: Ptr AllocatorInfo -> IO AllocatorInfo
peekCStruct Ptr AllocatorInfo
p = do
    Ptr Instance_T
instance' <- Ptr (Ptr Instance_T) -> IO (Ptr Instance_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Instance_T) ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Instance_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr (Ptr Instance_T)))
    Ptr PhysicalDevice_T
physicalDevice <- Ptr (Ptr PhysicalDevice_T) -> IO (Ptr PhysicalDevice_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PhysicalDevice_T) ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr PhysicalDevice_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr PhysicalDevice_T)))
    Ptr Device_T
device <- Ptr (Ptr Device_T) -> IO (Ptr Device_T)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Device_T) ((Ptr AllocatorInfo
p Ptr AllocatorInfo -> Int -> Ptr (Ptr Device_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr Device_T)))
    AllocatorInfo -> IO AllocatorInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocatorInfo -> IO AllocatorInfo)
-> AllocatorInfo -> IO AllocatorInfo
forall a b. (a -> b) -> a -> b
$ Ptr Instance_T
-> Ptr PhysicalDevice_T -> Ptr Device_T -> AllocatorInfo
AllocatorInfo
             Ptr Instance_T
instance' Ptr PhysicalDevice_T
physicalDevice Ptr Device_T
device

instance Storable AllocatorInfo where
  sizeOf :: AllocatorInfo -> Int
sizeOf ~AllocatorInfo
_ = Int
24
  alignment :: AllocatorInfo -> Int
alignment ~AllocatorInfo
_ = Int
8
  peek :: Ptr AllocatorInfo -> IO AllocatorInfo
peek = Ptr AllocatorInfo -> IO AllocatorInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr AllocatorInfo -> AllocatorInfo -> IO ()
poke Ptr AllocatorInfo
ptr AllocatorInfo
poked = Ptr AllocatorInfo -> AllocatorInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocatorInfo
ptr AllocatorInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero AllocatorInfo where
  zero :: AllocatorInfo
zero = Ptr Instance_T
-> Ptr PhysicalDevice_T -> Ptr Device_T -> AllocatorInfo
AllocatorInfo
           Ptr Instance_T
forall a. Zero a => a
zero
           Ptr PhysicalDevice_T
forall a. Zero a => a
zero
           Ptr Device_T
forall a. Zero a => a
zero


-- | 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'.
data Statistics = Statistics
  { -- | Number of @VkDeviceMemory@ objects - Vulkan memory blocks allocated.
    ("poolStats" ::: Statistics) -> "memoryTypeIndex" ::: Word32
blockCount :: Word32
  , -- | Number of 'Allocation' objects allocated.
    --
    -- Dedicated allocations have their own blocks, so each one adds 1 to
    -- @allocationCount@ as well as @blockCount@.
    ("poolStats" ::: Statistics) -> "memoryTypeIndex" ::: Word32
allocationCount :: Word32
  , -- | Number of bytes allocated in @VkDeviceMemory@ blocks.
    --
    -- Note
    --
    -- To avoid confusion, please be aware that what Vulkan calls an
    -- \"allocation\" - a whole @VkDeviceMemory@ object (e.g. as in
    -- @VkPhysicalDeviceLimits::maxMemoryAllocationCount@) is called a
    -- \"block\" in VMA, while VMA calls \"allocation\" a 'Allocation' object
    -- that represents a memory region sub-allocated from such block, usually
    -- for a single buffer or image.
    ("poolStats" ::: Statistics) -> "offset" ::: DeviceSize
blockBytes :: DeviceSize
  , -- | Total number of bytes occupied by all 'Allocation' objects.
    --
    -- Always less or equal than @blockBytes@. Difference
    -- @(blockBytes - allocationBytes)@ is the amount of memory allocated from
    -- Vulkan but unused by any 'Allocation'.
    ("poolStats" ::: Statistics) -> "offset" ::: DeviceSize
allocationBytes :: DeviceSize
  }
  deriving (Typeable, ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> Bool
(("poolStats" ::: Statistics)
 -> ("poolStats" ::: Statistics) -> Bool)
-> (("poolStats" ::: Statistics)
    -> ("poolStats" ::: Statistics) -> Bool)
-> Eq ("poolStats" ::: Statistics)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> Bool
$c/= :: ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> Bool
== :: ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> Bool
$c== :: ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Statistics)
#endif
deriving instance Show Statistics

instance ToCStruct Statistics where
  withCStruct :: ("poolStats" ::: Statistics)
-> (Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b
withCStruct "poolStats" ::: Statistics
x Ptr ("poolStats" ::: Statistics) -> IO b
f = Int -> (Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b)
-> (Ptr ("poolStats" ::: Statistics) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ("poolStats" ::: Statistics)
p -> Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: Statistics)
p "poolStats" ::: Statistics
x (Ptr ("poolStats" ::: Statistics) -> IO b
f Ptr ("poolStats" ::: Statistics)
p)
  pokeCStruct :: Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: Statistics)
p Statistics{"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
allocationBytes :: "offset" ::: DeviceSize
blockBytes :: "offset" ::: DeviceSize
allocationCount :: "memoryTypeIndex" ::: Word32
blockCount :: "memoryTypeIndex" ::: Word32
$sel:allocationBytes:Statistics :: ("poolStats" ::: Statistics) -> "offset" ::: DeviceSize
$sel:blockBytes:Statistics :: ("poolStats" ::: Statistics) -> "offset" ::: DeviceSize
$sel:allocationCount:Statistics :: ("poolStats" ::: Statistics) -> "memoryTypeIndex" ::: Word32
$sel:blockCount:Statistics :: ("poolStats" ::: Statistics) -> "memoryTypeIndex" ::: Word32
..} IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
blockCount)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
allocationCount)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
blockBytes)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
allocationBytes)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr ("poolStats" ::: Statistics) -> IO b -> IO b
pokeZeroCStruct Ptr ("poolStats" ::: Statistics)
p IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct Statistics where
  peekCStruct :: Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
peekCStruct Ptr ("poolStats" ::: Statistics)
p = do
    "memoryTypeIndex" ::: Word32
blockCount <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32))
    "memoryTypeIndex" ::: Word32
allocationCount <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr Word32))
    "offset" ::: DeviceSize
blockBytes <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
allocationBytes <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: Statistics)
p Ptr ("poolStats" ::: Statistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize))
    ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics))
-> ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> "poolStats" ::: Statistics
Statistics
             "memoryTypeIndex" ::: Word32
blockCount "memoryTypeIndex" ::: Word32
allocationCount "offset" ::: DeviceSize
blockBytes "offset" ::: DeviceSize
allocationBytes

instance Storable Statistics where
  sizeOf :: ("poolStats" ::: Statistics) -> Int
sizeOf ~"poolStats" ::: Statistics
_ = Int
24
  alignment :: ("poolStats" ::: Statistics) -> Int
alignment ~"poolStats" ::: Statistics
_ = Int
8
  peek :: Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
peek = Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO ()
poke Ptr ("poolStats" ::: Statistics)
ptr "poolStats" ::: Statistics
poked = Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: Statistics)
ptr "poolStats" ::: Statistics
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero Statistics where
  zero :: "poolStats" ::: Statistics
zero = ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> "poolStats" ::: Statistics
Statistics
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero


-- | 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;
data DetailedStatistics = DetailedStatistics
  { -- | Basic statistics.
    ("poolStats" ::: DetailedStatistics) -> "poolStats" ::: Statistics
statistics :: Statistics
  , -- | Number of free ranges of memory between allocations.
    ("poolStats" ::: DetailedStatistics)
-> "memoryTypeIndex" ::: Word32
unusedRangeCount :: Word32
  , -- | Smallest allocation size. @VK_WHOLE_SIZE@ if there are 0 allocations.
    ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
allocationSizeMin :: DeviceSize
  , -- | Largest allocation size. 0 if there are 0 allocations.
    ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
allocationSizeMax :: DeviceSize
  , -- | Smallest empty range size. @VK_WHOLE_SIZE@ if there are 0 empty ranges.
    ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
unusedRangeSizeMin :: DeviceSize
  , -- | Largest empty range size. 0 if there are 0 empty ranges.
    ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
unusedRangeSizeMax :: DeviceSize
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DetailedStatistics)
#endif
deriving instance Show DetailedStatistics

instance ToCStruct DetailedStatistics where
  withCStruct :: ("poolStats" ::: DetailedStatistics)
-> (Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b
withCStruct "poolStats" ::: DetailedStatistics
x Ptr ("poolStats" ::: DetailedStatistics) -> IO b
f = Int -> (Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
64 ((Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b)
-> (Ptr ("poolStats" ::: DetailedStatistics) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ("poolStats" ::: DetailedStatistics)
p -> Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: DetailedStatistics)
p "poolStats" ::: DetailedStatistics
x (Ptr ("poolStats" ::: DetailedStatistics) -> IO b
f Ptr ("poolStats" ::: DetailedStatistics)
p)
  pokeCStruct :: Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: DetailedStatistics)
p DetailedStatistics{"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
"poolStats" ::: Statistics
unusedRangeSizeMax :: "offset" ::: DeviceSize
unusedRangeSizeMin :: "offset" ::: DeviceSize
allocationSizeMax :: "offset" ::: DeviceSize
allocationSizeMin :: "offset" ::: DeviceSize
unusedRangeCount :: "memoryTypeIndex" ::: Word32
statistics :: "poolStats" ::: Statistics
$sel:unusedRangeSizeMax:DetailedStatistics :: ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
$sel:unusedRangeSizeMin:DetailedStatistics :: ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
$sel:allocationSizeMax:DetailedStatistics :: ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
$sel:allocationSizeMin:DetailedStatistics :: ("poolStats" ::: DetailedStatistics) -> "offset" ::: DeviceSize
$sel:unusedRangeCount:DetailedStatistics :: ("poolStats" ::: DetailedStatistics)
-> "memoryTypeIndex" ::: Word32
$sel:statistics:DetailedStatistics :: ("poolStats" ::: DetailedStatistics) -> "poolStats" ::: Statistics
..} IO b
f = do
    Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics)) ("poolStats" ::: Statistics
statistics)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
unusedRangeCount)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
allocationSizeMin)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
allocationSizeMax)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
unusedRangeSizeMin)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
unusedRangeSizeMax)
    IO b
f
  cStructSize :: Int
cStructSize = Int
64
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr ("poolStats" ::: DetailedStatistics) -> IO b -> IO b
pokeZeroCStruct Ptr ("poolStats" ::: DetailedStatistics)
p IO b
f = do
    Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics)) ("poolStats" ::: Statistics
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct DetailedStatistics where
  peekCStruct :: Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
peekCStruct Ptr ("poolStats" ::: DetailedStatistics)
p = do
    "poolStats" ::: Statistics
statistics <- Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Statistics ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics))
    "memoryTypeIndex" ::: Word32
unusedRangeCount <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32))
    "offset" ::: DeviceSize
allocationSizeMin <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
allocationSizeMax <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
unusedRangeSizeMin <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
unusedRangeSizeMax <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("poolStats" ::: DetailedStatistics)
p Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr DeviceSize))
    ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("poolStats" ::: DetailedStatistics)
 -> IO ("poolStats" ::: DetailedStatistics))
-> ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: Statistics)
-> ("memoryTypeIndex" ::: Word32)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> "poolStats" ::: DetailedStatistics
DetailedStatistics
             "poolStats" ::: Statistics
statistics "memoryTypeIndex" ::: Word32
unusedRangeCount "offset" ::: DeviceSize
allocationSizeMin "offset" ::: DeviceSize
allocationSizeMax "offset" ::: DeviceSize
unusedRangeSizeMin "offset" ::: DeviceSize
unusedRangeSizeMax

instance Storable DetailedStatistics where
  sizeOf :: ("poolStats" ::: DetailedStatistics) -> Int
sizeOf ~"poolStats" ::: DetailedStatistics
_ = Int
64
  alignment :: ("poolStats" ::: DetailedStatistics) -> Int
alignment ~"poolStats" ::: DetailedStatistics
_ = Int
8
  peek :: Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
peek = Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO ()
poke Ptr ("poolStats" ::: DetailedStatistics)
ptr "poolStats" ::: DetailedStatistics
poked = Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("poolStats" ::: DetailedStatistics)
ptr "poolStats" ::: DetailedStatistics
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DetailedStatistics where
  zero :: "poolStats" ::: DetailedStatistics
zero = ("poolStats" ::: Statistics)
-> ("memoryTypeIndex" ::: Word32)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> "poolStats" ::: DetailedStatistics
DetailedStatistics
           "poolStats" ::: Statistics
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero


-- | 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]@
data TotalStatistics = TotalStatistics
  { -- No documentation found for Nested "VmaTotalStatistics" "memoryType"
    ("stats" ::: TotalStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
memoryType :: Vector DetailedStatistics
  , -- No documentation found for Nested "VmaTotalStatistics" "memoryHeap"
    ("stats" ::: TotalStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
memoryHeap :: Vector DetailedStatistics
  , 
    ("stats" ::: TotalStatistics) -> "poolStats" ::: DetailedStatistics
total :: DetailedStatistics
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (TotalStatistics)
#endif
deriving instance Show TotalStatistics

instance ToCStruct TotalStatistics where
  withCStruct :: ("stats" ::: TotalStatistics)
-> (Ptr ("stats" ::: TotalStatistics) -> IO b) -> IO b
withCStruct "stats" ::: TotalStatistics
x Ptr ("stats" ::: TotalStatistics) -> IO b
f = Int -> (Ptr ("stats" ::: TotalStatistics) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
3136 ((Ptr ("stats" ::: TotalStatistics) -> IO b) -> IO b)
-> (Ptr ("stats" ::: TotalStatistics) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ("stats" ::: TotalStatistics)
p -> Ptr ("stats" ::: TotalStatistics)
-> ("stats" ::: TotalStatistics) -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("stats" ::: TotalStatistics)
p "stats" ::: TotalStatistics
x (Ptr ("stats" ::: TotalStatistics) -> IO b
f Ptr ("stats" ::: TotalStatistics)
p)
  pokeCStruct :: Ptr ("stats" ::: TotalStatistics)
-> ("stats" ::: TotalStatistics) -> IO b -> IO b
pokeCStruct Ptr ("stats" ::: TotalStatistics)
p TotalStatistics{Vector ("poolStats" ::: DetailedStatistics)
"poolStats" ::: DetailedStatistics
total :: "poolStats" ::: DetailedStatistics
memoryHeap :: Vector ("poolStats" ::: DetailedStatistics)
memoryType :: Vector ("poolStats" ::: DetailedStatistics)
$sel:total:TotalStatistics :: ("stats" ::: TotalStatistics) -> "poolStats" ::: DetailedStatistics
$sel:memoryHeap:TotalStatistics :: ("stats" ::: TotalStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
$sel:memoryType:TotalStatistics :: ("stats" ::: TotalStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
..} IO b
f = do
    Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((Vector ("poolStats" ::: DetailedStatistics) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("poolStats" ::: DetailedStatistics) -> Int)
-> Vector ("poolStats" ::: DetailedStatistics) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("poolStats" ::: DetailedStatistics)
memoryType)) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
forall a. Integral a => a
MAX_MEMORY_TYPES) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
      IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"memoryType is too long, a maximum of MAX_MEMORY_TYPES elements are allowed" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
    (Int -> ("poolStats" ::: DetailedStatistics) -> IO ())
-> Vector ("poolStats" ::: DetailedStatistics) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "poolStats" ::: DetailedStatistics
e -> Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr
  (FixedArray MAX_MEMORY_TYPES ("poolStats" ::: DetailedStatistics))
-> Ptr ("poolStats" ::: DetailedStatistics)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int
-> Ptr
     (FixedArray MAX_MEMORY_TYPES ("poolStats" ::: DetailedStatistics))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr (FixedArray MAX_MEMORY_TYPES DetailedStatistics)))) Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DetailedStatistics) ("poolStats" ::: DetailedStatistics
e)) (Vector ("poolStats" ::: DetailedStatistics)
memoryType)
    Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((Vector ("poolStats" ::: DetailedStatistics) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("poolStats" ::: DetailedStatistics) -> Int)
-> Vector ("poolStats" ::: DetailedStatistics) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("poolStats" ::: DetailedStatistics)
memoryHeap)) Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
forall a. Integral a => a
MAX_MEMORY_HEAPS) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
      IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"memoryHeap is too long, a maximum of MAX_MEMORY_HEAPS elements are allowed" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
    (Int -> ("poolStats" ::: DetailedStatistics) -> IO ())
-> Vector ("poolStats" ::: DetailedStatistics) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "poolStats" ::: DetailedStatistics
e -> Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr
  (FixedArray MAX_MEMORY_HEAPS ("poolStats" ::: DetailedStatistics))
-> Ptr ("poolStats" ::: DetailedStatistics)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int
-> Ptr
     (FixedArray MAX_MEMORY_HEAPS ("poolStats" ::: DetailedStatistics))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
2048 :: Ptr (FixedArray MAX_MEMORY_HEAPS DetailedStatistics)))) Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DetailedStatistics) ("poolStats" ::: DetailedStatistics
e)) (Vector ("poolStats" ::: DetailedStatistics)
memoryHeap)
    Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
3072 :: Ptr DetailedStatistics)) ("poolStats" ::: DetailedStatistics
total)
    IO b
f
  cStructSize :: Int
cStructSize = Int
3136
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr ("stats" ::: TotalStatistics) -> IO b -> IO b
pokeZeroCStruct Ptr ("stats" ::: TotalStatistics)
p IO b
f = do
    Ptr ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
3072 :: Ptr DetailedStatistics)) ("poolStats" ::: DetailedStatistics
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct TotalStatistics where
  peekCStruct :: Ptr ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
peekCStruct Ptr ("stats" ::: TotalStatistics)
p = do
    Vector ("poolStats" ::: DetailedStatistics)
memoryType <- Int
-> (Int -> IO ("poolStats" ::: DetailedStatistics))
-> IO (Vector ("poolStats" ::: DetailedStatistics))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Int
forall a. Integral a => a
MAX_MEMORY_TYPES) (\Int
i -> Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DetailedStatistics (((Ptr
  (FixedArray MAX_MEMORY_TYPES ("poolStats" ::: DetailedStatistics))
-> Ptr ("poolStats" ::: DetailedStatistics)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr @DetailedStatistics ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int
-> Ptr
     (FixedArray MAX_MEMORY_TYPES ("poolStats" ::: DetailedStatistics))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr (FixedArray MAX_MEMORY_TYPES DetailedStatistics)))) Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DetailedStatistics)))
    Vector ("poolStats" ::: DetailedStatistics)
memoryHeap <- Int
-> (Int -> IO ("poolStats" ::: DetailedStatistics))
-> IO (Vector ("poolStats" ::: DetailedStatistics))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Int
forall a. Integral a => a
MAX_MEMORY_HEAPS) (\Int
i -> Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DetailedStatistics (((Ptr
  (FixedArray MAX_MEMORY_HEAPS ("poolStats" ::: DetailedStatistics))
-> Ptr ("poolStats" ::: DetailedStatistics)
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr @DetailedStatistics ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int
-> Ptr
     (FixedArray MAX_MEMORY_HEAPS ("poolStats" ::: DetailedStatistics))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
2048 :: Ptr (FixedArray MAX_MEMORY_HEAPS DetailedStatistics)))) Ptr ("poolStats" ::: DetailedStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DetailedStatistics)))
    "poolStats" ::: DetailedStatistics
total <- Ptr ("poolStats" ::: DetailedStatistics)
-> IO ("poolStats" ::: DetailedStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DetailedStatistics ((Ptr ("stats" ::: TotalStatistics)
p Ptr ("stats" ::: TotalStatistics)
-> Int -> Ptr ("poolStats" ::: DetailedStatistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
3072 :: Ptr DetailedStatistics))
    ("stats" ::: TotalStatistics) -> IO ("stats" ::: TotalStatistics)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("stats" ::: TotalStatistics) -> IO ("stats" ::: TotalStatistics))
-> ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
forall a b. (a -> b) -> a -> b
$ Vector ("poolStats" ::: DetailedStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics)
-> "stats" ::: TotalStatistics
TotalStatistics
             Vector ("poolStats" ::: DetailedStatistics)
memoryType Vector ("poolStats" ::: DetailedStatistics)
memoryHeap "poolStats" ::: DetailedStatistics
total

instance Storable TotalStatistics where
  sizeOf :: ("stats" ::: TotalStatistics) -> Int
sizeOf ~"stats" ::: TotalStatistics
_ = Int
3136
  alignment :: ("stats" ::: TotalStatistics) -> Int
alignment ~"stats" ::: TotalStatistics
_ = Int
8
  peek :: Ptr ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
peek = Ptr ("stats" ::: TotalStatistics)
-> IO ("stats" ::: TotalStatistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr ("stats" ::: TotalStatistics)
-> ("stats" ::: TotalStatistics) -> IO ()
poke Ptr ("stats" ::: TotalStatistics)
ptr "stats" ::: TotalStatistics
poked = Ptr ("stats" ::: TotalStatistics)
-> ("stats" ::: TotalStatistics) -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("stats" ::: TotalStatistics)
ptr "stats" ::: TotalStatistics
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero TotalStatistics where
  zero :: "stats" ::: TotalStatistics
zero = Vector ("poolStats" ::: DetailedStatistics)
-> Vector ("poolStats" ::: DetailedStatistics)
-> ("poolStats" ::: DetailedStatistics)
-> "stats" ::: TotalStatistics
TotalStatistics
           Vector ("poolStats" ::: DetailedStatistics)
forall a. Monoid a => a
mempty
           Vector ("poolStats" ::: DetailedStatistics)
forall a. Monoid a => a
mempty
           "poolStats" ::: DetailedStatistics
forall a. Zero a => a
zero


-- | VmaBudget
--
-- Statistics of current memory usage and available budget for a specific
-- memory heap.
--
-- These are fast to calculate. See function 'getHeapBudgets'.
data Budget = Budget
  { -- | Statistics fetched from the library.
    Budget -> "poolStats" ::: Statistics
statistics :: Statistics
  , -- | Estimated current memory usage of the program, in bytes.
    --
    -- Fetched from system using VK_EXT_memory_budget extension if enabled.
    --
    -- It might be different than @statistics.blockBytes@ (usually higher) due
    -- to additional implicit objects also occupying the memory, like
    -- swapchain, pipelines, descriptor heaps, command buffers, or
    -- @VkDeviceMemory@ blocks allocated outside of this library, if any.
    Budget -> "offset" ::: DeviceSize
usage :: DeviceSize
  , -- | Estimated amount of memory available to the program, in bytes.
    --
    -- Fetched from system using VK_EXT_memory_budget extension if enabled.
    --
    -- It might be different (most probably smaller) than
    -- @VkMemoryHeap::size[heapIndex]@ due to factors external to the program,
    -- decided by the operating system. Difference @budget - usage@ is the
    -- amount of additional memory that can probably be allocated without
    -- problems. Exceeding the budget may result in various problems.
    Budget -> "offset" ::: DeviceSize
budget :: DeviceSize
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (Budget)
#endif
deriving instance Show Budget

instance ToCStruct Budget where
  withCStruct :: Budget -> (("budgets" ::: Ptr Budget) -> IO b) -> IO b
withCStruct Budget
x ("budgets" ::: Ptr Budget) -> IO b
f = Int -> (("budgets" ::: Ptr Budget) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 ((("budgets" ::: Ptr Budget) -> IO b) -> IO b)
-> (("budgets" ::: Ptr Budget) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \"budgets" ::: Ptr Budget
p -> ("budgets" ::: Ptr Budget) -> Budget -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "budgets" ::: Ptr Budget
p Budget
x (("budgets" ::: Ptr Budget) -> IO b
f "budgets" ::: Ptr Budget
p)
  pokeCStruct :: ("budgets" ::: Ptr Budget) -> Budget -> IO b -> IO b
pokeCStruct "budgets" ::: Ptr Budget
p Budget{"offset" ::: DeviceSize
"poolStats" ::: Statistics
budget :: "offset" ::: DeviceSize
usage :: "offset" ::: DeviceSize
statistics :: "poolStats" ::: Statistics
$sel:budget:Budget :: Budget -> "offset" ::: DeviceSize
$sel:usage:Budget :: Budget -> "offset" ::: DeviceSize
$sel:statistics:Budget :: Budget -> "poolStats" ::: Statistics
..} IO b
f = do
    Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics)) ("poolStats" ::: Statistics
statistics)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
usage)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
budget)
    IO b
f
  cStructSize :: Int
cStructSize = Int
40
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: ("budgets" ::: Ptr Budget) -> IO b -> IO b
pokeZeroCStruct "budgets" ::: Ptr Budget
p IO b
f = do
    Ptr ("poolStats" ::: Statistics)
-> ("poolStats" ::: Statistics) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics)) ("poolStats" ::: Statistics
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct Budget where
  peekCStruct :: ("budgets" ::: Ptr Budget) -> IO Budget
peekCStruct "budgets" ::: Ptr Budget
p = do
    "poolStats" ::: Statistics
statistics <- Ptr ("poolStats" ::: Statistics) -> IO ("poolStats" ::: Statistics)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Statistics (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget)
-> Int -> Ptr ("poolStats" ::: Statistics)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Statistics))
    "offset" ::: DeviceSize
usage <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
budget <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize (("budgets" ::: Ptr Budget
p ("budgets" ::: Ptr Budget) -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize))
    Budget -> IO Budget
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Budget -> IO Budget) -> Budget -> IO Budget
forall a b. (a -> b) -> a -> b
$ ("poolStats" ::: Statistics)
-> ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> Budget
Budget
             "poolStats" ::: Statistics
statistics "offset" ::: DeviceSize
usage "offset" ::: DeviceSize
budget

instance Storable Budget where
  sizeOf :: Budget -> Int
sizeOf ~Budget
_ = Int
40
  alignment :: Budget -> Int
alignment ~Budget
_ = Int
8
  peek :: ("budgets" ::: Ptr Budget) -> IO Budget
peek = ("budgets" ::: Ptr Budget) -> IO Budget
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: ("budgets" ::: Ptr Budget) -> Budget -> IO ()
poke "budgets" ::: Ptr Budget
ptr Budget
poked = ("budgets" ::: Ptr Budget) -> Budget -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "budgets" ::: Ptr Budget
ptr Budget
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero Budget where
  zero :: Budget
zero = ("poolStats" ::: Statistics)
-> ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> Budget
Budget
           "poolStats" ::: Statistics
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero


-- | VmaAllocationCreateInfo
--
-- Parameters of new 'Allocation'.
--
-- To be used with functions like 'createBuffer', 'createImage', and many
-- others.
data AllocationCreateInfo = AllocationCreateInfo
  { -- | Use 'AllocationCreateFlagBits' enum.
    AllocationCreateInfo -> AllocationCreateFlagBits
flags :: AllocationCreateFlags
  , -- | Intended usage of memory.
    --
    -- You can leave 'MEMORY_USAGE_UNKNOWN' if you specify memory requirements
    -- in other way.
    --
    -- >  
    --
    -- If @pool@ is not null, this member is ignored.
    AllocationCreateInfo -> MemoryUsage
usage :: MemoryUsage
  , -- | Flags that must be set in a Memory Type chosen for an allocation.
    --
    -- Leave 0 if you specify memory requirements in other way.
    --
    -- >  
    --
    -- If @pool@ is not null, this member is ignored.
    AllocationCreateInfo -> MemoryPropertyFlags
requiredFlags :: MemoryPropertyFlags
  , -- | Flags that preferably should be set in a memory type chosen for an
    -- allocation.
    --
    -- Set to 0 if no additional flags are preferred.
    --
    -- >  
    --
    -- If @pool@ is not null, this member is ignored.
    AllocationCreateInfo -> MemoryPropertyFlags
preferredFlags :: MemoryPropertyFlags
  , -- | Bitmask containing one bit set for every memory type acceptable for this
    -- allocation.
    --
    -- Value 0 is equivalent to @UINT32_MAX@ - it means any memory type is
    -- accepted if it meets other requirements specified by this structure,
    -- with no further restrictions on memory type index.
    --
    -- >  
    --
    -- If @pool@ is not null, this member is ignored.
    AllocationCreateInfo -> "memoryTypeIndex" ::: Word32
memoryTypeBits :: Word32
  , -- | Pool that this allocation should be created in.
    --
    -- Leave @VK_NULL_HANDLE@ to allocate from default pool. If not null,
    -- members: @usage@, @requiredFlags@, @preferredFlags@, @memoryTypeBits@
    -- are ignored.
    AllocationCreateInfo -> Pool
pool :: Pool
  , -- | Custom general-purpose pointer that will be stored in 'Allocation', can
    -- be read as /VmaAllocationInfo::pUserData/ and changed using
    -- 'setAllocationUserData'.
    --
    -- If 'ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT' is used, it must be
    -- either null or pointer to a null-terminated string. The string will be
    -- then copied to internal buffer, so it doesn\'t need to be valid after
    -- allocation call.
    AllocationCreateInfo -> "userData" ::: Ptr ()
userData :: Ptr ()
  , -- | A floating-point value between 0 and 1, indicating the priority of the
    -- allocation relative to other memory allocations.
    --
    -- It is used only when 'ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT' flag was
    -- used during creation of the 'Allocator' object and this allocation ends
    -- up as dedicated or is explicitly forced as dedicated using
    -- 'ALLOCATION_CREATE_DEDICATED_MEMORY_BIT'. Otherwise, it has the priority
    -- of a memory block where it is placed and this variable is ignored.
    AllocationCreateInfo -> Float
priority :: Float
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (AllocationCreateInfo)
#endif
deriving instance Show AllocationCreateInfo

instance ToCStruct AllocationCreateInfo where
  withCStruct :: AllocationCreateInfo -> (Ptr AllocationCreateInfo -> IO b) -> IO b
withCStruct AllocationCreateInfo
x Ptr AllocationCreateInfo -> IO b
f = Int -> (Ptr AllocationCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 ((Ptr AllocationCreateInfo -> IO b) -> IO b)
-> (Ptr AllocationCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr AllocationCreateInfo
p -> Ptr AllocationCreateInfo -> AllocationCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocationCreateInfo
p AllocationCreateInfo
x (Ptr AllocationCreateInfo -> IO b
f Ptr AllocationCreateInfo
p)
  pokeCStruct :: Ptr AllocationCreateInfo -> AllocationCreateInfo -> IO b -> IO b
pokeCStruct Ptr AllocationCreateInfo
p AllocationCreateInfo{Float
"memoryTypeIndex" ::: Word32
"userData" ::: Ptr ()
MemoryPropertyFlags
Pool
AllocationCreateFlagBits
MemoryUsage
priority :: Float
userData :: "userData" ::: Ptr ()
pool :: Pool
memoryTypeBits :: "memoryTypeIndex" ::: Word32
preferredFlags :: MemoryPropertyFlags
requiredFlags :: MemoryPropertyFlags
usage :: MemoryUsage
flags :: AllocationCreateFlagBits
$sel:priority:AllocationCreateInfo :: AllocationCreateInfo -> Float
$sel:userData:AllocationCreateInfo :: AllocationCreateInfo -> "userData" ::: Ptr ()
$sel:pool:AllocationCreateInfo :: AllocationCreateInfo -> Pool
$sel:memoryTypeBits:AllocationCreateInfo :: AllocationCreateInfo -> "memoryTypeIndex" ::: Word32
$sel:preferredFlags:AllocationCreateInfo :: AllocationCreateInfo -> MemoryPropertyFlags
$sel:requiredFlags:AllocationCreateInfo :: AllocationCreateInfo -> MemoryPropertyFlags
$sel:usage:AllocationCreateInfo :: AllocationCreateInfo -> MemoryUsage
$sel:flags:AllocationCreateInfo :: AllocationCreateInfo -> AllocationCreateFlagBits
..} IO b
f = do
    Ptr AllocationCreateFlagBits -> AllocationCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr AllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocationCreateFlags)) (AllocationCreateFlagBits
flags)
    Ptr MemoryUsage -> MemoryUsage -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryUsage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr MemoryUsage)) (MemoryUsage
usage)
    Ptr MemoryPropertyFlags -> MemoryPropertyFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr MemoryPropertyFlags)) (MemoryPropertyFlags
requiredFlags)
    Ptr MemoryPropertyFlags -> MemoryPropertyFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12 :: Ptr MemoryPropertyFlags)) (MemoryPropertyFlags
preferredFlags)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
memoryTypeBits)
    Ptr Pool -> Pool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr Pool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Pool)) (Pool
pool)
    Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
userData)
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
priority))
    IO b
f
  cStructSize :: Int
cStructSize = Int
48
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr AllocationCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr AllocationCreateInfo
p IO b
f = do
    Ptr AllocationCreateFlagBits -> AllocationCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr AllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocationCreateFlags)) (AllocationCreateFlagBits
forall a. Zero a => a
zero)
    Ptr MemoryUsage -> MemoryUsage -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryUsage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr MemoryUsage)) (MemoryUsage
forall a. Zero a => a
zero)
    Ptr MemoryPropertyFlags -> MemoryPropertyFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr MemoryPropertyFlags)) (MemoryPropertyFlags
forall a. Zero a => a
zero)
    Ptr MemoryPropertyFlags -> MemoryPropertyFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12 :: Ptr MemoryPropertyFlags)) (MemoryPropertyFlags
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct AllocationCreateInfo where
  peekCStruct :: Ptr AllocationCreateInfo -> IO AllocationCreateInfo
peekCStruct Ptr AllocationCreateInfo
p = do
    AllocationCreateFlagBits
flags <- Ptr AllocationCreateFlagBits -> IO AllocationCreateFlagBits
forall a. Storable a => Ptr a -> IO a
peek @AllocationCreateFlags ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr AllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr AllocationCreateFlags))
    MemoryUsage
usage <- Ptr MemoryUsage -> IO MemoryUsage
forall a. Storable a => Ptr a -> IO a
peek @MemoryUsage ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryUsage
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr MemoryUsage))
    MemoryPropertyFlags
requiredFlags <- Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags
forall a. Storable a => Ptr a -> IO a
peek @MemoryPropertyFlags ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr MemoryPropertyFlags))
    MemoryPropertyFlags
preferredFlags <- Ptr MemoryPropertyFlags -> IO MemoryPropertyFlags
forall a. Storable a => Ptr a -> IO a
peek @MemoryPropertyFlags ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr MemoryPropertyFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
12 :: Ptr MemoryPropertyFlags))
    "memoryTypeIndex" ::: Word32
memoryTypeBits <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    Pool
pool <- Ptr Pool -> IO Pool
forall a. Storable a => Ptr a -> IO a
peek @Pool ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr Pool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Pool))
    "userData" ::: Ptr ()
pUserData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr ())))
    CFloat
priority <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr AllocationCreateInfo
p Ptr AllocationCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr CFloat))
    AllocationCreateInfo -> IO AllocationCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocationCreateInfo -> IO AllocationCreateInfo)
-> AllocationCreateInfo -> IO AllocationCreateInfo
forall a b. (a -> b) -> a -> b
$ AllocationCreateFlagBits
-> MemoryUsage
-> MemoryPropertyFlags
-> MemoryPropertyFlags
-> ("memoryTypeIndex" ::: Word32)
-> Pool
-> ("userData" ::: Ptr ())
-> Float
-> AllocationCreateInfo
AllocationCreateInfo
             AllocationCreateFlagBits
flags MemoryUsage
usage MemoryPropertyFlags
requiredFlags MemoryPropertyFlags
preferredFlags "memoryTypeIndex" ::: Word32
memoryTypeBits Pool
pool "userData" ::: Ptr ()
pUserData (CFloat -> Float
coerce @CFloat @Float CFloat
priority)

instance Storable AllocationCreateInfo where
  sizeOf :: AllocationCreateInfo -> Int
sizeOf ~AllocationCreateInfo
_ = Int
48
  alignment :: AllocationCreateInfo -> Int
alignment ~AllocationCreateInfo
_ = Int
8
  peek :: Ptr AllocationCreateInfo -> IO AllocationCreateInfo
peek = Ptr AllocationCreateInfo -> IO AllocationCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr AllocationCreateInfo -> AllocationCreateInfo -> IO ()
poke Ptr AllocationCreateInfo
ptr AllocationCreateInfo
poked = Ptr AllocationCreateInfo -> AllocationCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocationCreateInfo
ptr AllocationCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero AllocationCreateInfo where
  zero :: AllocationCreateInfo
zero = AllocationCreateFlagBits
-> MemoryUsage
-> MemoryPropertyFlags
-> MemoryPropertyFlags
-> ("memoryTypeIndex" ::: Word32)
-> Pool
-> ("userData" ::: Ptr ())
-> Float
-> AllocationCreateInfo
AllocationCreateInfo
           AllocationCreateFlagBits
forall a. Zero a => a
zero
           MemoryUsage
forall a. Zero a => a
zero
           MemoryPropertyFlags
forall a. Zero a => a
zero
           MemoryPropertyFlags
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           Pool
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero
           Float
forall a. Zero a => a
zero


-- | VmaPoolCreateInfo
--
-- Describes parameter of created 'Pool'.
data PoolCreateInfo = PoolCreateInfo
  { -- | Vulkan memory type index to allocate this pool from.
    PoolCreateInfo -> "memoryTypeIndex" ::: Word32
memoryTypeIndex :: Word32
  , -- | Use combination of 'PoolCreateFlagBits'.
    PoolCreateInfo -> PoolCreateFlagBits
flags :: PoolCreateFlags
  , -- | Size of a single @VkDeviceMemory@ block to be allocated as part of this
    -- pool, in bytes. Optional.
    --
    -- Specify nonzero to set explicit, constant size of memory blocks used by
    -- this pool.
    --
    -- Leave 0 to use default and let the library manage block sizes
    -- automatically. Sizes of particular blocks may vary. In this case, the
    -- pool will also support dedicated allocations.
    PoolCreateInfo -> "offset" ::: DeviceSize
blockSize :: DeviceSize
  , -- | Minimum number of blocks to be always allocated in this pool, even if
    -- they stay empty.
    --
    -- Set to 0 to have no preallocated blocks and allow the pool be completely
    -- empty.
    PoolCreateInfo -> "offset" ::: DeviceSize
minBlockCount :: Word64
  , -- | Maximum number of blocks that can be allocated in this pool. Optional.
    --
    -- Set to 0 to use default, which is @SIZE_MAX@, which means no limit.
    --
    -- Set to same value as /VmaPoolCreateInfo::minBlockCount/ to have fixed
    -- amount of memory allocated throughout whole lifetime of this pool.
    PoolCreateInfo -> "offset" ::: DeviceSize
maxBlockCount :: Word64
  , -- | A floating-point value between 0 and 1, indicating the priority of the
    -- allocations in this pool relative to other memory allocations.
    --
    -- It is used only when 'ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT' flag was
    -- used during creation of the 'Allocator' object. Otherwise, this variable
    -- is ignored.
    PoolCreateInfo -> Float
priority :: Float
  , -- | Additional minimum alignment to be used for all allocations created from
    -- this pool. Can be 0.
    --
    -- Leave 0 (default) not to impose any additional alignment. If not 0, it
    -- must be a power of two. It can be useful in cases where alignment
    -- returned by Vulkan by functions like @vkGetBufferMemoryRequirements@ is
    -- not enough, e.g. when doing interop with OpenGL.
    PoolCreateInfo -> "offset" ::: DeviceSize
minAllocationAlignment :: DeviceSize
  , -- | Additional @pNext@ chain to be attached to @VkMemoryAllocateInfo@ used
    -- for every allocation made by this pool. Optional.
    --
    -- Optional, can be null. If not null, it must point to a @pNext@ chain of
    -- structures that can be attached to @VkMemoryAllocateInfo@. It can be
    -- useful for special needs such as adding @VkExportMemoryAllocateInfoKHR@.
    -- Structures pointed by this member must remain alive and unchanged for
    -- the whole lifetime of the custom pool.
    --
    -- Please note that some structures, e.g.
    -- @VkMemoryPriorityAllocateInfoEXT@, @VkMemoryDedicatedAllocateInfoKHR@,
    -- can be attached automatically by this library when using other, more
    -- convenient of its features.
    PoolCreateInfo -> "userData" ::: Ptr ()
memoryAllocateNext :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PoolCreateInfo)
#endif
deriving instance Show PoolCreateInfo

instance ToCStruct PoolCreateInfo where
  withCStruct :: PoolCreateInfo -> (Ptr PoolCreateInfo -> IO b) -> IO b
withCStruct PoolCreateInfo
x Ptr PoolCreateInfo -> IO b
f = Int -> (Ptr PoolCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
56 ((Ptr PoolCreateInfo -> IO b) -> IO b)
-> (Ptr PoolCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PoolCreateInfo
p -> Ptr PoolCreateInfo -> PoolCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PoolCreateInfo
p PoolCreateInfo
x (Ptr PoolCreateInfo -> IO b
f Ptr PoolCreateInfo
p)
  pokeCStruct :: Ptr PoolCreateInfo -> PoolCreateInfo -> IO b -> IO b
pokeCStruct Ptr PoolCreateInfo
p PoolCreateInfo{Float
"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
"userData" ::: Ptr ()
PoolCreateFlagBits
memoryAllocateNext :: "userData" ::: Ptr ()
minAllocationAlignment :: "offset" ::: DeviceSize
priority :: Float
maxBlockCount :: "offset" ::: DeviceSize
minBlockCount :: "offset" ::: DeviceSize
blockSize :: "offset" ::: DeviceSize
flags :: PoolCreateFlagBits
memoryTypeIndex :: "memoryTypeIndex" ::: Word32
$sel:memoryAllocateNext:PoolCreateInfo :: PoolCreateInfo -> "userData" ::: Ptr ()
$sel:minAllocationAlignment:PoolCreateInfo :: PoolCreateInfo -> "offset" ::: DeviceSize
$sel:priority:PoolCreateInfo :: PoolCreateInfo -> Float
$sel:maxBlockCount:PoolCreateInfo :: PoolCreateInfo -> "offset" ::: DeviceSize
$sel:minBlockCount:PoolCreateInfo :: PoolCreateInfo -> "offset" ::: DeviceSize
$sel:blockSize:PoolCreateInfo :: PoolCreateInfo -> "offset" ::: DeviceSize
$sel:flags:PoolCreateInfo :: PoolCreateInfo -> PoolCreateFlagBits
$sel:memoryTypeIndex:PoolCreateInfo :: PoolCreateInfo -> "memoryTypeIndex" ::: Word32
..} IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
memoryTypeIndex)
    Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr PoolCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr PoolCreateFlags)) (PoolCreateFlagBits
flags)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
blockSize)
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CSize)) (("offset" ::: DeviceSize) -> CSize
CSize ("offset" ::: DeviceSize
minBlockCount))
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr CSize)) (("offset" ::: DeviceSize) -> CSize
CSize ("offset" ::: DeviceSize
maxBlockCount))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
priority))
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
minAllocationAlignment)
    Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
memoryAllocateNext)
    IO b
f
  cStructSize :: Int
cStructSize = Int
56
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr PoolCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr PoolCreateInfo
p IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr PoolCreateFlagBits -> PoolCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr PoolCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr PoolCreateFlags)) (PoolCreateFlagBits
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CSize)) (("offset" ::: DeviceSize) -> CSize
CSize ("offset" ::: DeviceSize
forall a. Zero a => a
zero))
    Ptr CSize -> CSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr CSize)) (("offset" ::: DeviceSize) -> CSize
CSize ("offset" ::: DeviceSize
forall a. Zero a => a
zero))
    Ptr CFloat -> CFloat -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr CFloat)) (Float -> CFloat
CFloat (Float
forall a. Zero a => a
zero))
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct PoolCreateInfo where
  peekCStruct :: Ptr PoolCreateInfo -> IO PoolCreateInfo
peekCStruct Ptr PoolCreateInfo
p = do
    "memoryTypeIndex" ::: Word32
memoryTypeIndex <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32))
    PoolCreateFlagBits
flags <- Ptr PoolCreateFlagBits -> IO PoolCreateFlagBits
forall a. Storable a => Ptr a -> IO a
peek @PoolCreateFlags ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr PoolCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
4 :: Ptr PoolCreateFlags))
    "offset" ::: DeviceSize
blockSize <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize))
    CSize
minBlockCount <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek @CSize ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CSize))
    CSize
maxBlockCount <- Ptr CSize -> IO CSize
forall a. Storable a => Ptr a -> IO a
peek @CSize ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr CSize))
    CFloat
priority <- Ptr CFloat -> IO CFloat
forall a. Storable a => Ptr a -> IO a
peek @CFloat ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr CFloat
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr CFloat))
    "offset" ::: DeviceSize
minAllocationAlignment <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr DeviceSize))
    "userData" ::: Ptr ()
pMemoryAllocateNext <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr PoolCreateInfo
p Ptr PoolCreateInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr ())))
    PoolCreateInfo -> IO PoolCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PoolCreateInfo -> IO PoolCreateInfo)
-> PoolCreateInfo -> IO PoolCreateInfo
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32)
-> PoolCreateFlagBits
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> Float
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> PoolCreateInfo
PoolCreateInfo
             "memoryTypeIndex" ::: Word32
memoryTypeIndex PoolCreateFlagBits
flags "offset" ::: DeviceSize
blockSize (CSize -> "offset" ::: DeviceSize
coerce @CSize @Word64 CSize
minBlockCount) (CSize -> "offset" ::: DeviceSize
coerce @CSize @Word64 CSize
maxBlockCount) (CFloat -> Float
coerce @CFloat @Float CFloat
priority) "offset" ::: DeviceSize
minAllocationAlignment "userData" ::: Ptr ()
pMemoryAllocateNext

instance Storable PoolCreateInfo where
  sizeOf :: PoolCreateInfo -> Int
sizeOf ~PoolCreateInfo
_ = Int
56
  alignment :: PoolCreateInfo -> Int
alignment ~PoolCreateInfo
_ = Int
8
  peek :: Ptr PoolCreateInfo -> IO PoolCreateInfo
peek = Ptr PoolCreateInfo -> IO PoolCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PoolCreateInfo -> PoolCreateInfo -> IO ()
poke Ptr PoolCreateInfo
ptr PoolCreateInfo
poked = Ptr PoolCreateInfo -> PoolCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PoolCreateInfo
ptr PoolCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PoolCreateInfo where
  zero :: PoolCreateInfo
zero = ("memoryTypeIndex" ::: Word32)
-> PoolCreateFlagBits
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> Float
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> PoolCreateInfo
PoolCreateInfo
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           PoolCreateFlagBits
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           Float
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero


-- | VmaAllocationInfo
--
-- Parameters of 'Allocation' objects, that can be retrieved using function
-- 'getAllocationInfo'.
data AllocationInfo = AllocationInfo
  { -- | Memory type index that this allocation was allocated from.
    --
    -- It never changes.
    AllocationInfo -> "memoryTypeIndex" ::: Word32
memoryType :: Word32
  , -- | Handle to Vulkan memory object.
    --
    -- Same memory object can be shared by multiple allocations.
    --
    -- It can change after the allocation is moved during /Defragmentation/.
    AllocationInfo -> DeviceMemory
deviceMemory :: DeviceMemory
  , -- | Offset in @VkDeviceMemory@ object to the beginning of this allocation,
    -- in bytes. @(deviceMemory, offset)@ pair is unique to this allocation.
    --
    -- You usually don\'t need to use this offset. If you create a buffer or an
    -- image together with the allocation using e.g. function 'createBuffer',
    -- 'createImage', functions that operate on these resources refer to the
    -- beginning of the buffer or image, not entire device memory block.
    -- Functions like 'mapMemory', 'bindBufferMemory' also refer to the
    -- beginning of the allocation and apply this offset automatically.
    --
    -- It can change after the allocation is moved during /Defragmentation/.
    AllocationInfo -> "offset" ::: DeviceSize
offset :: DeviceSize
  , -- | Size of this allocation, in bytes.
    --
    -- It never changes.
    --
    -- Note
    --
    -- Allocation size returned in this variable may be greater than the size
    -- requested for the resource e.g. as @VkBufferCreateInfo::size@. Whole
    -- size of the allocation is accessible for operations on memory e.g. using
    -- a pointer after mapping with 'mapMemory', but operations on the resource
    -- e.g. using @vkCmdCopyBuffer@ must be limited to the size of the
    -- resource.
    AllocationInfo -> "offset" ::: DeviceSize
size :: DeviceSize
  , -- | Pointer to the beginning of this allocation as mapped data.
    --
    -- If the allocation hasn\'t been mapped using 'mapMemory' and hasn\'t been
    -- created with 'ALLOCATION_CREATE_MAPPED_BIT' flag, this value is null.
    --
    -- It can change after call to 'mapMemory', 'unmapMemory'. It can also
    -- change after the allocation is moved during /Defragmentation/.
    AllocationInfo -> "userData" ::: Ptr ()
mappedData :: Ptr ()
  , -- | Custom general-purpose pointer that was passed as
    -- /VmaAllocationCreateInfo::pUserData/ or set using
    -- 'setAllocationUserData'.
    --
    -- It can change after call to 'setAllocationUserData' for this allocation.
    AllocationInfo -> "userData" ::: Ptr ()
userData :: Ptr ()
  , -- | Custom allocation name that was set with 'setAllocationName'.
    --
    -- It can change after call to 'setAllocationName' for this allocation.
    --
    -- Another way to set custom name is to pass it in
    -- /VmaAllocationCreateInfo::pUserData/ with additional flag
    -- 'ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT' set [DEPRECATED].
    AllocationInfo -> "name" ::: Maybe ByteString
name :: Maybe ByteString
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (AllocationInfo)
#endif
deriving instance Show AllocationInfo

instance ToCStruct AllocationInfo where
  withCStruct :: AllocationInfo -> (Ptr AllocationInfo -> IO b) -> IO b
withCStruct AllocationInfo
x Ptr AllocationInfo -> IO b
f = Int -> (Ptr AllocationInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
56 ((Ptr AllocationInfo -> IO b) -> IO b)
-> (Ptr AllocationInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr AllocationInfo
p -> Ptr AllocationInfo -> AllocationInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr AllocationInfo
p AllocationInfo
x (Ptr AllocationInfo -> IO b
f Ptr AllocationInfo
p)
  pokeCStruct :: Ptr AllocationInfo -> AllocationInfo -> IO b -> IO b
pokeCStruct Ptr AllocationInfo
p AllocationInfo{"name" ::: Maybe ByteString
"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
"userData" ::: Ptr ()
DeviceMemory
name :: "name" ::: Maybe ByteString
userData :: "userData" ::: Ptr ()
mappedData :: "userData" ::: Ptr ()
size :: "offset" ::: DeviceSize
offset :: "offset" ::: DeviceSize
deviceMemory :: DeviceMemory
memoryType :: "memoryTypeIndex" ::: Word32
$sel:name:AllocationInfo :: AllocationInfo -> "name" ::: Maybe ByteString
$sel:userData:AllocationInfo :: AllocationInfo -> "userData" ::: Ptr ()
$sel:mappedData:AllocationInfo :: AllocationInfo -> "userData" ::: Ptr ()
$sel:size:AllocationInfo :: AllocationInfo -> "offset" ::: DeviceSize
$sel:offset:AllocationInfo :: AllocationInfo -> "offset" ::: DeviceSize
$sel:deviceMemory:AllocationInfo :: AllocationInfo -> DeviceMemory
$sel:memoryType:AllocationInfo :: AllocationInfo -> "memoryTypeIndex" ::: Word32
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
memoryType)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DeviceMemory -> DeviceMemory -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceMemory)) (DeviceMemory
deviceMemory)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
offset)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
size)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
mappedData)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
userData)
    "name" ::: Ptr CChar
pName'' <- case ("name" ::: Maybe ByteString
name) of
      "name" ::: Maybe ByteString
Nothing -> ("name" ::: Ptr CChar) -> ContT b IO ("name" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "name" ::: Ptr CChar
forall a. Ptr a
nullPtr
      Just ByteString
j -> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("name" ::: Ptr CChar) -> IO b) -> IO b)
 -> ContT b IO ("name" ::: Ptr CChar))
-> ((("name" ::: Ptr CChar) -> IO b) -> IO b)
-> ContT b IO ("name" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ByteString -> (("name" ::: Ptr CChar) -> IO b) -> IO b
forall a. ByteString -> (("name" ::: Ptr CChar) -> IO a) -> IO a
useAsCString (ByteString
j)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("name" ::: Ptr CChar) -> ("name" ::: Ptr CChar) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr CChar))) "name" ::: Ptr CChar
pName''
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = Int
56
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr AllocationInfo -> IO b -> IO b
pokeZeroCStruct Ptr AllocationInfo
p IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct AllocationInfo where
  peekCStruct :: Ptr AllocationInfo -> IO AllocationInfo
peekCStruct Ptr AllocationInfo
p = do
    "memoryTypeIndex" ::: Word32
memoryType <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32))
    DeviceMemory
deviceMemory <- Ptr DeviceMemory -> IO DeviceMemory
forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr DeviceMemory
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceMemory))
    "offset" ::: DeviceSize
offset <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
size <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize))
    "userData" ::: Ptr ()
pMappedData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr ())))
    "userData" ::: Ptr ()
pUserData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr ())))
    "name" ::: Ptr CChar
pName <- Ptr ("name" ::: Ptr CChar) -> IO ("name" ::: Ptr CChar)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr CChar) ((Ptr AllocationInfo
p Ptr AllocationInfo -> Int -> Ptr ("name" ::: Ptr CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr CChar)))
    "name" ::: Maybe ByteString
pName' <- (("name" ::: Ptr CChar) -> IO ByteString)
-> ("name" ::: Ptr CChar) -> IO ("name" ::: Maybe ByteString)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek (\"name" ::: Ptr CChar
j -> ("name" ::: Ptr CChar) -> IO ByteString
packCString ("name" ::: Ptr CChar
j)) "name" ::: Ptr CChar
pName
    AllocationInfo -> IO AllocationInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AllocationInfo -> IO AllocationInfo)
-> AllocationInfo -> IO AllocationInfo
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32)
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> ("userData" ::: Ptr ())
-> ("name" ::: Maybe ByteString)
-> AllocationInfo
AllocationInfo
             "memoryTypeIndex" ::: Word32
memoryType DeviceMemory
deviceMemory "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size "userData" ::: Ptr ()
pMappedData "userData" ::: Ptr ()
pUserData "name" ::: Maybe ByteString
pName'

instance Zero AllocationInfo where
  zero :: AllocationInfo
zero = ("memoryTypeIndex" ::: Word32)
-> DeviceMemory
-> ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> ("userData" ::: Ptr ())
-> ("name" ::: Maybe ByteString)
-> AllocationInfo
AllocationInfo
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           DeviceMemory
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero
           "name" ::: Maybe ByteString
forall a. Maybe a
Nothing


-- | VmaDefragmentationInfo
--
-- Parameters for defragmentation.
--
-- To be used with function 'beginDefragmentation'.
data DefragmentationInfo = DefragmentationInfo
  { -- | Use combination of 'DefragmentationFlagBits'.
    DefragmentationInfo -> DefragmentationFlagBits
flags :: DefragmentationFlags
  , -- | Custom pool to be defragmented.
    --
    -- If null then default pools will undergo defragmentation process.
    DefragmentationInfo -> Pool
pool :: Pool
  , -- | Maximum numbers of bytes that can be copied during single pass, while
    -- moving allocations to different places.
    --
    -- @0@ means no limit.
    DefragmentationInfo -> "offset" ::: DeviceSize
maxBytesPerPass :: DeviceSize
  , -- | Maximum number of allocations that can be moved during single pass to a
    -- different place.
    --
    -- @0@ means no limit.
    DefragmentationInfo -> "memoryTypeIndex" ::: Word32
maxAllocationsPerPass :: Word32
  }
  deriving (Typeable, DefragmentationInfo -> DefragmentationInfo -> Bool
(DefragmentationInfo -> DefragmentationInfo -> Bool)
-> (DefragmentationInfo -> DefragmentationInfo -> Bool)
-> Eq DefragmentationInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationInfo -> DefragmentationInfo -> Bool
$c/= :: DefragmentationInfo -> DefragmentationInfo -> Bool
== :: DefragmentationInfo -> DefragmentationInfo -> Bool
$c== :: DefragmentationInfo -> DefragmentationInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DefragmentationInfo)
#endif
deriving instance Show DefragmentationInfo

instance ToCStruct DefragmentationInfo where
  withCStruct :: DefragmentationInfo -> (Ptr DefragmentationInfo -> IO b) -> IO b
withCStruct DefragmentationInfo
x Ptr DefragmentationInfo -> IO b
f = Int -> (Ptr DefragmentationInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr DefragmentationInfo -> IO b) -> IO b)
-> (Ptr DefragmentationInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr DefragmentationInfo
p -> Ptr DefragmentationInfo -> DefragmentationInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationInfo
p DefragmentationInfo
x (Ptr DefragmentationInfo -> IO b
f Ptr DefragmentationInfo
p)
  pokeCStruct :: Ptr DefragmentationInfo -> DefragmentationInfo -> IO b -> IO b
pokeCStruct Ptr DefragmentationInfo
p DefragmentationInfo{"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
Pool
DefragmentationFlagBits
maxAllocationsPerPass :: "memoryTypeIndex" ::: Word32
maxBytesPerPass :: "offset" ::: DeviceSize
pool :: Pool
flags :: DefragmentationFlagBits
$sel:maxAllocationsPerPass:DefragmentationInfo :: DefragmentationInfo -> "memoryTypeIndex" ::: Word32
$sel:maxBytesPerPass:DefragmentationInfo :: DefragmentationInfo -> "offset" ::: DeviceSize
$sel:pool:DefragmentationInfo :: DefragmentationInfo -> Pool
$sel:flags:DefragmentationInfo :: DefragmentationInfo -> DefragmentationFlagBits
..} IO b
f = do
    Ptr DefragmentationFlagBits -> DefragmentationFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr DefragmentationFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationFlags)) (DefragmentationFlagBits
flags)
    Ptr Pool -> Pool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr Pool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Pool)) (Pool
pool)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
maxBytesPerPass)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
maxAllocationsPerPass)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr DefragmentationInfo -> IO b -> IO b
pokeZeroCStruct Ptr DefragmentationInfo
p IO b
f = do
    Ptr DefragmentationFlagBits -> DefragmentationFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr DefragmentationFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationFlags)) (DefragmentationFlagBits
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct DefragmentationInfo where
  peekCStruct :: Ptr DefragmentationInfo -> IO DefragmentationInfo
peekCStruct Ptr DefragmentationInfo
p = do
    DefragmentationFlagBits
flags <- Ptr DefragmentationFlagBits -> IO DefragmentationFlagBits
forall a. Storable a => Ptr a -> IO a
peek @DefragmentationFlags ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr DefragmentationFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationFlags))
    Pool
pool <- Ptr Pool -> IO Pool
forall a. Storable a => Ptr a -> IO a
peek @Pool ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr Pool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Pool))
    "offset" ::: DeviceSize
maxBytesPerPass <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr DeviceSize))
    "memoryTypeIndex" ::: Word32
maxAllocationsPerPass <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DefragmentationInfo
p Ptr DefragmentationInfo
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word32))
    DefragmentationInfo -> IO DefragmentationInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DefragmentationInfo -> IO DefragmentationInfo)
-> DefragmentationInfo -> IO DefragmentationInfo
forall a b. (a -> b) -> a -> b
$ DefragmentationFlagBits
-> Pool
-> ("offset" ::: DeviceSize)
-> ("memoryTypeIndex" ::: Word32)
-> DefragmentationInfo
DefragmentationInfo
             DefragmentationFlagBits
flags Pool
pool "offset" ::: DeviceSize
maxBytesPerPass "memoryTypeIndex" ::: Word32
maxAllocationsPerPass

instance Storable DefragmentationInfo where
  sizeOf :: DefragmentationInfo -> Int
sizeOf ~DefragmentationInfo
_ = Int
32
  alignment :: DefragmentationInfo -> Int
alignment ~DefragmentationInfo
_ = Int
8
  peek :: Ptr DefragmentationInfo -> IO DefragmentationInfo
peek = Ptr DefragmentationInfo -> IO DefragmentationInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr DefragmentationInfo -> DefragmentationInfo -> IO ()
poke Ptr DefragmentationInfo
ptr DefragmentationInfo
poked = Ptr DefragmentationInfo -> DefragmentationInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationInfo
ptr DefragmentationInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DefragmentationInfo where
  zero :: DefragmentationInfo
zero = DefragmentationFlagBits
-> Pool
-> ("offset" ::: DeviceSize)
-> ("memoryTypeIndex" ::: Word32)
-> DefragmentationInfo
DefragmentationInfo
           DefragmentationFlagBits
forall a. Zero a => a
zero
           Pool
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero


-- | VmaDefragmentationMove
--
-- Single move of an allocation to be done for defragmentation.
data DefragmentationMove = DefragmentationMove
  { -- | Operation to be performed on the allocation by 'endDefragmentationPass'.
    -- Default value is 'DEFRAGMENTATION_MOVE_OPERATION_COPY'. You can modify
    -- it.
    DefragmentationMove -> DefragmentationMoveOperation
operation :: DefragmentationMoveOperation
  , -- | Allocation that should be moved.
    DefragmentationMove -> Allocation
srcAllocation :: Allocation
  , -- | Temporary allocation pointing to destination memory that will replace
    -- @srcAllocation@.
    --
    -- Warning
    --
    -- Do not store this allocation in your data structures! It exists only
    -- temporarily, for the duration of the defragmentation pass, to be used
    -- for binding new buffer\/image to the destination memory using e.g.
    -- 'bindBufferMemory'. 'endDefragmentationPass' will destroy it and make
    -- @srcAllocation@ point to this memory.
    DefragmentationMove -> Allocation
dstTmpAllocation :: Allocation
  }
  deriving (Typeable, DefragmentationMove -> DefragmentationMove -> Bool
(DefragmentationMove -> DefragmentationMove -> Bool)
-> (DefragmentationMove -> DefragmentationMove -> Bool)
-> Eq DefragmentationMove
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationMove -> DefragmentationMove -> Bool
$c/= :: DefragmentationMove -> DefragmentationMove -> Bool
== :: DefragmentationMove -> DefragmentationMove -> Bool
$c== :: DefragmentationMove -> DefragmentationMove -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DefragmentationMove)
#endif
deriving instance Show DefragmentationMove

instance ToCStruct DefragmentationMove where
  withCStruct :: DefragmentationMove -> (Ptr DefragmentationMove -> IO b) -> IO b
withCStruct DefragmentationMove
x Ptr DefragmentationMove -> IO b
f = Int -> (Ptr DefragmentationMove -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr DefragmentationMove -> IO b) -> IO b)
-> (Ptr DefragmentationMove -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr DefragmentationMove
p -> Ptr DefragmentationMove -> DefragmentationMove -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationMove
p DefragmentationMove
x (Ptr DefragmentationMove -> IO b
f Ptr DefragmentationMove
p)
  pokeCStruct :: Ptr DefragmentationMove -> DefragmentationMove -> IO b -> IO b
pokeCStruct Ptr DefragmentationMove
p DefragmentationMove{Allocation
DefragmentationMoveOperation
dstTmpAllocation :: Allocation
srcAllocation :: Allocation
operation :: DefragmentationMoveOperation
$sel:dstTmpAllocation:DefragmentationMove :: DefragmentationMove -> Allocation
$sel:srcAllocation:DefragmentationMove :: DefragmentationMove -> Allocation
$sel:operation:DefragmentationMove :: DefragmentationMove -> DefragmentationMoveOperation
..} IO b
f = do
    Ptr DefragmentationMoveOperation
-> DefragmentationMoveOperation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr DefragmentationMoveOperation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationMoveOperation)) (DefragmentationMoveOperation
operation)
    Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Allocation)) (Allocation
srcAllocation)
    Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Allocation)) (Allocation
dstTmpAllocation)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr DefragmentationMove -> IO b -> IO b
pokeZeroCStruct Ptr DefragmentationMove
p IO b
f = do
    Ptr DefragmentationMoveOperation
-> DefragmentationMoveOperation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr DefragmentationMoveOperation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationMoveOperation)) (DefragmentationMoveOperation
forall a. Zero a => a
zero)
    Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Allocation)) (Allocation
forall a. Zero a => a
zero)
    Ptr Allocation -> Allocation -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Allocation)) (Allocation
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct DefragmentationMove where
  peekCStruct :: Ptr DefragmentationMove -> IO DefragmentationMove
peekCStruct Ptr DefragmentationMove
p = do
    DefragmentationMoveOperation
operation <- Ptr DefragmentationMoveOperation -> IO DefragmentationMoveOperation
forall a. Storable a => Ptr a -> IO a
peek @DefragmentationMoveOperation ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr DefragmentationMoveOperation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DefragmentationMoveOperation))
    Allocation
srcAllocation <- Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr Allocation))
    Allocation
dstTmpAllocation <- Ptr Allocation -> IO Allocation
forall a. Storable a => Ptr a -> IO a
peek @Allocation ((Ptr DefragmentationMove
p Ptr DefragmentationMove -> Int -> Ptr Allocation
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Allocation))
    DefragmentationMove -> IO DefragmentationMove
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DefragmentationMove -> IO DefragmentationMove)
-> DefragmentationMove -> IO DefragmentationMove
forall a b. (a -> b) -> a -> b
$ DefragmentationMoveOperation
-> Allocation -> Allocation -> DefragmentationMove
DefragmentationMove
             DefragmentationMoveOperation
operation Allocation
srcAllocation Allocation
dstTmpAllocation

instance Storable DefragmentationMove where
  sizeOf :: DefragmentationMove -> Int
sizeOf ~DefragmentationMove
_ = Int
24
  alignment :: DefragmentationMove -> Int
alignment ~DefragmentationMove
_ = Int
8
  peek :: Ptr DefragmentationMove -> IO DefragmentationMove
peek = Ptr DefragmentationMove -> IO DefragmentationMove
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr DefragmentationMove -> DefragmentationMove -> IO ()
poke Ptr DefragmentationMove
ptr DefragmentationMove
poked = Ptr DefragmentationMove -> DefragmentationMove -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationMove
ptr DefragmentationMove
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DefragmentationMove where
  zero :: DefragmentationMove
zero = DefragmentationMoveOperation
-> Allocation -> Allocation -> DefragmentationMove
DefragmentationMove
           DefragmentationMoveOperation
forall a. Zero a => a
zero
           Allocation
forall a. Zero a => a
zero
           Allocation
forall a. Zero a => a
zero


-- | VmaDefragmentationPassMoveInfo
--
-- Parameters for incremental defragmentation steps.
--
-- To be used with function 'beginDefragmentationPass'.
data DefragmentationPassMoveInfo = DefragmentationPassMoveInfo
  { -- | Number of elements in the @pMoves@ array.
    ("passInfo" ::: DefragmentationPassMoveInfo)
-> "memoryTypeIndex" ::: Word32
moveCount :: Word32
  , -- | Array of moves to be performed by the user in the current
    -- defragmentation pass.
    --
    -- Pointer to an array of @moveCount@ elements, owned by VMA, created in
    -- 'beginDefragmentationPass', destroyed in 'endDefragmentationPass'.
    --
    -- For each element, you should:
    --
    -- 1.  Create a new buffer\/image in the place pointed by
    --     VmaDefragmentationMove::dstMemory +
    --     VmaDefragmentationMove::dstOffset.
    --
    -- 2.  Copy data from the /VmaDefragmentationMove::srcAllocation/ e.g.
    --     using @vkCmdCopyBuffer@, @vkCmdCopyImage@.
    --
    -- 3.  Make sure these commands finished executing on the GPU.
    --
    -- 4.  Destroy the old buffer\/image.
    --
    -- Only then you can finish defragmentation pass by calling
    -- 'endDefragmentationPass'. After this call, the allocation will point to
    -- the new place in memory.
    --
    -- Alternatively, if you cannot move specific allocation, you can set
    -- /VmaDefragmentationMove::operation/ to
    -- 'DEFRAGMENTATION_MOVE_OPERATION_IGNORE'.
    --
    -- Alternatively, if you decide you want to completely remove the
    -- allocation:
    --
    -- 1.  Destroy its buffer\/image.
    --
    -- 2.  Set /VmaDefragmentationMove::operation/ to
    --     'DEFRAGMENTATION_MOVE_OPERATION_DESTROY'.
    --
    -- Then, after 'endDefragmentationPass' the allocation will be freed.
    ("passInfo" ::: DefragmentationPassMoveInfo)
-> Ptr DefragmentationMove
moves :: Ptr DefragmentationMove
  }
  deriving (Typeable, ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool
(("passInfo" ::: DefragmentationPassMoveInfo)
 -> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool)
-> (("passInfo" ::: DefragmentationPassMoveInfo)
    -> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool)
-> Eq ("passInfo" ::: DefragmentationPassMoveInfo)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool
$c/= :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool
== :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool
$c== :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DefragmentationPassMoveInfo)
#endif
deriving instance Show DefragmentationPassMoveInfo

instance ToCStruct DefragmentationPassMoveInfo where
  withCStruct :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> (Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b)
-> IO b
withCStruct "passInfo" ::: DefragmentationPassMoveInfo
x Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b
f = Int
-> (Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b)
-> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
16 ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b)
 -> IO b)
-> (Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b)
-> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p -> Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p "passInfo" ::: DefragmentationPassMoveInfo
x (Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b
f Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p)
  pokeCStruct :: Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b -> IO b
pokeCStruct Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p DefragmentationPassMoveInfo{"memoryTypeIndex" ::: Word32
Ptr DefragmentationMove
moves :: Ptr DefragmentationMove
moveCount :: "memoryTypeIndex" ::: Word32
$sel:moves:DefragmentationPassMoveInfo :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> Ptr DefragmentationMove
$sel:moveCount:DefragmentationPassMoveInfo :: ("passInfo" ::: DefragmentationPassMoveInfo)
-> "memoryTypeIndex" ::: Word32
..} IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
moveCount)
    Ptr (Ptr DefragmentationMove) -> Ptr DefragmentationMove -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> Int -> Ptr (Ptr DefragmentationMove)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr DefragmentationMove))) (Ptr DefragmentationMove
moves)
    IO b
f
  cStructSize :: Int
cStructSize = Int
16
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr ("passInfo" ::: DefragmentationPassMoveInfo) -> IO b -> IO b
pokeZeroCStruct Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p IO b
f = do
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct DefragmentationPassMoveInfo where
  peekCStruct :: Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
peekCStruct Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p = do
    "memoryTypeIndex" ::: Word32
moveCount <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr Word32))
    Ptr DefragmentationMove
pMoves <- Ptr (Ptr DefragmentationMove) -> IO (Ptr DefragmentationMove)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DefragmentationMove) ((Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
p Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> Int -> Ptr (Ptr DefragmentationMove)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr DefragmentationMove)))
    ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("passInfo" ::: DefragmentationPassMoveInfo)
 -> IO ("passInfo" ::: DefragmentationPassMoveInfo))
-> ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall a b. (a -> b) -> a -> b
$ ("memoryTypeIndex" ::: Word32)
-> Ptr DefragmentationMove
-> "passInfo" ::: DefragmentationPassMoveInfo
DefragmentationPassMoveInfo
             "memoryTypeIndex" ::: Word32
moveCount Ptr DefragmentationMove
pMoves

instance Storable DefragmentationPassMoveInfo where
  sizeOf :: ("passInfo" ::: DefragmentationPassMoveInfo) -> Int
sizeOf ~"passInfo" ::: DefragmentationPassMoveInfo
_ = Int
16
  alignment :: ("passInfo" ::: DefragmentationPassMoveInfo) -> Int
alignment ~"passInfo" ::: DefragmentationPassMoveInfo
_ = Int
8
  peek :: Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
peek = Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> IO ("passInfo" ::: DefragmentationPassMoveInfo)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> IO ()
poke Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
ptr "passInfo" ::: DefragmentationPassMoveInfo
poked = Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
-> ("passInfo" ::: DefragmentationPassMoveInfo) -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("passInfo" ::: DefragmentationPassMoveInfo)
ptr "passInfo" ::: DefragmentationPassMoveInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DefragmentationPassMoveInfo where
  zero :: "passInfo" ::: DefragmentationPassMoveInfo
zero = ("memoryTypeIndex" ::: Word32)
-> Ptr DefragmentationMove
-> "passInfo" ::: DefragmentationPassMoveInfo
DefragmentationPassMoveInfo
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           Ptr DefragmentationMove
forall a. Zero a => a
zero


-- | VmaDefragmentationStats
--
-- Statistics returned for defragmentation process in function
-- 'endDefragmentation'.
data DefragmentationStats = DefragmentationStats
  { -- | Total number of bytes that have been copied while moving allocations to
    -- different places.
    DefragmentationStats -> "offset" ::: DeviceSize
bytesMoved :: DeviceSize
  , -- | Total number of bytes that have been released to the system by freeing
    -- empty @VkDeviceMemory@ objects.
    DefragmentationStats -> "offset" ::: DeviceSize
bytesFreed :: DeviceSize
  , -- | Number of allocations that have been moved to different places.
    DefragmentationStats -> "memoryTypeIndex" ::: Word32
allocationsMoved :: Word32
  , -- | Number of empty @VkDeviceMemory@ objects that have been released to the
    -- system.
    DefragmentationStats -> "memoryTypeIndex" ::: Word32
deviceMemoryBlocksFreed :: Word32
  }
  deriving (Typeable, DefragmentationStats -> DefragmentationStats -> Bool
(DefragmentationStats -> DefragmentationStats -> Bool)
-> (DefragmentationStats -> DefragmentationStats -> Bool)
-> Eq DefragmentationStats
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefragmentationStats -> DefragmentationStats -> Bool
$c/= :: DefragmentationStats -> DefragmentationStats -> Bool
== :: DefragmentationStats -> DefragmentationStats -> Bool
$c== :: DefragmentationStats -> DefragmentationStats -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DefragmentationStats)
#endif
deriving instance Show DefragmentationStats

instance ToCStruct DefragmentationStats where
  withCStruct :: DefragmentationStats -> (Ptr DefragmentationStats -> IO b) -> IO b
withCStruct DefragmentationStats
x Ptr DefragmentationStats -> IO b
f = Int -> (Ptr DefragmentationStats -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr DefragmentationStats -> IO b) -> IO b)
-> (Ptr DefragmentationStats -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr DefragmentationStats
p -> Ptr DefragmentationStats -> DefragmentationStats -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationStats
p DefragmentationStats
x (Ptr DefragmentationStats -> IO b
f Ptr DefragmentationStats
p)
  pokeCStruct :: Ptr DefragmentationStats -> DefragmentationStats -> IO b -> IO b
pokeCStruct Ptr DefragmentationStats
p DefragmentationStats{"memoryTypeIndex" ::: Word32
"offset" ::: DeviceSize
deviceMemoryBlocksFreed :: "memoryTypeIndex" ::: Word32
allocationsMoved :: "memoryTypeIndex" ::: Word32
bytesFreed :: "offset" ::: DeviceSize
bytesMoved :: "offset" ::: DeviceSize
$sel:deviceMemoryBlocksFreed:DefragmentationStats :: DefragmentationStats -> "memoryTypeIndex" ::: Word32
$sel:allocationsMoved:DefragmentationStats :: DefragmentationStats -> "memoryTypeIndex" ::: Word32
$sel:bytesFreed:DefragmentationStats :: DefragmentationStats -> "offset" ::: DeviceSize
$sel:bytesMoved:DefragmentationStats :: DefragmentationStats -> "offset" ::: DeviceSize
..} IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
bytesMoved)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
bytesFreed)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
allocationsMoved)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
deviceMemoryBlocksFreed)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr DefragmentationStats -> IO b -> IO b
pokeZeroCStruct Ptr DefragmentationStats
p IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    Ptr ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32)) ("memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct DefragmentationStats where
  peekCStruct :: Ptr DefragmentationStats -> IO DefragmentationStats
peekCStruct Ptr DefragmentationStats
p = do
    "offset" ::: DeviceSize
bytesMoved <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
bytesFreed <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr DefragmentationStats
p Ptr DefragmentationStats -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize))
    "memoryTypeIndex" ::: Word32
allocationsMoved <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    "memoryTypeIndex" ::: Word32
deviceMemoryBlocksFreed <- Ptr ("memoryTypeIndex" ::: Word32)
-> IO ("memoryTypeIndex" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DefragmentationStats
p Ptr DefragmentationStats
-> Int -> Ptr ("memoryTypeIndex" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32))
    DefragmentationStats -> IO DefragmentationStats
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DefragmentationStats -> IO DefragmentationStats)
-> DefragmentationStats -> IO DefragmentationStats
forall a b. (a -> b) -> a -> b
$ ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32)
-> DefragmentationStats
DefragmentationStats
             "offset" ::: DeviceSize
bytesMoved "offset" ::: DeviceSize
bytesFreed "memoryTypeIndex" ::: Word32
allocationsMoved "memoryTypeIndex" ::: Word32
deviceMemoryBlocksFreed

instance Storable DefragmentationStats where
  sizeOf :: DefragmentationStats -> Int
sizeOf ~DefragmentationStats
_ = Int
24
  alignment :: DefragmentationStats -> Int
alignment ~DefragmentationStats
_ = Int
8
  peek :: Ptr DefragmentationStats -> IO DefragmentationStats
peek = Ptr DefragmentationStats -> IO DefragmentationStats
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr DefragmentationStats -> DefragmentationStats -> IO ()
poke Ptr DefragmentationStats
ptr DefragmentationStats
poked = Ptr DefragmentationStats -> DefragmentationStats -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DefragmentationStats
ptr DefragmentationStats
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero DefragmentationStats where
  zero :: DefragmentationStats
zero = ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("memoryTypeIndex" ::: Word32)
-> ("memoryTypeIndex" ::: Word32)
-> DefragmentationStats
DefragmentationStats
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero
           "memoryTypeIndex" ::: Word32
forall a. Zero a => a
zero


-- | VmaVirtualBlockCreateInfo
--
-- Parameters of created 'VirtualBlock' object to be passed to
-- 'createVirtualBlock'.
data VirtualBlockCreateInfo = VirtualBlockCreateInfo
  { -- | Total size of the virtual block.
    --
    -- Sizes can be expressed in bytes or any units you want as long as you are
    -- consistent in using them. For example, if you allocate from some array
    -- of structures, 1 can mean single instance of entire structure.
    VirtualBlockCreateInfo -> "offset" ::: DeviceSize
size :: DeviceSize
  , -- | Use combination of 'VirtualBlockCreateFlagBits'.
    VirtualBlockCreateInfo -> VirtualBlockCreateFlagBits
flags :: VirtualBlockCreateFlags
  , -- | Custom CPU memory allocation callbacks. Optional.
    --
    -- Optional, can be null. When specified, they will be used for all
    -- CPU-side memory allocations.
    VirtualBlockCreateInfo -> Maybe AllocationCallbacks
allocationCallbacks :: Maybe AllocationCallbacks
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (VirtualBlockCreateInfo)
#endif
deriving instance Show VirtualBlockCreateInfo

instance ToCStruct VirtualBlockCreateInfo where
  withCStruct :: VirtualBlockCreateInfo
-> (Ptr VirtualBlockCreateInfo -> IO b) -> IO b
withCStruct VirtualBlockCreateInfo
x Ptr VirtualBlockCreateInfo -> IO b
f = Int -> (Ptr VirtualBlockCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr VirtualBlockCreateInfo -> IO b) -> IO b)
-> (Ptr VirtualBlockCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr VirtualBlockCreateInfo
p -> Ptr VirtualBlockCreateInfo
-> VirtualBlockCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr VirtualBlockCreateInfo
p VirtualBlockCreateInfo
x (Ptr VirtualBlockCreateInfo -> IO b
f Ptr VirtualBlockCreateInfo
p)
  pokeCStruct :: Ptr VirtualBlockCreateInfo
-> VirtualBlockCreateInfo -> IO b -> IO b
pokeCStruct Ptr VirtualBlockCreateInfo
p VirtualBlockCreateInfo{Maybe AllocationCallbacks
"offset" ::: DeviceSize
VirtualBlockCreateFlagBits
allocationCallbacks :: Maybe AllocationCallbacks
flags :: VirtualBlockCreateFlagBits
size :: "offset" ::: DeviceSize
$sel:allocationCallbacks:VirtualBlockCreateInfo :: VirtualBlockCreateInfo -> Maybe AllocationCallbacks
$sel:flags:VirtualBlockCreateInfo :: VirtualBlockCreateInfo -> VirtualBlockCreateFlagBits
$sel:size:VirtualBlockCreateInfo :: VirtualBlockCreateInfo -> "offset" ::: DeviceSize
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
size)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr VirtualBlockCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr VirtualBlockCreateFlags)) (VirtualBlockCreateFlagBits
flags)
    Ptr AllocationCallbacks
pAllocationCallbacks'' <- case (Maybe AllocationCallbacks
allocationCallbacks) of
      Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks -> ContT b IO (Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
      Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO b) -> IO b)
 -> ContT b IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO b) -> IO b)
-> ContT b IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr AllocationCallbacks) -> Ptr AllocationCallbacks -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr (Ptr AllocationCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr AllocationCallbacks))) Ptr AllocationCallbacks
pAllocationCallbacks''
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr VirtualBlockCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr VirtualBlockCreateInfo
p IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr VirtualBlockCreateFlagBits
-> VirtualBlockCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr VirtualBlockCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr VirtualBlockCreateFlags)) (VirtualBlockCreateFlagBits
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct VirtualBlockCreateInfo where
  peekCStruct :: Ptr VirtualBlockCreateInfo -> IO VirtualBlockCreateInfo
peekCStruct Ptr VirtualBlockCreateInfo
p = do
    "offset" ::: DeviceSize
size <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize))
    VirtualBlockCreateFlagBits
flags <- Ptr VirtualBlockCreateFlagBits -> IO VirtualBlockCreateFlagBits
forall a. Storable a => Ptr a -> IO a
peek @VirtualBlockCreateFlags ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr VirtualBlockCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr VirtualBlockCreateFlags))
    Ptr AllocationCallbacks
pAllocationCallbacks <- Ptr (Ptr AllocationCallbacks) -> IO (Ptr AllocationCallbacks)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr AllocationCallbacks) ((Ptr VirtualBlockCreateInfo
p Ptr VirtualBlockCreateInfo -> Int -> Ptr (Ptr AllocationCallbacks)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr AllocationCallbacks)))
    Maybe AllocationCallbacks
pAllocationCallbacks' <- (Ptr AllocationCallbacks -> IO AllocationCallbacks)
-> Ptr AllocationCallbacks -> IO (Maybe AllocationCallbacks)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
maybePeek (\Ptr AllocationCallbacks
j -> Ptr AllocationCallbacks -> IO AllocationCallbacks
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @AllocationCallbacks (Ptr AllocationCallbacks
j)) Ptr AllocationCallbacks
pAllocationCallbacks
    VirtualBlockCreateInfo -> IO VirtualBlockCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VirtualBlockCreateInfo -> IO VirtualBlockCreateInfo)
-> VirtualBlockCreateInfo -> IO VirtualBlockCreateInfo
forall a b. (a -> b) -> a -> b
$ ("offset" ::: DeviceSize)
-> VirtualBlockCreateFlagBits
-> Maybe AllocationCallbacks
-> VirtualBlockCreateInfo
VirtualBlockCreateInfo
             "offset" ::: DeviceSize
size VirtualBlockCreateFlagBits
flags Maybe AllocationCallbacks
pAllocationCallbacks'

instance Zero VirtualBlockCreateInfo where
  zero :: VirtualBlockCreateInfo
zero = ("offset" ::: DeviceSize)
-> VirtualBlockCreateFlagBits
-> Maybe AllocationCallbacks
-> VirtualBlockCreateInfo
VirtualBlockCreateInfo
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           VirtualBlockCreateFlagBits
forall a. Zero a => a
zero
           Maybe AllocationCallbacks
forall a. Maybe a
Nothing


-- | VmaVirtualAllocationCreateInfo
--
-- Parameters of created virtual allocation to be passed to
-- 'virtualAllocate'.
data VirtualAllocationCreateInfo = VirtualAllocationCreateInfo
  { -- | Size of the allocation.
    --
    -- Cannot be zero.
    VirtualAllocationCreateInfo -> "offset" ::: DeviceSize
size :: DeviceSize
  , -- | Required alignment of the allocation. Optional.
    --
    -- Must be power of two. Special value 0 has the same meaning as 1 - means
    -- no special alignment is required, so allocation can start at any offset.
    VirtualAllocationCreateInfo -> "offset" ::: DeviceSize
alignment :: DeviceSize
  , -- | Use combination of 'VirtualAllocationCreateFlagBits'.
    VirtualAllocationCreateInfo -> VirtualAllocationCreateFlagBits
flags :: VirtualAllocationCreateFlags
  , -- | Custom pointer to be associated with the allocation. Optional.
    --
    -- It can be any value and can be used for user-defined purposes. It can be
    -- fetched or changed later.
    VirtualAllocationCreateInfo -> "userData" ::: Ptr ()
userData :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (VirtualAllocationCreateInfo)
#endif
deriving instance Show VirtualAllocationCreateInfo

instance ToCStruct VirtualAllocationCreateInfo where
  withCStruct :: VirtualAllocationCreateInfo
-> (Ptr VirtualAllocationCreateInfo -> IO b) -> IO b
withCStruct VirtualAllocationCreateInfo
x Ptr VirtualAllocationCreateInfo -> IO b
f = Int -> (Ptr VirtualAllocationCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr VirtualAllocationCreateInfo -> IO b) -> IO b)
-> (Ptr VirtualAllocationCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr VirtualAllocationCreateInfo
p -> Ptr VirtualAllocationCreateInfo
-> VirtualAllocationCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr VirtualAllocationCreateInfo
p VirtualAllocationCreateInfo
x (Ptr VirtualAllocationCreateInfo -> IO b
f Ptr VirtualAllocationCreateInfo
p)
  pokeCStruct :: Ptr VirtualAllocationCreateInfo
-> VirtualAllocationCreateInfo -> IO b -> IO b
pokeCStruct Ptr VirtualAllocationCreateInfo
p VirtualAllocationCreateInfo{"offset" ::: DeviceSize
"userData" ::: Ptr ()
VirtualAllocationCreateFlagBits
userData :: "userData" ::: Ptr ()
flags :: VirtualAllocationCreateFlagBits
alignment :: "offset" ::: DeviceSize
size :: "offset" ::: DeviceSize
$sel:userData:VirtualAllocationCreateInfo :: VirtualAllocationCreateInfo -> "userData" ::: Ptr ()
$sel:flags:VirtualAllocationCreateInfo :: VirtualAllocationCreateInfo -> VirtualAllocationCreateFlagBits
$sel:alignment:VirtualAllocationCreateInfo :: VirtualAllocationCreateInfo -> "offset" ::: DeviceSize
$sel:size:VirtualAllocationCreateInfo :: VirtualAllocationCreateInfo -> "offset" ::: DeviceSize
..} IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
size)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
alignment)
    Ptr VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr VirtualAllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr VirtualAllocationCreateFlags)) (VirtualAllocationCreateFlagBits
flags)
    Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
userData)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr VirtualAllocationCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr VirtualAllocationCreateInfo
p IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr VirtualAllocationCreateFlagBits
-> VirtualAllocationCreateFlagBits -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr VirtualAllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr VirtualAllocationCreateFlags)) (VirtualAllocationCreateFlagBits
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct VirtualAllocationCreateInfo where
  peekCStruct :: Ptr VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo
peekCStruct Ptr VirtualAllocationCreateInfo
p = do
    "offset" ::: DeviceSize
size <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
alignment <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize))
    VirtualAllocationCreateFlagBits
flags <- Ptr VirtualAllocationCreateFlagBits
-> IO VirtualAllocationCreateFlagBits
forall a. Storable a => Ptr a -> IO a
peek @VirtualAllocationCreateFlags ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr VirtualAllocationCreateFlagBits
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr VirtualAllocationCreateFlags))
    "userData" ::: Ptr ()
pUserData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr VirtualAllocationCreateInfo
p Ptr VirtualAllocationCreateInfo
-> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr ())))
    VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo)
-> VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo
forall a b. (a -> b) -> a -> b
$ ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> VirtualAllocationCreateFlagBits
-> ("userData" ::: Ptr ())
-> VirtualAllocationCreateInfo
VirtualAllocationCreateInfo
             "offset" ::: DeviceSize
size "offset" ::: DeviceSize
alignment VirtualAllocationCreateFlagBits
flags "userData" ::: Ptr ()
pUserData

instance Storable VirtualAllocationCreateInfo where
  sizeOf :: VirtualAllocationCreateInfo -> Int
sizeOf ~VirtualAllocationCreateInfo
_ = Int
32
  alignment :: VirtualAllocationCreateInfo -> Int
alignment ~VirtualAllocationCreateInfo
_ = Int
8
  peek :: Ptr VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo
peek = Ptr VirtualAllocationCreateInfo -> IO VirtualAllocationCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr VirtualAllocationCreateInfo
-> VirtualAllocationCreateInfo -> IO ()
poke Ptr VirtualAllocationCreateInfo
ptr VirtualAllocationCreateInfo
poked = Ptr VirtualAllocationCreateInfo
-> VirtualAllocationCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr VirtualAllocationCreateInfo
ptr VirtualAllocationCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero VirtualAllocationCreateInfo where
  zero :: VirtualAllocationCreateInfo
zero = ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> VirtualAllocationCreateFlagBits
-> ("userData" ::: Ptr ())
-> VirtualAllocationCreateInfo
VirtualAllocationCreateInfo
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           VirtualAllocationCreateFlagBits
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero


-- | VmaVirtualAllocationInfo
--
-- Parameters of an existing virtual allocation, returned by
-- 'getVirtualAllocationInfo'.
data VirtualAllocationInfo = VirtualAllocationInfo
  { -- | Offset of the allocation.
    --
    -- Offset at which the allocation was made.
    ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "offset" ::: DeviceSize
offset :: DeviceSize
  , -- | Size of the allocation.
    --
    -- Same value as passed in /VmaVirtualAllocationCreateInfo::size/.
    ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "offset" ::: DeviceSize
size :: DeviceSize
  , -- | Custom pointer associated with the allocation.
    --
    -- Same value as passed in /VmaVirtualAllocationCreateInfo::pUserData/ or
    -- to 'setVirtualAllocationUserData'.
    ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "userData" ::: Ptr ()
userData :: Ptr ()
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (VirtualAllocationInfo)
#endif
deriving instance Show VirtualAllocationInfo

instance ToCStruct VirtualAllocationInfo where
  withCStruct :: ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b)
-> IO b
withCStruct "virtualAllocInfo" ::: VirtualAllocationInfo
x Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b
f = Int
-> (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b)
-> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b)
 -> IO b)
-> (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b)
-> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p -> Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p "virtualAllocInfo" ::: VirtualAllocationInfo
x (Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b
f Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p)
  pokeCStruct :: Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b -> IO b
pokeCStruct Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p VirtualAllocationInfo{"offset" ::: DeviceSize
"userData" ::: Ptr ()
userData :: "userData" ::: Ptr ()
size :: "offset" ::: DeviceSize
offset :: "offset" ::: DeviceSize
$sel:userData:VirtualAllocationInfo :: ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "userData" ::: Ptr ()
$sel:size:VirtualAllocationInfo :: ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "offset" ::: DeviceSize
$sel:offset:VirtualAllocationInfo :: ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> "offset" ::: DeviceSize
..} IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
offset)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
size)
    Ptr ("userData" ::: Ptr ()) -> ("userData" ::: Ptr ()) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr ()))) ("userData" ::: Ptr ()
userData)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO b -> IO b
pokeZeroCStruct Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p IO b
f = do
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    Ptr ("offset" ::: DeviceSize) -> ("offset" ::: DeviceSize) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize)) ("offset" ::: DeviceSize
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct VirtualAllocationInfo where
  peekCStruct :: Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
peekCStruct Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p = do
    "offset" ::: DeviceSize
offset <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr DeviceSize))
    "offset" ::: DeviceSize
size <- Ptr ("offset" ::: DeviceSize) -> IO ("offset" ::: DeviceSize)
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("offset" ::: DeviceSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr DeviceSize))
    "userData" ::: Ptr ()
pUserData <- Ptr ("userData" ::: Ptr ()) -> IO ("userData" ::: Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
p Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> Int -> Ptr ("userData" ::: Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr (Ptr ())))
    ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("virtualAllocInfo" ::: VirtualAllocationInfo)
 -> IO ("virtualAllocInfo" ::: VirtualAllocationInfo))
-> ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a b. (a -> b) -> a -> b
$ ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> "virtualAllocInfo" ::: VirtualAllocationInfo
VirtualAllocationInfo
             "offset" ::: DeviceSize
offset "offset" ::: DeviceSize
size "userData" ::: Ptr ()
pUserData

instance Storable VirtualAllocationInfo where
  sizeOf :: ("virtualAllocInfo" ::: VirtualAllocationInfo) -> Int
sizeOf ~"virtualAllocInfo" ::: VirtualAllocationInfo
_ = Int
24
  alignment :: ("virtualAllocInfo" ::: VirtualAllocationInfo) -> Int
alignment ~"virtualAllocInfo" ::: VirtualAllocationInfo
_ = Int
8
  peek :: Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
peek = Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> IO ("virtualAllocInfo" ::: VirtualAllocationInfo)
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO ()
poke Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
ptr "virtualAllocInfo" ::: VirtualAllocationInfo
poked = Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
-> ("virtualAllocInfo" ::: VirtualAllocationInfo) -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ("virtualAllocInfo" ::: VirtualAllocationInfo)
ptr "virtualAllocInfo" ::: VirtualAllocationInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero VirtualAllocationInfo where
  zero :: "virtualAllocInfo" ::: VirtualAllocationInfo
zero = ("offset" ::: DeviceSize)
-> ("offset" ::: DeviceSize)
-> ("userData" ::: Ptr ())
-> "virtualAllocInfo" ::: VirtualAllocationInfo
VirtualAllocationInfo
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "offset" ::: DeviceSize
forall a. Zero a => a
zero
           "userData" ::: Ptr ()
forall a. Zero a => a
zero