{-# language CPP #-}
-- No documentation found for Chapter "Queue"
module Vulkan.Core10.Queue  ( getDeviceQueue
                            , queueSubmit
                            , queueWaitIdle
                            , queueWaitIdleSafe
                            , deviceWaitIdle
                            , deviceWaitIdleSafe
                            , SubmitInfo(..)
                            , Queue(..)
                            , PipelineStageFlagBits(..)
                            , PipelineStageFlags
                            ) where

import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (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(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (pokeSomeCStruct)
import Vulkan.NamedType ((:::))
import {-# SOURCE #-} Vulkan.Extensions.VK_SEC_amigo_profiling (AmigoProfilingSubmitInfoSEC)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (CommandBuffer_T)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_external_semaphore_win32 (D3D12FenceSubmitInfoKHR)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkDeviceWaitIdle))
import Vulkan.Dynamic (DeviceCmds(pVkGetDeviceQueue))
import Vulkan.Dynamic (DeviceCmds(pVkQueueSubmit))
import Vulkan.Dynamic (DeviceCmds(pVkQueueWaitIdle))
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_group (DeviceGroupSubmitInfo)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.Core10.Handles (Fence)
import Vulkan.Core10.Handles (Fence(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_frame_boundary (FrameBoundaryEXT)
import {-# SOURCE #-} Vulkan.Extensions.VK_ARM_tensors (FrameBoundaryTensorsARM)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_low_latency2 (LatencySubmissionPresentIdNV)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_performance_query (PerformanceQuerySubmitInfoKHR)
import Vulkan.Core10.Enums.PipelineStageFlagBits (PipelineStageFlags)
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import {-# SOURCE #-} Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory (ProtectedSubmitInfo)
import Vulkan.Core10.Handles (Queue)
import Vulkan.Core10.Handles (Queue(..))
import Vulkan.Core10.Handles (Queue(Queue))
import Vulkan.Core10.Handles (Queue_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Core10.Handles (Semaphore)
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore (TimelineSemaphoreSubmitInfo)
import Vulkan.Exception (VulkanException(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_win32_keyed_mutex (Win32KeyedMutexAcquireReleaseInfoKHR)
import {-# SOURCE #-} Vulkan.Extensions.VK_NV_win32_keyed_mutex (Win32KeyedMutexAcquireReleaseInfoNV)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SUBMIT_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Enums.PipelineStageFlagBits (PipelineStageFlagBits(..))
import Vulkan.Core10.Enums.PipelineStageFlagBits (PipelineStageFlags)
import Vulkan.Core10.Handles (Queue(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkGetDeviceQueue
  :: FunPtr (Ptr Device_T -> Word32 -> Word32 -> Ptr (Ptr Queue_T) -> IO ()) -> Ptr Device_T -> Word32 -> Word32 -> Ptr (Ptr Queue_T) -> IO ()

-- | vkGetDeviceQueue - Get a queue handle from a device
--
-- = Description
--
-- 'getDeviceQueue' /must/ only be used to get queues that were created
-- with the @flags@ parameter of
-- 'Vulkan.Core10.Device.DeviceQueueCreateInfo' set to zero. To get queues
-- that were created with a non-zero @flags@ parameter use
-- 'Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory.getDeviceQueue2'.
--
-- == Valid Usage
--
-- -   #VUID-vkGetDeviceQueue-queueFamilyIndex-00384# @queueFamilyIndex@
--     /must/ be one of the queue family indices specified when @device@
--     was created, via the 'Vulkan.Core10.Device.DeviceQueueCreateInfo'
--     structure
--
-- -   #VUID-vkGetDeviceQueue-queueIndex-00385# @queueIndex@ /must/ be less
--     than the value of
--     'Vulkan.Core10.Device.DeviceQueueCreateInfo'::@queueCount@ for the
--     queue family indicated by @queueFamilyIndex@ when @device@ was
--     created
--
-- -   #VUID-vkGetDeviceQueue-flags-01841#
--     'Vulkan.Core10.Device.DeviceQueueCreateInfo'::@flags@ /must/ have
--     been zero when @device@ was created
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkGetDeviceQueue-device-parameter# @device@ /must/ be a valid
--     'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkGetDeviceQueue-pQueue-parameter# @pQueue@ /must/ be a valid
--     pointer to a 'Vulkan.Core10.Handles.Queue' handle
--
-- = 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.Device', 'Vulkan.Core10.Handles.Queue'
getDeviceQueue :: forall io
                . (MonadIO io)
               => -- | @device@ is the logical device that owns the queue.
                  Device
               -> -- | @queueFamilyIndex@ is the index of the queue family to which the queue
                  -- belongs.
                  ("queueFamilyIndex" ::: Word32)
               -> -- | @queueIndex@ is the index within this queue family of the queue to
                  -- retrieve.
                  ("queueIndex" ::: Word32)
               -> io (Queue)
getDeviceQueue :: forall (io :: * -> *).
MonadIO io =>
Device
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> io Queue
getDeviceQueue Device
device "queueFamilyIndex" ::: Word32
queueFamilyIndex "queueFamilyIndex" ::: Word32
queueIndex = IO Queue -> io Queue
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Queue -> io Queue)
-> (ContT Queue IO Queue -> IO Queue)
-> ContT Queue IO Queue
-> io Queue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Queue IO Queue -> IO Queue
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Queue IO Queue -> io Queue)
-> ContT Queue IO Queue -> io Queue
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 vkGetDeviceQueuePtr :: FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_T)
   -> IO ())
vkGetDeviceQueuePtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("queueFamilyIndex" ::: Word32)
      -> ("queueFamilyIndex" ::: Word32)
      -> Ptr (Ptr Queue_T)
      -> IO ())
pVkGetDeviceQueue DeviceCmds
cmds
  IO () -> ContT Queue IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT Queue m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Queue IO ()) -> IO () -> ContT Queue IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_T)
   -> IO ())
vkGetDeviceQueuePtr FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_T)
   -> IO ())
-> FunPtr
     (Ptr Device_T
      -> ("queueFamilyIndex" ::: Word32)
      -> ("queueFamilyIndex" ::: Word32)
      -> Ptr (Ptr Queue_T)
      -> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_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 vkGetDeviceQueue is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkGetDeviceQueue' :: Ptr Device_T
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> Ptr (Ptr Queue_T)
-> IO ()
vkGetDeviceQueue' = FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_T)
   -> IO ())
-> Ptr Device_T
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> Ptr (Ptr Queue_T)
-> IO ()
mkVkGetDeviceQueue FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (Ptr Queue_T)
   -> IO ())
vkGetDeviceQueuePtr
  pPQueue <- ((Ptr (Ptr Queue_T) -> IO Queue) -> IO Queue)
-> ContT Queue IO (Ptr (Ptr Queue_T))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Ptr Queue_T) -> IO Queue) -> IO Queue)
 -> ContT Queue IO (Ptr (Ptr Queue_T)))
