{-# language CPP #-}
-- No documentation found for Chapter "Promoted_From_VK_KHR_timeline_semaphore"
module Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore  ( getSemaphoreCounterValue
                                                              , waitSemaphores
                                                              , waitSemaphoresSafe
                                                              , signalSemaphore
                                                              , PhysicalDeviceTimelineSemaphoreFeatures(..)
                                                              , PhysicalDeviceTimelineSemaphoreProperties(..)
                                                              , SemaphoreTypeCreateInfo(..)
                                                              , TimelineSemaphoreSubmitInfo(..)
                                                              , SemaphoreWaitInfo(..)
                                                              , SemaphoreSignalInfo(..)
                                                              , StructureType(..)
                                                              , SemaphoreType(..)
                                                              , SemaphoreWaitFlagBits(..)
                                                              , SemaphoreWaitFlags
                                                              ) where

import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
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 (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import qualified Data.Vector (null)
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.Typeable (Typeable)
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Word (Word64)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkGetSemaphoreCounterValue))
import Vulkan.Dynamic (DeviceCmds(pVkSignalSemaphore))
import Vulkan.Dynamic (DeviceCmds(pVkWaitSemaphores))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Core10.Handles (Semaphore)
import Vulkan.Core10.Handles (Semaphore(..))
import Vulkan.Core12.Enums.SemaphoreType (SemaphoreType)
import Vulkan.Core12.Enums.SemaphoreWaitFlagBits (SemaphoreWaitFlags)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core12.Enums.SemaphoreType (SemaphoreType(..))
import Vulkan.Core12.Enums.SemaphoreWaitFlagBits (SemaphoreWaitFlagBits(..))
import Vulkan.Core12.Enums.SemaphoreWaitFlagBits (SemaphoreWaitFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkGetSemaphoreCounterValue
  :: FunPtr (Ptr Device_T -> Semaphore -> Ptr Word64 -> IO Result) -> Ptr Device_T -> Semaphore -> Ptr Word64 -> IO Result

-- | vkGetSemaphoreCounterValue - Query the current state of a timeline
-- semaphore
--
-- = Description
--
-- Note
--
-- If a
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#devsandqueues-submission queue submission>
-- command is pending execution, then the value returned by this command
-- /may/ immediately be out of date.
--
-- == 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_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Handles.Device', 'Vulkan.Core10.Handles.Semaphore'
getSemaphoreCounterValue :: forall io
                          . (MonadIO io)
                         => -- | @device@ is the logical device that owns the semaphore.
                            --
                            -- #VUID-vkGetSemaphoreCounterValue-device-parameter# @device@ /must/ be a
                            -- valid 'Vulkan.Core10.Handles.Device' handle
                            Device
                         -> -- | @semaphore@ is the handle of the semaphore to query.
                            --
                            -- #VUID-vkGetSemaphoreCounterValue-semaphore-03255# @semaphore@ /must/
                            -- have been created with a
                            -- 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
                            -- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE'
                            --
                            -- #VUID-vkGetSemaphoreCounterValue-semaphore-parameter# @semaphore@ /must/
                            -- be a valid 'Vulkan.Core10.Handles.Semaphore' handle
                            --
                            -- #VUID-vkGetSemaphoreCounterValue-semaphore-parent# @semaphore@ /must/
                            -- have been created, allocated, or retrieved from @device@
                            Semaphore
                         -> io (("value" ::: Word64))
getSemaphoreCounterValue :: forall (io :: * -> *).
MonadIO io =>
Device -> Semaphore -> io ("value" ::: Word64)
getSemaphoreCounterValue Device
device Semaphore
semaphore = IO ("value" ::: Word64) -> io ("value" ::: Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("value" ::: Word64) -> io ("value" ::: Word64))
-> (ContT ("value" ::: Word64) IO ("value" ::: Word64)
    -> IO ("value" ::: Word64))
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
-> io ("value" ::: Word64)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT ("value" ::: Word64) IO ("value" ::: Word64)
-> IO ("value" ::: Word64)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT ("value" ::: Word64) IO ("value" ::: Word64)
 -> io ("value" ::: Word64))
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
-> io ("value" ::: Word64)
forall a b. (a -> b) -> a -> b
$ do
  let vkGetSemaphoreCounterValuePtr :: FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
vkGetSemaphoreCounterValuePtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> Semaphore
      -> ("pValue" ::: Ptr ("value" ::: Word64))
      -> IO Result)
pVkGetSemaphoreCounterValue (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT ("value" ::: Word64) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("value" ::: Word64) IO ())
-> IO () -> ContT ("value" ::: Word64) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
vkGetSemaphoreCounterValuePtr FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> Semaphore
      -> ("pValue" ::: Ptr ("value" ::: Word64))
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkGetSemaphoreCounterValue is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkGetSemaphoreCounterValue' :: Ptr Device_T
-> Semaphore
-> ("pValue" ::: Ptr ("value" ::: Word64))
-> IO Result
vkGetSemaphoreCounterValue' = FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
-> Ptr Device_T
-> Semaphore
-> ("pValue" ::: Ptr ("value" ::: Word64))
-> IO Result
mkVkGetSemaphoreCounterValue FunPtr
  (Ptr Device_T
   -> Semaphore
   -> ("pValue" ::: Ptr ("value" ::: Word64))
   -> IO Result)
vkGetSemaphoreCounterValuePtr
  "pValue" ::: Ptr ("value" ::: Word64)
pPValue <- ((("pValue" ::: Ptr ("value" ::: Word64))
  -> IO ("value" ::: Word64))
 -> IO ("value" ::: Word64))
-> ContT
     ("value" ::: Word64) IO ("pValue" ::: Ptr ("value" ::: Word64))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pValue" ::: Ptr ("value" ::: Word64))
   -> IO ("value" ::: Word64))
  -> IO ("value" ::: Word64))
 -> ContT
      ("value" ::: Word64) IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ((("pValue" ::: Ptr ("value" ::: Word64))
     -> IO ("value" ::: Word64))
    -> IO ("value" ::: Word64))
-> ContT
     ("value" ::: Word64) IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ IO ("pValue" ::: Ptr ("value" ::: Word64))
-> (("pValue" ::: Ptr ("value" ::: Word64)) -> IO ())
-> (("pValue" ::: Ptr ("value" ::: Word64))
    -> IO ("value" ::: Word64))
-> IO ("value" ::: Word64)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @Word64 Int
8) ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result -> ContT ("value" ::: Word64) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT ("value" ::: Word64) IO Result)
-> IO Result -> ContT ("value" ::: Word64) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetSemaphoreCounterValue" (Ptr Device_T
-> Semaphore
-> ("pValue" ::: Ptr ("value" ::: Word64))
-> IO Result
vkGetSemaphoreCounterValue'
                                                               (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                               (Semaphore
semaphore)
                                                               ("pValue" ::: Ptr ("value" ::: Word64)
pPValue))
  IO () -> ContT ("value" ::: Word64) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("value" ::: Word64) IO ())
-> IO () -> ContT ("value" ::: Word64) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  "value" ::: Word64
pValue <- IO ("value" ::: Word64)
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("value" ::: Word64)
 -> ContT ("value" ::: Word64) IO ("value" ::: Word64))
