{-# language CPP #-}
module Vulkan.Core10.Fence ( createFence
, withFence
, destroyFence
, resetFences
, getFenceStatus
, waitForFences
, waitForFencesSafe
, FenceCreateInfo(..)
, Fence(..)
, FenceCreateFlagBits(..)
, FenceCreateFlags
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Word (Word64)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.Core10.FundamentalTypes (Bool32(..))
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkCreateFence))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyFence))
import Vulkan.Dynamic (DeviceCmds(pVkGetFenceStatus))
import Vulkan.Dynamic (DeviceCmds(pVkResetFences))
import Vulkan.Dynamic (DeviceCmds(pVkWaitForFences))
import Vulkan.Core10.Handles (Device_T)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_external_fence (ExportFenceCreateInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_external_fence_win32 (ExportFenceWin32HandleInfoKHR)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.Core10.Handles (Fence)
import Vulkan.Core10.Handles (Fence(..))
import Vulkan.Core10.Enums.FenceCreateFlagBits (FenceCreateFlags)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Exception (VulkanException(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_FENCE_CREATE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Handles (Fence(..))
import Vulkan.Core10.Enums.FenceCreateFlagBits (FenceCreateFlagBits(..))
import Vulkan.Core10.Enums.FenceCreateFlagBits (FenceCreateFlags)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkCreateFence
:: FunPtr (Ptr Device_T -> Ptr (SomeStruct FenceCreateInfo) -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result) -> Ptr Device_T -> Ptr (SomeStruct FenceCreateInfo) -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result
createFence :: forall a io
. (Extendss FenceCreateInfo a, PokeChain a, MonadIO io)
=>
Device
->
(FenceCreateInfo a)
->
("allocator" ::: Maybe AllocationCallbacks)
-> io (Fence)
createFence :: Device
-> FenceCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io Fence
createFence device :: Device
device createInfo :: FenceCreateInfo a
createInfo allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO Fence -> io Fence
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Fence -> io Fence)
-> (ContT Fence IO Fence -> IO Fence)
-> ContT Fence IO Fence
-> io Fence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Fence IO Fence -> IO Fence
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Fence IO Fence -> io Fence)
-> ContT Fence IO Fence -> io Fence
forall a b. (a -> b) -> a -> b
$ do
let vkCreateFencePtr :: FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkCreateFencePtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
pVkCreateFence (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT Fence IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Fence IO ()) -> IO () -> ContT Fence IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkCreateFencePtr FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> 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 vkCreateFence is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkCreateFence' :: Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result
vkCreateFence' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result
mkVkCreateFence FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkCreateFencePtr
Ptr (FenceCreateInfo a)
pCreateInfo <- ((Ptr (FenceCreateInfo a) -> IO Fence) -> IO Fence)
-> ContT Fence IO (Ptr (FenceCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (FenceCreateInfo a) -> IO Fence) -> IO Fence)
-> ContT Fence IO (Ptr (FenceCreateInfo a)))
-> ((Ptr (FenceCreateInfo a) -> IO Fence) -> IO Fence)
-> ContT Fence IO (Ptr (FenceCreateInfo a))
forall a b. (a -> b) -> a -> b
$ FenceCreateInfo a
-> (Ptr (FenceCreateInfo a) -> IO Fence) -> IO Fence
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (FenceCreateInfo a
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT Fence IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pAllocator" ::: Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just j :: AllocationCallbacks
j -> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO Fence)
-> IO Fence)
-> ContT Fence IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pAllocator" ::: Ptr AllocationCallbacks) -> IO Fence)
-> IO Fence)
-> ContT Fence IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO Fence)
-> IO Fence)
-> ContT Fence IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks) -> IO Fence)
-> IO Fence
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pFence" ::: Ptr Fence
pPFence <- ((("pFence" ::: Ptr Fence) -> IO Fence) -> IO Fence)
-> ContT Fence IO ("pFence" ::: Ptr Fence)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pFence" ::: Ptr Fence) -> IO Fence) -> IO Fence)
-> ContT Fence IO ("pFence" ::: Ptr Fence))
-> ((("pFence" ::: Ptr Fence) -> IO Fence) -> IO Fence)
-> ContT Fence IO ("pFence" ::: Ptr Fence)
forall a b. (a -> b) -> a -> b
$ IO ("pFence" ::: Ptr Fence)
-> (("pFence" ::: Ptr Fence) -> IO ())
-> (("pFence" ::: Ptr Fence) -> IO Fence)
-> IO Fence
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pFence" ::: Ptr Fence)
forall a. Int -> IO (Ptr a)
callocBytes @Fence 8) ("pFence" ::: Ptr Fence) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT Fence IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT Fence IO Result)
-> IO Result -> ContT Fence IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkCreateFence" (Ptr Device_T
-> ("pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pFence" ::: Ptr Fence)
-> IO Result
vkCreateFence' (Device -> Ptr Device_T
deviceHandle (Device
device)) (Ptr (FenceCreateInfo a)
-> "pCreateInfo" ::: Ptr (SomeStruct FenceCreateInfo)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (FenceCreateInfo a)
pCreateInfo) "pAllocator" ::: Ptr AllocationCallbacks
pAllocator ("pFence" ::: Ptr Fence
pPFence))
IO () -> ContT Fence IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Fence IO ()) -> IO () -> ContT Fence 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))
Fence
pFence <- IO Fence -> ContT Fence IO Fence
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Fence -> ContT Fence IO Fence)
-> IO Fence -> ContT Fence IO Fence
forall a b. (a -> b) -> a -> b
$ ("pFence" ::: Ptr Fence) -> IO Fence
forall a. Storable a => Ptr a -> IO a
peek @Fence "pFence" ::: Ptr Fence
pPFence
Fence -> ContT Fence IO Fence
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Fence -> ContT Fence IO Fence) -> Fence -> ContT Fence IO Fence
forall a b. (a -> b) -> a -> b
$ (Fence
pFence)
withFence :: forall a io r . (Extendss FenceCreateInfo a, PokeChain a, MonadIO io) => Device -> FenceCreateInfo a -> Maybe AllocationCallbacks -> (io Fence -> (Fence -> io ()) -> r) -> r
withFence :: Device
-> FenceCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io Fence -> (Fence -> io ()) -> r)
-> r
withFence device :: Device
device pCreateInfo :: FenceCreateInfo a
pCreateInfo pAllocator :: "allocator" ::: Maybe AllocationCallbacks
pAllocator b :: io Fence -> (Fence -> io ()) -> r
b =
io Fence -> (Fence -> io ()) -> r
b (Device
-> FenceCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io Fence
forall (a :: [*]) (io :: * -> *).
(Extendss FenceCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> FenceCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io Fence
createFence Device
device FenceCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(Fence
o0) -> Device
-> Fence -> ("allocator" ::: Maybe AllocationCallbacks) -> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> Fence -> ("allocator" ::: Maybe AllocationCallbacks) -> io ()
destroyFence Device
device Fence
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDestroyFence
:: FunPtr (Ptr Device_T -> Fence -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> Fence -> Ptr AllocationCallbacks -> IO ()
destroyFence :: forall io
. (MonadIO io)
=>
Device
->
Fence
->
("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyFence :: Device
-> Fence -> ("allocator" ::: Maybe AllocationCallbacks) -> io ()
destroyFence device :: Device
device fence :: Fence
fence allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = 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 vkDestroyFencePtr :: FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
vkDestroyFencePtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
pVkDestroyFence (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
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
vkDestroyFencePtr FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
-> FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
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 vkDestroyFence is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkDestroyFence' :: Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()
vkDestroyFence' = FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
-> Ptr Device_T
-> Fence
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkDestroyFence FunPtr
(Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ())
vkDestroyFencePtr
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pAllocator" ::: Ptr AllocationCallbacks
forall a. Ptr a
nullPtr
Just j :: AllocationCallbacks
j -> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ())
-> ContT () IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()) -> IO ()
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
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
$ String -> IO () -> IO ()
forall a. String -> IO a -> IO a
traceAroundEvent "vkDestroyFence" (Ptr Device_T
-> Fence -> ("pAllocator" ::: Ptr AllocationCallbacks) -> IO ()
vkDestroyFence' (Device -> Ptr Device_T
deviceHandle (Device
device)) (Fence
fence) "pAllocator" ::: Ptr AllocationCallbacks
pAllocator)
() -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkResetFences
:: FunPtr (Ptr Device_T -> Word32 -> Ptr Fence -> IO Result) -> Ptr Device_T -> Word32 -> Ptr Fence -> IO Result
resetFences :: forall io
. (MonadIO io)
=>
Device
->
("fences" ::: Vector Fence)
-> io ()
resetFences :: Device -> ("fences" ::: Vector Fence) -> io ()
resetFences device :: Device
device fences :: "fences" ::: Vector Fence
fences = 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 vkResetFencesPtr :: FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkResetFencesPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
pVkResetFences (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
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkResetFencesPtr FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> 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 vkResetFences is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkResetFences' :: Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result
vkResetFences' = FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result
mkVkResetFences FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result)
vkResetFencesPtr
"pFence" ::: Ptr Fence
pPFences <- ((("pFence" ::: Ptr Fence) -> IO ()) -> IO ())
-> ContT () IO ("pFence" ::: Ptr Fence)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pFence" ::: Ptr Fence) -> IO ()) -> IO ())
-> ContT () IO ("pFence" ::: Ptr Fence))
-> ((("pFence" ::: Ptr Fence) -> IO ()) -> IO ())
-> ContT () IO ("pFence" ::: Ptr Fence)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (("pFence" ::: Ptr Fence) -> IO ()) -> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Fence ((("fences" ::: Vector Fence) -> Int
forall a. Vector a -> Int
Data.Vector.length ("fences" ::: Vector Fence
fences)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
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
$ (Int -> Fence -> IO ()) -> ("fences" ::: Vector Fence) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Fence
e -> ("pFence" ::: Ptr Fence) -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pFence" ::: Ptr Fence
pPFences ("pFence" ::: Ptr Fence) -> Int -> "pFence" ::: Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Fence) (Fence
e)) ("fences" ::: Vector Fence
fences)
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 "vkResetFences" (Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> IO Result
vkResetFences' (Device -> Ptr Device_T
deviceHandle (Device
device)) ((Int -> "fenceCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("fences" ::: Vector Fence) -> Int
forall a. Vector a -> Int
Data.Vector.length (("fences" ::: Vector Fence) -> Int)
-> ("fences" ::: Vector Fence) -> Int
forall a b. (a -> b) -> a -> b
$ ("fences" ::: Vector Fence
fences)) :: Word32)) ("pFence" ::: Ptr Fence
pPFences))
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))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetFenceStatus
:: FunPtr (Ptr Device_T -> Fence -> IO Result) -> Ptr Device_T -> Fence -> IO Result
getFenceStatus :: forall io
. (MonadIO io)
=>
Device
->
Fence
-> io (Result)
getFenceStatus :: Device -> Fence -> io Result
getFenceStatus device :: Device
device fence :: Fence
fence = IO Result -> io Result
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> io Result) -> IO Result -> io Result
forall a b. (a -> b) -> a -> b
$ do
let vkGetFenceStatusPtr :: FunPtr (Ptr Device_T -> Fence -> IO Result)
vkGetFenceStatusPtr = DeviceCmds -> FunPtr (Ptr Device_T -> Fence -> IO Result)
pVkGetFenceStatus (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr Device_T -> Fence -> IO Result)
vkGetFenceStatusPtr FunPtr (Ptr Device_T -> Fence -> IO Result)
-> FunPtr (Ptr Device_T -> Fence -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr Device_T -> Fence -> 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 vkGetFenceStatus is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkGetFenceStatus' :: Ptr Device_T -> Fence -> IO Result
vkGetFenceStatus' = FunPtr (Ptr Device_T -> Fence -> IO Result)
-> Ptr Device_T -> Fence -> IO Result
mkVkGetFenceStatus FunPtr (Ptr Device_T -> Fence -> IO Result)
vkGetFenceStatusPtr
Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkGetFenceStatus" (Ptr Device_T -> Fence -> IO Result
vkGetFenceStatus' (Device -> Ptr Device_T
deviceHandle (Device
device)) (Fence
fence))
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 -> IO Result
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Result -> IO Result) -> Result -> IO Result
forall a b. (a -> b) -> a -> b
$ (Result
r)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkWaitForFencesUnsafe
:: FunPtr (Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result) -> Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result
foreign import ccall
"dynamic" mkVkWaitForFencesSafe
:: FunPtr (Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result) -> Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result
waitForFencesSafeOrUnsafe :: forall io
. (MonadIO io)
=>
(FunPtr (Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result) -> Ptr Device_T -> Word32 -> Ptr Fence -> Bool32 -> Word64 -> IO Result)
->
Device
->
("fences" ::: Vector Fence)
->
("waitAll" ::: Bool)
->
("timeout" ::: Word64)
-> io (Result)
waitForFencesSafeOrUnsafe :: (FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Device
-> ("fences" ::: Vector Fence)
-> Bool
-> Word64
-> io Result
waitForFencesSafeOrUnsafe mkVkWaitForFences :: FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
mkVkWaitForFences device :: Device
device fences :: "fences" ::: Vector Fence
fences waitAll :: Bool
waitAll timeout :: 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 vkWaitForFencesPtr :: FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
vkWaitForFencesPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
pVkWaitForFences (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
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
vkWaitForFencesPtr FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> 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 vkWaitForFences is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkWaitForFences' :: Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
vkWaitForFences' = FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
mkVkWaitForFences FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
vkWaitForFencesPtr
"pFence" ::: Ptr Fence
pPFences <- ((("pFence" ::: Ptr Fence) -> IO Result) -> IO Result)
-> ContT Result IO ("pFence" ::: Ptr Fence)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pFence" ::: Ptr Fence) -> IO Result) -> IO Result)
-> ContT Result IO ("pFence" ::: Ptr Fence))
-> ((("pFence" ::: Ptr Fence) -> IO Result) -> IO Result)
-> ContT Result IO ("pFence" ::: Ptr Fence)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (("pFence" ::: Ptr Fence) -> IO Result) -> IO Result
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Fence ((("fences" ::: Vector Fence) -> Int
forall a. Vector a -> Int
Data.Vector.length ("fences" ::: Vector Fence
fences)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 8
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
$ (Int -> Fence -> IO ()) -> ("fences" ::: Vector Fence) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Fence
e -> ("pFence" ::: Ptr Fence) -> Fence -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pFence" ::: Ptr Fence
pPFences ("pFence" ::: Ptr Fence) -> Int -> "pFence" ::: Ptr Fence
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Fence) (Fence
e)) ("fences" ::: Vector Fence
fences)
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 "vkWaitForFences" (Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
vkWaitForFences' (Device -> Ptr Device_T
deviceHandle (Device
device)) ((Int -> "fenceCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("fences" ::: Vector Fence) -> Int
forall a. Vector a -> Int
Data.Vector.length (("fences" ::: Vector Fence) -> Int)
-> ("fences" ::: Vector Fence) -> Int
forall a b. (a -> b) -> a -> b
$ ("fences" ::: Vector Fence
fences)) :: Word32)) ("pFence" ::: Ptr Fence
pPFences) (Bool -> Bool32
boolToBool32 (Bool
waitAll)) (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)
waitForFences :: forall io
. (MonadIO io)
=>
Device
->
("fences" ::: Vector Fence)
->
("waitAll" ::: Bool)
->
("timeout" ::: Word64)
-> io (Result)
waitForFences :: Device
-> ("fences" ::: Vector Fence) -> Bool -> Word64 -> io Result
waitForFences = (FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Device
-> ("fences" ::: Vector Fence)
-> Bool
-> Word64
-> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Device
-> ("fences" ::: Vector Fence)
-> Bool
-> Word64
-> io Result
waitForFencesSafeOrUnsafe FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
mkVkWaitForFencesUnsafe
waitForFencesSafe :: forall io
. (MonadIO io)
=>
Device
->
("fences" ::: Vector Fence)
->
("waitAll" ::: Bool)
->
("timeout" ::: Word64)
-> io (Result)
waitForFencesSafe :: Device
-> ("fences" ::: Vector Fence) -> Bool -> Word64 -> io Result
waitForFencesSafe = (FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Device
-> ("fences" ::: Vector Fence)
-> Bool
-> Word64
-> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Device
-> ("fences" ::: Vector Fence)
-> Bool
-> Word64
-> io Result
waitForFencesSafeOrUnsafe FunPtr
(Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result)
-> Ptr Device_T
-> ("fenceCount" ::: Word32)
-> ("pFence" ::: Ptr Fence)
-> Bool32
-> Word64
-> IO Result
mkVkWaitForFencesSafe
data FenceCreateInfo (es :: [Type]) = FenceCreateInfo
{
FenceCreateInfo es -> Chain es
next :: Chain es
,
FenceCreateInfo es -> FenceCreateFlags
flags :: FenceCreateFlags
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (FenceCreateInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (FenceCreateInfo es)
instance Extensible FenceCreateInfo where
extensibleType :: StructureType
extensibleType = StructureType
STRUCTURE_TYPE_FENCE_CREATE_INFO
setNext :: FenceCreateInfo ds -> Chain es -> FenceCreateInfo es
setNext x :: FenceCreateInfo ds
x next :: Chain es
next = FenceCreateInfo ds
x{$sel:next:FenceCreateInfo :: Chain es
next = Chain es
next}
getNext :: FenceCreateInfo es -> Chain es
getNext FenceCreateInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends FenceCreateInfo e => b) -> Maybe b
extends :: proxy e -> (Extends FenceCreateInfo e => b) -> Maybe b
extends _ f :: Extends FenceCreateInfo e => b
f
| Just Refl <- (Typeable e, Typeable ExportFenceWin32HandleInfoKHR) =>
Maybe (e :~: ExportFenceWin32HandleInfoKHR)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportFenceWin32HandleInfoKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends FenceCreateInfo e => b
f
| Just Refl <- (Typeable e, Typeable ExportFenceCreateInfo) =>
Maybe (e :~: ExportFenceCreateInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @ExportFenceCreateInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends FenceCreateInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss FenceCreateInfo es, PokeChain es) => ToCStruct (FenceCreateInfo es) where
withCStruct :: FenceCreateInfo es -> (Ptr (FenceCreateInfo es) -> IO b) -> IO b
withCStruct x :: FenceCreateInfo es
x f :: Ptr (FenceCreateInfo es) -> IO b
f = Int -> Int -> (Ptr (FenceCreateInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr (FenceCreateInfo es) -> IO b) -> IO b)
-> (Ptr (FenceCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (FenceCreateInfo es)
p -> Ptr (FenceCreateInfo es) -> FenceCreateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (FenceCreateInfo es)
p FenceCreateInfo es
x (Ptr (FenceCreateInfo es) -> IO b
f Ptr (FenceCreateInfo es)
p)
pokeCStruct :: Ptr (FenceCreateInfo es) -> FenceCreateInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (FenceCreateInfo es)
p FenceCreateInfo{..} 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 (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_FENCE_CREATE_INFO)
Ptr ()
pNext'' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ Chain es -> (Ptr (Chain es) -> IO b) -> IO b
forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
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 (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext''
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 FenceCreateFlags -> FenceCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr FenceCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr FenceCreateFlags)) (FenceCreateFlags
flags)
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 = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (FenceCreateInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (FenceCreateInfo es)
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 (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_FENCE_CREATE_INFO)
Ptr ()
pNext' <- (Ptr (Chain es) -> Ptr ())
-> ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Ptr (Chain es) -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr (ContT b IO (Ptr (Chain es)) -> ContT b IO (Ptr ()))
-> (((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr (Chain es)))
-> ((Ptr (Chain es) -> IO b) -> IO b)
-> ContT b IO (Ptr ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr (Chain es))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ()))
-> ((Ptr (Chain es) -> IO b) -> IO b) -> ContT b IO (Ptr ())
forall a b. (a -> b) -> a -> b
$ forall a. PokeChain es => (Ptr (Chain es) -> IO a) -> IO a
forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
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 (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
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 (Extendss FenceCreateInfo es, PeekChain es) => FromCStruct (FenceCreateInfo es) where
peekCStruct :: Ptr (FenceCreateInfo es) -> IO (FenceCreateInfo es)
peekCStruct p :: Ptr (FenceCreateInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ())))
Chain es
next <- Ptr (Chain es) -> IO (Chain es)
forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (Ptr () -> Ptr (Chain es)
forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
FenceCreateFlags
flags <- Ptr FenceCreateFlags -> IO FenceCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @FenceCreateFlags ((Ptr (FenceCreateInfo es)
p Ptr (FenceCreateInfo es) -> Int -> Ptr FenceCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr FenceCreateFlags))
FenceCreateInfo es -> IO (FenceCreateInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FenceCreateInfo es -> IO (FenceCreateInfo es))
-> FenceCreateInfo es -> IO (FenceCreateInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es -> FenceCreateFlags -> FenceCreateInfo es
forall (es :: [*]).
Chain es -> FenceCreateFlags -> FenceCreateInfo es
FenceCreateInfo
Chain es
next FenceCreateFlags
flags
instance es ~ '[] => Zero (FenceCreateInfo es) where
zero :: FenceCreateInfo es
zero = Chain es -> FenceCreateFlags -> FenceCreateInfo es
forall (es :: [*]).
Chain es -> FenceCreateFlags -> FenceCreateInfo es
FenceCreateInfo
()
FenceCreateFlags
forall a. Zero a => a
zero