-> ((Ptr (Ptr Queue_T) -> IO Queue) -> IO Queue)
-> ContT Queue IO (Ptr (Ptr Queue_T))
forall a b. (a -> b) -> a -> b
$ IO (Ptr (Ptr Queue_T))
-> (Ptr (Ptr Queue_T) -> IO ())
-> (Ptr (Ptr Queue_T) -> IO Queue)
-> IO Queue
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @(Ptr Queue_T) Int
8) Ptr (Ptr Queue_T) -> IO ()
forall a. Ptr a -> IO ()
free
  lift $ traceAroundEvent "vkGetDeviceQueue" (vkGetDeviceQueue'
                                                (deviceHandle (device))
                                                (queueFamilyIndex)
                                                (queueIndex)
                                                (pPQueue))
  pQueue <- lift $ peek @(Ptr Queue_T) pPQueue
  pure $ (((\Ptr Queue_T
h -> Ptr Queue_T -> DeviceCmds -> Queue
Queue Ptr Queue_T
h DeviceCmds
cmds ) pQueue))


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkQueueSubmit
  :: FunPtr (Ptr Queue_T -> Word32 -> Ptr (SomeStruct SubmitInfo) -> Fence -> IO Result) -> Ptr Queue_T -> Word32 -> Ptr (SomeStruct SubmitInfo) -> Fence -> IO Result

-- | vkQueueSubmit - Submits a sequence of semaphores or command buffers to a
-- queue
--
-- = Description
--
-- 'queueSubmit' is a
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#devsandqueues-submission queue submission command>,
-- with each batch defined by an element of @pSubmits@. Batches begin
-- execution in the order they appear in @pSubmits@, but /may/ complete out
-- of order.
--
-- The order that batches appear in @pSubmits@ is used to determine
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-submission-order submission order>,
-- and thus all the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-implicit implicit ordering guarantees>
-- that respect it. Other than these implicit ordering guarantees and any
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization explicit synchronization primitives>,
-- these batches /may/ overlap or otherwise execute out of order.
--
-- Fence operations submitted with 'queueSubmit' have additional ordering
-- constraints compared to other submission commands, with dependencies
-- involving previous and subsequent queue operations. Information about
-- these additional constraints can be found in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-fences fence>
-- sections of
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization the synchronization chapter>.
--
-- The first
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-dependencies-scopes synchronization scope>
-- of each
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-signaling semaphore signal operation>
-- defined by this command includes every command in the same batch that
-- the signal operation is defined in, and all commands that occur earlier
-- in
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-submission-order submission order>.
--
-- The second
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-dependencies-scopes synchronization scope>
-- of each
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-waiting semaphore wait operation>
-- defined by this command includes every command in the same batch that
-- the wait operation is defined in, and all commands that occur later in
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-submission-order submission order>.
-- The scope is limited by the @pWaitDstStageMask@ for each batch, as
-- described in 'SubmitInfo'.
--
-- If any command buffer submitted to this queue is in the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle executable state>,
-- it is moved to the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>.
-- Once execution of all submissions of a command buffer complete, it moves
-- from the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>,
-- back to the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle executable state>.
-- If a command buffer was recorded with the
-- 'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT'
-- flag, it instead moves to the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle invalid state>.
--
-- If 'queueSubmit' fails, it /may/ return
-- 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY' or
-- 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'. If it does, the
-- implementation /must/ ensure that the state and contents of any
-- resources or synchronization primitives referenced by the submitted
-- command buffers and any semaphores referenced by @pSubmits@ is
-- unaffected by the call or its failure. If 'queueSubmit' fails in such a
-- way that the implementation is unable to make that guarantee, the
-- implementation /must/ return
-- 'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'. See
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#devsandqueues-lost-device Lost Device>.
--
-- == Valid Usage
--
-- -   #VUID-vkQueueSubmit-fence-00063# If @fence@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', @fence@ /must/ be
--     unsignaled
--
-- -   #VUID-vkQueueSubmit-fence-00064# If @fence@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', @fence@ /must/ not be
--     associated with any other queue command that has not yet completed
--     execution on that queue
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00065# Any calls to
--     'Vulkan.Core10.CommandBufferBuilding.cmdSetEvent',
--     'Vulkan.Core10.CommandBufferBuilding.cmdResetEvent' or
--     'Vulkan.Core10.CommandBufferBuilding.cmdWaitEvents' that have been
--     recorded into any of the command buffer elements of the
--     @pCommandBuffers@ member of any element of @pSubmits@, /must/ not
--     reference any 'Vulkan.Core10.Handles.Event' that is referenced by
--     any of those commands in a command buffer that has been submitted to
--     another queue and is still in the /pending state/
--
-- -   #VUID-vkQueueSubmit-pWaitDstStageMask-00066# Any stage flag included
--     in any element of the @pWaitDstStageMask@ member of any element of
--     @pSubmits@ /must/ be a pipeline stage supported by one of the
--     capabilities of @queue@, as specified in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-pipeline-stages-supported table of supported pipeline stages>
--
-- -   #VUID-vkQueueSubmit-pSignalSemaphores-00067# Each binary semaphore
--     element of the @pSignalSemaphores@ member of any element of
--     @pSubmits@ /must/ be unsignaled when the semaphore signal operation
--     it defines is executed on the device
--
-- -   #VUID-vkQueueSubmit-pWaitSemaphores-00068# When a semaphore wait
--     operation referring to a binary semaphore defined by any element of
--     the @pWaitSemaphores@ member of any element of @pSubmits@ executes
--     on @queue@, there /must/ be no other queues waiting on the same
--     semaphore
--
-- -   #VUID-vkQueueSubmit-pWaitSemaphores-03238# All elements of the
--     @pWaitSemaphores@ member of all elements of @pSubmits@ created with
--     a 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_BINARY' /must/
--     reference a semaphore signal operation that has been submitted for
--     execution and any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-signaling semaphore signal operations>
--     on which it depends /must/ have also been submitted for execution
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00070# Each element of the
--     @pCommandBuffers@ member of each element of @pSubmits@ /must/ be in
--     the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending or executable state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00071# If any element of the
--     @pCommandBuffers@ member of any element of @pSubmits@ was not
--     recorded with the
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT',
--     it /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00072# Any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-secondary secondary command buffers recorded>
--     into any element of the @pCommandBuffers@ member of any element of
--     @pSubmits@ /must/ be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending or executable state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00073# If any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-secondary secondary command buffers recorded>
--     into any element of the @pCommandBuffers@ member of any element of
--     @pSubmits@ was not recorded with the
--     'Vulkan.Core10.Enums.CommandBufferUsageFlagBits.COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT',
--     it /must/ not be in the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00074# Each element of the
--     @pCommandBuffers@ member of each element of @pSubmits@ /must/ have
--     been allocated from a 'Vulkan.Core10.Handles.CommandPool' that was
--     created for the same queue family @queue@ belongs to
--
-- -   #VUID-vkQueueSubmit-pSubmits-02207# If any element of
--     @pSubmits->pCommandBuffers@ includes a
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-queue-transfers-acquire Queue Family Ownership Transfer Acquire Operation>,
--     there /must/ exist a previously submitted
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-queue-transfers-release Queue Family Ownership Transfer Release Operation>
--     on a queue in the queue family identified by the acquire operation,
--     with parameters matching the acquire operation as defined in the
--     definition of such
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-queue-transfers-acquire acquire operations>,
--     and which happens-before the acquire operation
--
-- -   #VUID-vkQueueSubmit-pSubmits-10911# If any element of
--     @pSubmits->pCommandBuffers@ includes a
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-queue-transfers-acquire Queue Family Ownership Transfer Acquire Operation>,
--     the affected resource /must/ not be modified in any way between the
--     last matching release operation and the acquire operation
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-03220# If a command recorded
--     into any element of @pCommandBuffers@ was a
--     'Vulkan.Core10.CommandBufferBuilding.cmdBeginQuery' whose
--     @queryPool@ was created with a @queryType@ of
--     'Vulkan.Core10.Enums.QueryType.QUERY_TYPE_PERFORMANCE_QUERY_KHR',
--     the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#profiling-lock profiling lock>
--     /must/ have been held continuously on the
--     'Vulkan.Core10.Handles.Device' that @queue@ was retrieved from,
--     throughout recording of those command buffers
--
-- -   #VUID-vkQueueSubmit-pSubmits-02808# Any resource created with
--     'Vulkan.Core10.Enums.SharingMode.SHARING_MODE_EXCLUSIVE' that is
--     read by an operation specified by @pSubmits@ /must/ not be owned by
--     any queue family other than the one which @queue@ belongs to, at the
--     time it is executed
--
-- -   #VUID-vkQueueSubmit-pSubmits-04626# Any resource created with
--     'Vulkan.Core10.Enums.SharingMode.SHARING_MODE_CONCURRENT' that is
--     accessed by an operation specified by @pSubmits@ /must/ have
--     included the queue family of @queue@ at resource creation time
--
-- -   #VUID-vkQueueSubmit-queue-06448# If @queue@ was not created with
--     'Vulkan.Core10.Enums.DeviceQueueCreateFlagBits.DEVICE_QUEUE_CREATE_PROTECTED_BIT',
--     there /must/ be no element of @pSubmits@ that includes a
--     'Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory.ProtectedSubmitInfo'
--     structure in its @pNext@ chain with @protectedSubmit@ equal to
--     'Vulkan.Core10.FundamentalTypes.TRUE'
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkQueueSubmit-queue-parameter# @queue@ /must/ be a valid
--     'Vulkan.Core10.Handles.Queue' handle
--
-- -   #VUID-vkQueueSubmit-pSubmits-parameter# If @submitCount@ is not @0@,
--     @pSubmits@ /must/ be a valid pointer to an array of @submitCount@
--     valid 'SubmitInfo' structures
--
-- -   #VUID-vkQueueSubmit-fence-parameter# If @fence@ is not
--     'Vulkan.Core10.APIConstants.NULL_HANDLE', @fence@ /must/ be a valid
--     'Vulkan.Core10.Handles.Fence' handle
--
-- -   #VUID-vkQueueSubmit-commonparent# Both of @fence@, and @queue@ that
--     are valid handles of non-ignored parameters /must/ have been
--     created, allocated, or retrieved from the same
--     'Vulkan.Core10.Handles.Device'
--
-- == Host Synchronization
--
-- -   Host access to @queue@ /must/ be externally synchronized if it was
--     not created with
--     'Vulkan.Core10.Enums.DeviceQueueCreateFlagBits.DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR'
--
-- -   Host access to @fence@ /must/ be externally synchronized
--
-- == Command Properties
--
-- \'
--
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
-- | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkCommandBufferLevel Command Buffer Levels> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkCmdBeginRenderPass Render Pass Scope> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkCmdBeginVideoCodingKHR Video Coding Scope> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkQueueFlagBits Supported Queue Types> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-queueoperation-command-types Command Type> |
-- +============================================================================================================================+========================================================================================================================+=============================================================================================================================+=======================================================================================================================+========================================================================================================================================+
-- | -                                                                                                                          | -                                                                                                                      | -                                                                                                                           | Any                                                                                                                   | -                                                                                                                                      |
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
--
-- == 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_DEVICE_LOST'
--
--     -   '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.Fence', 'Vulkan.Core10.Handles.Queue',
-- 'SubmitInfo'
queueSubmit :: forall io
             . (MonadIO io)
            => -- | @queue@ is the queue that the command buffers will be submitted to.
               Queue
            -> -- | @pSubmits@ is a pointer to an array of 'SubmitInfo' structures, each
               -- specifying a command buffer submission batch. Command buffers and
               -- semaphores specified in this array /may/ be accessed at any point until
               -- the
               -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#devsandqueues-submission queue operations>
               -- they define complete execution on the device.
               ("submits" ::: Vector (SomeStruct SubmitInfo))
            -> -- | @fence@ is an /optional/ handle to a fence to be signaled once all
               -- submitted command buffers have completed execution. If @fence@ is not
               -- 'Vulkan.Core10.APIConstants.NULL_HANDLE', it defines a
               -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-fences-signaling fence signal operation>.
               -- If it is not 'Vulkan.Core10.APIConstants.NULL_HANDLE', @fence@ /may/ be
               -- accessed at any point until this command completes on the device.
               Fence
            -> io ()