-> IO ("value" ::: Word64)
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @Word64 "pValue" ::: Ptr ("value" ::: Word64)
pPValue
  ("value" ::: Word64)
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("value" ::: Word64)
 -> ContT ("value" ::: Word64) IO ("value" ::: Word64))
-> ("value" ::: Word64)
-> ContT ("value" ::: Word64) IO ("value" ::: Word64)
forall a b. (a -> b) -> a -> b
$ ("value" ::: Word64
pValue)


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

foreign import ccall
  "dynamic" mkVkWaitSemaphoresSafe
  :: FunPtr (Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result) -> Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result

-- | waitSemaphores with selectable safeness
waitSemaphoresSafeOrUnsafe :: forall io
                            . (MonadIO io)
                           => (FunPtr (Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result) -> Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result)
                           -> -- | @device@ is the logical device that owns the semaphores.
                              --
                              -- #VUID-vkWaitSemaphores-device-parameter# @device@ /must/ be a valid
                              -- 'Vulkan.Core10.Handles.Device' handle
                              Device
                           -> -- | @pWaitInfo@ is a pointer to a 'SemaphoreWaitInfo' structure containing
                              -- information about the wait condition.
                              --
                              -- #VUID-vkWaitSemaphores-pWaitInfo-parameter# @pWaitInfo@ /must/ be a
                              -- valid pointer to a valid 'SemaphoreWaitInfo' structure
                              SemaphoreWaitInfo
                           -> -- | @timeout@ is the timeout period in units of nanoseconds. @timeout@ is
                              -- adjusted to the closest value allowed by the implementation-dependent
                              -- timeout accuracy, which /may/ be substantially longer than one
                              -- nanosecond, and /may/ be longer than the requested period.
                              ("timeout" ::: Word64)
                           -> io (Result)
waitSemaphoresSafeOrUnsafe :: forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
 -> Ptr Device_T
 -> Ptr SemaphoreWaitInfo
 -> ("value" ::: Word64)
 -> IO Result)
-> Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
waitSemaphoresSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Ptr Device_T
-> Ptr SemaphoreWaitInfo
-> ("value" ::: Word64)
-> IO Result
mkVkWaitSemaphores Device
device
                                                SemaphoreWaitInfo
waitInfo
                                                "value" ::: Word64
timeout = IO Result -> io Result
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> io Result)
-> (ContT Result IO Result -> IO Result)
-> ContT Result IO Result
-> io Result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Result IO Result -> IO Result
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Result IO Result -> io Result)
-> ContT Result IO Result -> io Result
forall a b. (a -> b) -> a -> b
$ do
  let vkWaitSemaphoresPtr :: FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
vkWaitSemaphoresPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
pVkWaitSemaphores (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT Result IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Result IO ()) -> IO () -> ContT Result IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
vkWaitSemaphoresPtr FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkWaitSemaphores is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkWaitSemaphores' :: Ptr Device_T
-> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result
vkWaitSemaphores' = FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Ptr Device_T
-> Ptr SemaphoreWaitInfo
-> ("value" ::: Word64)
-> IO Result
mkVkWaitSemaphores FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
vkWaitSemaphoresPtr
  Ptr SemaphoreWaitInfo
pWaitInfo <- ((Ptr SemaphoreWaitInfo -> IO Result) -> IO Result)
-> ContT Result IO (Ptr SemaphoreWaitInfo)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr SemaphoreWaitInfo -> IO Result) -> IO Result)
 -> ContT Result IO (Ptr SemaphoreWaitInfo))
-> ((Ptr SemaphoreWaitInfo -> IO Result) -> IO Result)
-> ContT Result IO (Ptr SemaphoreWaitInfo)
forall a b. (a -> b) -> a -> b
$ SemaphoreWaitInfo
-> (Ptr SemaphoreWaitInfo -> IO Result) -> IO Result
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (SemaphoreWaitInfo
waitInfo)
  Result
r <- IO Result -> ContT Result IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Result IO Result)
-> IO Result -> ContT Result IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkWaitSemaphores" (Ptr Device_T
-> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result
vkWaitSemaphores'
                                                     (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                     Ptr SemaphoreWaitInfo
pWaitInfo
                                                     ("value" ::: Word64
timeout))
  IO () -> ContT Result IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Result IO ()) -> IO () -> ContT Result IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Result -> ContT Result IO Result
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Result -> ContT Result IO Result)
-> Result -> ContT Result IO Result
forall a b. (a -> b) -> a -> b
$ (Result
r)

