{-# 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 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 set to 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
  let cmds :: DeviceCmds
cmds = case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds
  let vkGetDeviceQueuePtr :: FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pQueue" ::: Ptr (Ptr Queue_T))
   -> IO ())
vkGetDeviceQueuePtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("queueFamilyIndex" ::: Word32)
      -> ("queueFamilyIndex" ::: Word32)
      -> ("pQueue" ::: Ptr (Ptr Queue_T))
      -> IO ())
pVkGetDeviceQueue DeviceCmds
cmds
  forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pQueue" ::: Ptr (Ptr Queue_T))
   -> IO ())
vkGetDeviceQueuePtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
    forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkGetDeviceQueue is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
  let vkGetDeviceQueue' :: Ptr Device_T
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> ("pQueue" ::: Ptr (Ptr Queue_T))
-> IO ()
vkGetDeviceQueue' = FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pQueue" ::: Ptr (Ptr Queue_T))
   -> IO ())
-> Ptr Device_T
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> ("pQueue" ::: Ptr (Ptr Queue_T))
-> IO ()
mkVkGetDeviceQueue FunPtr
  (Ptr Device_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pQueue" ::: Ptr (Ptr Queue_T))
   -> IO ())
vkGetDeviceQueuePtr
  "pQueue" ::: Ptr (Ptr Queue_T)
pPQueue <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ 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) forall a. Ptr a -> IO ()
free
  forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetDeviceQueue" (Ptr Device_T
-> ("queueFamilyIndex" ::: Word32)
-> ("queueFamilyIndex" ::: Word32)
-> ("pQueue" ::: Ptr (Ptr Queue_T))
-> IO ()
vkGetDeviceQueue'
                                                (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                ("queueFamilyIndex" ::: Word32
queueFamilyIndex)
                                                ("queueFamilyIndex" ::: Word32
queueIndex)
                                                ("pQueue" ::: Ptr (Ptr Queue_T)
pPQueue))
  Ptr Queue_T
pQueue <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @(Ptr Queue_T) "pQueue" ::: Ptr (Ptr Queue_T)
pPQueue
  forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (((\Ptr Queue_T
h -> Ptr Queue_T -> DeviceCmds -> Queue
Queue Ptr Queue_T
h DeviceCmds
cmds ) Ptr Queue_T
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/1.3-extensions/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.
--
-- Fence and semaphore 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/1.3-extensions/html/vkspec.html#synchronization-semaphores semaphore>
-- and
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-fences fence>
-- sections of
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization the synchronization chapter>.
--
-- Details on the interaction of @pWaitDstStageMask@ with synchronization
-- are described in the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-semaphores-waiting semaphore wait operation>
-- section of
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization the synchronization chapter>.
--
-- The order that batches appear in @pSubmits@ is used to determine
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-submission-order submission order>,
-- and thus all the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/html/vkspec.html#synchronization explicit synchronization primitives>,
-- these batches /may/ overlap or otherwise execute out of order.
--
-- If any command buffer submitted to this queue is in the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#commandbuffers-lifecycle executable state>,
-- it is moved to the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/html/vkspec.html#commandbuffers-lifecycle pending state>,
-- back to the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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 semaphore signal operations on which it depends
--     (if any) /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/1.3-extensions/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/1.3-extensions/html/vkspec.html#commandbuffers-lifecycle pending state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00072# Any
--     <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/html/vkspec.html#commandbuffers-lifecycle pending or executable state>
--
-- -   #VUID-vkQueueSubmit-pCommandBuffers-00073# If any
--     <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/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/1.3-extensions/html/vkspec.html#synchronization-queue-transfers-acquire Queue Family Transfer Acquire Operation>,
--     there /must/ exist a previously submitted
--     <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-queue-transfers-release Queue Family 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/1.3-extensions/html/vkspec.html#synchronization-queue-transfers-acquire acquire operations>,
--     and which happens-before 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/1.3-extensions/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 an
--     '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
--
-- -   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> |
-- +============================================================================================================================+========================================================================================================================+=============================================================================================================================+=======================================================================================================================+========================================================================================================================================+
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
--
-- == 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_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'
--
-- = 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.
               ("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/1.3-extensions/html/vkspec.html#synchronization-fences-signaling fence signal operation>.
               Fence
            -> io ()
queueSubmit :: forall (io :: * -> *).
MonadIO io =>
Queue
-> ("submits" ::: Vector (SomeStruct SubmitInfo)) -> Fence -> io ()
queueSubmit Queue
queue "submits" ::: Vector (SomeStruct SubmitInfo)
submits Fence
fence = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
  let vkQueueSubmitPtr :: FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
   -> Fence
   -> IO Result)
vkQueueSubmitPtr = DeviceCmds
-> FunPtr
     (Ptr Queue_T
      -> ("queueFamilyIndex" ::: Word32)
      -> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
      -> Fence
      -> IO Result)
pVkQueueSubmit (case Queue
queue of Queue{DeviceCmds
$sel:deviceCmds:Queue :: Queue -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
   -> Fence
   -> IO Result)
vkQueueSubmitPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
    forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkQueueSubmit is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
  let vkQueueSubmit' :: Ptr Queue_T
-> ("queueFamilyIndex" ::: Word32)
-> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
-> Fence
-> IO Result
vkQueueSubmit' = FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
   -> Fence
   -> IO Result)
-> Ptr Queue_T
-> ("queueFamilyIndex" ::: Word32)
-> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
-> Fence
-> IO Result
mkVkQueueSubmit FunPtr
  (Ptr Queue_T
   -> ("queueFamilyIndex" ::: Word32)
   -> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
   -> Fence
   -> IO Result)
vkQueueSubmitPtr
  Ptr (SubmitInfo Any)
pPSubmits <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(SubmitInfo _) ((forall a. Vector a -> Int
Data.Vector.length ("submits" ::: Vector (SomeStruct SubmitInfo)
submits)) forall a. Num a => a -> a -> a
* Int
72)
  forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i SomeStruct SubmitInfo
e -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (a :: [*] -> *) b.
(forall (es :: [*]).
 (Extendss a es, PokeChain es) =>
 ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (SubmitInfo Any)
pPSubmits forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
72 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (SubmitInfo _))) (SomeStruct SubmitInfo
e) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a b. (a -> b) -> a -> b
$ ())) ("submits" ::: Vector (SomeStruct SubmitInfo)
submits)
  Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkQueueSubmit" (Ptr Queue_T