queueSubmit :: forall (io :: * -> *).
MonadIO io =>
Queue
-> ("submits" ::: Vector (SomeStruct SubmitInfo)) -> Fence -> io ()
queueSubmit Queue
queue "submits" ::: Vector (SomeStruct SubmitInfo)
submits Fence
fence = 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 vkQueueSubmitPtr :: FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> IO Result)
vkQueueSubmitPtr = DeviceCmds
-> FunPtr
     (Ptr Queue_T
      -> ("queueFamilyIndex" ::: Word32)
      -> Ptr (SomeStruct SubmitInfo)
      -> Fence
      -> IO Result)
pVkQueueSubmit (case Queue
queue of Queue{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Queue -> 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 Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> IO Result)
vkQueueSubmitPtr FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> IO Result)
-> FunPtr
     (Ptr Queue_T
      -> ("queueFamilyIndex" ::: Word32)
      -> Ptr (SomeStruct SubmitInfo)
      -> Fence
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> 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 vkQueueSubmit is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkQueueSubmit' :: Ptr Queue_T
-> ("queueFamilyIndex" ::: Word32)
-> Ptr (SomeStruct SubmitInfo)
-> Fence
-> IO Result
vkQueueSubmit' = FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> IO Result)
-> Ptr Queue_T
-> ("queueFamilyIndex" ::: Word32)
-> Ptr (SomeStruct SubmitInfo)
-> Fence
-> IO Result
mkVkQueueSubmit FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> Ptr (SomeStruct SubmitInfo)
   -> Fence
   -> IO Result)
vkQueueSubmitPtr
  pPSubmits <- ((Ptr (SubmitInfo (ZonkAny 0)) -> IO ()) -> IO ())