-- | vkWaitSemaphores - Wait for timeline semaphores on the host
--
-- = Description
--
-- If the condition is satisfied when 'waitSemaphores' is called, then
-- 'waitSemaphores' returns immediately. If the condition is not satisfied
-- at the time 'waitSemaphores' is called, then 'waitSemaphores' will block
-- and wait until the condition is satisfied or the @timeout@ has expired,
-- whichever is sooner.
--
-- If @timeout@ is zero, then 'waitSemaphores' does not wait, but simply
-- returns information about the current state of the semaphores.
-- 'Vulkan.Core10.Enums.Result.TIMEOUT' will be returned in this case if
-- the condition is not satisfied, even though no actual wait was
-- performed.
--
-- If the condition is satisfied before the @timeout@ has expired,
-- 'waitSemaphores' returns 'Vulkan.Core10.Enums.Result.SUCCESS'.
-- Otherwise, 'waitSemaphores' returns 'Vulkan.Core10.Enums.Result.TIMEOUT'
-- after the @timeout@ has expired.
--
-- If device loss occurs (see
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#devsandqueues-lost-device Lost Device>)
-- before the timeout has expired, 'waitSemaphores' /must/ return in finite
-- time with either 'Vulkan.Core10.Enums.Result.SUCCESS' or
-- 'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'.
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
--     -   'Vulkan.Core10.Enums.Result.TIMEOUT'
--
-- [<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_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Handles.Device', 'SemaphoreWaitInfo'
waitSemaphores :: forall io
                . (MonadIO io)
               => -- | @device@ is the logical device that owns the semaphores.
                  --
                  -- #VUID-vkWaitSemaphores-device-parameter# @device@ /must/ be a valid
                  -- 'Vulkan.Core10.Handles.Device' handle
                  Device
               -> -- | @pWaitInfo@ is a pointer to a 'SemaphoreWaitInfo' structure containing
                  -- information about the wait condition.
                  --
                  -- #VUID-vkWaitSemaphores-pWaitInfo-parameter# @pWaitInfo@ /must/ be a
                  -- valid pointer to a valid 'SemaphoreWaitInfo' structure
                  SemaphoreWaitInfo
               -> -- | @timeout@ is the timeout period in units of nanoseconds. @timeout@ is
                  -- adjusted to the closest value allowed by the implementation-dependent
                  -- timeout accuracy, which /may/ be substantially longer than one
                  -- nanosecond, and /may/ be longer than the requested period.
                  ("timeout" ::: Word64)
               -> io (Result)
waitSemaphores :: forall (io :: * -> *).
MonadIO io =>
Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
waitSemaphores = (FunPtr
   (Ptr Device_T
    -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
 -> Ptr Device_T
 -> Ptr SemaphoreWaitInfo
 -> ("value" ::: Word64)
 -> IO Result)
-> Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
 -> Ptr Device_T
 -> Ptr SemaphoreWaitInfo
 -> ("value" ::: Word64)
 -> IO Result)
-> Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
waitSemaphoresSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Ptr Device_T
-> Ptr SemaphoreWaitInfo
-> ("value" ::: Word64)
-> IO Result
mkVkWaitSemaphoresUnsafe

-- | A variant of 'waitSemaphores' which makes a *safe* FFI call
waitSemaphoresSafe :: forall io
                    . (MonadIO io)
                   => -- | @device@ is the logical device that owns the semaphores.
                      --
                      -- #VUID-vkWaitSemaphores-device-parameter# @device@ /must/ be a valid
                      -- 'Vulkan.Core10.Handles.Device' handle
                      Device
                   -> -- | @pWaitInfo@ is a pointer to a 'SemaphoreWaitInfo' structure containing
                      -- information about the wait condition.
                      --
                      -- #VUID-vkWaitSemaphores-pWaitInfo-parameter# @pWaitInfo@ /must/ be a
                      -- valid pointer to a valid 'SemaphoreWaitInfo' structure
                      SemaphoreWaitInfo
                   -> -- | @timeout@ is the timeout period in units of nanoseconds. @timeout@ is
                      -- adjusted to the closest value allowed by the implementation-dependent
                      -- timeout accuracy, which /may/ be substantially longer than one
                      -- nanosecond, and /may/ be longer than the requested period.
                      ("timeout" ::: Word64)
                   -> io (Result)
waitSemaphoresSafe :: forall (io :: * -> *).
MonadIO io =>
Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
waitSemaphoresSafe = (FunPtr
   (Ptr Device_T
    -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
 -> Ptr Device_T
 -> Ptr SemaphoreWaitInfo
 -> ("value" ::: Word64)
 -> IO Result)
-> Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
 -> Ptr Device_T
 -> Ptr SemaphoreWaitInfo
 -> ("value" ::: Word64)
 -> IO Result)
-> Device -> SemaphoreWaitInfo -> ("value" ::: Word64) -> io Result
waitSemaphoresSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Ptr Device_T
-> Ptr SemaphoreWaitInfo
-> ("value" ::: Word64)
-> IO Result
mkVkWaitSemaphoresSafe


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

-- | vkSignalSemaphore - Signal a timeline semaphore on the host
--
-- = Description
--
-- When 'signalSemaphore' is executed on the host, it defines and
-- immediately executes a
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-semaphores-signaling semaphore signal operation>
-- which sets the timeline semaphore to the given value.
--
-- The first synchronization scope is defined by the host execution model,
-- but includes execution of 'signalSemaphore' on the host and anything
-- that happened-before it.
--
-- The second synchronization scope is empty.
--
-- == 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'
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Handles.Device', 'SemaphoreSignalInfo'
signalSemaphore :: forall io
                 . (MonadIO io)
                => -- | @device@ is the logical device that owns the semaphore.
                   --
                   -- #VUID-vkSignalSemaphore-device-parameter# @device@ /must/ be a valid
                   -- 'Vulkan.Core10.Handles.Device' handle
                   Device
                -> -- | @pSignalInfo@ is a pointer to a 'SemaphoreSignalInfo' structure
                   -- containing information about the signal operation.
                   --
                   -- #VUID-vkSignalSemaphore-pSignalInfo-parameter# @pSignalInfo@ /must/ be a
                   -- valid pointer to a valid 'SemaphoreSignalInfo' structure
                   SemaphoreSignalInfo
                -> io ()
signalSemaphore :: forall (io :: * -> *).
MonadIO io =>
Device -> SemaphoreSignalInfo -> io ()
signalSemaphore Device
device SemaphoreSignalInfo
signalInfo = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ())
-> (ContT () IO () -> IO ()) -> ContT () IO () -> io ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> io ()) -> ContT () IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
  let vkSignalSemaphorePtr :: FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
vkSignalSemaphorePtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
pVkSignalSemaphore (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
vkSignalSemaphorePtr FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkSignalSemaphore is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkSignalSemaphore' :: Ptr Device_T
-> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result
vkSignalSemaphore' = FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
-> Ptr Device_T
-> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> IO Result
mkVkSignalSemaphore FunPtr
  (Ptr Device_T
   -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result)
vkSignalSemaphorePtr
  "pSignalInfo" ::: Ptr SemaphoreSignalInfo
pSignalInfo <- ((("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO ()) -> IO ())
-> ContT () IO ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO ()) -> IO ())
 -> ContT () IO ("pSignalInfo" ::: Ptr SemaphoreSignalInfo))
-> ((("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO ())
    -> IO ())
-> ContT () IO ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
forall a b. (a -> b) -> a -> b
$ SemaphoreSignalInfo
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (SemaphoreSignalInfo
signalInfo)
  Result
r <- IO Result -> ContT () IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT () IO Result)
-> IO Result -> ContT () IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkSignalSemaphore" (Ptr Device_T
-> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO Result
vkSignalSemaphore'
                                                      (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                      "pSignalInfo" ::: Ptr SemaphoreSignalInfo
pSignalInfo)
  IO () -> ContT () IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))


-- | VkPhysicalDeviceTimelineSemaphoreFeatures - Structure describing
-- timeline semaphore features that can be supported by an implementation
--
-- = Members
--
-- This structure describes the following feature:
--
-- = Description
--
-- If the 'PhysicalDeviceTimelineSemaphoreFeatures' structure is included
-- in the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceFeatures2',
-- it is filled in to indicate whether each corresponding feature is
-- supported. 'PhysicalDeviceTimelineSemaphoreFeatures' /can/ also be used
-- in the @pNext@ chain of 'Vulkan.Core10.Device.DeviceCreateInfo' to
-- selectively enable these features.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceTimelineSemaphoreFeatures = PhysicalDeviceTimelineSemaphoreFeatures
  { -- | #extension-features-timelineSemaphore# @timelineSemaphore@ indicates
    -- whether semaphores created with a
    -- 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
    -- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE' are
    -- supported.
    PhysicalDeviceTimelineSemaphoreFeatures -> Bool
timelineSemaphore :: Bool }
  deriving (Typeable, PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> Bool
(PhysicalDeviceTimelineSemaphoreFeatures
 -> PhysicalDeviceTimelineSemaphoreFeatures -> Bool)
-> (PhysicalDeviceTimelineSemaphoreFeatures
    -> PhysicalDeviceTimelineSemaphoreFeatures -> Bool)
-> Eq PhysicalDeviceTimelineSemaphoreFeatures
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> Bool
$c/= :: PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> Bool
== :: PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> Bool
$c== :: PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceTimelineSemaphoreFeatures)
#endif
deriving instance Show PhysicalDeviceTimelineSemaphoreFeatures

instance ToCStruct PhysicalDeviceTimelineSemaphoreFeatures where
  withCStruct :: forall b.
PhysicalDeviceTimelineSemaphoreFeatures
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b
withCStruct PhysicalDeviceTimelineSemaphoreFeatures
x Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b
f = Int
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b)
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDeviceTimelineSemaphoreFeatures
p -> Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceTimelineSemaphoreFeatures
p PhysicalDeviceTimelineSemaphoreFeatures
x (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b
f Ptr PhysicalDeviceTimelineSemaphoreFeatures
p)
  pokeCStruct :: forall b.
Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceTimelineSemaphoreFeatures
p PhysicalDeviceTimelineSemaphoreFeatures{Bool
timelineSemaphore :: Bool
$sel:timelineSemaphore:PhysicalDeviceTimelineSemaphoreFeatures :: PhysicalDeviceTimelineSemaphoreFeatures -> Bool
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
timelineSemaphore))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b.
Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDeviceTimelineSemaphoreFeatures
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct PhysicalDeviceTimelineSemaphoreFeatures where
  peekCStruct :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> IO PhysicalDeviceTimelineSemaphoreFeatures
