{-# language CPP #-}
-- No documentation found for Chapter "CommandBuffer"
module Vulkan.Core10.CommandBuffer  ( allocateCommandBuffers
                                    , withCommandBuffers
                                    , freeCommandBuffers
                                    , beginCommandBuffer
                                    , useCommandBuffer
                                    , endCommandBuffer
                                    , resetCommandBuffer
                                    , CommandBufferAllocateInfo(..)
                                    , CommandBufferInheritanceInfo(..)
                                    , CommandBufferBeginInfo(..)
                                    , CommandBuffer(..)
                                    , CommandBufferLevel(..)
                                    , QueryControlFlagBits(..)
                                    , QueryControlFlags
                                    , CommandBufferUsageFlagBits(..)
                                    , CommandBufferUsageFlags
                                    , CommandBufferResetFlagBits(..)
                                    , CommandBufferResetFlags
                                    ) 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 Foreign.Marshal.Utils (maybePeek)
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 Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
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)
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 Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (peekSomeCStruct)
import Vulkan.CStruct.Extends (withSomeCStruct)
import Vulkan.NamedType ((:::))
import {-# SOURCE #-} Vulkan.Extensions.VK_AMD_mixed_attachment_samples (AttachmentSampleCountInfoAMD)
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (CommandBuffer)
import Vulkan.Core10.Handles (CommandBuffer(..))
import Vulkan.Core10.Handles (CommandBuffer(CommandBuffer))
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_conditional_rendering (CommandBufferInheritanceConditionalRenderingInfoEXT)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_descriptor_heap (CommandBufferInheritanceDescriptorHeapInfoEXT)
import {-# SOURCE #-} Vulkan.Extensions.VK_QCOM_render_pass_transform (CommandBufferInheritanceRenderPassTransformInfoQCOM)
import {-# SOURCE #-} Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering (CommandBufferInheritanceRenderingInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_inherited_viewport_scissor (CommandBufferInheritanceViewportScissorInfoNV)
import Vulkan.Core10.Enums.CommandBufferLevel (CommandBufferLevel)
import Vulkan.Core10.Enums.CommandBufferResetFlagBits (CommandBufferResetFlagBits(..))
import Vulkan.Core10.Enums.CommandBufferResetFlagBits (CommandBufferResetFlags)
import Vulkan.Core10.Enums.CommandBufferUsageFlagBits (CommandBufferUsageFlags)
import Vulkan.Core10.Handles (CommandBuffer_T)
import Vulkan.Core10.Handles (CommandPool)
import Vulkan.Core10.Handles (CommandPool(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_custom_resolve (CustomResolveCreateInfoEXT)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkAllocateCommandBuffers))
import Vulkan.Dynamic (DeviceCmds(pVkBeginCommandBuffer))
import Vulkan.Dynamic (DeviceCmds(pVkEndCommandBuffer))
import Vulkan.Dynamic (DeviceCmds(pVkFreeCommandBuffers))
import Vulkan.Dynamic (DeviceCmds(pVkResetCommandBuffer))
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_group (DeviceGroupCommandBufferBeginInfo)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer (ExternalFormatANDROID)
import Vulkan.Core10.Handles (Framebuffer)
import {-# SOURCE #-} Vulkan.Extensions.VK_NVX_multiview_per_view_attributes (MultiviewPerViewAttributesInfoNVX)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.QueryControlFlagBits (QueryControlFlags)
import Vulkan.Core10.Enums.QueryPipelineStatisticFlagBits (QueryPipelineStatisticFlags)
import Vulkan.Core10.Handles (RenderPass)
import {-# SOURCE #-} Vulkan.Extensions.VK_QCOM_tile_shading (RenderPassTileShadingCreateInfoQCOM)
import {-# SOURCE #-} Vulkan.Core14.Promoted_From_VK_KHR_dynamic_rendering_local_readRoadmap (RenderingAttachmentLocationInfo)
import {-# SOURCE #-} Vulkan.Core14.Promoted_From_VK_KHR_dynamic_rendering_local_readRoadmap (RenderingInputAttachmentIndexInfo)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import {-# SOURCE #-} Vulkan.Extensions.VK_QCOM_tile_memory_heap (TileMemoryBindInfoQCOM)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Handles (CommandBuffer(..))
import Vulkan.Core10.Enums.CommandBufferLevel (CommandBufferLevel(..))
import Vulkan.Core10.Enums.CommandBufferResetFlagBits (CommandBufferResetFlagBits(..))
import Vulkan.Core10.Enums.CommandBufferResetFlagBits (CommandBufferResetFlags)
import Vulkan.Core10.Enums.CommandBufferUsageFlagBits (CommandBufferUsageFlagBits(..))
import Vulkan.Core10.Enums.CommandBufferUsageFlagBits (CommandBufferUsageFlags)
import Vulkan.Core10.Enums.QueryControlFlagBits (QueryControlFlagBits(..))
import Vulkan.Core10.Enums.QueryControlFlagBits (QueryControlFlags)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkAllocateCommandBuffers
  :: FunPtr (Ptr Device_T -> Ptr CommandBufferAllocateInfo -> Ptr (Ptr CommandBuffer_T) -> IO Result) -> Ptr Device_T -> Ptr CommandBufferAllocateInfo -> Ptr (Ptr CommandBuffer_T) -> IO Result

-- | vkAllocateCommandBuffers - Allocate command buffers from an existing
-- command pool
--
-- = Description
--
-- 'allocateCommandBuffers' /can/ be used to allocate multiple command
-- buffers. If the allocation of any of those command buffers fails, the
-- implementation /must/ free all successfully allocated command buffer
-- objects from this command, set all entries of the @pCommandBuffers@
-- array to @NULL@ and return the error.
--
-- Filling @pCommandBuffers@ with @NULL@ values on failure is an exception
-- to the default error behavior that output parameters will have undefined
-- contents.
--
-- When command buffers are first allocated, they are in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle initial state>.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkAllocateCommandBuffers-device-parameter# @device@ /must/ be
--     a valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkAllocateCommandBuffers-pAllocateInfo-parameter#
--     @pAllocateInfo@ /must/ be a valid pointer to a valid
--     'CommandBufferAllocateInfo' structure
--
-- -   #VUID-vkAllocateCommandBuffers-pCommandBuffers-parameter#
--     @pCommandBuffers@ /must/ be a valid pointer to an array of
--     @pAllocateInfo->commandBufferCount@
--     'Vulkan.Core10.Handles.CommandBuffer' handles
--
-- -   #VUID-vkAllocateCommandBuffers-device-queuecount# The device /must/
--     have been created with at least @1@ queue
--
-- -   #VUID-vkAllocateCommandBuffers-pAllocateInfo::commandBufferCount-arraylength#
--     @pAllocateInfo->commandBufferCount@ /must/ be greater than @0@
--
-- == 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.Handles.CommandBuffer', 'CommandBufferAllocateInfo',
-- 'Vulkan.Core10.Handles.Device'
allocateCommandBuffers :: forall io
                        . (MonadIO io)
                       => -- | @device@ is the logical device that owns the command pool.
                          Device
                       -> -- | @pAllocateInfo@ is a pointer to a 'CommandBufferAllocateInfo' structure
                          -- describing parameters of the allocation. @commandPool@ /may/ be accessed
                          -- any time one of the resulting command buffers is accessed.
                          CommandBufferAllocateInfo
                       -> io (("commandBuffers" ::: Vector CommandBuffer))
allocateCommandBuffers :: forall (io :: * -> *).
MonadIO io =>
Device
-> CommandBufferAllocateInfo
-> io ("commandBuffers" ::: Vector CommandBuffer)
allocateCommandBuffers Device
device CommandBufferAllocateInfo
allocateInfo = IO ("commandBuffers" ::: Vector CommandBuffer)
-> io ("commandBuffers" ::: Vector CommandBuffer)
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("commandBuffers" ::: Vector CommandBuffer)
 -> io ("commandBuffers" ::: Vector CommandBuffer))
-> (ContT
      ("commandBuffers" ::: Vector CommandBuffer)
      IO
      ("commandBuffers" ::: Vector CommandBuffer)
    -> IO ("commandBuffers" ::: Vector CommandBuffer))
-> ContT
     ("commandBuffers" ::: Vector CommandBuffer)
     IO
     ("commandBuffers" ::: Vector CommandBuffer)
-> io ("commandBuffers" ::: Vector CommandBuffer)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  ("commandBuffers" ::: Vector CommandBuffer)
  IO
  ("commandBuffers" ::: Vector CommandBuffer)
-> IO ("commandBuffers" ::: Vector CommandBuffer)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   ("commandBuffers" ::: Vector CommandBuffer)
   IO
   ("commandBuffers" ::: Vector CommandBuffer)
 -> io ("commandBuffers" ::: Vector CommandBuffer))
-> ContT
     ("commandBuffers" ::: Vector CommandBuffer)
     IO
     ("commandBuffers" ::: Vector CommandBuffer)
-> io ("commandBuffers" ::: Vector CommandBuffer)
forall a b. (a -> b) -> a -> b
$ do
  let cmds :: DeviceCmds
cmds = case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds
  let vkAllocateCommandBuffersPtr :: FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> IO Result)
vkAllocateCommandBuffersPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> Ptr CommandBufferAllocateInfo
      -> Ptr (Ptr CommandBuffer_T)
      -> IO Result)
pVkAllocateCommandBuffers DeviceCmds
cmds
  IO () -> ContT ("commandBuffers" ::: Vector CommandBuffer) IO ()
forall (m :: * -> *) a.
Monad m =>
m a -> ContT ("commandBuffers" ::: Vector CommandBuffer) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("commandBuffers" ::: Vector CommandBuffer) IO ())
-> IO () -> ContT ("commandBuffers" ::: Vector CommandBuffer) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> IO Result)
vkAllocateCommandBuffersPtr FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> Ptr CommandBufferAllocateInfo
      -> Ptr (Ptr CommandBuffer_T)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> 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 vkAllocateCommandBuffers is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkAllocateCommandBuffers' :: Ptr Device_T
-> Ptr CommandBufferAllocateInfo
-> Ptr (Ptr CommandBuffer_T)
-> IO Result
vkAllocateCommandBuffers' = FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> IO Result)
-> Ptr Device_T
-> Ptr CommandBufferAllocateInfo
-> Ptr (Ptr CommandBuffer_T)
-> IO Result
mkVkAllocateCommandBuffers FunPtr
  (Ptr Device_T
   -> Ptr CommandBufferAllocateInfo
   -> Ptr (Ptr CommandBuffer_T)
   -> IO Result)
vkAllocateCommandBuffersPtr
  pAllocateInfo <- ((Ptr CommandBufferAllocateInfo
  -> IO ("commandBuffers" ::: Vector CommandBuffer))
 -> IO ("commandBuffers" ::: Vector CommandBuffer))
-> ContT
     ("commandBuffers" ::: Vector CommandBuffer)
     IO
     (Ptr CommandBufferAllocateInfo)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr CommandBufferAllocateInfo
   -> IO ("commandBuffers" ::: Vector CommandBuffer))
  -> IO ("commandBuffers" ::: Vector CommandBuffer))
 -> ContT
      ("commandBuffers" ::: Vector CommandBuffer)
      IO
      (Ptr CommandBufferAllocateInfo))