-> ContT () IO (Ptr (SubmitInfo (ZonkAny 0)))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (SubmitInfo (ZonkAny 0)) -> IO ()) -> IO ())
 -> ContT () IO (Ptr (SubmitInfo (ZonkAny 0))))
-> ((Ptr (SubmitInfo (ZonkAny 0)) -> IO ()) -> IO ())
-> ContT () IO (Ptr (SubmitInfo (ZonkAny 0)))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(SubmitInfo _) ((("submits" ::: Vector (SomeStruct SubmitInfo)) -> Int
forall a. Vector a -> Int
Data.Vector.length ("submits" ::: Vector (SomeStruct SubmitInfo)
submits)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
72)
  Data.Vector.imapM_ (\Int
i SomeStruct SubmitInfo
e -> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ()) -> IO ()) -> ContT () IO ())
-> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (SomeStruct SubmitInfo)
-> SomeStruct SubmitInfo -> IO () -> IO ()
forall (a :: [*] -> *) b.
(forall (es :: [*]).
 (Extendss a es, PokeChain es) =>
 ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (Ptr (SubmitInfo (ZonkAny 1)) -> Ptr (SomeStruct SubmitInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (SubmitInfo (ZonkAny 0))
pPSubmits Ptr (SubmitInfo (ZonkAny 0)) -> Int -> Ptr (SubmitInfo w)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
72 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (SubmitInfo _))) (SomeStruct SubmitInfo
e) (IO () -> IO ())
-> ((() -> IO ()) -> IO ()) -> (() -> IO ()) -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ())) (submits)
  r <- lift $ traceAroundEvent "vkQueueSubmit" (vkQueueSubmit'
                                                  (queueHandle (queue))
                                                  ((fromIntegral (Data.Vector.length $ (submits)) :: Word32))
                                                  (forgetExtensions (pPSubmits))
                                                  (fence))
  lift $ when (r < SUCCESS) (throwIO (VulkanException r))


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

foreign import ccall
  "dynamic" mkVkQueueWaitIdleSafe
  :: FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result

