{-# language CPP #-}
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 (allocaBytesAligned)
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.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
getSemaphoreCounterValue :: forall io
. (MonadIO io)
=>
Device
->
Semaphore
-> io (("value" ::: Word64))
getSemaphoreCounterValue :: Device -> Semaphore -> io ("value" ::: Word64)
getSemaphoreCounterValue device :: Device
device semaphore :: 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 (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
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 "" "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 (Int -> IO ("pValue" ::: Ptr ("value" ::: Word64))
forall a. Int -> IO (Ptr a)
callocBytes @Word64 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 "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
$ ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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
waitSemaphoresSafeOrUnsafe :: forall io
. (MonadIO io)
=> (FunPtr (Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result) -> Ptr Device_T -> Ptr SemaphoreWaitInfo -> Word64 -> IO Result)
->
Device
->
SemaphoreWaitInfo
->
("timeout" ::: Word64)
-> io (Result)
waitSemaphoresSafeOrUnsafe :: (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 mkVkWaitSemaphores :: FunPtr
(Ptr Device_T
-> Ptr SemaphoreWaitInfo -> ("value" ::: Word64) -> IO Result)
-> Ptr Device_T
-> Ptr SemaphoreWaitInfo
-> ("value" ::: Word64)
-> IO Result
mkVkWaitSemaphores device :: Device
device waitInfo :: SemaphoreWaitInfo
waitInfo timeout :: "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 (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
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 "" "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 "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)
waitSemaphores :: forall io
. (MonadIO io)
=>
Device
->
SemaphoreWaitInfo
->
("timeout" ::: Word64)
-> io (Result)
waitSemaphores :: 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
waitSemaphoresSafe :: forall io
. (MonadIO io)
=>
Device
->
SemaphoreWaitInfo
->
("timeout" ::: Word64)
-> io (Result)
waitSemaphoresSafe :: 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
signalSemaphore :: forall io
. (MonadIO io)
=>
Device
->
SemaphoreSignalInfo
-> io ()
signalSemaphore :: Device -> SemaphoreSignalInfo -> io ()
signalSemaphore device :: Device
device signalInfo :: 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 (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
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 "" "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 "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))
data PhysicalDeviceTimelineSemaphoreFeatures = PhysicalDeviceTimelineSemaphoreFeatures
{
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 :: PhysicalDeviceTimelineSemaphoreFeatures
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b
withCStruct x :: PhysicalDeviceTimelineSemaphoreFeatures
x f :: Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b
f = Int
-> Int
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b)
-> (Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: 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 :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
-> PhysicalDeviceTimelineSemaphoreFeatures -> IO b -> IO b
pokeCStruct p :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
p PhysicalDeviceTimelineSemaphoreFeatures{..} f :: 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` 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` 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` 16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
timelineSemaphore))
IO b
f
cStructSize :: Int
cStructSize = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr PhysicalDeviceTimelineSemaphoreFeatures -> IO b -> IO b
pokeZeroCStruct p :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
p f :: 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` 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` 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` 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 p :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
p = do
Bool32
timelineSemaphore <- Ptr Bool32 -> IO Bool32
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` 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
_ = 24
alignment :: PhysicalDeviceTimelineSemaphoreFeatures -> Int
alignment ~PhysicalDeviceTimelineSemaphoreFeatures
_ = 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 :: Ptr PhysicalDeviceTimelineSemaphoreFeatures
ptr poked :: 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
data PhysicalDeviceTimelineSemaphoreProperties = PhysicalDeviceTimelineSemaphoreProperties
{
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 :: PhysicalDeviceTimelineSemaphoreProperties
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b
withCStruct x :: PhysicalDeviceTimelineSemaphoreProperties
x f :: Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b
f = Int
-> Int
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b)
-> (Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: 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 :: Ptr PhysicalDeviceTimelineSemaphoreProperties
-> PhysicalDeviceTimelineSemaphoreProperties -> IO b -> IO b
pokeCStruct p :: Ptr PhysicalDeviceTimelineSemaphoreProperties
p PhysicalDeviceTimelineSemaphoreProperties{..} f :: 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` 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` 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` 16 :: Ptr Word64)) ("value" ::: Word64
maxTimelineSemaphoreValueDifference)
IO b
f
cStructSize :: Int
cStructSize = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr PhysicalDeviceTimelineSemaphoreProperties -> IO b -> IO b
pokeZeroCStruct p :: Ptr PhysicalDeviceTimelineSemaphoreProperties
p f :: 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` 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` 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` 16 :: Ptr Word64)) ("value" ::: Word64
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct PhysicalDeviceTimelineSemaphoreProperties where
peekCStruct :: Ptr PhysicalDeviceTimelineSemaphoreProperties
-> IO PhysicalDeviceTimelineSemaphoreProperties
peekCStruct p :: Ptr PhysicalDeviceTimelineSemaphoreProperties
p = do
"value" ::: Word64
maxTimelineSemaphoreValueDifference <- ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` 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
_ = 24
alignment :: PhysicalDeviceTimelineSemaphoreProperties -> Int
alignment ~PhysicalDeviceTimelineSemaphoreProperties
_ = 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 :: Ptr PhysicalDeviceTimelineSemaphoreProperties
ptr poked :: 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
data SemaphoreTypeCreateInfo = SemaphoreTypeCreateInfo
{
SemaphoreTypeCreateInfo -> SemaphoreType
semaphoreType :: SemaphoreType
,
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 :: SemaphoreTypeCreateInfo
-> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
withCStruct x :: SemaphoreTypeCreateInfo
x f :: Ptr SemaphoreTypeCreateInfo -> IO b
f = Int -> Int -> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b)
-> (Ptr SemaphoreTypeCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: 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 :: Ptr SemaphoreTypeCreateInfo
-> SemaphoreTypeCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr SemaphoreTypeCreateInfo
p SemaphoreTypeCreateInfo{..} f :: 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` 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` 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` 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` 24 :: Ptr Word64)) ("value" ::: Word64
initialValue)
IO b
f
cStructSize :: Int
cStructSize = 32
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr SemaphoreTypeCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr SemaphoreTypeCreateInfo
p f :: 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` 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` 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` 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` 24 :: Ptr Word64)) ("value" ::: Word64
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct SemaphoreTypeCreateInfo where
peekCStruct :: Ptr SemaphoreTypeCreateInfo -> IO SemaphoreTypeCreateInfo
peekCStruct p :: Ptr SemaphoreTypeCreateInfo
p = do
SemaphoreType
semaphoreType <- Ptr SemaphoreType -> IO 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` 16 :: Ptr SemaphoreType))
"value" ::: Word64
initialValue <- ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` 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
_ = 32
alignment :: SemaphoreTypeCreateInfo -> Int
alignment ~SemaphoreTypeCreateInfo
_ = 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 :: Ptr SemaphoreTypeCreateInfo
ptr poked :: 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
data TimelineSemaphoreSubmitInfo = TimelineSemaphoreSubmitInfo
{
TimelineSemaphoreSubmitInfo -> Word32
waitSemaphoreValueCount :: Word32
,
TimelineSemaphoreSubmitInfo -> Vector ("value" ::: Word64)
waitSemaphoreValues :: Vector Word64
,
TimelineSemaphoreSubmitInfo -> Word32
signalSemaphoreValueCount :: Word32
,
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 :: TimelineSemaphoreSubmitInfo
-> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
withCStruct x :: TimelineSemaphoreSubmitInfo
x f :: Ptr TimelineSemaphoreSubmitInfo -> IO b
f = Int -> Int -> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 48 8 ((Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b)
-> (Ptr TimelineSemaphoreSubmitInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: 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 :: Ptr TimelineSemaphoreSubmitInfo
-> TimelineSemaphoreSubmitInfo -> IO b -> IO b
pokeCStruct p :: Ptr TimelineSemaphoreSubmitInfo
p TimelineSemaphoreSubmitInfo{..} f :: 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` 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` 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
== 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
== 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 "" "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` 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
$ Int
-> Int -> (("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @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
* 8) 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_ (\i :: Int
i e :: "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` (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` 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
== 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
== 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 "" "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` 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
$ Int
-> Int -> (("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @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
* 8) 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_ (\i :: Int
i e :: "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` (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` 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 = 48
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr TimelineSemaphoreSubmitInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr TimelineSemaphoreSubmitInfo
p f :: 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` 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` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct TimelineSemaphoreSubmitInfo where
peekCStruct :: Ptr TimelineSemaphoreSubmitInfo -> IO TimelineSemaphoreSubmitInfo
peekCStruct p :: Ptr TimelineSemaphoreSubmitInfo
p = do
Word32
waitSemaphoreValueCount <- Ptr Word32 -> IO Word32
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` 16 :: Ptr Word32))
"pValue" ::: Ptr ("value" ::: Word64)
pWaitSemaphoreValues <- Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> IO ("pValue" ::: Ptr ("value" ::: Word64))
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` 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 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 (\i :: Int
i -> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
Word32
signalSemaphoreValueCount <- Ptr Word32 -> IO Word32
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` 32 :: Ptr Word32))
"pValue" ::: Ptr ("value" ::: Word64)
pSignalSemaphoreValues <- Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> IO ("pValue" ::: Ptr ("value" ::: Word64))
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` 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 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 (\i :: Int
i -> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` (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
data SemaphoreWaitInfo = SemaphoreWaitInfo
{
SemaphoreWaitInfo -> SemaphoreWaitFlags
flags :: SemaphoreWaitFlags
,
SemaphoreWaitInfo -> Vector Semaphore
semaphores :: Vector Semaphore
,
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 :: SemaphoreWaitInfo -> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
withCStruct x :: SemaphoreWaitInfo
x f :: Ptr SemaphoreWaitInfo -> IO b
f = Int -> Int -> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((Ptr SemaphoreWaitInfo -> IO b) -> IO b)
-> (Ptr SemaphoreWaitInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: 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 :: Ptr SemaphoreWaitInfo -> SemaphoreWaitInfo -> IO b -> IO b
pokeCStruct p :: Ptr SemaphoreWaitInfo
p SemaphoreWaitInfo{..} f :: 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` 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` 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` 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 "" "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` 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
$ Int -> Int -> (Ptr Semaphore -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @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
* 8) 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_ (\i :: Int
i e :: 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` (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` 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
$ Int
-> Int -> (("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @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
* 8) 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_ (\i :: Int
i e :: "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` (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` 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 = 40
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr SemaphoreWaitInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr SemaphoreWaitInfo
p f :: 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` 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` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
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
$ Int -> Int -> (Ptr Semaphore -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Semaphore ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 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_ (\i :: Int
i e :: 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` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore) (Semaphore
e)) (Vector Semaphore
forall a. Monoid a => a
mempty)
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` 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
$ Int
-> Int -> (("pValue" ::: Ptr ("value" ::: Word64)) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Word64 ((Vector Any -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Any
forall a. Monoid a => a
mempty)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 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_ (\i :: Int
i e :: "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` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) ("value" ::: Word64
e)) (Vector ("value" ::: Word64)
forall a. Monoid a => a
mempty)
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` 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
instance FromCStruct SemaphoreWaitInfo where
peekCStruct :: Ptr SemaphoreWaitInfo -> IO SemaphoreWaitInfo
peekCStruct p :: Ptr SemaphoreWaitInfo
p = do
SemaphoreWaitFlags
flags <- Ptr SemaphoreWaitFlags -> IO SemaphoreWaitFlags
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` 16 :: Ptr SemaphoreWaitFlags))
Word32
semaphoreCount <- Ptr Word32 -> IO Word32
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` 20 :: Ptr Word32))
Ptr Semaphore
pSemaphores <- Ptr (Ptr Semaphore) -> IO (Ptr Semaphore)
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` 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) (\i :: Int
i -> Ptr Semaphore -> IO Semaphore
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` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Semaphore)))
"pValue" ::: Ptr ("value" ::: Word64)
pValues <- Ptr ("pValue" ::: Ptr ("value" ::: Word64))
-> IO ("pValue" ::: Ptr ("value" ::: Word64))
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` 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) (\i :: Int
i -> ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` (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
data SemaphoreSignalInfo = SemaphoreSignalInfo
{
SemaphoreSignalInfo -> Semaphore
semaphore :: Semaphore
,
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 :: SemaphoreSignalInfo
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b
withCStruct x :: SemaphoreSignalInfo
x f :: ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b
f = Int
-> Int
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b)
-> (("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "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 :: ("pSignalInfo" ::: Ptr SemaphoreSignalInfo)
-> SemaphoreSignalInfo -> IO b -> IO b
pokeCStruct p :: "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p SemaphoreSignalInfo{..} f :: 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` 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` 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` 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` 24 :: Ptr Word64)) ("value" ::: Word64
value)
IO b
f
cStructSize :: Int
cStructSize = 32
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: ("pSignalInfo" ::: Ptr SemaphoreSignalInfo) -> IO b -> IO b
pokeZeroCStruct p :: "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p f :: 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` 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` 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` 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` 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 p :: "pSignalInfo" ::: Ptr SemaphoreSignalInfo
p = do
Semaphore
semaphore <- Ptr Semaphore -> IO 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` 16 :: Ptr Semaphore))
"value" ::: Word64
value <- ("pValue" ::: Ptr ("value" ::: Word64)) -> IO ("value" ::: Word64)
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` 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
_ = 32
alignment :: SemaphoreSignalInfo -> Int
alignment ~SemaphoreSignalInfo
_ = 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 ptr :: "pSignalInfo" ::: Ptr SemaphoreSignalInfo
ptr poked :: 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