-> ((Ptr CommandBufferAllocateInfo
     -> IO ("commandBuffers" ::: Vector CommandBuffer))
    -> IO ("commandBuffers" ::: Vector CommandBuffer))
-> ContT
     ("commandBuffers" ::: Vector CommandBuffer)
     IO
     (Ptr CommandBufferAllocateInfo)
forall a b. (a -> b) -> a -> b
$ CommandBufferAllocateInfo
-> (Ptr CommandBufferAllocateInfo
    -> IO ("commandBuffers" ::: Vector CommandBuffer))
-> IO ("commandBuffers" ::: Vector CommandBuffer)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
CommandBufferAllocateInfo
-> (Ptr CommandBufferAllocateInfo -> IO b) -> IO b
withCStruct (CommandBufferAllocateInfo
allocateInfo)
  pPCommandBuffers <- ContT $ bracket (callocBytes @(Ptr CommandBuffer_T) ((fromIntegral $ commandBufferCount ((allocateInfo) :: CommandBufferAllocateInfo)) * 8)) free
  r <- lift $ traceAroundEvent "vkAllocateCommandBuffers" (vkAllocateCommandBuffers'
                                                             (deviceHandle (device))
                                                             pAllocateInfo
                                                             (pPCommandBuffers))
  lift $ when (r < SUCCESS) (throwIO (VulkanException r))
  pCommandBuffers <- lift $ generateM (fromIntegral $ commandBufferCount ((allocateInfo) :: CommandBufferAllocateInfo)) (\Int
i -> do
    pCommandBuffersElem <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr CommandBuffer_T) ((Ptr (Ptr CommandBuffer_T)
pPCommandBuffers Ptr (Ptr CommandBuffer_T) -> Int -> Ptr (Ptr CommandBuffer_T)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CommandBuffer_T)))
    pure $ (\Ptr CommandBuffer_T
h -> Ptr CommandBuffer_T -> DeviceCmds -> CommandBuffer
CommandBuffer Ptr CommandBuffer_T
h DeviceCmds
cmds ) pCommandBuffersElem)
  pure $ (pCommandBuffers)

-- | A convenience wrapper to make a compatible pair of calls to
-- 'allocateCommandBuffers' and 'freeCommandBuffers'
--
-- To ensure that 'freeCommandBuffers' 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.
--
withCommandBuffers :: forall io r . MonadIO io => Device -> CommandBufferAllocateInfo -> (io (Vector CommandBuffer) -> (Vector CommandBuffer -> io ()) -> r) -> r
withCommandBuffers :: forall (io :: * -> *) r.
MonadIO io =>
Device
-> CommandBufferAllocateInfo
-> (io ("commandBuffers" ::: Vector CommandBuffer)
    -> (("commandBuffers" ::: Vector CommandBuffer) -> io ()) -> r)
-> r
withCommandBuffers Device
device CommandBufferAllocateInfo
pAllocateInfo io ("commandBuffers" ::: Vector CommandBuffer)
-> (("commandBuffers" ::: Vector CommandBuffer) -> io ()) -> r
b =
  io ("commandBuffers" ::: Vector CommandBuffer)
-> (("commandBuffers" ::: Vector CommandBuffer) -> io ()) -> r
b (Device
-> CommandBufferAllocateInfo
-> io ("commandBuffers" ::: Vector CommandBuffer)
forall (io :: * -> *).
MonadIO io =>
Device
-> CommandBufferAllocateInfo
-> io ("commandBuffers" ::: Vector CommandBuffer)
allocateCommandBuffers Device
device CommandBufferAllocateInfo
pAllocateInfo)
    (\("commandBuffers" ::: Vector CommandBuffer
o0) -> Device
-> CommandPool
-> ("commandBuffers" ::: Vector CommandBuffer)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPool
-> ("commandBuffers" ::: Vector CommandBuffer)
-> io ()
freeCommandBuffers Device
device
                                   (CommandBufferAllocateInfo -> CommandPool
commandPool (CommandBufferAllocateInfo
pAllocateInfo :: CommandBufferAllocateInfo))
                                   "commandBuffers" ::: Vector CommandBuffer
o0)


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

-- | vkFreeCommandBuffers - Free command buffers
--
-- = Description
--
-- Any primary command buffer that is in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording or executable state>
-- and has any element of @pCommandBuffers@ recorded into it, becomes
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid>.
--
-- == Valid Usage
--
-- -   #VUID-vkFreeCommandBuffers-pCommandBuffers-00047# All elements of
--     @pCommandBuffers@ /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkFreeCommandBuffers-pCommandBuffers-00048# @pCommandBuffers@
--     /must/ be a valid pointer to an array of @commandBufferCount@
--     'Vulkan.Core10.Handles.CommandBuffer' handles, each element of which
--     /must/ either be a valid handle or @NULL@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkFreeCommandBuffers-device-parameter# @device@ /must/ be a
--     valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkFreeCommandBuffers-commandPool-parameter# @commandPool@
--     /must/ be a valid 'Vulkan.Core10.Handles.CommandPool' handle
--
-- -   #VUID-vkFreeCommandBuffers-commandBufferCount-arraylength#
--     @commandBufferCount@ /must/ be greater than @0@
--
-- -   #VUID-vkFreeCommandBuffers-commandPool-parent# @commandPool@ /must/
--     have been created, allocated, or retrieved from @device@
--
-- -   #VUID-vkFreeCommandBuffers-pCommandBuffers-parent# Each element of
--     @pCommandBuffers@ that is a valid handle /must/ have been created,
--     allocated, or retrieved from @commandPool@
--
-- == Host Synchronization
--
-- -   Host access to @commandPool@ /must/ be externally synchronized
--
-- -   Host access to each member of @pCommandBuffers@ /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.Handles.CommandBuffer',
-- 'Vulkan.Core10.Handles.CommandPool', 'Vulkan.Core10.Handles.Device'
freeCommandBuffers :: forall io
                    . (MonadIO io)
                   => -- | @device@ is the logical device that owns the command pool.
                      Device
                   -> -- | @commandPool@ is the command pool from which the command buffers were
                      -- allocated.
                      CommandPool
                   -> -- | @pCommandBuffers@ is a pointer to an array of handles of command buffers
                      -- to free.
                      ("commandBuffers" ::: Vector CommandBuffer)
                   -> io ()
