{-# language CPP #-}
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_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 ()
getDeviceQueue :: forall io
. (MonadIO io)
=>
Device
->
("queueFamilyIndex" ::: Word32)
->
("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
queueSubmit :: forall io
. (MonadIO io)
=>
Queue
->
("submits" ::: Vector (SomeStruct SubmitInfo))
->
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
queueWaitIdleSafeOrUnsafe :: forall io
. (MonadIO io)
=> (FunPtr (Ptr Queue_T -> IO Result) -> Ptr Queue_T -> IO Result)
->
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))
queueWaitIdle :: forall io
. (MonadIO io)
=>
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
queueWaitIdleSafe :: forall io
. (MonadIO io)
=>
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
deviceWaitIdleSafeOrUnsafe :: forall io
. (MonadIO io)
=> (FunPtr (Ptr Device_T -> IO Result) -> Ptr Device_T -> IO Result)
->
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))
deviceWaitIdle :: forall io
. (MonadIO io)
=>
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
deviceWaitIdleSafe :: forall io
. (MonadIO io)
=>
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
data SubmitInfo (es :: [Type]) = SubmitInfo
{
forall (es :: [*]). SubmitInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]). SubmitInfo es -> Vector Semaphore
waitSemaphores :: Vector Semaphore
,
forall (es :: [*]). SubmitInfo es -> Vector PipelineStageFlags
waitDstStageMask :: Vector PipelineStageFlags
,
forall (es :: [*]). SubmitInfo es -> Vector (Ptr CommandBuffer_T)
commandBuffers :: Vector (Ptr CommandBuffer_T)
,
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 :~: LatencySubmissionPresentIdNV
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @LatencySubmissionPresentIdNV = forall a. a -> Maybe a
Just Extends SubmitInfo e => b
f
| Just e :~: FrameBoundaryEXT
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @FrameBoundaryEXT = forall a. a -> Maybe a
Just 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