peekCStruct Ptr PhysicalDeviceTimelineSemaphoreFeatures
p = do
    Bool32
timelineSemaphore <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDeviceTimelineSemaphoreFeatures
p Ptr PhysicalDeviceTimelineSemaphoreFeatures -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    PhysicalDeviceTimelineSemaphoreFeatures
-> IO PhysicalDeviceTimelineSemaphoreFeatures
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDeviceTimelineSemaphoreFeatures
 -> IO PhysicalDeviceTimelineSemaphoreFeatures)
-> PhysicalDeviceTimelineSemaphoreFeatures
-> IO PhysicalDeviceTimelineSemaphoreFeatures
forall a b. (a -> b) -> a -> b
$ Bool -> PhysicalDeviceTimelineSemaphoreFeatures
PhysicalDeviceTimelineSemaphoreFeatures
             (Bool32 -> Bool
bool32ToBool Bool32
timelineSemaphore)

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

instance Zero PhysicalDeviceTimelineSemaphoreFeatures where
  zero :: PhysicalDeviceTimelineSemaphoreFeatures
zero = Bool -> PhysicalDeviceTimelineSemaphoreFeatures
PhysicalDeviceTimelineSemaphoreFeatures
           Bool
forall a. Zero a => a
zero


-- | VkPhysicalDeviceTimelineSemaphoreProperties - Structure describing
-- timeline semaphore properties that can be supported by an implementation
--
-- = Description
--
-- If the 'PhysicalDeviceTimelineSemaphoreProperties' structure is included
-- in the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceProperties2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceProperties2',
-- it is filled in with each corresponding implementation-dependent
-- property.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceTimelineSemaphoreProperties = PhysicalDeviceTimelineSemaphoreProperties
  { -- | #extension-limits-maxTimelineSemaphoreValueDifference#
    -- @maxTimelineSemaphoreValueDifference@ indicates the maximum difference
    -- allowed by the implementation between the current value of a timeline
    -- semaphore and any pending signal or wait operations.
    PhysicalDeviceTimelineSemaphoreProperties -> "value" ::: Word64
maxTimelineSemaphoreValueDifference :: Word64 }
  deriving (Typeable, PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> Bool
(PhysicalDeviceTimelineSemaphoreProperties
 -> PhysicalDeviceTimelineSemaphoreProperties -> Bool)
-> (PhysicalDeviceTimelineSemaphoreProperties
    -> PhysicalDeviceTimelineSemaphoreProperties -> Bool)
-> Eq PhysicalDeviceTimelineSemaphoreProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> Bool
$c/= :: PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> Bool
== :: PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> Bool
$c== :: PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceTimelineSemaphoreProperties)
#endif
deriving instance Show PhysicalDeviceTimelineSemaphoreProperties

instance ToCStruct PhysicalDeviceTimelineSemaphoreProperties where
  withCStruct :: forall b.
PhysicalDeviceTimelineSemaphoreProperties
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b
withCStruct PhysicalDeviceTimelineSemaphoreProperties
x Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b
f = Int
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b)
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDeviceTimelineSemaphoreProperties
p -> Ptr PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceTimelineSemaphoreProperties
p PhysicalDeviceTimelineSemaphoreProperties
x (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b
f Ptr PhysicalDeviceTimelineSemaphoreProperties
p)
  pokeCStruct :: forall b.
Ptr PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceTimelineSemaphoreProperties
p PhysicalDeviceTimelineSemaphoreProperties{"value" ::: Word64
maxTimelineSemaphoreValueDifference :: "value" ::: Word64
$sel:maxTimelineSemaphoreValueDifference:PhysicalDeviceTimelineSemaphoreProperties :: PhysicalDeviceTimelineSemaphoreProperties -> "value" ::: Word64
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64)) ("value" ::: Word64
maxTimelineSemaphoreValueDifference)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b.
Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDeviceTimelineSemaphoreProperties
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64)) ("value" ::: Word64
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct PhysicalDeviceTimelineSemaphoreProperties where
  peekCStruct :: Ptr PhysicalDeviceTimelineSemaphoreProperties
-> IO PhysicalDeviceTimelineSemaphoreProperties
peekCStruct Ptr PhysicalDeviceTimelineSemaphoreProperties
p = do
    "value" ::: Word64
maxTimelineSemaphoreValueDifference <- forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr PhysicalDeviceTimelineSemaphoreProperties
p Ptr PhysicalDeviceTimelineSemaphoreProperties
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64))
    PhysicalDeviceTimelineSemaphoreProperties
-> IO PhysicalDeviceTimelineSemaphoreProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDeviceTimelineSemaphoreProperties
 -> IO PhysicalDeviceTimelineSemaphoreProperties)
-> PhysicalDeviceTimelineSemaphoreProperties
-> IO PhysicalDeviceTimelineSemaphoreProperties
forall a b. (a -> b) -> a -> b
$ ("value" ::: Word64) -> PhysicalDeviceTimelineSemaphoreProperties
PhysicalDeviceTimelineSemaphoreProperties
             "value" ::: Word64
maxTimelineSemaphoreValueDifference

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

instance Zero PhysicalDeviceTimelineSemaphoreProperties where
  zero :: PhysicalDeviceTimelineSemaphoreProperties
zero = ("value" ::: Word64) -> PhysicalDeviceTimelineSemaphoreProperties
PhysicalDeviceTimelineSemaphoreProperties
           "value" ::: Word64
forall a. Zero a => a
zero


-- | VkSemaphoreTypeCreateInfo - Structure specifying the type of a newly
-- created semaphore
--
-- = Description
--
-- To create a semaphore of a specific type, add a
-- 'SemaphoreTypeCreateInfo' structure to the
-- 'Vulkan.Core10.QueueSemaphore.SemaphoreCreateInfo'::@pNext@ chain.
--
-- If no 'SemaphoreTypeCreateInfo' structure is included in the @pNext@
-- chain of 'Vulkan.Core10.QueueSemaphore.SemaphoreCreateInfo', then the
-- created semaphore will have a default
-- 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
-- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_BINARY'.
--
-- == Valid Usage
--
-- -   #VUID-VkSemaphoreTypeCreateInfo-timelineSemaphore-03252# If the
--     <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#features-timelineSemaphore timelineSemaphore>
--     feature is not enabled, @semaphoreType@ /must/ not equal
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE'
--
-- -   #VUID-VkSemaphoreTypeCreateInfo-semaphoreType-03279# If
--     @semaphoreType@ is
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_BINARY',
--     @initialValue@ /must/ be zero
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkSemaphoreTypeCreateInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO'
--
-- -   #VUID-VkSemaphoreTypeCreateInfo-semaphoreType-parameter#
--     @semaphoreType@ /must/ be a valid
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' value
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data SemaphoreTypeCreateInfo = SemaphoreTypeCreateInfo
  { -- | @semaphoreType@ is a 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType'
    -- value specifying the type of the semaphore.
    SemaphoreTypeCreateInfo -> SemaphoreType
semaphoreType :: SemaphoreType
  , -- | @initialValue@ is the initial payload value if @semaphoreType@ is
    -- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE'.
    SemaphoreTypeCreateInfo -> "value" ::: Word64
initialValue :: Word64
  }
  deriving (Typeable, SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool
(SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool)
-> (SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool)
-> Eq SemaphoreTypeCreateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool
$c/= :: SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool
== :: SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool
$c== :: SemaphoreTypeCreateInfo -> SemaphoreTypeCreateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SemaphoreTypeCreateInfo)
#endif
deriving instance Show SemaphoreTypeCreateInfo