freeCommandBuffers :: forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPool
-> ("commandBuffers" ::: Vector CommandBuffer)
-> io ()
freeCommandBuffers Device
device CommandPool
commandPool "commandBuffers" ::: Vector CommandBuffer
commandBuffers = 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 vkFreeCommandBuffersPtr :: FunPtr
  (Ptr Device_T
   -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
vkFreeCommandBuffersPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
pVkFreeCommandBuffers (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 -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
vkFreeCommandBuffersPtr FunPtr
  (Ptr Device_T
   -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
-> FunPtr
     (Ptr Device_T
      -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> 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 vkFreeCommandBuffers is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkFreeCommandBuffers' :: Ptr Device_T
-> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ()
vkFreeCommandBuffers' = FunPtr
  (Ptr Device_T
   -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
-> Ptr Device_T
-> CommandPool
-> Word32
-> Ptr (Ptr CommandBuffer_T)
-> IO ()
mkVkFreeCommandBuffers FunPtr
  (Ptr Device_T
   -> CommandPool -> Word32 -> Ptr (Ptr CommandBuffer_T) -> IO ())
vkFreeCommandBuffersPtr
  pPCommandBuffers <- ((Ptr (Ptr CommandBuffer_T) -> IO ()) -> IO ())
-> ContT () IO (Ptr (Ptr CommandBuffer_T))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr CommandBuffer_T) -> IO ()) -> IO ())
 -> ContT () IO (Ptr (Ptr CommandBuffer_T)))
-> ((Ptr (Ptr CommandBuffer_T) -> IO ()) -> IO ())
-> ContT () IO (Ptr (Ptr CommandBuffer_T))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(Ptr CommandBuffer_T) ((("commandBuffers" ::: Vector CommandBuffer) -> Int
forall a. Vector a -> Int
Data.Vector.length ("commandBuffers" ::: Vector CommandBuffer
commandBuffers)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
  lift $ Data.Vector.imapM_ (\Int
i CommandBuffer
e -> Ptr (Ptr CommandBuffer_T) -> Ptr CommandBuffer_T -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Ptr CommandBuffer_T)
pPCommandBuffers Ptr (Ptr CommandBuffer_T) -> Int -> Ptr (Ptr CommandBuffer_T)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CommandBuffer_T)) (CommandBuffer -> Ptr CommandBuffer_T
commandBufferHandle (CommandBuffer
e))) (commandBuffers)
  lift $ traceAroundEvent "vkFreeCommandBuffers" (vkFreeCommandBuffers'
                                                    (deviceHandle (device))
                                                    (commandPool)
                                                    ((fromIntegral (Data.Vector.length $ (commandBuffers)) :: Word32))
                                                    (pPCommandBuffers))
  pure $ ()


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkBeginCommandBuffer
  :: FunPtr (Ptr CommandBuffer_T -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result) -> Ptr CommandBuffer_T -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result

-- | vkBeginCommandBuffer - Start recording a command buffer
--
-- == Valid Usage
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-00049# @commandBuffer@
--     /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording or pending state>
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-00050# If @commandBuffer@
--     was allocated from a 'Vulkan.Core10.Handles.CommandPool' which did
--     not have the
--     'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT'
--     flag set, @commandBuffer@ /must/ be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle initial state>
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-00051# If @commandBuffer@
--     is a secondary command buffer, the @pInheritanceInfo@ member of
--     @pBeginInfo@ /must/ be a valid 'CommandBufferInheritanceInfo'
--     structure
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-00052# If @commandBuffer@
--     is a secondary command buffer and either the @occlusionQueryEnable@
--     member of the @pInheritanceInfo@ member of @pBeginInfo@ is
--     'Vulkan.Core10.FundamentalTypes.FALSE', or the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-occlusionQueryPrecise occlusionQueryPrecise>
--     feature is not enabled, then
--     @pBeginInfo->pInheritanceInfo->queryFlags@ /must/ not contain
--     'Vulkan.Core10.Enums.QueryControlFlagBits.QUERY_CONTROL_PRECISE_BIT'
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-02840# If @commandBuffer@
--     is a primary command buffer, then @pBeginInfo->flags@ /must/ not set
--     both the
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT'
--     and the
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT'
--     flags
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkBeginCommandBuffer-commandBuffer-parameter# @commandBuffer@
--     /must/ be a valid 'Vulkan.Core10.Handles.CommandBuffer' handle
--
-- -   #VUID-vkBeginCommandBuffer-pBeginInfo-parameter# @pBeginInfo@ /must/
--     be a valid pointer to a valid 'CommandBufferBeginInfo' structure
--
-- == Host Synchronization
--
-- -   Host access to @commandBuffer@ /must/ be externally synchronized
--
-- -   Host access to the 'Vulkan.Core10.Handles.CommandPool' that
--     @commandBuffer@ was allocated from /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_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.Handles.CommandBuffer', 'CommandBufferBeginInfo'
beginCommandBuffer :: forall a io
                    . ( Extendss CommandBufferBeginInfo a
                      , PokeChain a
                      , MonadIO io )
                   => -- | @commandBuffer@ is the handle of the command buffer which is to be put
                      -- in the recording state.
                      CommandBuffer
                   -> -- | @pBeginInfo@ is a pointer to a 'CommandBufferBeginInfo' structure
                      -- defining additional information about how the command buffer begins
                      -- recording.
                      (CommandBufferBeginInfo a)
                   -> io ()
