{-# language CPP #-}
-- No documentation found for Chapter "CommandPool"
module Vulkan.Core10.CommandPool  ( createCommandPool
                                  , withCommandPool
                                  , destroyCommandPool
                                  , resetCommandPool
                                  , CommandPoolCreateInfo(..)
                                  , CommandPool(..)
                                  , CommandPoolCreateFlagBits(..)
                                  , CommandPoolCreateFlags
                                  , CommandPoolResetFlagBits(..)
                                  , CommandPoolResetFlags
                                  ) where

import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (CommandPool)
import Vulkan.Core10.Handles (CommandPool(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlags)
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlags)
import {-# SOURCE #-} Vulkan.Extensions.VK_ARM_data_graph (DataGraphProcessingEngineCreateInfoARM)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkCreateCommandPool))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyCommandPool))
import Vulkan.Dynamic (DeviceCmds(pVkResetCommandPool))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Handles (CommandPool(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlags)
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlags)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkCreateCommandPool
  :: FunPtr (Ptr Device_T -> Ptr (SomeStruct CommandPoolCreateInfo) -> Ptr AllocationCallbacks -> Ptr CommandPool -> IO Result) -> Ptr Device_T -> Ptr (SomeStruct CommandPoolCreateInfo) -> Ptr AllocationCallbacks -> Ptr CommandPool -> IO Result

-- | vkCreateCommandPool - Create a new command pool object
--
-- == Valid Usage
--
-- -   #VUID-vkCreateCommandPool-queueFamilyIndex-01937#
--     @pCreateInfo->queueFamilyIndex@ /must/ be the index of a queue
--     family available in the logical device @device@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkCreateCommandPool-device-parameter# @device@ /must/ be a
--     valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkCreateCommandPool-pCreateInfo-parameter# @pCreateInfo@
--     /must/ be a valid pointer to a valid 'CommandPoolCreateInfo'
--     structure
--
-- -   #VUID-vkCreateCommandPool-pAllocator-parameter# If @pAllocator@ is
--     not @NULL@, @pAllocator@ /must/ be a valid pointer to a valid
--     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' structure
--
-- -   #VUID-vkCreateCommandPool-pCommandPool-parameter# @pCommandPool@
--     /must/ be a valid pointer to a 'Vulkan.Core10.Handles.CommandPool'
--     handle
--
-- -   #VUID-vkCreateCommandPool-device-queuecount# The device /must/ have
--     been created with at least @1@ queue
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_UNKNOWN'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_VALIDATION_FAILED'
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>,
-- 'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks',
-- 'Vulkan.Core10.Handles.CommandPool', 'CommandPoolCreateInfo',
-- 'Vulkan.Core10.Handles.Device'
createCommandPool :: forall a io
                   . (Extendss CommandPoolCreateInfo a, PokeChain a, MonadIO io)
                  => -- | @device@ is the logical device that creates the command pool.
                     Device
                  -> -- | @pCreateInfo@ is a pointer to a 'CommandPoolCreateInfo' structure
                     -- specifying the state of the command pool object.
                     (CommandPoolCreateInfo a)
                  -> -- | @pAllocator@ controls host memory allocation as described in the
                     -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#memory-allocation Memory Allocation>
                     -- chapter.
                     ("allocator" ::: Maybe AllocationCallbacks)
                  -> io (CommandPool)
createCommandPool :: forall (a :: [*]) (io :: * -> *).
(Extendss CommandPoolCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> CommandPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
createCommandPool Device
device CommandPoolCreateInfo a
createInfo "allocator" ::: Maybe AllocationCallbacks
allocator = IO CommandPool -> io CommandPool
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CommandPool -> io CommandPool)
-> (ContT CommandPool IO CommandPool -> IO CommandPool)
-> ContT CommandPool IO CommandPool
-> io CommandPool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT CommandPool IO CommandPool -> IO CommandPool
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT CommandPool IO CommandPool -> io CommandPool)
-> ContT CommandPool IO CommandPool -> io CommandPool
forall a b. (a -> b) -> a -> b
$ do
  let vkCreateCommandPoolPtr :: FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
vkCreateCommandPoolPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> Ptr (SomeStruct CommandPoolCreateInfo)
      -> Ptr AllocationCallbacks
      -> Ptr CommandPool
      -> IO Result)