instance ToCStruct SemaphoreTypeCreateInfo where
  withCStruct :: forall b.
SemaphoreTypeCreateInfo
-> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
withCStruct SemaphoreTypeCreateInfo
x Ptr SemaphoreTypeCreateInfo -> IO b
f = Int -> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b)
-> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SemaphoreTypeCreateInfo
p -> Ptr SemaphoreTypeCreateInfo
-> SemaphoreTypeCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SemaphoreTypeCreateInfo
p SemaphoreTypeCreateInfo
x (Ptr SemaphoreTypeCreateInfo -> IO b
f Ptr SemaphoreTypeCreateInfo
p)
  pokeCStruct :: forall b.
Ptr SemaphoreTypeCreateInfo
-> SemaphoreTypeCreateInfo -> IO b -> IO b
pokeCStruct Ptr SemaphoreTypeCreateInfo
p SemaphoreTypeCreateInfo{"value" ::: Word64
SemaphoreType
initialValue :: "value" ::: Word64
semaphoreType :: SemaphoreType
$sel:initialValue:SemaphoreTypeCreateInfo :: SemaphoreTypeCreateInfo -> "value" ::: Word64
$sel:semaphoreType:SemaphoreTypeCreateInfo :: SemaphoreTypeCreateInfo -> SemaphoreType
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr SemaphoreType -> SemaphoreType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr SemaphoreType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SemaphoreType)) (SemaphoreType
semaphoreType)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) ("value" ::: Word64
initialValue)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr SemaphoreTypeCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr SemaphoreTypeCreateInfo
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr SemaphoreType -> SemaphoreType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr SemaphoreType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SemaphoreType)) (SemaphoreType
forall a. Zero a => a
zero)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) ("value" ::: Word64
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct SemaphoreTypeCreateInfo where
  peekCStruct :: Ptr SemaphoreTypeCreateInfo -> IO SemaphoreTypeCreateInfo
peekCStruct Ptr SemaphoreTypeCreateInfo
p = do
    SemaphoreType
semaphoreType <- forall a. Storable a => Ptr a -> IO a
peek @SemaphoreType ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo -> Int -> Ptr SemaphoreType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SemaphoreType))
    "value" ::: Word64
initialValue <- forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr SemaphoreTypeCreateInfo
p Ptr SemaphoreTypeCreateInfo
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64))
    SemaphoreTypeCreateInfo -> IO SemaphoreTypeCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SemaphoreTypeCreateInfo -> IO SemaphoreTypeCreateInfo)
-> SemaphoreTypeCreateInfo -> IO SemaphoreTypeCreateInfo
forall a b. (a -> b) -> a -> b
$ SemaphoreType -> ("value" ::: Word64) -> SemaphoreTypeCreateInfo
SemaphoreTypeCreateInfo
             SemaphoreType
semaphoreType "value" ::: Word64
initialValue

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

instance Zero SemaphoreTypeCreateInfo where
  zero :: SemaphoreTypeCreateInfo
zero = SemaphoreType -> ("value" ::: Word64) -> SemaphoreTypeCreateInfo
SemaphoreTypeCreateInfo
           SemaphoreType
forall a. Zero a => a
zero
           "value" ::: Word64
forall a. Zero a => a
zero


-- | VkTimelineSemaphoreSubmitInfo - Structure specifying signal and wait
-- values for timeline semaphores
--
-- = Description
--
-- If the semaphore in 'Vulkan.Core10.Queue.SubmitInfo'::@pWaitSemaphores@
-- or 'Vulkan.Core10.Queue.SubmitInfo'::@pSignalSemaphores@ corresponding
-- to an entry in @pWaitSemaphoreValues@ or @pSignalSemaphoreValues@
-- respectively was not created with a
-- 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
-- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE', the
-- implementation /must/ ignore the value in the @pWaitSemaphoreValues@ or
-- @pSignalSemaphoreValues@ entry.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkTimelineSemaphoreSubmitInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO'
--
-- -   #VUID-VkTimelineSemaphoreSubmitInfo-pWaitSemaphoreValues-parameter#
--     If @waitSemaphoreValueCount@ is not @0@, and @pWaitSemaphoreValues@
--     is not @NULL@, @pWaitSemaphoreValues@ /must/ be a valid pointer to
--     an array of @waitSemaphoreValueCount@ @uint64_t@ values
--
-- -   #VUID-VkTimelineSemaphoreSubmitInfo-pSignalSemaphoreValues-parameter#
--     If @signalSemaphoreValueCount@ is not @0@, and
--     @pSignalSemaphoreValues@ is not @NULL@, @pSignalSemaphoreValues@
--     /must/ be a valid pointer to an array of @signalSemaphoreValueCount@
--     @uint64_t@ values
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data TimelineSemaphoreSubmitInfo = TimelineSemaphoreSubmitInfo
  { -- | @waitSemaphoreValueCount@ is the number of semaphore wait values
    -- specified in @pWaitSemaphoreValues@.
    TimelineSemaphoreSubmitInfo -> Word32
waitSemaphoreValueCount :: Word32
  , -- | @pWaitSemaphoreValues@ is a pointer to an array of
    -- @waitSemaphoreValueCount@ values for the corresponding semaphores in
    -- 'Vulkan.Core10.Queue.SubmitInfo'::@pWaitSemaphores@ to wait for.
    TimelineSemaphoreSubmitInfo -> Vector ("value" ::: Word64)
waitSemaphoreValues :: Vector Word64
  , -- | @signalSemaphoreValueCount@ is the number of semaphore signal values
    -- specified in @pSignalSemaphoreValues@.
    TimelineSemaphoreSubmitInfo -> Word32
signalSemaphoreValueCount :: Word32
  , -- | @pSignalSemaphoreValues@ is a pointer to an array
    -- @signalSemaphoreValueCount@ values for the corresponding semaphores in
    -- 'Vulkan.Core10.Queue.SubmitInfo'::@pSignalSemaphores@ to set when
    -- signaled.
    TimelineSemaphoreSubmitInfo -> Vector ("value" ::: Word64)
signalSemaphoreValues :: Vector Word64
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (TimelineSemaphoreSubmitInfo)
#endif
deriving instance Show TimelineSemaphoreSubmitInfo

instance ToCStruct TimelineSemaphoreSubmitInfo where
  withCStruct :: forall b.
TimelineSemaphoreSubmitInfo
-> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
withCStruct TimelineSemaphoreSubmitInfo
x Ptr TimelineSemaphoreSubmitInfo -> IO b
f = Int -> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 ((Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b)
-> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr TimelineSemaphoreSubmitInfo
p -> Ptr TimelineSemaphoreSubmitInfo
-> TimelineSemaphoreSubmitInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr TimelineSemaphoreSubmitInfo
p TimelineSemaphoreSubmitInfo
x (Ptr TimelineSemaphoreSubmitInfo -> IO b
f Ptr TimelineSemaphoreSubmitInfo
p)
  pokeCStruct :: forall b.
Ptr TimelineSemaphoreSubmitInfo
-> TimelineSemaphoreSubmitInfo -> IO b -> IO b
pokeCStruct Ptr TimelineSemaphoreSubmitInfo
p TimelineSemaphoreSubmitInfo{Word32
Vector ("value" ::: Word64)
signalSemaphoreValues :: Vector ("value" ::: Word64)
signalSemaphoreValueCount :: Word32
waitSemaphoreValues :: Vector ("value" ::: Word64)
waitSemaphoreValueCount :: Word32
$sel:signalSemaphoreValues:TimelineSemaphoreSubmitInfo :: TimelineSemaphoreSubmitInfo -> Vector ("value" ::: Word64)
$sel:signalSemaphoreValueCount:TimelineSemaphoreSubmitInfo :: TimelineSemaphoreSubmitInfo -> Word32
$sel:waitSemaphoreValues:TimelineSemaphoreSubmitInfo :: TimelineSemaphoreSubmitInfo -> Vector ("value" ::: Word64)
$sel:waitSemaphoreValueCount:TimelineSemaphoreSubmitInfo :: TimelineSemaphoreSubmitInfo -> Word32
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    let pWaitSemaphoreValuesLength :: Int
pWaitSemaphoreValuesLength = Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64) -> Int)
-> Vector ("value" ::: Word64) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("value" ::: Word64)
waitSemaphoreValues)
    Word32