-- | queueWaitIdle with selectable safeness
queueWaitIdleSafeOrUnsafe :: forall io
                           . (MonadIO io)
                          => (FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
                          -> -- | @queue@ is the queue on which to wait.
                             Queue
                          -> io ()
queueWaitIdleSafeOrUnsafe :: forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
-> Queue -> io ()
queueWaitIdleSafeOrUnsafe FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result
mkVkQueueWaitIdle Queue
queue = 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 vkQueueWaitIdlePtr :: FunPtr (Ptr Queue_T -> IO Result)
vkQueueWaitIdlePtr = DeviceCmds -> FunPtr (Ptr Queue_T -> IO Result)
pVkQueueWaitIdle (case Queue
queue of Queue{DeviceCmds
deviceCmds :: Queue -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Queue_T -> IO Result)
vkQueueWaitIdlePtr FunPtr (Ptr Queue_T -> IO Result)
-> FunPtr (Ptr Queue_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Queue_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 vkQueueWaitIdle is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkQueueWaitIdle' :: Ptr Queue_T -> IO Result
vkQueueWaitIdle' = FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result
mkVkQueueWaitIdle FunPtr (Ptr Queue_T -> IO Result)
vkQueueWaitIdlePtr
  r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkQueueWaitIdle" (Ptr Queue_T -> IO Result
vkQueueWaitIdle'
                                             (Queue -> Ptr Queue_T
queueHandle (Queue
queue)))
  when (r < SUCCESS) (throwIO (VulkanException r))

-- | vkQueueWaitIdle - Wait for a queue to become idle
--
-- = Description
--
-- 'queueWaitIdle' is equivalent to having submitted a valid fence to every
-- previously executed
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#devsandqueues-submission queue submission command>
-- that accepts a fence, then waiting for all of those fences to signal
-- using 'Vulkan.Core10.Fence.waitForFences' with an infinite timeout and
-- @waitAll@ set to 'Vulkan.Core10.FundamentalTypes.TRUE'.
--
-- Even though 'Vulkan.Extensions.VK_KHR_swapchain.queuePresentKHR' does
-- not have a fence parameter, it does accept a fence through
-- 'Vulkan.Extensions.VK_EXT_swapchain_maintenance1.SwapchainPresentFenceInfoEXT'.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkQueueWaitIdle-queue-parameter# @queue@ /must/ be a valid
--     'Vulkan.Core10.Handles.Queue' handle
--
-- == Host Synchronization
--
-- -   Host access to @queue@ /must/ be externally synchronized if it was
--     not created with
--     'Vulkan.Core10.Enums.DeviceQueueCreateFlagBits.DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR'
--
-- == Command Properties
--
-- \'
--
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
-- | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkCommandBufferLevel Command Buffer Levels> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkCmdBeginRenderPass Render Pass Scope> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#vkCmdBeginVideoCodingKHR Video Coding Scope> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VkQueueFlagBits Supported Queue Types> | <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-queueoperation-command-types Command Type> |
-- +============================================================================================================================+========================================================================================================================+=============================================================================================================================+=======================================================================================================================+========================================================================================================================================+
-- | -                                                                                                                          | -                                                                                                                      | -                                                                                                                           | Any                                                                                                                   | -                                                                                                                                      |
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
--
-- == 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_DEVICE_LOST'
--
--     -   '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.Queue'
queueWaitIdle :: forall io
               . (MonadIO io)
              => -- | @queue@ is the queue on which to wait.
                 Queue
              -> io ()
queueWaitIdle :: forall (io :: * -> *). MonadIO io => Queue -> io ()
queueWaitIdle = (FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
-> Queue -> io ()
forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
-> Queue -> io ()
queueWaitIdleSafeOrUnsafe FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result
mkVkQueueWaitIdleUnsafe

-- | A variant of 'queueWaitIdle' which makes a *safe* FFI call
queueWaitIdleSafe :: forall io
                   . (MonadIO io)
                  => -- | @queue@ is the queue on which to wait.
                     Queue
                  -> io ()
queueWaitIdleSafe :: forall (io :: * -> *). MonadIO io => Queue -> io ()
queueWaitIdleSafe = (FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
-> Queue -> io ()
forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
-> Queue -> io ()
queueWaitIdleSafeOrUnsafe FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result
mkVkQueueWaitIdleSafe


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

foreign import ccall
  "dynamic" mkVkDeviceWaitIdleSafe
  :: FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result

-- | deviceWaitIdle with selectable safeness
deviceWaitIdleSafeOrUnsafe :: forall io
                            . (MonadIO io)
                           => (FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
                           -> -- | @device@ is the logical device to idle.
                              Device
                           -> io ()
deviceWaitIdleSafeOrUnsafe :: forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
-> Device -> io ()
deviceWaitIdleSafeOrUnsafe FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result
mkVkDeviceWaitIdle Device
device = 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 vkDeviceWaitIdlePtr :: FunPtr (Ptr Device_T -> IO Result)
vkDeviceWaitIdlePtr = DeviceCmds -> FunPtr (Ptr Device_T -> IO Result)
pVkDeviceWaitIdle (case Device
device of Device{DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Device_T -> IO Result)
vkDeviceWaitIdlePtr FunPtr (Ptr Device_T -> IO Result)
-> FunPtr (Ptr Device_T -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Device_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 vkDeviceWaitIdle is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkDeviceWaitIdle' :: Ptr Device_T -> IO Result
vkDeviceWaitIdle' = FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result
mkVkDeviceWaitIdle FunPtr (Ptr Device_T -> IO Result)
vkDeviceWaitIdlePtr
  r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkDeviceWaitIdle" (Ptr Device_T -> IO Result
vkDeviceWaitIdle'
                                              (Device -> Ptr Device_T
deviceHandle (Device
device)))
  when (r < SUCCESS) (throwIO (VulkanException r))

-- | vkDeviceWaitIdle - Wait for a device to become idle
--
-- = Description
--
-- 'deviceWaitIdle' is equivalent to calling 'queueWaitIdle' for all queues
-- owned by @device@.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkDeviceWaitIdle-device-parameter# @device@ /must/ be a valid
--     'Vulkan.Core10.Handles.Device' handle
--
-- == Host Synchronization
--
-- -   Host access to all 'Vulkan.Core10.Handles.Queue' objects created
--     from @device@ that are not created with
--     'Vulkan.Core10.Enums.DeviceQueueCreateFlagBits.DEVICE_QUEUE_CREATE_INTERNALLY_SYNCHRONIZED_BIT_KHR'
--     /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_DEVICE_LOST'
--
--     -   '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.Device'
deviceWaitIdle :: forall io
                . (MonadIO io)
               => -- | @device@ is the logical device to idle.
                  Device
               -> io ()
deviceWaitIdle :: forall (io :: * -> *). MonadIO io => Device -> io ()
deviceWaitIdle = (FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
-> Device -> io ()
forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
-> Device -> io ()
deviceWaitIdleSafeOrUnsafe FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result
mkVkDeviceWaitIdleUnsafe

-- | A variant of 'deviceWaitIdle' which makes a *safe* FFI call
deviceWaitIdleSafe :: forall io
                    . (MonadIO io)
                   => -- | @device@ is the logical device to idle.
                      Device
                   -> io ()
deviceWaitIdleSafe :: forall (io :: * -> *). MonadIO io => Device -> io ()
deviceWaitIdleSafe = (FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
-> Device -> io ()
forall (io :: * -> *).
MonadIO io =>
(FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
-> Device -> io ()
deviceWaitIdleSafeOrUnsafe FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result
mkVkDeviceWaitIdleSafe


-- | VkSubmitInfo - Structure specifying a queue submit operation
--
-- = Description
--
-- The order that command buffers appear in @pCommandBuffers@ is used to
-- determine
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-submission-order submission order>,
-- and thus all the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-implicit implicit ordering guarantees>
-- that respect it. Other than these implicit ordering guarantees and any
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization explicit synchronization primitives>,
-- these command buffers /may/ overlap or otherwise execute out of order.
--
-- The second
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-dependencies-scopes synchronization scope>
-- of each
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-waiting semaphore wait operation>
-- defined by this structure is limited to operations in stages indicated
-- by the corresponding element of @pWaitDstStageMask@.
--
-- A common scenario for using @pWaitDstStageMask@ with values other than
-- 'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_ALL_COMMANDS_BIT'
-- is when synchronizing a window system presentation operation against
-- subsequent command buffers which render the next frame. In this case, a
-- presentation image /must/ not be overwritten until the presentation
-- operation completes, but other pipeline stages /can/ execute without
-- waiting. A mask of
-- 'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT'
-- prevents subsequent color attachment writes from executing until the
-- semaphore signals. Some implementations /may/ be able to execute
-- transfer operations and\/or pre-rasterization work before the semaphore
-- is signaled.
--
-- If an image layout transition needs to be performed on a presentable
-- image before it is used in a framebuffer, that /can/ be performed as the
-- first operation submitted to the queue after acquiring the image, and
-- /should/ not prevent other work from overlapping with the presentation
-- operation. For example, a 'Vulkan.Core10.OtherTypes.ImageMemoryBarrier'
-- could use:
--
-- -   @srcStageMask@ =
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT'
--
-- -   @srcAccessMask@ = 0
--
-- -   @dstStageMask@ =
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT'
--
-- -   @dstAccessMask@ =
--     'Vulkan.Core10.Enums.AccessFlagBits.ACCESS_COLOR_ATTACHMENT_READ_BIT'
--     |
--     'Vulkan.Core10.Enums.AccessFlagBits.ACCESS_COLOR_ATTACHMENT_WRITE_BIT'.
--
-- -   @oldLayout@ =
--     'Vulkan.Core10.Enums.ImageLayout.IMAGE_LAYOUT_PRESENT_SRC_KHR'
--
-- -   @newLayout@ =
--     'Vulkan.Core10.Enums.ImageLayout.IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL'
--
-- Alternatively, @oldLayout@ /can/ be
-- 'Vulkan.Core10.Enums.ImageLayout.IMAGE_LAYOUT_UNDEFINED', if the image’s
-- contents need not be preserved.
--
-- This barrier accomplishes a dependency chain between previous
-- presentation operations and subsequent color attachment output
-- operations, with the layout transition performed in between, and does
-- not introduce a dependency between previous work and any
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#pipelines-graphics-subsets-pre-rasterization pre-rasterization shader stage>s.
-- More precisely, the semaphore signals after the presentation operation
-- completes, the semaphore wait stalls the
-- 'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT'
-- stage, and there is a dependency from that same stage to itself with the
-- layout transition performed in between.
--
-- == Valid Usage
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04090# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-geometryShader geometryShader>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_GEOMETRY_SHADER_BIT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04091# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-tessellationShader tessellationShader>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT'
--     or
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04092# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-conditionalRendering conditionalRendering>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04093# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-fragmentDensityMap fragmentDensityMap>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04094# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-transformFeedback transformFeedback>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04095# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-meshShader meshShader>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_MESH_SHADER_BIT_EXT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-04096# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-taskShader taskShader>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_TASK_SHADER_BIT_EXT'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-07318# If neither of the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-shadingRateImage shadingRateImage>
--     or the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-attachmentFragmentShadingRate attachmentFragmentShadingRate>
--     features are enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-03937# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-synchronization2 synchronization2>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not be @0@
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-07949# If neither the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_NV_ray_tracing VK_NV_ray_tracing>
--     extension or the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-rayTracingPipeline rayTracingPipeline>
--     feature are enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-10754# If the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-accelerationStructure accelerationStructure>
--     feature is not enabled, @pWaitDstStageMask@ /must/ not contain
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR'
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-00075# Each element of
--     @pCommandBuffers@ /must/ not have been allocated with
--     'Vulkan.Core10.Enums.CommandBufferLevel.COMMAND_BUFFER_LEVEL_SECONDARY'
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-00078# Each element of
--     @pWaitDstStageMask@ /must/ not include
--     'Vulkan.Core10.Enums.PipelineStageFlagBits.PIPELINE_STAGE_HOST_BIT'
--
-- -   #VUID-VkSubmitInfo-pWaitSemaphores-03239# If any element of
--     @pWaitSemaphores@ or @pSignalSemaphores@ was created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE', then
--     the @pNext@ chain /must/ include a
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'
--     structure
--
-- -   #VUID-VkSubmitInfo-pNext-03240# If the @pNext@ chain of this
--     structure includes a
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'
--     structure and any element of @pWaitSemaphores@ was created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE', then
--     its @waitSemaphoreValueCount@ member /must/ equal
--     @waitSemaphoreCount@
--
-- -   #VUID-VkSubmitInfo-pNext-03241# If the @pNext@ chain of this
--     structure includes a
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'
--     structure and any element of @pSignalSemaphores@ was created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE', then
--     its @signalSemaphoreValueCount@ member /must/ equal
--     @signalSemaphoreCount@
--
-- -   #VUID-VkSubmitInfo-pSignalSemaphores-03242# For each element of
--     @pSignalSemaphores@ created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE' the
--     corresponding element of
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'::@pSignalSemaphoreValues@
--     /must/ have a value greater than the current value of the semaphore
--     when the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-signaling semaphore signal operation>
--     is executed
--
-- -   #VUID-VkSubmitInfo-pWaitSemaphores-03243# For each element of
--     @pWaitSemaphores@ created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE' the
--     corresponding element of
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'::@pWaitSemaphoreValues@
--     /must/ have a value which does not differ from the current value of
--     the semaphore or the value of any outstanding semaphore wait or
--     signal operation on that semaphore by more than
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-maxTimelineSemaphoreValueDifference maxTimelineSemaphoreValueDifference>
--
-- -   #VUID-VkSubmitInfo-pSignalSemaphores-03244# For each element of
--     @pSignalSemaphores@ created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE' the
--     corresponding element of
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo'::@pSignalSemaphoreValues@
--     /must/ have a value which does not differ from the current value of
--     the semaphore or the value of any outstanding semaphore wait or
--     signal operation on that semaphore by more than
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-maxTimelineSemaphoreValueDifference maxTimelineSemaphoreValueDifference>
--
-- -   #VUID-VkSubmitInfo-pNext-04120# If the @pNext@ chain of this
--     structure does not include a
--     'Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory.ProtectedSubmitInfo'
--     structure with @protectedSubmit@ set to
--     'Vulkan.Core10.FundamentalTypes.TRUE', then each element of the
--     @pCommandBuffers@ array /must/ be an unprotected command buffer
--
-- -   #VUID-VkSubmitInfo-pNext-04148# If the @pNext@ chain of this
--     structure includes a
--     'Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory.ProtectedSubmitInfo'
--     structure with @protectedSubmit@ set to
--     'Vulkan.Core10.FundamentalTypes.TRUE', then each element of the
--     @pCommandBuffers@ array /must/ be a protected command buffer
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-06193# If @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-suspension resumed render pass instances>,
--     they /must/ be suspended by a render pass instance earlier in
--     submission order within @pCommandBuffers@
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-06014# If @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-suspension suspended render pass instances>,
--     they /must/ be resumed by a render pass instance later in submission
--     order within @pCommandBuffers@
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-06015# If @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-suspension suspended render pass instances>,
--     there /must/ be no action or synchronization commands executed in a
--     primary or
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#commandbuffers-secondary secondary>
--     command buffer between that render pass instance and the render pass
--     instance that resumes it
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-06016# If @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-suspension suspended render pass instances>,
--     there /must/ be no render pass instances between that render pass
--     instance and the render pass instance that resumes it
--
-- -   #VUID-VkSubmitInfo-variableSampleLocations-06017# If the
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#limits-variableSampleLocations variableSampleLocations>
--     limit is not supported, and any element of @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#renderpass-suspension suspended render pass instances>,
--     where a graphics pipeline has been bound, any pipelines bound in the
--     render pass instance that resumes it, or any subsequent render pass
--     instances that resume from that one and so on, /must/ use the same
--     sample locations
--
-- -   #VUID-VkSubmitInfo-pNext-09683# If the @pNext@ chain of this
--     structure includes a
--     'Vulkan.Extensions.VK_ARM_tensors.FrameBoundaryTensorsARM' structure
--     then it /must/ also include a
--     'Vulkan.Extensions.VK_EXT_frame_boundary.FrameBoundaryEXT' structure
--
-- -   #VUID-VkSubmitInfo-pCommandBufferInfos-09942# If at least one
--     'Vulkan.Core13.Promoted_From_VK_KHR_synchronization2.CommandBufferSubmitInfo'
--     structure in @pCommandBufferInfos@ references a @commandBuffer@
--     allocated from a pool that was created with a
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--     structure in the @pNext@ chain of
--     'Vulkan.Core10.CommandPool.CommandPoolCreateInfo' that included a
--     foreign data graph processing engine in its @pProcessingEngines@
--     member, then @pWaitSemaphoreInfos@ and @pSignalSemaphoreInfos@
--     /must/ only reference @semaphore@ objects that were created from
--     external handle types reported as supported in a
--     'Vulkan.Extensions.VK_ARM_data_graph.QueueFamilyDataGraphProcessingEnginePropertiesARM'::@foreignSemaphoreHandleTypes@
--     structure via
--     'Vulkan.Extensions.VK_ARM_data_graph.getPhysicalDeviceQueueFamilyDataGraphProcessingEnginePropertiesARM'
--     with a @queueFamilyIndex@ matching the one the command pool was
--     created for, for all the foreign data graph processing engines that
--     were part of the
--     'Vulkan.Extensions.VK_ARM_data_graph.DataGraphProcessingEngineCreateInfoARM'
--     used to create the command pool
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkSubmitInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_SUBMIT_INFO'
--
-- -   #VUID-VkSubmitInfo-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_SEC_amigo_profiling.AmigoProfilingSubmitInfoSEC',
--     'Vulkan.Extensions.VK_KHR_external_semaphore_win32.D3D12FenceSubmitInfoKHR',
--     'Vulkan.Core11.Promoted_From_VK_KHR_device_group.DeviceGroupSubmitInfo',
--     'Vulkan.Extensions.VK_EXT_frame_boundary.FrameBoundaryEXT',
--     'Vulkan.Extensions.VK_ARM_tensors.FrameBoundaryTensorsARM',
--     'Vulkan.Extensions.VK_NV_low_latency2.LatencySubmissionPresentIdNV',
--     'Vulkan.Extensions.VK_KHR_performance_query.PerformanceQuerySubmitInfoKHR',
--     'Vulkan.Core11.Originally_Based_On_VK_KHR_protected_memory.ProtectedSubmitInfo',
--     'Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore.TimelineSemaphoreSubmitInfo',
--     'Vulkan.Extensions.VK_KHR_win32_keyed_mutex.Win32KeyedMutexAcquireReleaseInfoKHR',
--     or
--     'Vulkan.Extensions.VK_NV_win32_keyed_mutex.Win32KeyedMutexAcquireReleaseInfoNV'
--
-- -   #VUID-VkSubmitInfo-sType-unique# The @sType@ value of each structure
--     in the @pNext@ chain /must/ be unique
--
-- -   #VUID-VkSubmitInfo-pWaitSemaphores-parameter# If
--     @waitSemaphoreCount@ is not @0@, @pWaitSemaphores@ /must/ be a valid
--     pointer to an array of @waitSemaphoreCount@ valid
--     'Vulkan.Core10.Handles.Semaphore' handles
--
-- -   #VUID-VkSubmitInfo-pWaitDstStageMask-parameter# If
--     @waitSemaphoreCount@ is not @0@, @pWaitDstStageMask@ /must/ be a
--     valid pointer to an array of @waitSemaphoreCount@ valid combinations
--     of 'Vulkan.Core10.Enums.PipelineStageFlagBits.PipelineStageFlagBits'
--     values
--
-- -   #VUID-VkSubmitInfo-pCommandBuffers-parameter# If
--     @commandBufferCount@ is not @0@, @pCommandBuffers@ /must/ be a valid
--     pointer to an array of @commandBufferCount@ valid
--     'Vulkan.Core10.Handles.CommandBuffer' handles
--
-- -   #VUID-VkSubmitInfo-pSignalSemaphores-parameter# If
--     @signalSemaphoreCount@ is not @0@, @pSignalSemaphores@ /must/ be a
--     valid pointer to an array of @signalSemaphoreCount@ valid
--     'Vulkan.Core10.Handles.Semaphore' handles
--
-- -   #VUID-VkSubmitInfo-commonparent# Each of the elements of
--     @pCommandBuffers@, the elements of @pSignalSemaphores@, and the
--     elements of @pWaitSemaphores@ 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.Handles.CommandBuffer',
-- 'Vulkan.Core10.Enums.PipelineStageFlagBits.PipelineStageFlags',
-- 'Vulkan.Core10.Handles.Semaphore',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'queueSubmit'
data SubmitInfo (es :: [Type]) = SubmitInfo
  { -- | @pNext@ is @NULL@ or a pointer to a structure extending this structure.
    forall (es :: [*]). SubmitInfo es -> Chain es
next :: Chain es
  , -- | @pWaitSemaphores@ is a pointer to an array of
    -- 'Vulkan.Core10.Handles.Semaphore' handles upon which to wait before the
    -- command buffers for this batch begin execution. If semaphores to wait on
    -- are provided, they define a
    -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-waiting semaphore wait operation>.
    forall (es :: [*]). SubmitInfo es -> Vector Semaphore
waitSemaphores :: Vector Semaphore
  , -- | @pWaitDstStageMask@ is a pointer to an array of pipeline stages at which
    -- each corresponding semaphore wait will occur.
    forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
waitDstStageMask :: Vector PipelineStageFlags
  , -- | @pCommandBuffers@ is a pointer to an array of
    -- 'Vulkan.Core10.Handles.CommandBuffer' handles to execute in the batch.
    forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
commandBuffers :: Vector (Ptr CommandBuffer_T)
  , -- | @pSignalSemaphores@ is a pointer to an array of
    -- 'Vulkan.Core10.Handles.Semaphore' handles which will be signaled when
    -- the command buffers for this batch have completed execution. If
    -- semaphores to be signaled are provided, they define a
    -- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#synchronization-semaphores-signaling semaphore signal operation>.
    forall (es :: [*]). SubmitInfo es -> Vector Semaphore
signalSemaphores :: Vector Semaphore
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SubmitInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (SubmitInfo es)

instance Extensible SubmitInfo where
  extensibleTypeName :: String
extensibleTypeName = String
"SubmitInfo"
  setNext :: forall (ds :: [*]) (es :: [*]).
SubmitInfo ds -> Chain es -> SubmitInfo es
setNext SubmitInfo{Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
Chain ds
next :: forall (es :: [*]). SubmitInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
waitDstStageMask :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
commandBuffers :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
signalSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
next :: Chain ds
waitSemaphores :: Vector Semaphore
waitDstStageMask :: Vector PipelineStageFlags
commandBuffers :: Vector (Ptr CommandBuffer_T)
signalSemaphores :: Vector Semaphore
..} Chain es
next' = SubmitInfo{next :: Chain es
next = Chain es
next', Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
waitSemaphores :: Vector Semaphore
waitDstStageMask :: Vector PipelineStageFlags
commandBuffers :: Vector (Ptr CommandBuffer_T)
signalSemaphores :: Vector Semaphore
waitSemaphores :: Vector Semaphore
waitDstStageMask :: Vector PipelineStageFlags
commandBuffers :: Vector (Ptr CommandBuffer_T)
signalSemaphores :: Vector Semaphore
..}
  getNext :: forall (es :: [*]). SubmitInfo es -> Chain es
getNext SubmitInfo{Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
Chain es
next :: forall (es :: [*]). SubmitInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
waitDstStageMask :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
commandBuffers :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
signalSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
next :: Chain es
waitSemaphores :: Vector Semaphore
waitDstStageMask :: Vector PipelineStageFlags
commandBuffers :: Vector (Ptr CommandBuffer_T)
signalSemaphores :: Vector Semaphore
..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends SubmitInfo e => b) -> Maybe b
  extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends SubmitInfo e => b) -> Maybe b
extends proxy e
_ Extends SubmitInfo e => b
f
    | Just e :~: FrameBoundaryTensorsARM
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 @FrameBoundaryTensorsARM = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: LatencySubmissionPresentIdNV
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 @LatencySubmissionPresentIdNV = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: FrameBoundaryEXT
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 @FrameBoundaryEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: AmigoProfilingSubmitInfoSEC
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 @AmigoProfilingSubmitInfoSEC = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: PerformanceQuerySubmitInfoKHR
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 @PerformanceQuerySubmitInfoKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: TimelineSemaphoreSubmitInfo
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 @TimelineSemaphoreSubmitInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: ProtectedSubmitInfo
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 @ProtectedSubmitInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: DeviceGroupSubmitInfo
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 @DeviceGroupSubmitInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: D3D12FenceSubmitInfoKHR
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 @D3D12FenceSubmitInfoKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: Win32KeyedMutexAcquireReleaseInfoKHR
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 @Win32KeyedMutexAcquireReleaseInfoKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Just e :~: Win32KeyedMutexAcquireReleaseInfoNV
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 @Win32KeyedMutexAcquireReleaseInfoNV = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends SubmitInfo e => b
f
    | Bool
otherwise = Maybe b
forall a. Maybe a
Nothing

instance ( Extendss SubmitInfo es
         , PokeChain es ) => ToCStruct (SubmitInfo es) where
  withCStruct :: forall b. SubmitInfo es -> (Ptr (SubmitInfo es) -> IO b) -> IO b
withCStruct SubmitInfo es
x Ptr (SubmitInfo es) -> IO b
f = Int -> (Ptr (SubmitInfo es) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
72 ((Ptr (SubmitInfo es) -> IO b) -> IO b)
-> (Ptr (SubmitInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr (SubmitInfo es)
p -> Ptr (SubmitInfo es) -> SubmitInfo es -> IO b -> IO b
forall b. Ptr (SubmitInfo es) -> SubmitInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (SubmitInfo es)
p SubmitInfo es
x (Ptr (SubmitInfo es) -> IO b
f Ptr (SubmitInfo es)
p)
  pokeCStruct :: forall b. Ptr (SubmitInfo es) -> SubmitInfo es -> IO b -> IO b
pokeCStruct Ptr (SubmitInfo es)
p SubmitInfo{Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
Chain es
next :: forall (es :: [*]). SubmitInfo es -> Chain es
waitSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
waitDstStageMask :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
commandBuffers :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
signalSemaphores :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
next :: Chain es
waitSemaphores :: Vector Semaphore
waitDstStageMask :: Vector PipelineStageFlags
commandBuffers :: Vector (Ptr CommandBuffer_T)
signalSemaphores :: Vector Semaphore
..} 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 (SubmitInfo es)
p Ptr (SubmitInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SUBMIT_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''
    let pWaitSemaphoresLength = Vector Semaphore -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Semaphore -> Int) -> Vector Semaphore -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Semaphore
waitSemaphores)
    lift $ unless ((Data.Vector.length $ (waitDstStageMask)) == pWaitSemaphoresLength) $
      throwIO $ IOError Nothing InvalidArgument "" "pWaitDstStageMask and pWaitSemaphores must have the same length" Nothing Nothing
    lift $ poke ((p `plusPtr` 16 :: Ptr Word32)) ((fromIntegral pWaitSemaphoresLength :: Word32))
    pPWaitSemaphores' <- ContT $ allocaBytes @Semaphore ((Data.Vector.length (waitSemaphores)) * 8)
    lift $ Data.Vector.imapM_ (\Int
i Semaphore
e -> Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPWaitSemaphores' Ptr Semaphore -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (waitSemaphores)
    lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr Semaphore))) (pPWaitSemaphores')
    pPWaitDstStageMask' <- ContT $ allocaBytes @PipelineStageFlags ((Data.Vector.length (waitDstStageMask)) * 4)
    lift $ Data.Vector.imapM_ (\Int
i PipelineStageFlags
e -> Ptr PipelineStageFlags -> PipelineStageFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr PipelineStageFlags
pPWaitDstStageMask' Ptr PipelineStageFlags -> Int -> Ptr PipelineStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PipelineStageFlags) (PipelineStageFlags
e)) (waitDstStageMask)
    lift $ poke ((p `plusPtr` 32 :: Ptr (Ptr PipelineStageFlags))) (pPWaitDstStageMask')
    lift $ poke ((p `plusPtr` 40 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (commandBuffers)) :: Word32))
    pPCommandBuffers' <- ContT $ allocaBytes @(Ptr CommandBuffer_T) ((Data.Vector.length (commandBuffers)) * 8)
    lift $ Data.Vector.imapM_ (\Int
i Ptr CommandBuffer_T
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)) (Ptr CommandBuffer_T
e)) (commandBuffers)
    lift $ poke ((p `plusPtr` 48 :: Ptr (Ptr (Ptr CommandBuffer_T)))) (pPCommandBuffers')
    lift $ poke ((p `plusPtr` 56 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (signalSemaphores)) :: Word32))
    pPSignalSemaphores' <- ContT $ allocaBytes @Semaphore ((Data.Vector.length (signalSemaphores)) * 8)
    lift $ Data.Vector.imapM_ (\Int
i Semaphore
e -> Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPSignalSemaphores' Ptr Semaphore -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (signalSemaphores)
    lift $ poke ((p `plusPtr` 64 :: Ptr (Ptr Semaphore))) (pPSignalSemaphores')
    lift $ f
  cStructSize :: Int
cStructSize = Int
72
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr (SubmitInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (SubmitInfo 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 (SubmitInfo es)
p Ptr (SubmitInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SUBMIT_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 SubmitInfo es
         , PeekChain es ) => FromCStruct (SubmitInfo es) where
  peekCStruct :: Ptr (SubmitInfo es) -> IO (SubmitInfo es)
peekCStruct Ptr (SubmitInfo es)
p = do
    pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (SubmitInfo es)
p Ptr (SubmitInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
    next <- peekChain (castPtr pNext)
    waitSemaphoreCount <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
    pWaitSemaphores <- peek @(Ptr Semaphore) ((p `plusPtr` 24 :: Ptr (Ptr Semaphore)))
    pWaitSemaphores' <- generateM (fromIntegral waitSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pWaitSemaphores Ptr Semaphore -> Int -> Ptr Semaphore
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
    pWaitDstStageMask <- peek @(Ptr PipelineStageFlags) ((p `plusPtr` 32 :: Ptr (Ptr PipelineStageFlags)))
    pWaitDstStageMask' <- generateM (fromIntegral waitSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @PipelineStageFlags ((Ptr PipelineStageFlags
pWaitDstStageMask Ptr PipelineStageFlags -> Int -> Ptr PipelineStageFlags
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
4 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PipelineStageFlags)))
    commandBufferCount <- peek @Word32 ((p `plusPtr` 40 :: Ptr Word32))
    pCommandBuffers <- peek @(Ptr (Ptr CommandBuffer_T)) ((p `plusPtr` 48 :: Ptr (Ptr (Ptr CommandBuffer_T))))
    pCommandBuffers' <- generateM (fromIntegral commandBufferCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @(Ptr CommandBuffer_T) ((Ptr (Ptr CommandBuffer_T)
pCommandBuffers 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))))
    signalSemaphoreCount <- peek @Word32 ((p `plusPtr` 56 :: Ptr Word32))
    pSignalSemaphores <- peek @(Ptr Semaphore) ((p `plusPtr` 64 :: Ptr (Ptr Semaphore)))
    pSignalSemaphores' <- generateM (fromIntegral signalSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pSignalSemaphores Ptr Semaphore -> Int -> Ptr Semaphore
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
    pure $ SubmitInfo
             next
             pWaitSemaphores'
             pWaitDstStageMask'
             pCommandBuffers'
             pSignalSemaphores'

instance es ~ '[] => Zero (SubmitInfo es) where
  zero :: SubmitInfo es
zero = Chain es
-> Vector Semaphore
-> Vector PipelineStageFlags
-> Vector (Ptr CommandBuffer_T)
-> Vector Semaphore
-> SubmitInfo es
forall (es :: [*]).
Chain es
-> Vector Semaphore
-> Vector PipelineStageFlags
-> Vector (Ptr CommandBuffer_T)
-> Vector Semaphore
-> SubmitInfo es
SubmitInfo
           ()
           Vector Semaphore
forall a. Monoid a => a
mempty
           Vector PipelineStageFlags
forall a. Monoid a => a
mempty
           Vector (Ptr CommandBuffer_T)
forall a. Monoid a => a
mempty
           Vector Semaphore
forall a. Monoid a => a
mempty