beginCommandBuffer :: forall (a :: [*]) (io :: * -> *).
(Extendss CommandBufferBeginInfo a, PokeChain a, MonadIO io) =>
CommandBuffer -> CommandBufferBeginInfo a -> io ()
beginCommandBuffer CommandBuffer
commandBuffer CommandBufferBeginInfo a
beginInfo = 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 vkBeginCommandBufferPtr :: FunPtr
  (Ptr CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
vkBeginCommandBufferPtr = DeviceCmds
-> FunPtr
     (Ptr CommandBuffer_T
      -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
pVkBeginCommandBuffer (case CommandBuffer
commandBuffer of CommandBuffer{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: CommandBuffer -> 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 CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
vkBeginCommandBufferPtr FunPtr
  (Ptr CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
-> FunPtr
     (Ptr CommandBuffer_T
      -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> 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 vkBeginCommandBuffer is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkBeginCommandBuffer' :: Ptr CommandBuffer_T
-> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result
vkBeginCommandBuffer' = FunPtr
  (Ptr CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
-> Ptr CommandBuffer_T
-> Ptr (SomeStruct CommandBufferBeginInfo)
-> IO Result
mkVkBeginCommandBuffer FunPtr
  (Ptr CommandBuffer_T
   -> Ptr (SomeStruct CommandBufferBeginInfo) -> IO Result)
vkBeginCommandBufferPtr
  pBeginInfo <- ((Ptr (CommandBufferBeginInfo a) -> IO ()) -> IO ())
-> ContT () IO (Ptr (CommandBufferBeginInfo a))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (CommandBufferBeginInfo a) -> IO ()) -> IO ())
 -> ContT () IO (Ptr (CommandBufferBeginInfo a)))
-> ((Ptr (CommandBufferBeginInfo a) -> IO ()) -> IO ())
-> ContT () IO (Ptr (CommandBufferBeginInfo a))
forall a b. (a -> b) -> a -> b
$ CommandBufferBeginInfo a
-> (Ptr (CommandBufferBeginInfo a) -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
CommandBufferBeginInfo a
-> (Ptr (CommandBufferBeginInfo a) -> IO b) -> IO b
withCStruct (CommandBufferBeginInfo a
beginInfo)
  r <- lift $ traceAroundEvent "vkBeginCommandBuffer" (vkBeginCommandBuffer'
                                                         (commandBufferHandle (commandBuffer))
                                                         (forgetExtensions pBeginInfo))
  lift $ when (r < SUCCESS) (throwIO (VulkanException r))

-- | This function will call the supplied action between calls to
-- 'beginCommandBuffer' and 'endCommandBuffer'
--
-- Note that 'endCommandBuffer' is *not* called if an exception is thrown
-- by the inner action.
useCommandBuffer :: forall a io r . (Extendss CommandBufferBeginInfo a, PokeChain a, MonadIO io) => CommandBuffer -> CommandBufferBeginInfo a -> io r -> io r
useCommandBuffer :: forall (a :: [*]) (io :: * -> *) r.
(Extendss CommandBufferBeginInfo a, PokeChain a, MonadIO io) =>
CommandBuffer -> CommandBufferBeginInfo a -> io r -> io r
useCommandBuffer CommandBuffer
commandBuffer CommandBufferBeginInfo a
pBeginInfo io r
a =
  (CommandBuffer -> CommandBufferBeginInfo a -> io ()
forall (a :: [*]) (io :: * -> *).
(Extendss CommandBufferBeginInfo a, PokeChain a, MonadIO io) =>
CommandBuffer -> CommandBufferBeginInfo a -> io ()
beginCommandBuffer CommandBuffer
commandBuffer
                        CommandBufferBeginInfo a
pBeginInfo) io () -> io r -> io r
forall a b. io a -> io b -> io b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> io r
a io r -> io () -> io r
forall a b. io a -> io b -> io a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* (CommandBuffer -> io ()
forall (io :: * -> *). MonadIO io => CommandBuffer -> io ()
endCommandBuffer CommandBuffer
commandBuffer)


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkEndCommandBuffer
  :: FunPtr (Ptr CommandBuffer_T -> IO Result) -> Ptr CommandBuffer_T -> IO Result

-- | vkEndCommandBuffer - Finish recording a command buffer
--
-- = Description
--
-- The command buffer /must/ have been in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording state>,
-- and, if successful, is moved to the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle executable state>.
--
-- If there was an error during recording, the application will be notified
-- by an unsuccessful return code returned by 'endCommandBuffer', and the
-- command buffer will be moved to the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid state>.
--
-- In case the application recorded one or more
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#video-encode-operations video encode operations>
-- into the command buffer, implementations /may/ return the
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkResult VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR>
-- error if any of the specified Video Std parameters do not adhere to the
-- syntactic or semantic requirements of the used video compression
-- standard, or if values derived from parameters according to the rules
-- defined by the used video compression standard do not adhere to the
-- capabilities of the video compression standard or the implementation.
--
-- Applications /should/ not rely on the
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkResult VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR>
-- error being returned by any command as a means to verify Video Std
-- parameters, as implementations are not required to report the error in
-- any specific set of cases.
--
-- == Valid Usage
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-00059# @commandBuffer@ /must/
--     be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording state>
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-00060# If @commandBuffer@ is
--     a primary command buffer, there /must/ not be an active render pass
--     instance
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-00061# All queries made
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#queries-operation-active active>
--     during the recording of @commandBuffer@ /must/ have been made
--     inactive
--
-- -   #VUID-vkEndCommandBuffer-None-01978# Conditional rendering /must/
--     not be
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#active-conditional-rendering active>
--
-- -   #VUID-vkEndCommandBuffer-None-06991# There /must/ be no video
--     session object bound
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-01815# If @commandBuffer@ is
--     a secondary command buffer, there /must/ not be an outstanding
--     'Vulkan.Extensions.VK_EXT_debug_utils.cmdBeginDebugUtilsLabelEXT'
--     command recorded to @commandBuffer@ that has not previously been
--     ended by a call to
--     'Vulkan.Extensions.VK_EXT_debug_utils.cmdEndDebugUtilsLabelEXT'
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-00062# If @commandBuffer@ is
--     a secondary command buffer, there /must/ not be an outstanding
--     'Vulkan.Extensions.VK_EXT_debug_marker.cmdDebugMarkerBeginEXT'
--     command recorded to @commandBuffer@ that has not previously been
--     ended by a call to
--     'Vulkan.Extensions.VK_EXT_debug_marker.cmdDebugMarkerEndEXT'
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkEndCommandBuffer-commandBuffer-parameter# @commandBuffer@
--     /must/ be a valid 'Vulkan.Core10.Handles.CommandBuffer' handle
--
-- == Host Synchronization
--
-- -   Host access to @commandBuffer@ /must/ be externally synchronized
--
-- -   Host access to the 'Vulkan.Core10.Handles.CommandPool' that
--     @commandBuffer@ was allocated from /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>]
--
--     -   <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkResult VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR>
--
--     -   '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.Handles.CommandBuffer'
endCommandBuffer :: forall io
                  . (MonadIO io)
                 => -- | @commandBuffer@ is the command buffer to complete recording.
                    CommandBuffer
                 -> io ()
endCommandBuffer :: forall (io :: * -> *). MonadIO io => CommandBuffer -> io ()
endCommandBuffer CommandBuffer
commandBuffer = 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 vkEndCommandBufferPtr :: FunPtr (Ptr CommandBuffer_T -> IO Result)
vkEndCommandBufferPtr = DeviceCmds -> FunPtr (Ptr CommandBuffer_T -> IO Result)
pVkEndCommandBuffer (case CommandBuffer
commandBuffer of CommandBuffer{DeviceCmds
deviceCmds :: CommandBuffer -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr CommandBuffer_T -> IO Result)
vkEndCommandBufferPtr FunPtr (Ptr CommandBuffer_T -> IO Result)
-> FunPtr (Ptr CommandBuffer_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr CommandBuffer_T -> 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 vkEndCommandBuffer is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkEndCommandBuffer' :: Ptr CommandBuffer_T -> IO Result
vkEndCommandBuffer' = FunPtr (Ptr CommandBuffer_T -> IO Result)
-> Ptr CommandBuffer_T -> IO Result
mkVkEndCommandBuffer FunPtr (Ptr CommandBuffer_T -> IO Result)
vkEndCommandBufferPtr
  r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkEndCommandBuffer" (Ptr CommandBuffer_T -> IO Result
vkEndCommandBuffer'
                                                (CommandBuffer -> Ptr CommandBuffer_T
commandBufferHandle (CommandBuffer
commandBuffer)))
  when (r < SUCCESS) (throwIO (VulkanException r))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkResetCommandBuffer
  :: FunPtr (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result) -> Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result

-- | vkResetCommandBuffer - Reset a command buffer to the initial state
--
-- = Description
--
-- Any primary command buffer that is in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle recording or executable state>
-- and has @commandBuffer@ recorded into it, becomes
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid>.
--
-- After a command buffer is reset, any objects or memory specified by
-- commands recorded into the command buffer /must/ no longer be accessed
-- when the command buffer is accessed by the implementation.
--
-- == Valid Usage
--
-- -   #VUID-vkResetCommandBuffer-commandBuffer-00045# @commandBuffer@
--     /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkResetCommandBuffer-commandBuffer-00046# @commandBuffer@
--     /must/ have been allocated from a pool that was created with the
--     'Vulkan.Core10.Enums.CommandPoolCreateFlagBits.COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT'
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkResetCommandBuffer-commandBuffer-parameter# @commandBuffer@
--     /must/ be a valid 'Vulkan.Core10.Handles.CommandBuffer' handle
--
-- -   #VUID-vkResetCommandBuffer-flags-parameter# @flags@ /must/ be a
--     valid combination of
--     'Vulkan.Core10.Enums.CommandBufferResetFlagBits.CommandBufferResetFlagBits'
--     values
--
-- == Host Synchronization
--
-- -   Host access to @commandBuffer@ /must/ be externally synchronized
--
-- -   Host access to the 'Vulkan.Core10.Handles.CommandPool' that
--     @commandBuffer@ was allocated from /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.CommandBuffer',
-- 'Vulkan.Core10.Enums.CommandBufferResetFlagBits.CommandBufferResetFlags'
resetCommandBuffer :: forall io
                    . (MonadIO io)
                   => -- | @commandBuffer@ is the command buffer to reset. The command buffer /can/
                      -- be in any state other than
                      -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending>,
                      -- and is moved into the
                      -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle initial state>.
                      CommandBuffer
                   -> -- | @flags@ is a bitmask of
                      -- 'Vulkan.Core10.Enums.CommandBufferResetFlagBits.CommandBufferResetFlagBits'
                      -- controlling the reset operation.
                      CommandBufferResetFlags
                   -> io ()
resetCommandBuffer :: forall (io :: * -> *).
MonadIO io =>
CommandBuffer -> CommandBufferResetFlags -> io ()
resetCommandBuffer CommandBuffer
commandBuffer CommandBufferResetFlags
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 vkResetCommandBufferPtr :: FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
vkResetCommandBufferPtr = DeviceCmds
-> FunPtr
     (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
pVkResetCommandBuffer (case CommandBuffer
commandBuffer of CommandBuffer{DeviceCmds
deviceCmds :: CommandBuffer -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
vkResetCommandBufferPtr FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
-> FunPtr
     (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> 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 vkResetCommandBuffer is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkResetCommandBuffer' :: Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result
vkResetCommandBuffer' = FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
-> Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result
mkVkResetCommandBuffer FunPtr
  (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result)
vkResetCommandBufferPtr
  r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkResetCommandBuffer" (Ptr CommandBuffer_T -> CommandBufferResetFlags -> IO Result
vkResetCommandBuffer'
                                                  (CommandBuffer -> Ptr CommandBuffer_T
commandBufferHandle (CommandBuffer
commandBuffer))
                                                  (CommandBufferResetFlags
flags))
  when (r < SUCCESS) (throwIO (VulkanException r))


-- | VkCommandBufferAllocateInfo - Structure specifying the allocation
-- parameters for command buffer object
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkCommandBufferAllocateInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO'
--
-- -   #VUID-VkCommandBufferAllocateInfo-pNext-pNext# @pNext@ /must/ be
--     @NULL@
--
-- -   #VUID-VkCommandBufferAllocateInfo-commandPool-parameter#
--     @commandPool@ /must/ be a valid 'Vulkan.Core10.Handles.CommandPool'
--     handle
--
-- -   #VUID-VkCommandBufferAllocateInfo-level-parameter# @level@ /must/ be
--     a valid 'Vulkan.Core10.Enums.CommandBufferLevel.CommandBufferLevel'
--     value
--
-- == 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.Enums.CommandBufferLevel.CommandBufferLevel',
-- 'Vulkan.Core10.Handles.CommandPool',
-- 'Vulkan.Core10.Enums.StructureType.StructureType',
-- 'allocateCommandBuffers'
data CommandBufferAllocateInfo = CommandBufferAllocateInfo
  { -- | @commandPool@ is the command pool from which the command buffers are
    -- allocated.
    CommandBufferAllocateInfo -> CommandPool
commandPool :: CommandPool
  , -- | @level@ is a 'Vulkan.Core10.Enums.CommandBufferLevel.CommandBufferLevel'
    -- value specifying the command buffer level.
    CommandBufferAllocateInfo -> CommandBufferLevel
level :: CommandBufferLevel
  , -- | @commandBufferCount@ is the number of command buffers to allocate from
    -- the pool.
    CommandBufferAllocateInfo -> Word32
commandBufferCount :: Word32
  }
  deriving (Typeable, CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool
(CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool)
-> (CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool)
-> Eq CommandBufferAllocateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool
== :: CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool
$c/= :: CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool
/= :: CommandBufferAllocateInfo -> CommandBufferAllocateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (CommandBufferAllocateInfo)
#endif
deriving instance Show CommandBufferAllocateInfo

instance ToCStruct CommandBufferAllocateInfo where
  withCStruct :: forall b.
CommandBufferAllocateInfo
-> (Ptr CommandBufferAllocateInfo -> IO b) -> IO b
withCStruct CommandBufferAllocateInfo
x Ptr CommandBufferAllocateInfo -> IO b
f = Int -> (Ptr CommandBufferAllocateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr CommandBufferAllocateInfo -> IO b) -> IO b)
-> (Ptr CommandBufferAllocateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr CommandBufferAllocateInfo
p -> Ptr CommandBufferAllocateInfo
-> CommandBufferAllocateInfo -> IO b -> IO b
forall b.
Ptr CommandBufferAllocateInfo
-> CommandBufferAllocateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr CommandBufferAllocateInfo
p CommandBufferAllocateInfo
x (Ptr CommandBufferAllocateInfo -> IO b
f Ptr CommandBufferAllocateInfo
p)
  pokeCStruct :: forall b.
Ptr CommandBufferAllocateInfo
-> CommandBufferAllocateInfo -> IO b -> IO b
pokeCStruct Ptr CommandBufferAllocateInfo
p CommandBufferAllocateInfo{Word32
CommandBufferLevel
CommandPool
commandBufferCount :: CommandBufferAllocateInfo -> Word32
commandPool :: CommandBufferAllocateInfo -> CommandPool
level :: CommandBufferAllocateInfo -> CommandBufferLevel
commandPool :: CommandPool
level :: CommandBufferLevel
commandBufferCount :: Word32
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr CommandPool -> CommandPool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr CommandPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CommandPool)) (CommandPool
commandPool)
    Ptr CommandBufferLevel -> CommandBufferLevel -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr CommandBufferLevel
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr CommandBufferLevel)) (CommandBufferLevel
level)
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
28 :: Ptr Word32)) (Word32
commandBufferCount)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr CommandBufferAllocateInfo -> IO b -> IO b
pokeZeroCStruct Ptr CommandBufferAllocateInfo
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr CommandPool -> CommandPool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr CommandPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CommandPool)) (CommandPool
forall a. Zero a => a
zero)
    Ptr CommandBufferLevel -> CommandBufferLevel -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr CommandBufferLevel
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr CommandBufferLevel)) (CommandBufferLevel
forall a. Zero a => a
zero)
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
28 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct CommandBufferAllocateInfo where
  peekCStruct :: Ptr CommandBufferAllocateInfo -> IO CommandBufferAllocateInfo