waitSemaphoreValueCount'' <- IO Word32 -> ContT b IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32 -> ContT b IO Word32) -> IO Word32 -> ContT b IO Word32
forall a b. (a -> b) -> a -> b
$ if (Word32
waitSemaphoreValueCount) Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== Word32
0
      then Word32 -> IO Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32 -> IO Word32) -> Word32 -> IO Word32
forall a b. (a -> b) -> a -> b
$ Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pWaitSemaphoreValuesLength
      else do
        Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pWaitSemaphoreValuesLength Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== (Word32
waitSemaphoreValueCount) Bool -> Bool -> Bool
|| Int
pWaitSemaphoreValuesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
          IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pWaitSemaphoreValues must be empty or have 'waitSemaphoreValueCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
        Word32 -> IO Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32
waitSemaphoreValueCount)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) (Word32
waitSemaphoreValueCount'')
    "pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues'' <- if Vector ("value" ::: Word64) -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector ("value" ::: Word64)
waitSemaphoreValues)
      then ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a
nullPtr
      else do
        "pValue" ::: Ptr ("value" ::: Word64)
pPWaitSemaphoreValues <- ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
 -> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Word64 (((Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64)
waitSemaphoreValues))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
        IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("value" ::: Word64) -> IO ())
-> Vector ("value" ::: Word64) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "value" ::: Word64
e -> ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pValue" ::: Ptr ("value" ::: Word64)
pPWaitSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) ("value" ::: Word64
e)) ((Vector ("value" ::: Word64)
waitSemaphoreValues))
        ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("pValue" ::: Ptr ("value" ::: Word64))
 -> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ "pValue" ::: Ptr ("value" ::: Word64)
pPWaitSemaphoreValues
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word64))) "pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues''
    let pSignalSemaphoreValuesLength :: Int
pSignalSemaphoreValuesLength = Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64) -> Int)
-> Vector ("value" ::: Word64) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("value" ::: Word64)
signalSemaphoreValues)
    Word32
signalSemaphoreValueCount'' <- IO Word32 -> ContT b IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32 -> ContT b IO Word32) -> IO Word32 -> ContT b IO Word32
forall a b. (a -> b) -> a -> b
$ if (Word32
signalSemaphoreValueCount) Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== Word32
0
      then Word32 -> IO Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32 -> IO Word32) -> Word32 -> IO Word32
forall a b. (a -> b) -> a -> b
$ Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pSignalSemaphoreValuesLength
      else do
        Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pSignalSemaphoreValuesLength Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== (Word32
signalSemaphoreValueCount) Bool -> Bool -> Bool
|| Int
pSignalSemaphoreValuesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
          IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pSignalSemaphoreValues must be empty or have 'signalSemaphoreValueCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
        Word32 -> IO Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32
signalSemaphoreValueCount)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32)) (Word32
signalSemaphoreValueCount'')
    "pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues'' <- if Vector ("value" ::: Word64) -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector ("value" ::: Word64)
signalSemaphoreValues)
      then ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a
nullPtr
      else do
        "pValue" ::: Ptr ("value" ::: Word64)
pPSignalSemaphoreValues <- ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
 -> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Word64 (((Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64)
signalSemaphoreValues))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
        IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("value" ::: Word64) -> IO ())
-> Vector ("value" ::: Word64) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "value" ::: Word64
e -> ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pValue" ::: Ptr ("value" ::: Word64)
pPSignalSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) ("value" ::: Word64
e)) ((Vector ("value" ::: Word64)
signalSemaphoreValues))
        ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("pValue" ::: Ptr ("value" ::: Word64))
 -> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ("pValue" ::: Ptr ("value" ::: Word64))
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ "pValue" ::: Ptr ("value" ::: Word64)
pPSignalSemaphoreValues
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Word64))) "pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues''
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = Int
48
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr TimelineSemaphoreSubmitInfo -> IO b -> IO b
pokeZeroCStruct Ptr TimelineSemaphoreSubmitInfo
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO b
f

instance FromCStruct TimelineSemaphoreSubmitInfo where
  peekCStruct :: Ptr TimelineSemaphoreSubmitInfo -> IO TimelineSemaphoreSubmitInfo
peekCStruct Ptr TimelineSemaphoreSubmitInfo
p = do
    Word32
waitSemaphoreValueCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    "pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word64) ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word64)))
    let pWaitSemaphoreValuesLength :: Int
pWaitSemaphoreValuesLength = if "pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> ("pValue" ::: Ptr ("value" ::: Word64)) -> Bool
forall a. Eq a => a -> a -> Bool
== "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a
nullPtr then Int
0 else (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
waitSemaphoreValueCount)
    Vector ("value" ::: Word64)
pWaitSemaphoreValues' <- Int
-> (Int -> IO ("value" ::: Word64))
-> IO (Vector ("value" ::: Word64))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pWaitSemaphoreValuesLength (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 (("pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
    Word32
signalSemaphoreValueCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32))
    "pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word64) ((Ptr TimelineSemaphoreSubmitInfo
p Ptr TimelineSemaphoreSubmitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Word64)))
    let pSignalSemaphoreValuesLength :: Int
pSignalSemaphoreValuesLength = if "pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> ("pValue" ::: Ptr ("value" ::: Word64)) -> Bool
forall a. Eq a => a -> a -> Bool
== "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a
nullPtr then Int
0 else (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
signalSemaphoreValueCount)
    Vector ("value" ::: Word64)