-> ("queueFamilyIndex" ::: Word32)
-> ("pSubmits" ::: Ptr (SomeStruct SubmitInfo))
-> Fence
-> IO Result
vkQueueSubmit'
                                                  (Queue -> Ptr Queue_T
queueHandle (Queue
queue))
                                                  ((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ ("submits" ::: Vector (SomeStruct SubmitInfo)
submits)) :: Word32))
                                                  (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (SubmitInfo Any)
pPSubmits))
                                                  (Fence
fence))
  forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO 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 :: DeviceCmds
$sel:deviceCmds:Queue :: Queue -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Queue_T -> IO Result)
vkQueueWaitIdlePtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
    forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkQueueWaitIdle is null" forall a. Maybe a
Nothing 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
  Result
r <- forall a. String -> IO a -> IO a
traceAroundEvent String
"vkQueueWaitIdle" (Ptr Queue_T -> IO Result
vkQueueWaitIdle'
                                             (Queue -> Ptr Queue_T
queueHandle (Queue
queue)))
  forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
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/1.3-extensions/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'.
--
-- == 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
--
-- == 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> |
-- +============================================================================================================================+========================================================================================================================+=============================================================================================================================+=======================================================================================================================+========================================================================================================================================+
-- +----------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
--
-- == 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_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'
--
-- = 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 = 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 = 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO 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 :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Device_T -> IO Result)
vkDeviceWaitIdlePtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
    forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkDeviceWaitIdle is null" forall a. Maybe a
Nothing 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
  Result