peekCStruct Ptr CommandBufferAllocateInfo
p = do
    commandPool <- forall a. Storable a => Ptr a -> IO a
peek @CommandPool ((Ptr CommandBufferAllocateInfo
p Ptr CommandBufferAllocateInfo -> Int -> Ptr CommandPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr CommandPool))
    level <- peek @CommandBufferLevel ((p `plusPtr` 24 :: Ptr CommandBufferLevel))
    commandBufferCount <- peek @Word32 ((p `plusPtr` 28 :: Ptr Word32))
    pure $ CommandBufferAllocateInfo
             commandPool level commandBufferCount

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

instance Zero CommandBufferAllocateInfo where
  zero :: CommandBufferAllocateInfo
zero = CommandPool
-> CommandBufferLevel -> Word32 -> CommandBufferAllocateInfo
CommandBufferAllocateInfo
           CommandPool
forall a. Zero a => a
zero
           CommandBufferLevel
forall a. Zero a => a
zero
           Word32
forall a. Zero a => a
zero


-- | VkCommandBufferInheritanceInfo - Structure specifying command buffer
-- inheritance information
--
-- = Description
--
-- If the 'Vulkan.Core10.Handles.CommandBuffer' will not be executed within
-- a render pass instance, or if the render pass instance was begun with
-- 'Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering.cmdBeginRendering',
-- @renderPass@, @subpass@, and @framebuffer@ are ignored.
--
-- == Valid Usage
--
-- -   #VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056# If
--     the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-inheritedQueries inheritedQueries>
--     feature is not enabled, @occlusionQueryEnable@ /must/ be
--     'Vulkan.Core10.FundamentalTypes.FALSE'
--
-- -   #VUID-VkCommandBufferInheritanceInfo-queryFlags-00057# If the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-inheritedQueries inheritedQueries>
--     feature is enabled, @queryFlags@ /must/ be a valid combination of
--     'Vulkan.Core10.Enums.QueryControlFlagBits.QueryControlFlagBits'
--     values
--
-- -   #VUID-VkCommandBufferInheritanceInfo-queryFlags-02788# If the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-inheritedQueries inheritedQueries>
--     feature is not enabled, @queryFlags@ /must/ be @0@
--
-- -   #VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789# If
--     the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-pipelineStatisticsQuery pipelineStatisticsQuery>
--     feature is enabled, @pipelineStatistics@ /must/ be a valid
--     combination of
--     'Vulkan.Core10.Enums.QueryPipelineStatisticFlagBits.QueryPipelineStatisticFlagBits'
--     values
--
-- -   #VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058# If
--     the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-pipelineStatisticsQuery pipelineStatisticsQuery>
--     feature is not enabled, @pipelineStatistics@ /must/ be @0@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkCommandBufferInheritanceInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO'
--
-- -   #VUID-VkCommandBufferInheritanceInfo-pNext-pNext# Each @pNext@
--     member of any structure (including this one) in the @pNext@ chain
--     /must/ be either @NULL@ or a pointer to a valid instance of
--     'Vulkan.Extensions.VK_AMD_mixed_attachment_samples.AttachmentSampleCountInfoAMD',
--     'Vulkan.Extensions.VK_EXT_conditional_rendering.CommandBufferInheritanceConditionalRenderingInfoEXT',
--     'Vulkan.Extensions.VK_EXT_descriptor_heap.CommandBufferInheritanceDescriptorHeapInfoEXT',
--     'Vulkan.Extensions.VK_QCOM_render_pass_transform.CommandBufferInheritanceRenderPassTransformInfoQCOM',
--     'Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering.CommandBufferInheritanceRenderingInfo',
--     'Vulkan.Extensions.VK_NV_inherited_viewport_scissor.CommandBufferInheritanceViewportScissorInfoNV',
--     'Vulkan.Extensions.VK_EXT_custom_resolve.CustomResolveCreateInfoEXT',
--     'Vulkan.Extensions.VK_ANDROID_external_memory_android_hardware_buffer.ExternalFormatANDROID',
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkExternalFormatOHOS VkExternalFormatOHOS>,
--     'Vulkan.Extensions.VK_NVX_multiview_per_view_attributes.MultiviewPerViewAttributesInfoNVX',
--     'Vulkan.Extensions.VK_QCOM_tile_shading.RenderPassTileShadingCreateInfoQCOM',
--     'Vulkan.Core14.Promoted_From_VK_KHR_dynamic_rendering_local_readRoadmap.RenderingAttachmentLocationInfo',
--     'Vulkan.Core14.Promoted_From_VK_KHR_dynamic_rendering_local_readRoadmap.RenderingInputAttachmentIndexInfo',
--     or
--     'Vulkan.Extensions.VK_QCOM_tile_memory_heap.TileMemoryBindInfoQCOM'
--
-- -   #VUID-VkCommandBufferInheritanceInfo-sType-unique# The @sType@ value
--     of each structure in the @pNext@ chain /must/ be unique
--
-- -   #VUID-VkCommandBufferInheritanceInfo-commonparent# Both of
--     @framebuffer@, and @renderPass@ that are valid handles of
--     non-ignored parameters /must/ have been created, allocated, or
--     retrieved from the same 'Vulkan.Core10.Handles.Device'
--
-- = 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.FundamentalTypes.Bool32', 'CommandBufferBeginInfo',
-- 'Vulkan.Core10.Handles.Framebuffer',
-- 'Vulkan.Core10.Enums.QueryControlFlagBits.QueryControlFlags',
-- 'Vulkan.Core10.Enums.QueryPipelineStatisticFlagBits.QueryPipelineStatisticFlags',
-- 'Vulkan.Core10.Handles.RenderPass',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data CommandBufferInheritanceInfo (es :: [Type]) = CommandBufferInheritanceInfo
  { -- | @pNext@ is @NULL@ or a pointer to a structure extending this structure.
    forall (es :: [*]). CommandBufferInheritanceInfo es -> Chain es
next :: Chain es
  , -- | @renderPass@ is a 'Vulkan.Core10.Handles.RenderPass' object defining
    -- which render passes the 'Vulkan.Core10.Handles.CommandBuffer' will be
    -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-compatibility compatible>
    -- with and /can/ be executed within.
    forall (es :: [*]). CommandBufferInheritanceInfo es -> RenderPass
renderPass :: RenderPass
  , -- | @subpass@ is the index of the subpass within the render pass instance
    -- that the 'Vulkan.Core10.Handles.CommandBuffer' will be executed within.
    forall (es :: [*]). CommandBufferInheritanceInfo es -> Word32
subpass :: Word32
  , -- | @framebuffer@ /can/ refer to the 'Vulkan.Core10.Handles.Framebuffer'
    -- object that the 'Vulkan.Core10.Handles.CommandBuffer' will be rendering
    -- to if it is executed within a render pass instance. It /can/ be
    -- 'Vulkan.Core10.APIConstants.NULL_HANDLE' if the framebuffer is not
    -- known.
    --
    -- Specifying the exact framebuffer that the secondary command buffer will
    -- be executed with /may/ result in better performance at command buffer
    -- execution time.
    forall (es :: [*]). CommandBufferInheritanceInfo es -> Framebuffer
framebuffer :: Framebuffer
  , -- | @occlusionQueryEnable@ specifies whether the command buffer /can/ be
    -- executed while an occlusion query is active in the primary command
    -- buffer. If this is 'Vulkan.Core10.FundamentalTypes.TRUE', then this
    -- command buffer /can/ be executed whether the primary command buffer has
    -- an occlusion query active or not. If this is
    -- 'Vulkan.Core10.FundamentalTypes.FALSE', then the primary command buffer
    -- /must/ not have an occlusion query active.
    forall (es :: [*]). CommandBufferInheritanceInfo es -> Bool
occlusionQueryEnable :: Bool
  , -- | @queryFlags@ specifies the query flags that /can/ be used by an active
    -- occlusion query in the primary command buffer when this secondary
    -- command buffer is executed. If this value includes the
    -- 'Vulkan.Core10.Enums.QueryControlFlagBits.QUERY_CONTROL_PRECISE_BIT'
    -- bit, then the active query /can/ return boolean results or actual sample
    -- counts. If this bit is not set, then the active query /must/ not use the
    -- 'Vulkan.Core10.Enums.QueryControlFlagBits.QUERY_CONTROL_PRECISE_BIT'
    -- bit.
    forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryControlFlags
queryFlags :: QueryControlFlags
  , -- | @pipelineStatistics@ is a bitmask of
    -- 'Vulkan.Core10.Enums.QueryPipelineStatisticFlagBits.QueryPipelineStatisticFlagBits'
    -- specifying the set of pipeline statistics that /can/ be counted by an
    -- active query in the primary command buffer when this secondary command
    -- buffer is executed. If this value includes a given bit, then this
    -- command buffer /can/ be executed whether the primary command buffer has
    -- a pipeline statistics query active that includes this bit or not. If
    -- this value excludes a given bit, then the active pipeline statistics
    -- query /must/ not be from a query pool that counts that statistic.
    forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryPipelineStatisticFlags
pipelineStatistics :: QueryPipelineStatisticFlags
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (CommandBufferInheritanceInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (CommandBufferInheritanceInfo es)

instance Extensible CommandBufferInheritanceInfo where
  extensibleTypeName :: String
extensibleTypeName = String
"CommandBufferInheritanceInfo"
  setNext :: forall (ds :: [*]) (es :: [*]).
CommandBufferInheritanceInfo ds
-> Chain es -> CommandBufferInheritanceInfo es
setNext CommandBufferInheritanceInfo{Bool
Word32
QueryPipelineStatisticFlags
QueryControlFlags
RenderPass
Framebuffer
Chain ds
next :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Chain es
renderPass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> RenderPass
subpass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Word32
framebuffer :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Framebuffer
occlusionQueryEnable :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Bool
queryFlags :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryControlFlags
pipelineStatistics :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryPipelineStatisticFlags
next :: Chain ds
renderPass :: RenderPass
subpass :: Word32
framebuffer :: Framebuffer
occlusionQueryEnable :: Bool
queryFlags :: QueryControlFlags
pipelineStatistics :: QueryPipelineStatisticFlags
..} Chain es
next' = CommandBufferInheritanceInfo{next :: Chain es
next = Chain es
next', Bool
Word32
QueryPipelineStatisticFlags
QueryControlFlags
RenderPass
Framebuffer
renderPass :: RenderPass
subpass :: Word32
framebuffer :: Framebuffer
occlusionQueryEnable :: Bool
queryFlags :: QueryControlFlags
pipelineStatistics :: QueryPipelineStatisticFlags
renderPass :: RenderPass
subpass :: Word32
framebuffer :: Framebuffer
occlusionQueryEnable :: Bool
queryFlags :: QueryControlFlags
pipelineStatistics :: QueryPipelineStatisticFlags
..}
  getNext :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Chain es
getNext CommandBufferInheritanceInfo{Bool
Word32
QueryPipelineStatisticFlags
QueryControlFlags
RenderPass
Framebuffer
Chain es
next :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Chain es
renderPass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> RenderPass
subpass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Word32
framebuffer :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Framebuffer
occlusionQueryEnable :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Bool
queryFlags :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryControlFlags
pipelineStatistics :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryPipelineStatisticFlags
next :: Chain es
renderPass :: RenderPass
subpass :: Word32
framebuffer :: Framebuffer
occlusionQueryEnable :: Bool
queryFlags :: QueryControlFlags
pipelineStatistics :: QueryPipelineStatisticFlags
..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends CommandBufferInheritanceInfo e => b) -> Maybe b
  extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends CommandBufferInheritanceInfo e => b) -> Maybe b