pVkCreateCommandPool (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT CommandPool IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT CommandPool m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT CommandPool IO ())
-> IO () -> ContT CommandPool IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
vkCreateCommandPoolPtr FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> Ptr (SomeStruct CommandPoolCreateInfo)
      -> Ptr AllocationCallbacks
      -> Ptr CommandPool
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. (HasCallStack, 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
"The function pointer for vkCreateCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkCreateCommandPool' :: Ptr Device_T
-> Ptr (SomeStruct CommandPoolCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr CommandPool
-> IO Result
vkCreateCommandPool' = FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
-> Ptr Device_T
-> Ptr (SomeStruct CommandPoolCreateInfo)
-> Ptr AllocationCallbacks
-> Ptr CommandPool
-> IO Result
mkVkCreateCommandPool FunPtr
  (Ptr Device_T
   -> Ptr (SomeStruct CommandPoolCreateInfo)
   -> Ptr AllocationCallbacks
   -> Ptr CommandPool
   -> IO Result)
vkCreateCommandPoolPtr
  pCreateInfo <- ((Ptr (CommandPoolCreateInfo a) -> IO CommandPool)
 -> IO CommandPool)
-> ContT CommandPool IO (Ptr (CommandPoolCreateInfo a))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (CommandPoolCreateInfo a) -> IO CommandPool)
  -> IO CommandPool)
 -> ContT CommandPool IO (Ptr (CommandPoolCreateInfo a)))
-> ((Ptr (CommandPoolCreateInfo a) -> IO CommandPool)
    -> IO CommandPool)
-> ContT CommandPool IO (Ptr (CommandPoolCreateInfo a))
forall a b. (a -> b) -> a -> b
$ CommandPoolCreateInfo a
-> (Ptr (CommandPoolCreateInfo a) -> IO CommandPool)
-> IO CommandPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
CommandPoolCreateInfo a
-> (Ptr (CommandPoolCreateInfo a) -> IO b) -> IO b
withCStruct (CommandPoolCreateInfo a
createInfo)
  pAllocator <- case (allocator) of
    "allocator" ::: Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks
-> ContT CommandPool IO (Ptr AllocationCallbacks)
forall a. a -> ContT CommandPool IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
    Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO CommandPool) -> IO CommandPool)
-> ContT CommandPool IO (Ptr AllocationCallbacks)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO CommandPool) -> IO CommandPool)
 -> ContT CommandPool IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO CommandPool) -> IO CommandPool)
-> ContT CommandPool IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (Ptr AllocationCallbacks -> IO CommandPool) -> IO CommandPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
  pPCommandPool <- ContT $ bracket (callocBytes @CommandPool 8) free
  r <- lift $ traceAroundEvent "vkCreateCommandPool" (vkCreateCommandPool'
                                                        (deviceHandle (device))
                                                        (forgetExtensions pCreateInfo)
                                                        pAllocator
                                                        (pPCommandPool))
  lift $ when (r < SUCCESS) (throwIO (VulkanException r))
  pCommandPool <- lift $ peek @CommandPool pPCommandPool
  pure $ (pCommandPool)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'createCommandPool' and 'destroyCommandPool'
--
-- To ensure that 'destroyCommandPool' 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.
--
withCommandPool :: forall a io r . (Extendss CommandPoolCreateInfo a, PokeChain a, MonadIO io) => Device -> CommandPoolCreateInfo a -> Maybe AllocationCallbacks -> (io CommandPool -> (CommandPool -> io ()) -> r) -> r
withCommandPool :: forall (a :: [*]) (io :: * -> *) r.
(Extendss CommandPoolCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> CommandPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io CommandPool -> (CommandPool -> io ()) -> r)
-> r
withCommandPool Device
device CommandPoolCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator io CommandPool -> (CommandPool -> io ()) -> r
b =
  io CommandPool -> (CommandPool -> io ()) -> r