r <- forall a. String -> IO a -> IO a
traceAroundEvent String
"vkDeviceWaitIdle" (Ptr Device_T -> IO Result
vkDeviceWaitIdle'
                                              (Device -> Ptr Device_T
deviceHandle (Device
device)))
  forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
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@ /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_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'
--
-- = 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 = 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 = 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/1.3-extensions/html/vkspec.html#synchronization-submission-order submission order>,
-- and thus all the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/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/1.3-extensions/html/vkspec.html#synchronization explicit synchronization primitives>,
-- these command buffers /may/ overlap or otherwise execute out of order.
--
-- == 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 the
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-shadingRateImage shadingRateImage>
--     or
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#features-attachmentFragmentShadingRate attachmentFragmentShadingRate>
--     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-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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/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/1.3-extensions/html/vkspec.html#limits-variableSampleLocations variableSampleLocations>
--     limit is not supported, and any element of @pCommandBuffers@
--     contains any
--     <https://registry.khronos.org/vulkan/specs/1.3-extensions/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
--
-- == 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_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 struct 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/1.3-extensions/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/1.3-extensions/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
signalSemaphores :: Vector Semaphore
commandBuffers :: Vector (Ptr CommandBuffer_T)
waitDstStageMask :: Vector PipelineStageFlags
waitSemaphores :: Vector Semaphore
next :: Chain ds
$sel:signalSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:commandBuffers:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
$sel:waitDstStageMask:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
$sel:waitSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:next:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Chain es
..} Chain es
next' = SubmitInfo{$sel:next:SubmitInfo :: Chain es
next = Chain es
next', Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
signalSemaphores :: Vector Semaphore
commandBuffers :: Vector (Ptr CommandBuffer_T)
waitDstStageMask :: Vector PipelineStageFlags
waitSemaphores :: Vector Semaphore
$sel:signalSemaphores:SubmitInfo :: Vector Semaphore
$sel:commandBuffers:SubmitInfo :: Vector (Ptr CommandBuffer_T)
$sel:waitDstStageMask:SubmitInfo :: Vector PipelineStageFlags
$sel:waitSemaphores:SubmitInfo :: Vector Semaphore
..}
  getNext :: forall (es :: [*]). SubmitInfo es -> Chain es
getNext SubmitInfo{Vector (Ptr CommandBuffer_T)
Vector PipelineStageFlags
Vector Semaphore
Chain es
signalSemaphores :: Vector Semaphore
commandBuffers :: Vector (Ptr CommandBuffer_T)
waitDstStageMask :: Vector PipelineStageFlags
waitSemaphores :: Vector Semaphore
next :: Chain es
$sel:signalSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:commandBuffers:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
$sel:waitDstStageMask:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
$sel:waitSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:next:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Chain es
..} = 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 :~: AmigoProfilingSubmitInfoSEC
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @AmigoProfilingSubmitInfoSEC = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: PerformanceQuerySubmitInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @PerformanceQuerySubmitInfoKHR = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: TimelineSemaphoreSubmitInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @TimelineSemaphoreSubmitInfo = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: ProtectedSubmitInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ProtectedSubmitInfo = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: DeviceGroupSubmitInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DeviceGroupSubmitInfo = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: D3D12FenceSubmitInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @D3D12FenceSubmitInfoKHR = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: Win32KeyedMutexAcquireReleaseInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @Win32KeyedMutexAcquireReleaseInfoKHR = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Just e :~: Win32KeyedMutexAcquireReleaseInfoNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @Win32KeyedMutexAcquireReleaseInfoNV = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
    | Bool
otherwise = 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 = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
72 forall a b. (a -> b) -> a -> b
$ \Ptr (SubmitInfo es)
p -> 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
signalSemaphores :: Vector Semaphore
commandBuffers :: Vector (Ptr CommandBuffer_T)
waitDstStageMask :: Vector PipelineStageFlags
waitSemaphores :: Vector Semaphore
next :: Chain es
$sel:signalSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:commandBuffers:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
$sel:waitDstStageMask:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
$sel:waitSemaphores:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Vector Semaphore
$sel:next:SubmitInfo :: forall (es :: [*]). SubmitInfo es -> Chain es
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SUBMIT_INFO)
    Ptr ()
pNext'' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext''
    let pWaitSemaphoresLength :: Int
pWaitSemaphoresLength = forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector Semaphore
waitSemaphores)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector PipelineStageFlags
waitDstStageMask)) forall a. Eq a => a -> a -> Bool
== Int
pWaitSemaphoresLength) forall a b. (a -> b) -> a -> b
$
      forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pWaitDstStageMask and pWaitSemaphores must have the same length" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ((forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pWaitSemaphoresLength :: Word32))
    Ptr Semaphore