extends proxy e
_ Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CommandBufferInheritanceDescriptorHeapInfoEXT
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 @CommandBufferInheritanceDescriptorHeapInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: RenderPassTileShadingCreateInfoQCOM
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 @RenderPassTileShadingCreateInfoQCOM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: RenderingInputAttachmentIndexInfo
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 @RenderingInputAttachmentIndexInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: RenderingAttachmentLocationInfo
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 @RenderingAttachmentLocationInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: TileMemoryBindInfoQCOM
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 @TileMemoryBindInfoQCOM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: MultiviewPerViewAttributesInfoNVX
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 @MultiviewPerViewAttributesInfoNVX = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: AttachmentSampleCountInfoAMD
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 @AttachmentSampleCountInfoAMD = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CommandBufferInheritanceRenderingInfo
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 @CommandBufferInheritanceRenderingInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CommandBufferInheritanceViewportScissorInfoNV
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 @CommandBufferInheritanceViewportScissorInfoNV = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CustomResolveCreateInfoEXT
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 @CustomResolveCreateInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CommandBufferInheritanceRenderPassTransformInfoQCOM
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 @CommandBufferInheritanceRenderPassTransformInfoQCOM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: ExternalFormatANDROID
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 @ExternalFormatANDROID = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Just e :~: CommandBufferInheritanceConditionalRenderingInfoEXT
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 @CommandBufferInheritanceConditionalRenderingInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferInheritanceInfo e => b
f
    | Bool
otherwise = Maybe b
forall a. Maybe a
Nothing

instance ( Extendss CommandBufferInheritanceInfo es
         , PokeChain es ) => ToCStruct (CommandBufferInheritanceInfo es) where
  withCStruct :: forall b.