b (Device
-> CommandPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
forall (a :: [*]) (io :: * -> *).
(Extendss CommandPoolCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> CommandPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
createCommandPool Device
device CommandPoolCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
    (\(CommandPool
o0) -> Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyCommandPool Device
device CommandPool
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkDestroyCommandPool
  :: FunPtr (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()

-- | vkDestroyCommandPool - Destroy a command pool object
--
-- = Description
--
-- When a pool is destroyed, all command buffers allocated from the pool
-- are <vkFreeCommandBuffers.html freed>.
--
-- Any primary command buffer allocated from another
-- 'Vulkan.Core10.Handles.CommandPool' that is in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording or executable state>
-- and has a secondary command buffer allocated from @commandPool@ recorded
-- into it, becomes
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid>.
--
-- == Valid Usage
--
-- -   #VUID-vkDestroyCommandPool-commandPool-00041# All
--     'Vulkan.Core10.Handles.CommandBuffer' objects allocated from
--     @commandPool@ /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkDestroyCommandPool-commandPool-00042# If
--     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' were
--     provided when @commandPool@ was created, a compatible set of
--     callbacks /must/ be provided here
--
-- -   #VUID-vkDestroyCommandPool-commandPool-00043# If no
--     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' were
--     provided when @commandPool@ was created, @pAllocator@ /must/ be
--     @NULL@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkDestroyCommandPool-device-parameter# @device@ /must/ be a
--     valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkDestroyCommandPool-commandPool-parameter# If @commandPool@
--     is not 'Vulkan.Core10.APIConstants.NULL_HANDLE', @commandPool@
--     /must/ be a valid 'Vulkan.Core10.Handles.CommandPool' handle
--
-- -   #VUID-vkDestroyCommandPool-pAllocator-parameter# If @pAllocator@ is
--     not @NULL@, @pAllocator@ /must/ be a valid pointer to a valid
--     'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks' structure
--
-- -   #VUID-vkDestroyCommandPool-commandPool-parent# If @commandPool@ is a
--     valid handle, it /must/ have been created, allocated, or retrieved
--     from @device@
--
-- == Host Synchronization
--
-- -   Host access to @commandPool@ /must/ be externally synchronized
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>,
-- 'Vulkan.Core10.AllocationCallbacks.AllocationCallbacks',
-- 'Vulkan.Core10.Handles.CommandPool', 'Vulkan.Core10.Handles.Device'
destroyCommandPool :: forall io
                    . (MonadIO io)
                   => -- | @device@ is the logical device that destroys the command pool.
                      Device
                   -> -- | @commandPool@ is the handle of the command pool to destroy.
                      CommandPool
                   -> -- | @pAllocator@ controls host memory allocation as described in the
                      -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#memory-allocation Memory Allocation>
                      -- chapter.
                      ("allocator" ::: Maybe AllocationCallbacks)
                   -> io ()
destroyCommandPool :: forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyCommandPool Device
device CommandPool
commandPool "allocator" ::: Maybe AllocationCallbacks
allocator = IO () -> io ()
forall a. IO a -> io a
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 vkDestroyCommandPoolPtr :: FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
vkDestroyCommandPoolPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
pVkDestroyCommandPool (case Device
device of Device{DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT () IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT () m a
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 (FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
vkDestroyCommandPoolPtr FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
-> FunPtr
     (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. (HasCallStack, 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
"The function pointer for vkDestroyCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkDestroyCommandPool' :: Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()
vkDestroyCommandPool' = FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
-> Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()
mkVkDestroyCommandPool FunPtr
  (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ())
vkDestroyCommandPoolPtr
  pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
    "allocator" ::: Maybe AllocationCallbacks
Nothing -> Ptr AllocationCallbacks -> ContT () IO (Ptr AllocationCallbacks)
forall a. a -> ContT () IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
    Just AllocationCallbacks
j -> ((Ptr AllocationCallbacks -> IO ()) -> IO ())
-> ContT () IO (Ptr AllocationCallbacks)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr AllocationCallbacks -> IO ()) -> IO ())
 -> ContT () IO (Ptr AllocationCallbacks))
-> ((Ptr AllocationCallbacks -> IO ()) -> IO ())
-> ContT () IO (Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks -> (Ptr AllocationCallbacks -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
AllocationCallbacks -> (Ptr AllocationCallbacks -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
  lift $ traceAroundEvent "vkDestroyCommandPool" (vkDestroyCommandPool'
                                                    (deviceHandle (device))
                                                    (commandPool)
                                                    pAllocator)
  pure $ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkResetCommandPool
  :: FunPtr (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result) -> Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result

-- | vkResetCommandPool - Reset a command pool
--
-- = Description
--
-- Resetting a command pool recycles all of the resources from all of the
-- command buffers allocated from the command pool back to the command
-- pool. All command buffers that have been allocated from the command pool
-- are put in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle initial state>.
--
-- Any primary command buffer allocated from another
-- 'Vulkan.Core10.Handles.CommandPool' that is in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording or executable state>
-- and has a secondary command buffer allocated from @commandPool@ recorded
-- into it, becomes
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid>.
--
-- == Valid Usage
--
-- -   #VUID-vkResetCommandPool-commandPool-00040# All
--     'Vulkan.Core10.Handles.CommandBuffer' objects allocated from
--     @commandPool@ /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkResetCommandPool-device-parameter# @device@ /must/ be a
--     valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkResetCommandPool-commandPool-parameter# @commandPool@ /must/
--     be a valid 'Vulkan.Core10.Handles.CommandPool' handle
--
-- -   #VUID-vkResetCommandPool-flags-parameter# @flags@ /must/ be a valid
--     combination of
--     'Vulkan.Core10.Enums.CommandPoolResetFlagBits.CommandPoolResetFlagBits'
--     values
--
-- -   #VUID-vkResetCommandPool-commandPool-parent# @commandPool@ /must/
--     have been created, allocated, or retrieved from @device@
--
-- == Host Synchronization
--
-- -   Host access to @commandPool@ /must/ be externally synchronized
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_UNKNOWN'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_VALIDATION_FAILED'
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>,
-- 'Vulkan.Core10.Handles.CommandPool',
-- 'Vulkan.Core10.Enums.CommandPoolResetFlagBits.CommandPoolResetFlags',
-- 'Vulkan.Core10.Handles.Device'
resetCommandPool :: forall io
                  . (MonadIO io)
                 => -- | @device@ is the logical device that owns the command pool.
                    Device
                 -> -- | @commandPool@ is the command pool to reset.
                    CommandPool
                 -> -- | @flags@ is a bitmask of
                    -- 'Vulkan.Core10.Enums.CommandPoolResetFlagBits.CommandPoolResetFlagBits'
                    -- controlling the reset operation.
                    CommandPoolResetFlags
                 -> io ()
resetCommandPool :: forall (io :: * -> *).
MonadIO io =>
Device -> CommandPool -> CommandPoolResetFlags -> io ()
resetCommandPool Device
device CommandPool
commandPool CommandPoolResetFlags
flags = IO () -> io ()
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let vkResetCommandPoolPtr :: FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
pVkResetCommandPool (case Device
device of Device{DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> FunPtr
     (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. (HasCallStack, 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
"The function pointer for vkResetCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkResetCommandPool' :: Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result
vkResetCommandPool' = FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> Ptr Device_T
-> CommandPool
-> CommandPoolResetFlags
-> IO Result
mkVkResetCommandPool FunPtr
  (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr
  r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkResetCommandPool" (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result
vkResetCommandPool'
                                                (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                (CommandPool
commandPool)
                                                (CommandPoolResetFlags
flags))
  when (r < SUCCESS) (throwIO (VulkanException r))


-- | VkCommandPoolCreateInfo - Structure specifying parameters of a newly
-- created command pool
--
-- == Valid Usage
--
-- -   #VUID-VkCommandPoolCreateInfo-flags-02860# If the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-protectedMemory protectedMemory>
--     feature is not enabled, the
--     'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.COMMAND_POOL_CREATE_PROTECTED_BIT'
--     bit of @flags@ /must/ not be set
--
-- -   #VUID-VkCommandPoolCreateInfo-pNext-09908# If the @pNext@ chain
--     includes a
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--     structure, then @queueFamilyIndex@ /must/ designate a queue family
--     that supports
--     'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_DATA_GRAPH_BIT_ARM'
--
-- -   #VUID-VkCommandPoolCreateInfo-pNext-09909# If the @pNext@ chain
--     includes a
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--     structure, each member of @pProcessingEngines@ /must/ be identical
--     to
--     'Vulkan.Extensions.VK_ARM_data_graph.QueueFamilyDataGraphPropertiesARM'::@engine@
--     retrieved from
--     'Vulkan.Extensions.VK_ARM_data_graph.getPhysicalDeviceQueueFamilyDataGraphPropertiesARM'
--     with @queueFamilyIndex@ and the @physicalDevice@ that was used to
--     create @device@
--
-- -   #VUID-VkCommandPoolCreateInfo-queueFamilyIndex-11830# If
--     @queueFamilyIndex@ designates a queue family that supports
--     'Vulkan.Core10.Enums.QueueFlagBits.QUEUE_DATA_GRAPH_BIT_ARM' and
--     enumerates a foreign engine through
--     'Vulkan.Extensions.VK_ARM_data_graph.getPhysicalDeviceQueueFamilyDataGraphPropertiesARM'
--     with type
--     'Vulkan.Extensions.VK_ARM_data_graph.PHYSICAL_DEVICE_DATA_GRAPH_PROCESSING_ENGINE_TYPE_NEURAL_QCOM'
--     or
--     'Vulkan.Extensions.VK_ARM_data_graph.PHYSICAL_DEVICE_DATA_GRAPH_PROCESSING_ENGINE_TYPE_COMPUTE_QCOM',
--     the @pNext@ chain must include
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--     with
--     'Vulkan.Extensions.VK_ARM_data_graph.PhysicalDeviceDataGraphProcessingEngineARM'::@isForeign@
--     set to 'Vulkan.Core10.FundamentalTypes.TRUE' for all elements of
--     @pProcessingEngines@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkCommandPoolCreateInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO'
--
-- -   #VUID-VkCommandPoolCreateInfo-pNext-pNext# @pNext@ /must/ be @NULL@
--     or a pointer to a valid instance of
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--
-- -   #VUID-VkCommandPoolCreateInfo-sType-unique# The @sType@ value of
--     each structure in the @pNext@ chain /must/ be unique
--
-- -   #VUID-VkCommandPoolCreateInfo-flags-parameter# @flags@ /must/ be a
--     valid combination of
--     'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.CommandPoolCreateFlagBits'
--     values
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>,
-- 'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.CommandPoolCreateFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'createCommandPool'
data CommandPoolCreateInfo (es :: [Type]) = CommandPoolCreateInfo
  { -- | @pNext@ is @NULL@ or a pointer to a structure extending this structure.
    forall (es :: [*]). CommandPoolCreateInfo es -> Chain es
next :: Chain es
  , -- | @flags@ is a bitmask of
    -- 'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.CommandPoolCreateFlagBits'
    -- indicating usage behavior for the pool and command buffers allocated
    -- from it.
    forall (es :: [*]).
CommandPoolCreateInfo es -> CommandPoolCreateFlags
flags :: CommandPoolCreateFlags
  , -- | @queueFamilyIndex@ designates a queue family as described in section
    -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#devsandqueues-queueprops Queue Family Properties>.
    -- All command buffers allocated from this command pool /must/ be submitted
    -- on queues from the same queue family.
    forall (es :: [*]). CommandPoolCreateInfo es -> Word32
queueFamilyIndex :: Word32
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (CommandPoolCreateInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (CommandPoolCreateInfo es)

instance Extensible CommandPoolCreateInfo where
  extensibleTypeName :: String
extensibleTypeName = String
"CommandPoolCreateInfo"
  setNext :: forall (ds :: [*]) (es :: [*]).
CommandPoolCreateInfo ds -> Chain es -> CommandPoolCreateInfo es
setNext CommandPoolCreateInfo{Word32
CommandPoolCreateFlags
Chain ds
next :: forall (es :: [*]). CommandPoolCreateInfo es -> Chain es
flags :: forall (es :: [*]).
CommandPoolCreateInfo es -> CommandPoolCreateFlags
queueFamilyIndex :: forall (es :: [*]). CommandPoolCreateInfo es -> Word32
next :: Chain ds
flags :: CommandPoolCreateFlags
queueFamilyIndex :: Word32
..} Chain es
next' = CommandPoolCreateInfo{next :: Chain es
next = Chain es
next', Word32
CommandPoolCreateFlags
flags :: CommandPoolCreateFlags
queueFamilyIndex :: Word32
flags :: CommandPoolCreateFlags
queueFamilyIndex :: Word32
..}
  getNext :: forall (es :: [*]). CommandPoolCreateInfo es -> Chain es
getNext CommandPoolCreateInfo{Word32
CommandPoolCreateFlags
Chain es
next :: forall (es :: [*]). CommandPoolCreateInfo es -> Chain es
flags :: forall (es :: [*]).
CommandPoolCreateInfo es -> CommandPoolCreateFlags
queueFamilyIndex :: forall (es :: [*]). CommandPoolCreateInfo es -> Word32
next :: Chain es
flags :: CommandPoolCreateFlags
queueFamilyIndex :: Word32
..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends CommandPoolCreateInfo e => b) -> Maybe b
  extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends CommandPoolCreateInfo e => b) -> Maybe b
extends proxy e
_ Extends CommandPoolCreateInfo e => b
f
    | Just e :~: DataGraphProcessingEngineCreateInfoARM
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
forall a b. (Typeable a, Typeable b) => Maybe (a :~: b)
eqT @e @DataGraphProcessingEngineCreateInfoARM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandPoolCreateInfo e => b
f
    | Bool
otherwise = Maybe b
forall a. Maybe a
Nothing

instance ( Extendss CommandPoolCreateInfo es
         , PokeChain es ) => ToCStruct (CommandPoolCreateInfo es) where
  withCStruct :: forall b.
CommandPoolCreateInfo es
-> (Ptr (CommandPoolCreateInfo es) -> IO b) -> IO b
withCStruct CommandPoolCreateInfo es
x Ptr (CommandPoolCreateInfo es) -> IO b
f = Int -> (Ptr (CommandPoolCreateInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr (CommandPoolCreateInfo es) -> IO b) -> IO b)
-> (Ptr (CommandPoolCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (CommandPoolCreateInfo es)
p -> Ptr (CommandPoolCreateInfo es)
-> CommandPoolCreateInfo es -> IO b -> IO b
forall b.
Ptr (CommandPoolCreateInfo es)
-> CommandPoolCreateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (CommandPoolCreateInfo es)
p CommandPoolCreateInfo es
x (Ptr (CommandPoolCreateInfo es) -> IO b
f Ptr (CommandPoolCreateInfo es)
p)
  pokeCStruct :: forall b.
Ptr (CommandPoolCreateInfo es)
-> CommandPoolCreateInfo es -> IO b -> IO b
pokeCStruct Ptr (CommandPoolCreateInfo es)
p CommandPoolCreateInfo{Word32
CommandPoolCreateFlags
Chain es
next :: forall (es :: [*]). CommandPoolCreateInfo es -> Chain es
flags :: forall (es :: [*]).
CommandPoolCreateInfo es -> CommandPoolCreateFlags
queueFamilyIndex :: forall (es :: [*]). CommandPoolCreateInfo es -> Word32
next :: Chain es
flags :: CommandPoolCreateFlags
queueFamilyIndex :: 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 (m :: * -> *) a. Monad m => m a -> ContT b m a
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 StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (CommandPoolCreateInfo es)
p Ptr (CommandPoolCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
    pNext'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> ContT b IO a -> ContT b IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
    -> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ Chain es -> (Ptr (Chain es) -> IO b) -> IO b
forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
forall a. Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
    lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext''
    lift $ poke ((p `plusPtr` 16 :: Ptr CommandPoolCreateFlags)) (flags)
    lift $ poke ((p `plusPtr` 20 :: Ptr Word32)) (queueFamilyIndex)
    lift $ f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr (CommandPoolCreateInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (CommandPoolCreateInfo es)
p 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 (m :: * -> *) a. Monad m => m a -> ContT b m a
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 StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (CommandPoolCreateInfo es)
p Ptr (CommandPoolCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
    pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> ContT b IO a -> ContT b IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
    -> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
    lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext'
    lift $ poke ((p `plusPtr` 20 :: Ptr Word32)) (zero)
    lift $ f

instance ( Extendss CommandPoolCreateInfo es
         , PeekChain es ) => FromCStruct (CommandPoolCreateInfo es) where
  peekCStruct :: Ptr (CommandPoolCreateInfo es) -> IO (CommandPoolCreateInfo es)
peekCStruct Ptr (CommandPoolCreateInfo es)
p = do
    pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (CommandPoolCreateInfo es)
p Ptr (CommandPoolCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
    next <- peekChain (castPtr pNext)
    flags <- peek @CommandPoolCreateFlags ((p `plusPtr` 16 :: Ptr CommandPoolCreateFlags))
    queueFamilyIndex <- peek @Word32 ((p `plusPtr` 20 :: Ptr Word32))
    pure $ CommandPoolCreateInfo
             next flags queueFamilyIndex

instance es ~ '[] => Zero (CommandPoolCreateInfo es) where
  zero :: CommandPoolCreateInfo es
zero = Chain es
-> CommandPoolCreateFlags -> Word32 -> CommandPoolCreateInfo es
forall (es :: [*]).
Chain es
-> CommandPoolCreateFlags -> Word32 -> CommandPoolCreateInfo es
CommandPoolCreateInfo
           ()
           CommandPoolCreateFlags
forall a. Zero a => a
zero
           Word32
forall a. Zero a => a
zero