pSignalSemaphoreValues' <- Int
-> (Int -> IO ("value" ::: Word64))
-> IO (Vector ("value" ::: Word64))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pSignalSemaphoreValuesLength (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 (("pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
    TimelineSemaphoreSubmitInfo -> IO TimelineSemaphoreSubmitInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TimelineSemaphoreSubmitInfo -> IO TimelineSemaphoreSubmitInfo)
-> TimelineSemaphoreSubmitInfo -> IO TimelineSemaphoreSubmitInfo
forall a b. (a -> b) -> a -> b
$ Word32
-> Vector ("value" ::: Word64)
-> Word32
-> Vector ("value" ::: Word64)
-> TimelineSemaphoreSubmitInfo
TimelineSemaphoreSubmitInfo
             Word32
waitSemaphoreValueCount
             Vector ("value" ::: Word64)
pWaitSemaphoreValues'
             Word32
signalSemaphoreValueCount
             Vector ("value" ::: Word64)
pSignalSemaphoreValues'

instance Zero TimelineSemaphoreSubmitInfo where
  zero :: TimelineSemaphoreSubmitInfo
zero = Word32
-> Vector ("value" ::: Word64)
-> Word32
-> Vector ("value" ::: Word64)
-> TimelineSemaphoreSubmitInfo
TimelineSemaphoreSubmitInfo
           Word32
forall a. Zero a => a
zero
           Vector ("value" ::: Word64)
forall a. Monoid a => a
mempty
           Word32
forall a. Zero a => a
zero
           Vector ("value" ::: Word64)
forall a. Monoid a => a
mempty


-- | VkSemaphoreWaitInfo - Structure containing information about the
-- semaphore wait condition
--
-- == Valid Usage
--
-- -   #VUID-VkSemaphoreWaitInfo-pSemaphores-03256# All of the elements of
--     @pSemaphores@ /must/ reference a semaphore that was created with a
--     'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
--     'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE'
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkSemaphoreWaitInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO'
--
-- -   #VUID-VkSemaphoreWaitInfo-pNext-pNext# @pNext@ /must/ be @NULL@
--
-- -   #VUID-VkSemaphoreWaitInfo-flags-parameter# @flags@ /must/ be a valid
--     combination of
--     'Vulkan.Core12.Enums.SemaphoreWaitFlagBits.SemaphoreWaitFlagBits'
--     values
--
-- -   #VUID-VkSemaphoreWaitInfo-pSemaphores-parameter# @pSemaphores@
--     /must/ be a valid pointer to an array of @semaphoreCount@ valid
--     'Vulkan.Core10.Handles.Semaphore' handles
--
-- -   #VUID-VkSemaphoreWaitInfo-pValues-parameter# @pValues@ /must/ be a
--     valid pointer to an array of @semaphoreCount@ @uint64_t@ values
--
-- -   #VUID-VkSemaphoreWaitInfo-semaphoreCount-arraylength#
--     @semaphoreCount@ /must/ be greater than @0@
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Handles.Semaphore',
-- 'Vulkan.Core12.Enums.SemaphoreWaitFlagBits.SemaphoreWaitFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'waitSemaphores',
-- 'Vulkan.Extensions.VK_KHR_timeline_semaphore.waitSemaphoresKHR'
data SemaphoreWaitInfo = SemaphoreWaitInfo
  { -- | @flags@ is a bitmask of
    -- 'Vulkan.Core12.Enums.SemaphoreWaitFlagBits.SemaphoreWaitFlagBits'
    -- specifying additional parameters for the semaphore wait operation.
    SemaphoreWaitInfo -> SemaphoreWaitFlags
flags :: SemaphoreWaitFlags
  , -- | @pSemaphores@ is a pointer to an array of @semaphoreCount@ semaphore
    -- handles to wait on.
    SemaphoreWaitInfo -> Vector Semaphore
semaphores :: Vector Semaphore
  , -- | @pValues@ is a pointer to an array of @semaphoreCount@ timeline
    -- semaphore values.
    SemaphoreWaitInfo -> Vector ("value" ::: Word64)
values :: Vector Word64
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SemaphoreWaitInfo)
#endif
deriving instance Show SemaphoreWaitInfo

instance ToCStruct SemaphoreWaitInfo where
  withCStruct :: forall b.
SemaphoreWaitInfo -> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
withCStruct SemaphoreWaitInfo
x Ptr SemaphoreWaitInfo -> IO b
f = Int -> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 ((Ptr SemaphoreWaitInfo -> IO b) -> IO b)
-> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SemaphoreWaitInfo
p -> Ptr SemaphoreWaitInfo -> SemaphoreWaitInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SemaphoreWaitInfo
p SemaphoreWaitInfo
x (Ptr SemaphoreWaitInfo -> IO b
f Ptr SemaphoreWaitInfo
p)
  pokeCStruct :: forall b.
Ptr SemaphoreWaitInfo -> SemaphoreWaitInfo -> IO b -> IO b
pokeCStruct Ptr SemaphoreWaitInfo
p SemaphoreWaitInfo{Vector ("value" ::: Word64)
Vector Semaphore
SemaphoreWaitFlags
values :: Vector ("value" ::: Word64)
semaphores :: Vector Semaphore
flags :: SemaphoreWaitFlags
$sel:values:SemaphoreWaitInfo :: SemaphoreWaitInfo -> Vector ("value" ::: Word64)
$sel:semaphores:SemaphoreWaitInfo :: SemaphoreWaitInfo -> Vector Semaphore
$sel:flags:SemaphoreWaitInfo :: SemaphoreWaitInfo -> SemaphoreWaitFlags
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr SemaphoreWaitFlags -> SemaphoreWaitFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr SemaphoreWaitFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SemaphoreWaitFlags)) (SemaphoreWaitFlags
flags)
    let pSemaphoresLength :: Int
pSemaphoresLength = Vector Semaphore -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Semaphore -> Int) -> Vector Semaphore -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Semaphore
semaphores)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ((Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64) -> Int)
-> Vector ("value" ::: Word64) -> Int
forall a b. (a -> b) -> a -> b
$ (Vector ("value" ::: Word64)
values)) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
pSemaphoresLength) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
      IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"pValues and pSemaphores must have the same length" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pSemaphoresLength :: Word32))
    Ptr Semaphore
pPSemaphores' <- ((Ptr Semaphore -> IO b) -> IO b) -> ContT b IO (Ptr Semaphore)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Semaphore -> IO b) -> IO b) -> ContT b IO (Ptr Semaphore))
-> ((Ptr Semaphore -> IO b) -> IO b) -> ContT b IO (Ptr Semaphore)
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Semaphore ((Vector Semaphore -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Semaphore
semaphores)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> Semaphore -> IO ()) -> Vector Semaphore -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Semaphore
e -> Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Semaphore
pPSemaphores' Ptr Semaphore -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (Vector Semaphore
semaphores)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr Semaphore) -> Ptr Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr (Ptr Semaphore)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Semaphore))) (Ptr Semaphore
pPSemaphores')
    "pValue" ::: Ptr ("value" ::: Word64)
pPValues' <- ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
 -> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64)))
-> ((("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b)
-> ContT b IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @Word64 ((Vector ("value" ::: Word64) -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector ("value" ::: Word64)
values)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
8)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ (Int -> ("value" ::: Word64) -> IO ())
-> Vector ("value" ::: Word64) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i "value" ::: Word64
e -> ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pValue" ::: Ptr ("value" ::: Word64)
pPValues' ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) ("value" ::: Word64
e)) (Vector ("value" ::: Word64)
values)
    IO () -> ContT b IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr Word64))) ("pValue" ::: Ptr ("value" ::: Word64)
pPValues')
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = Int
40
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr SemaphoreWaitInfo -> IO b -> IO b
pokeZeroCStruct Ptr SemaphoreWaitInfo
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO b
f

instance FromCStruct SemaphoreWaitInfo where
  peekCStruct :: Ptr SemaphoreWaitInfo -> IO SemaphoreWaitInfo
peekCStruct Ptr SemaphoreWaitInfo
p = do
    SemaphoreWaitFlags
flags <- forall a. Storable a => Ptr a -> IO a
peek @SemaphoreWaitFlags ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr SemaphoreWaitFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr SemaphoreWaitFlags))
    Word32
semaphoreCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
20 :: Ptr Word32))
    Ptr Semaphore
pSemaphores <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Semaphore) ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo -> Int -> Ptr (Ptr Semaphore)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Semaphore)))
    Vector Semaphore
pSemaphores' <- Int -> (Int -> IO Semaphore) -> IO (Vector Semaphore)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
semaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Semaphore ((Ptr Semaphore
pSemaphores Ptr Semaphore -> Int -> Ptr Semaphore
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
    "pValue" ::: Ptr ("value" ::: Word64)
pValues <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word64) ((Ptr SemaphoreWaitInfo
p Ptr SemaphoreWaitInfo
-> Int -> Ptr ("pValue" ::: Ptr ("value" ::: Word64))
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr (Ptr Word64)))
    Vector ("value" ::: Word64)
pValues' <- Int
-> (Int -> IO ("value" ::: Word64))
-> IO (Vector ("value" ::: Word64))
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
semaphoreCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 (("pValue" ::: Ptr ("value" ::: Word64)
pValues ("pValue" ::: Ptr ("value" ::: Word64))
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
    SemaphoreWaitInfo -> IO SemaphoreWaitInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SemaphoreWaitInfo -> IO SemaphoreWaitInfo)
-> SemaphoreWaitInfo -> IO SemaphoreWaitInfo
forall a b. (a -> b) -> a -> b
$ SemaphoreWaitFlags
-> Vector Semaphore
-> Vector ("value" ::: Word64)
-> SemaphoreWaitInfo
SemaphoreWaitInfo
             SemaphoreWaitFlags
flags Vector Semaphore
pSemaphores' Vector ("value" ::: Word64)
pValues'

instance Zero SemaphoreWaitInfo where
  zero :: SemaphoreWaitInfo
zero = SemaphoreWaitFlags
-> Vector Semaphore
-> Vector ("value" ::: Word64)
-> SemaphoreWaitInfo
SemaphoreWaitInfo
           SemaphoreWaitFlags
forall a. Zero a => a
zero
           Vector Semaphore
forall a. Monoid a => a
mempty
           Vector ("value" ::: Word64)
forall a. Monoid a => a
mempty


-- | VkSemaphoreSignalInfo - Structure containing information about a
-- semaphore signal operation
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_timeline_semaphore VK_KHR_timeline_semaphore>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Handles.Semaphore',
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'signalSemaphore',
-- 'Vulkan.Extensions.VK_KHR_timeline_semaphore.signalSemaphoreKHR'
data SemaphoreSignalInfo = SemaphoreSignalInfo
  { -- | @semaphore@ is the handle of the semaphore to signal.
    --
    -- #VUID-VkSemaphoreSignalInfo-semaphore-03257# @semaphore@ /must/ have
    -- been created with a 'Vulkan.Core12.Enums.SemaphoreType.SemaphoreType' of
    -- 'Vulkan.Core12.Enums.SemaphoreType.SEMAPHORE_TYPE_TIMELINE'
    --
    -- #VUID-VkSemaphoreSignalInfo-semaphore-parameter# @semaphore@ /must/ be a
    -- valid 'Vulkan.Core10.Handles.Semaphore' handle
    SemaphoreSignalInfo -> Semaphore
semaphore :: Semaphore
  , -- | @value@ is the value to signal.
    --
    -- #VUID-VkSemaphoreSignalInfo-value-03258# @value@ /must/ have a value
    -- greater than the current value of the semaphore
    --
    -- #VUID-VkSemaphoreSignalInfo-value-03259# @value@ /must/ be less than the
    -- value of any pending semaphore signal operations
    --
    -- #VUID-VkSemaphoreSignalInfo-value-03260# @value@ /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
    -- @semaphore@ by more than
    -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#limits-maxTimelineSemaphoreValueDifference maxTimelineSemaphoreValueDifference>
    SemaphoreSignalInfo -> "value" ::: Word64
value :: Word64
  }
  deriving (Typeable, SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool
(SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool)
-> (SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool)
-> Eq SemaphoreSignalInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool
$c/= :: SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool
== :: SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool
$c== :: SemaphoreSignalInfo -> SemaphoreSignalInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SemaphoreSignalInfo)
#endif
deriving instance Show SemaphoreSignalInfo

instance ToCStruct SemaphoreSignalInfo where
  withCStruct :: forall b.
SemaphoreSignalInfo
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b
withCStruct SemaphoreSignalInfo
x ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b
f = Int
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b)
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \"pSignalInfo" ::: Ptr SemaphoreSignalInfo
p -> ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> SemaphoreSignalInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p SemaphoreSignalInfo
x (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b
f "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p)
  pokeCStruct :: forall b.
("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> SemaphoreSignalInfo -> IO b -> IO b
pokeCStruct "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p SemaphoreSignalInfo{"value" ::: Word64
Semaphore
value :: "value" ::: Word64
semaphore :: Semaphore
$sel:value:SemaphoreSignalInfo :: SemaphoreSignalInfo -> "value" ::: Word64
$sel:semaphore:SemaphoreSignalInfo :: SemaphoreSignalInfo -> Semaphore
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (Semaphore
semaphore)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) ("value" ::: Word64
value)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b.
("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b -> IO b
pokeZeroCStruct "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Semaphore -> Semaphore -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore)) (Semaphore
forall a. Zero a => a
zero)
    ("pValue" ::: Ptr ("value" ::: Word64))
-> ("value" ::: Word64) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) ("value" ::: Word64
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct SemaphoreSignalInfo where
  peekCStruct :: ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> IO SemaphoreSignalInfo
peekCStruct "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p = do
    Semaphore
semaphore <- forall a. Storable a => Ptr a -> IO a
peek @Semaphore (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> Int -> Ptr Semaphore
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Semaphore))
    "value" ::: Word64
value <- forall a. Storable a => Ptr a -> IO a
peek @Word64 (("pSignalInfo" ::: Ptr SemaphoreSignalInfo
p ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> Int -> "pValue" ::: Ptr ("value" ::: Word64)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64))
    SemaphoreSignalInfo -> IO SemaphoreSignalInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SemaphoreSignalInfo -> IO SemaphoreSignalInfo)
-> SemaphoreSignalInfo -> IO SemaphoreSignalInfo
forall a b. (a -> b) -> a -> b
$ Semaphore -> ("value" ::: Word64) -> SemaphoreSignalInfo
SemaphoreSignalInfo
             Semaphore
semaphore "value" ::: Word64
value

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

instance Zero SemaphoreSignalInfo where
  zero :: SemaphoreSignalInfo
zero = Semaphore -> ("value" ::: Word64) -> SemaphoreSignalInfo
SemaphoreSignalInfo
           Semaphore
forall a. Zero a => a
zero
           "value" ::: Word64
forall a. Zero a => a
zero