CommandBufferInheritanceInfo es
-> (Ptr (CommandBufferInheritanceInfo es) -> IO b) -> IO b
withCStruct CommandBufferInheritanceInfo es
x Ptr (CommandBufferInheritanceInfo es) -> IO b
f = Int -> (Ptr (CommandBufferInheritanceInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
56 ((Ptr (CommandBufferInheritanceInfo es) -> IO b) -> IO b)
-> (Ptr (CommandBufferInheritanceInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (CommandBufferInheritanceInfo es)
p -> Ptr (CommandBufferInheritanceInfo es)
-> CommandBufferInheritanceInfo es -> IO b -> IO b
forall b.
Ptr (CommandBufferInheritanceInfo es)
-> CommandBufferInheritanceInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (CommandBufferInheritanceInfo es)
p CommandBufferInheritanceInfo es
x (Ptr (CommandBufferInheritanceInfo es) -> IO b
f Ptr (CommandBufferInheritanceInfo es)
p)
  pokeCStruct :: forall b.
Ptr (CommandBufferInheritanceInfo es)
-> CommandBufferInheritanceInfo es -> IO b -> IO b
pokeCStruct Ptr (CommandBufferInheritanceInfo es)
p CommandBufferInheritanceInfo{Bool
Word32
QueryPipelineStatisticFlags
QueryControlFlags
RenderPass
Framebuffer
Chain es
next :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Chain es
renderPass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> RenderPass
subpass :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Word32
framebuffer :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Framebuffer
occlusionQueryEnable :: forall (es :: [*]). CommandBufferInheritanceInfo es -> Bool
queryFlags :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryControlFlags
pipelineStatistics :: forall (es :: [*]).
CommandBufferInheritanceInfo es -> QueryPipelineStatisticFlags
next :: Chain es
renderPass :: RenderPass
subpass :: Word32
framebuffer :: Framebuffer
occlusionQueryEnable :: Bool
queryFlags :: QueryControlFlags
pipelineStatistics :: QueryPipelineStatisticFlags
..} 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 (CommandBufferInheritanceInfo es)
p Ptr (CommandBufferInheritanceInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_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 RenderPass)) (renderPass)
    lift $ poke ((p `plusPtr` 24 :: Ptr Word32)) (subpass)
    lift $ poke ((p `plusPtr` 32 :: Ptr Framebuffer)) (framebuffer)
    lift $ poke ((p `plusPtr` 40 :: Ptr Bool32)) (boolToBool32 (occlusionQueryEnable))
    lift $ poke ((p `plusPtr` 44 :: Ptr QueryControlFlags)) (queryFlags)
    lift $ poke ((p `plusPtr` 48 :: Ptr QueryPipelineStatisticFlags)) (pipelineStatistics)
    lift $ f
  cStructSize :: Int
cStructSize = Int
56
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr (CommandBufferInheritanceInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (CommandBufferInheritanceInfo 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 (CommandBufferInheritanceInfo es)
p Ptr (CommandBufferInheritanceInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_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` 24 :: Ptr Word32)) (zero)
    lift $ poke ((p `plusPtr` 40 :: Ptr Bool32)) (boolToBool32 (zero))
    lift $ f

instance ( Extendss CommandBufferInheritanceInfo es
         , PeekChain es ) => FromCStruct (CommandBufferInheritanceInfo es) where
  peekCStruct :: Ptr (CommandBufferInheritanceInfo es)
-> IO (CommandBufferInheritanceInfo es)
peekCStruct Ptr (CommandBufferInheritanceInfo es)
p = do
    pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (CommandBufferInheritanceInfo es)
p Ptr (CommandBufferInheritanceInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
    next <- peekChain (castPtr pNext)
    renderPass <- peek @RenderPass ((p `plusPtr` 16 :: Ptr RenderPass))
    subpass <- peek @Word32 ((p `plusPtr` 24 :: Ptr Word32))
    framebuffer <- peek @Framebuffer ((p `plusPtr` 32 :: Ptr Framebuffer))
    occlusionQueryEnable <- peek @Bool32 ((p `plusPtr` 40 :: Ptr Bool32))
    queryFlags <- peek @QueryControlFlags ((p `plusPtr` 44 :: Ptr QueryControlFlags))
    pipelineStatistics <- peek @QueryPipelineStatisticFlags ((p `plusPtr` 48 :: Ptr QueryPipelineStatisticFlags))
    pure $ CommandBufferInheritanceInfo
             next
             renderPass
             subpass
             framebuffer
             (bool32ToBool occlusionQueryEnable)
             queryFlags
             pipelineStatistics

instance es ~ '[] => Zero (CommandBufferInheritanceInfo es) where
  zero :: CommandBufferInheritanceInfo es
zero = Chain es
-> RenderPass
-> Word32
-> Framebuffer
-> Bool
-> QueryControlFlags
-> QueryPipelineStatisticFlags
-> CommandBufferInheritanceInfo es
forall (es :: [*]).
Chain es
-> RenderPass
-> Word32
-> Framebuffer
-> Bool
-> QueryControlFlags
-> QueryPipelineStatisticFlags
-> CommandBufferInheritanceInfo es
CommandBufferInheritanceInfo
           ()
           RenderPass
forall a. Zero a => a
zero
           Word32
forall a. Zero a => a
zero
           Framebuffer
forall a. Zero a => a
zero
           Bool
forall a. Zero a => a
zero
           QueryControlFlags
forall a. Zero a => a
zero
           QueryPipelineStatisticFlags
forall a. Zero a => a
zero


-- | VkCommandBufferBeginInfo - Structure specifying a command buffer begin
-- operation
--
-- == Valid Usage
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-09123# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT',
--     the 'Vulkan.Core10.Handles.CommandPool' that @commandBuffer@ was
--     allocated from /must/ support graphics operations
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-00055# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT',
--     the @framebuffer@ member of @pInheritanceInfo@ /must/ be either
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', or a valid
--     'Vulkan.Core10.Handles.Framebuffer' that is compatible with the
--     @renderPass@ member of @pInheritanceInfo@
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-09240# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     and the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-dynamicRendering dynamicRendering>
--     feature is not enabled, the @renderPass@ member of
--     @pInheritanceInfo@ /must/ not be
--     'Vulkan.Core10.APIConstants.NULL_HANDLE'
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-06002# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     and the @renderPass@ member of @pInheritanceInfo@ is
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', the @pNext@ chain of
--     @pInheritanceInfo@ /must/ include a
--     'Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering.CommandBufferInheritanceRenderingInfo'
--     structure
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-06003# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT',
--     the @renderPass@ member of @pInheritanceInfo@ is
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', and the @pNext@ chain of
--     @pInheritanceInfo@ includes a
--     'Vulkan.Extensions.VK_AMD_mixed_attachment_samples.AttachmentSampleCountInfoAMD'
--     or
--     'Vulkan.Extensions.VK_NV_framebuffer_mixed_samples.AttachmentSampleCountInfoNV'
--     structure, the @colorAttachmentCount@ member of that structure
--     /must/ be equal to the value of
--     'Vulkan.Core13.Promoted_From_VK_KHR_dynamic_rendering.CommandBufferInheritanceRenderingInfo'::@colorAttachmentCount@
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-06000# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     and the @renderPass@ member of @pInheritanceInfo@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', the @renderPass@ member of
--     @pInheritanceInfo@ /must/ be a valid
--     'Vulkan.Core10.Handles.RenderPass'
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-06001# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     and the @renderPass@ member of @pInheritanceInfo@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', the @subpass@ member of
--     @pInheritanceInfo@ /must/ be a valid subpass index within the
--     @renderPass@ member of @pInheritanceInfo@
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-10617# If @flags@ contains
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     , the @renderPass@ member of @pInheritanceInfo@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', and @renderPass@ was
--     created with
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-tile-shading tile shading enabled>,
--     'Vulkan.Extensions.VK_QCOM_tile_shading.TILE_SHADING_RENDER_PASS_ENABLE_BIT_QCOM'
--     /must/ be included in
--     'Vulkan.Extensions.VK_QCOM_tile_shading.RenderPassTileShadingCreateInfoQCOM'::@flags@
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-10618# If @flags@ does not
--     contain
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT'
--     , the @renderPass@ member of @pInheritanceInfo@ is
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', or @renderPass@ was not
--     created with tile shading enabled,
--     'Vulkan.Extensions.VK_QCOM_tile_shading.TILE_SHADING_RENDER_PASS_ENABLE_BIT_QCOM'
--     /must/ not be included in
--     'Vulkan.Extensions.VK_QCOM_tile_shading.RenderPassTileShadingCreateInfoQCOM'::@flags@
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-10619# If
--     'Vulkan.Extensions.VK_QCOM_tile_shading.TILE_SHADING_RENDER_PASS_ENABLE_BIT_QCOM'
--     is included in
--     'Vulkan.Extensions.VK_QCOM_tile_shading.RenderPassTileShadingCreateInfoQCOM'::@flags@,
--     'Vulkan.Extensions.VK_QCOM_tile_shading.RenderPassTileShadingCreateInfoQCOM'::@tileApronSize@
--     /must/ be equal to the @tileApronSize@ used to create @renderPass@
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkCommandBufferBeginInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO'
--
-- -   #VUID-VkCommandBufferBeginInfo-pNext-pNext# @pNext@ /must/ be @NULL@
--     or a pointer to a valid instance of
--     'Vulkan.Core11.Promoted_From_VK_KHR_device_group.DeviceGroupCommandBufferBeginInfo'
--
-- -   #VUID-VkCommandBufferBeginInfo-sType-unique# The @sType@ value of
--     each structure in the @pNext@ chain /must/ be unique
--
-- -   #VUID-VkCommandBufferBeginInfo-flags-parameter# @flags@ /must/ be a
--     valid combination of
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.CommandBufferUsageFlagBits'
--     values
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_0 VK_VERSION_1_0>,
-- 'CommandBufferInheritanceInfo',
-- 'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.CommandBufferUsageFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'beginCommandBuffer'
data CommandBufferBeginInfo (es :: [Type]) = CommandBufferBeginInfo
  { -- | @pNext@ is @NULL@ or a pointer to a structure extending this structure.
    forall (es :: [*]). CommandBufferBeginInfo es -> Chain es
next :: Chain es
  , -- | @flags@ is a bitmask of
    -- 'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.CommandBufferUsageFlagBits'
    -- specifying usage behavior for the command buffer.
    forall (es :: [*]).
CommandBufferBeginInfo es -> CommandBufferUsageFlags
flags :: CommandBufferUsageFlags
  , -- | @pInheritanceInfo@ is a pointer to a 'CommandBufferInheritanceInfo'
    -- structure, used if @commandBuffer@ is a secondary command buffer. If
    -- this is a primary command buffer, then this value is ignored.
    forall (es :: [*]).
CommandBufferBeginInfo es
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (CommandBufferBeginInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (CommandBufferBeginInfo es)

instance Extensible CommandBufferBeginInfo where
  extensibleTypeName :: String
extensibleTypeName = String
"CommandBufferBeginInfo"
  setNext :: forall (ds :: [*]) (es :: [*]).
CommandBufferBeginInfo ds -> Chain es -> CommandBufferBeginInfo es
setNext CommandBufferBeginInfo{Maybe (SomeStruct CommandBufferInheritanceInfo)
CommandBufferUsageFlags
Chain ds
next :: forall (es :: [*]). CommandBufferBeginInfo es -> Chain es
flags :: forall (es :: [*]).
CommandBufferBeginInfo es -> CommandBufferUsageFlags
inheritanceInfo :: forall (es :: [*]).
CommandBufferBeginInfo es
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
next :: Chain ds
flags :: CommandBufferUsageFlags
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
..} Chain es
next' = CommandBufferBeginInfo{next :: Chain es
next = Chain es
next', Maybe (SomeStruct CommandBufferInheritanceInfo)
CommandBufferUsageFlags
flags :: CommandBufferUsageFlags
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
flags :: CommandBufferUsageFlags
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
..}
  getNext :: forall (es :: [*]). CommandBufferBeginInfo es -> Chain es
getNext CommandBufferBeginInfo{Maybe (SomeStruct CommandBufferInheritanceInfo)
CommandBufferUsageFlags
Chain es
next :: forall (es :: [*]). CommandBufferBeginInfo es -> Chain es
flags :: forall (es :: [*]).
CommandBufferBeginInfo es -> CommandBufferUsageFlags
inheritanceInfo :: forall (es :: [*]).
CommandBufferBeginInfo es
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
next :: Chain es
flags :: CommandBufferUsageFlags
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends CommandBufferBeginInfo e => b) -> Maybe b
  extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends CommandBufferBeginInfo e => b) -> Maybe b
extends proxy e
_ Extends CommandBufferBeginInfo e => b
f
    | Just e :~: DeviceGroupCommandBufferBeginInfo
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 @DeviceGroupCommandBufferBeginInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends CommandBufferBeginInfo e => b
f
    | Bool
otherwise = Maybe b
forall a. Maybe a
Nothing

instance ( Extendss CommandBufferBeginInfo es
         , PokeChain es ) => ToCStruct (CommandBufferBeginInfo es) where
  withCStruct :: forall b.
CommandBufferBeginInfo es
-> (Ptr (CommandBufferBeginInfo es) -> IO b) -> IO b
withCStruct CommandBufferBeginInfo es
x Ptr (CommandBufferBeginInfo es) -> IO b
f = Int -> (Ptr (CommandBufferBeginInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr (CommandBufferBeginInfo es) -> IO b) -> IO b)
-> (Ptr (CommandBufferBeginInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (CommandBufferBeginInfo es)
p -> Ptr (CommandBufferBeginInfo es)
-> CommandBufferBeginInfo es -> IO b -> IO b
forall b.
Ptr (CommandBufferBeginInfo es)
-> CommandBufferBeginInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (CommandBufferBeginInfo es)
p CommandBufferBeginInfo es
x (Ptr (CommandBufferBeginInfo es) -> IO b
f Ptr (CommandBufferBeginInfo es)
p)
  pokeCStruct :: forall b.
Ptr (CommandBufferBeginInfo es)
-> CommandBufferBeginInfo es -> IO b -> IO b
pokeCStruct Ptr (CommandBufferBeginInfo es)
p CommandBufferBeginInfo{Maybe (SomeStruct CommandBufferInheritanceInfo)
CommandBufferUsageFlags
Chain es
next :: forall (es :: [*]). CommandBufferBeginInfo es -> Chain es
flags :: forall (es :: [*]).
CommandBufferBeginInfo es -> CommandBufferUsageFlags
inheritanceInfo :: forall (es :: [*]).
CommandBufferBeginInfo es
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
next :: Chain es
flags :: CommandBufferUsageFlags
inheritanceInfo :: Maybe (SomeStruct CommandBufferInheritanceInfo)
..} 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 (CommandBufferBeginInfo es)
p Ptr (CommandBufferBeginInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_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 CommandBufferUsageFlags)) (flags)
    pInheritanceInfo'' <- case (inheritanceInfo) of
      Maybe (SomeStruct CommandBufferInheritanceInfo)
Nothing -> Ptr (CommandBufferInheritanceInfo '[])
-> ContT b IO (Ptr (CommandBufferInheritanceInfo '[]))
forall a. a -> ContT b IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr (CommandBufferInheritanceInfo '[])
forall a. Ptr a
nullPtr
      Just SomeStruct CommandBufferInheritanceInfo
j -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
forall r (m :: * -> *) a. ((a -> m r) -> m r) -> ContT r m a
ContT @_ @_ @(Ptr (CommandBufferInheritanceInfo '[])) (((Ptr (CommandBufferInheritanceInfo '[]) -> IO b) -> IO b)
 -> ContT b IO (Ptr (CommandBufferInheritanceInfo '[])))
-> ((Ptr (CommandBufferInheritanceInfo '[]) -> IO b) -> IO b)
-> ContT b IO (Ptr (CommandBufferInheritanceInfo '[]))
forall a b. (a -> b) -> a -> b
$ \Ptr (CommandBufferInheritanceInfo '[]) -> IO b
cont -> forall (a :: [*] -> *) b.
(forall (es :: [*]).
 (Extendss a es, PokeChain es) =>
 ToCStruct (a es)) =>
SomeStruct a
-> (forall (es :: [*]).
    (Extendss a es, PokeChain es) =>
    Ptr (a es) -> IO b)
-> IO b
withSomeCStruct @CommandBufferInheritanceInfo (SomeStruct CommandBufferInheritanceInfo
j) (Ptr (CommandBufferInheritanceInfo '[]) -> IO b
cont (Ptr (CommandBufferInheritanceInfo '[]) -> IO b)
-> (Ptr (CommandBufferInheritanceInfo es)
    -> Ptr (CommandBufferInheritanceInfo '[]))
-> Ptr (CommandBufferInheritanceInfo es)
-> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr (CommandBufferInheritanceInfo es)
-> Ptr (CommandBufferInheritanceInfo '[])
forall a b. Ptr a -> Ptr b
castPtr)
    lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr (CommandBufferInheritanceInfo _)))) pInheritanceInfo''
    lift $ f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr (CommandBufferBeginInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (CommandBufferBeginInfo 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 (CommandBufferBeginInfo es)
p Ptr (CommandBufferBeginInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_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 $ f

instance ( Extendss CommandBufferBeginInfo es
         , PeekChain es ) => FromCStruct (CommandBufferBeginInfo es) where
  peekCStruct :: Ptr (CommandBufferBeginInfo es) -> IO (CommandBufferBeginInfo es)
peekCStruct Ptr (CommandBufferBeginInfo es)
p = do
    pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (CommandBufferBeginInfo es)
p Ptr (CommandBufferBeginInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
    next <- peekChain (castPtr pNext)
    flags <- peek @CommandBufferUsageFlags ((p `plusPtr` 16 :: Ptr CommandBufferUsageFlags))
    pInheritanceInfo <- peek @(Ptr (CommandBufferInheritanceInfo _)) ((p `plusPtr` 24 :: Ptr (Ptr (CommandBufferInheritanceInfo _))))
    pInheritanceInfo' <- maybePeek (\Ptr (CommandBufferInheritanceInfo (ZonkAny 0))
j -> Ptr (SomeStruct CommandBufferInheritanceInfo)
-> IO (SomeStruct CommandBufferInheritanceInfo)
forall (a :: [*] -> *).
(Extensible a,
 forall (es :: [*]).
 (Extendss a es, PeekChain es) =>
 FromCStruct (a es)) =>
Ptr (SomeStruct a) -> IO (SomeStruct a)
peekSomeCStruct (Ptr (CommandBufferInheritanceInfo (ZonkAny 0))
-> Ptr (SomeStruct CommandBufferInheritanceInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (CommandBufferInheritanceInfo (ZonkAny 0))
j))) pInheritanceInfo
    pure $ CommandBufferBeginInfo
             next flags pInheritanceInfo'

instance es ~ '[] => Zero (CommandBufferBeginInfo es) where
  zero :: CommandBufferBeginInfo es
zero = Chain es
-> CommandBufferUsageFlags
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
-> CommandBufferBeginInfo es
forall (es :: [*]).
Chain es
-> CommandBufferUsageFlags
-> Maybe (SomeStruct CommandBufferInheritanceInfo)
-> CommandBufferBeginInfo es
CommandBufferBeginInfo
           ()
           CommandBufferUsageFlags
forall a. Zero a => a
zero
           Maybe (SomeStruct CommandBufferInheritanceInfo)
forall a. Maybe a
Nothing