pPWaitSemaphores' <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Semaphore ((forall a. Vector a -> Int
Data.Vector.length (Vector Semaphore
waitSemaphores)) forall a. Num a => a -> a -> a
* Int
8)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Semaphore
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPWaitSemaphores' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (Vector Semaphore
waitSemaphores)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Semaphore))) (Ptr Semaphore
pPWaitSemaphores')
    Ptr PipelineStageFlags
pPWaitDstStageMask' <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @PipelineStageFlags ((forall a. Vector a -> Int
Data.Vector.length (Vector PipelineStageFlags
waitDstStageMask)) forall a. Num a => a -> a -> a
* Int
4)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i PipelineStageFlags
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr PipelineStageFlags
pPWaitDstStageMask' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PipelineStageFlags) (PipelineStageFlags
e)) (Vector PipelineStageFlags
waitDstStageMask)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr PipelineStageFlags))) (Ptr PipelineStageFlags
pPWaitDstStageMask')
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr Word32)) ((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector (Ptr CommandBuffer_T)
commandBuffers)) :: Word32))
    Ptr (Ptr CommandBuffer_T)
pPCommandBuffers' <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(Ptr CommandBuffer_T) ((forall a. Vector a -> Int
Data.Vector.length (Vector (Ptr CommandBuffer_T)
commandBuffers)) forall a. Num a => a -> a -> a
* Int
8)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Ptr CommandBuffer_T
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr (Ptr CommandBuffer_T)
pPCommandBuffers' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CommandBuffer_T)) (Ptr CommandBuffer_T
e)) (Vector (Ptr CommandBuffer_T)
commandBuffers)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr (Ptr CommandBuffer_T)))) (Ptr (Ptr CommandBuffer_T)
pPCommandBuffers')
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr Word32)) ((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ (Vector Semaphore
signalSemaphores)) :: Word32))
    Ptr Semaphore
pPSignalSemaphores' <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Semaphore ((forall a. Vector a -> Int
Data.Vector.length (Vector Semaphore
signalSemaphores)) forall a. Num a => a -> a -> a
* Int
8)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Semaphore
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPSignalSemaphores' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (Vector Semaphore
signalSemaphores)
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr (Ptr Semaphore))) (Ptr Semaphore
pPSignalSemaphores')
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
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 = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SUBMIT_INFO)
    Ptr ()
pNext' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext'
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f

instance ( Extendss SubmitInfo es
         , PeekChain es ) => FromCStruct (SubmitInfo es) where
  peekCStruct :: Ptr (SubmitInfo es) -> IO (SubmitInfo es)
peekCStruct Ptr (SubmitInfo es)
p = do
    Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
    Chain es
next <- forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
    "queueFamilyIndex" ::: Word32
waitSemaphoreCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    Ptr Semaphore
pWaitSemaphores <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Semaphore) ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Semaphore)))
    Vector Semaphore
pWaitSemaphores' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral "queueFamilyIndex" ::: Word32
waitSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pWaitSemaphores forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
    Ptr PipelineStageFlags
pWaitDstStageMask <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr PipelineStageFlags) ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr PipelineStageFlags)))
    Vector PipelineStageFlags
pWaitDstStageMask' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral "queueFamilyIndex" ::: Word32
waitSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @PipelineStageFlags ((Ptr PipelineStageFlags
pWaitDstStageMask forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PipelineStageFlags)))
    "queueFamilyIndex" ::: Word32
commandBufferCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr Word32))
    Ptr (Ptr CommandBuffer_T)
pCommandBuffers <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr (Ptr CommandBuffer_T)) ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
48 :: Ptr (Ptr (Ptr CommandBuffer_T))))
    Vector (Ptr CommandBuffer_T)
pCommandBuffers' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral "queueFamilyIndex" ::: Word32
commandBufferCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @(Ptr CommandBuffer_T) ((Ptr (Ptr CommandBuffer_T)
pCommandBuffers forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (Ptr CommandBuffer_T))))
    "queueFamilyIndex" ::: Word32
signalSemaphoreCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
56 :: Ptr Word32))
    Ptr Semaphore
pSignalSemaphores <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Semaphore) ((Ptr (SubmitInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
64 :: Ptr (Ptr Semaphore)))
    Vector Semaphore
pSignalSemaphores' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral "queueFamilyIndex" ::: Word32
signalSemaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pSignalSemaphores forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es
-> Vector Semaphore
-> Vector PipelineStageFlags
-> Vector (Ptr CommandBuffer_T)
-> Vector Semaphore
-> SubmitInfo es
SubmitInfo
             Chain es
next
             Vector Semaphore
pWaitSemaphores'
             Vector PipelineStageFlags
pWaitDstStageMask'
             Vector (Ptr CommandBuffer_T)
pCommandBuffers'
             Vector Semaphore
pSignalSemaphores'

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