{-# language CPP #-}
module Vulkan.Core10.CommandPool ( createCommandPool
, withCommandPool
, destroyCommandPool
, resetCommandPool
, CommandPoolCreateInfo(..)
, CommandPool(..)
, CommandPoolCreateFlagBits(..)
, CommandPoolCreateFlags
, CommandPoolResetFlagBits(..)
, CommandPoolResetFlags
) 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 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.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.Core10.Handles (CommandPool)
import Vulkan.Core10.Handles (CommandPool(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlags)
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlags)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkCreateCommandPool))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyCommandPool))
import Vulkan.Dynamic (DeviceCmds(pVkResetCommandPool))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
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_COMMAND_POOL_CREATE_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Handles (CommandPool(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolCreateFlagBits (CommandPoolCreateFlags)
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlagBits(..))
import Vulkan.Core10.Enums.CommandPoolResetFlagBits (CommandPoolResetFlags)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkCreateCommandPool
:: FunPtr (Ptr Device_T -> Ptr CommandPoolCreateInfo -> Ptr AllocationCallbacks -> Ptr CommandPool -> IO Result) -> Ptr Device_T -> Ptr CommandPoolCreateInfo -> Ptr AllocationCallbacks -> Ptr CommandPool -> IO Result
createCommandPool :: forall io
. (MonadIO io)
=>
Device
->
CommandPoolCreateInfo
->
("allocator" ::: Maybe AllocationCallbacks)
-> io (CommandPool)
createCommandPool :: Device
-> CommandPoolCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
createCommandPool device :: Device
device createInfo :: CommandPoolCreateInfo
createInfo allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO CommandPool -> io CommandPool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CommandPool -> io CommandPool)
-> (ContT CommandPool IO CommandPool -> IO CommandPool)
-> ContT CommandPool IO CommandPool
-> io CommandPool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT CommandPool IO CommandPool -> IO CommandPool
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT CommandPool IO CommandPool -> io CommandPool)
-> ContT CommandPool IO CommandPool -> io CommandPool
forall a b. (a -> b) -> a -> b
$ do
let vkCreateCommandPoolPtr :: FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
vkCreateCommandPoolPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
pVkCreateCommandPool (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT CommandPool IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT CommandPool IO ())
-> IO () -> ContT CommandPool 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 CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
vkCreateCommandPoolPtr FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> 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 vkCreateCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkCreateCommandPool' :: Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result
vkCreateCommandPool' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result
mkVkCreateCommandPool FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result)
vkCreateCommandPoolPtr
"pCreateInfo" ::: Ptr CommandPoolCreateInfo
pCreateInfo <- ((("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO CommandPool)
-> IO CommandPool)
-> ContT
CommandPool IO ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO CommandPool)
-> IO CommandPool)
-> ContT
CommandPool IO ("pCreateInfo" ::: Ptr CommandPoolCreateInfo))
-> ((("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> IO CommandPool)
-> IO CommandPool)
-> ContT
CommandPool IO ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
forall a b. (a -> b) -> a -> b
$ CommandPoolCreateInfo
-> (("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> IO CommandPool)
-> IO CommandPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (CommandPoolCreateInfo
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT CommandPool 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 CommandPool)
-> IO CommandPool)
-> ContT CommandPool 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 CommandPool)
-> IO CommandPool)
-> ContT CommandPool IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks) -> IO CommandPool)
-> IO CommandPool)
-> ContT CommandPool IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks) -> IO CommandPool)
-> IO CommandPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pCommandPool" ::: Ptr CommandPool
pPCommandPool <- ((("pCommandPool" ::: Ptr CommandPool) -> IO CommandPool)
-> IO CommandPool)
-> ContT CommandPool IO ("pCommandPool" ::: Ptr CommandPool)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pCommandPool" ::: Ptr CommandPool) -> IO CommandPool)
-> IO CommandPool)
-> ContT CommandPool IO ("pCommandPool" ::: Ptr CommandPool))
-> ((("pCommandPool" ::: Ptr CommandPool) -> IO CommandPool)
-> IO CommandPool)
-> ContT CommandPool IO ("pCommandPool" ::: Ptr CommandPool)
forall a b. (a -> b) -> a -> b
$ IO ("pCommandPool" ::: Ptr CommandPool)
-> (("pCommandPool" ::: Ptr CommandPool) -> IO ())
-> (("pCommandPool" ::: Ptr CommandPool) -> IO CommandPool)
-> IO CommandPool
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pCommandPool" ::: Ptr CommandPool)
forall a. Int -> IO (Ptr a)
callocBytes @CommandPool 8) ("pCommandPool" ::: Ptr CommandPool) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT CommandPool IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT CommandPool IO Result)
-> IO Result -> ContT CommandPool IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkCreateCommandPool" (Ptr Device_T
-> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pCommandPool" ::: Ptr CommandPool)
-> IO Result
vkCreateCommandPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pCreateInfo" ::: Ptr CommandPoolCreateInfo
pCreateInfo "pAllocator" ::: Ptr AllocationCallbacks
pAllocator ("pCommandPool" ::: Ptr CommandPool
pPCommandPool))
IO () -> ContT CommandPool IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT CommandPool IO ())
-> IO () -> ContT CommandPool 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))
CommandPool
pCommandPool <- IO CommandPool -> ContT CommandPool IO CommandPool
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO CommandPool -> ContT CommandPool IO CommandPool)
-> IO CommandPool -> ContT CommandPool IO CommandPool
forall a b. (a -> b) -> a -> b
$ ("pCommandPool" ::: Ptr CommandPool) -> IO CommandPool
forall a. Storable a => Ptr a -> IO a
peek @CommandPool "pCommandPool" ::: Ptr CommandPool
pPCommandPool
CommandPool -> ContT CommandPool IO CommandPool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommandPool -> ContT CommandPool IO CommandPool)
-> CommandPool -> ContT CommandPool IO CommandPool
forall a b. (a -> b) -> a -> b
$ (CommandPool
pCommandPool)
withCommandPool :: forall io r . MonadIO io => Device -> CommandPoolCreateInfo -> Maybe AllocationCallbacks -> (io CommandPool -> (CommandPool -> io ()) -> r) -> r
withCommandPool :: Device
-> CommandPoolCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io CommandPool -> (CommandPool -> io ()) -> r)
-> r
withCommandPool device :: Device
device pCreateInfo :: CommandPoolCreateInfo
pCreateInfo pAllocator :: "allocator" ::: Maybe AllocationCallbacks
pAllocator b :: io CommandPool -> (CommandPool -> io ()) -> r
b =
io CommandPool -> (CommandPool -> io ()) -> r
b (Device
-> CommandPoolCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPoolCreateInfo
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io CommandPool
createCommandPool Device
device CommandPoolCreateInfo
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(CommandPool
o0) -> Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyCommandPool Device
device CommandPool
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDestroyCommandPool
:: FunPtr (Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> CommandPool -> Ptr AllocationCallbacks -> IO ()
destroyCommandPool :: forall io
. (MonadIO io)
=>
Device
->
CommandPool
->
("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyCommandPool :: Device
-> CommandPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyCommandPool device :: Device
device commandPool :: CommandPool
commandPool 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 vkDestroyCommandPoolPtr :: FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyCommandPoolPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkDestroyCommandPool (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
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyCommandPoolPtr FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> CommandPool
-> ("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 vkDestroyCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkDestroyCommandPool' :: Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyCommandPool' = FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkDestroyCommandPool FunPtr
(Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyCommandPoolPtr
"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 "vkDestroyCommandPool" (Ptr Device_T
-> CommandPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyCommandPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) (CommandPool
commandPool) "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" mkVkResetCommandPool
:: FunPtr (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result) -> Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result
resetCommandPool :: forall io
. (MonadIO io)
=>
Device
->
CommandPool
->
CommandPoolResetFlags
-> io ()
resetCommandPool :: Device -> CommandPool -> CommandPoolResetFlags -> io ()
resetCommandPool device :: Device
device commandPool :: CommandPool
commandPool flags :: CommandPoolResetFlags
flags = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
let vkResetCommandPoolPtr :: FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr = DeviceCmds
-> FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
pVkResetCommandPool (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> 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 vkResetCommandPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkResetCommandPool' :: Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result
vkResetCommandPool' = FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
-> Ptr Device_T
-> CommandPool
-> CommandPoolResetFlags
-> IO Result
mkVkResetCommandPool FunPtr
(Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result)
vkResetCommandPoolPtr
Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkResetCommandPool" (Ptr Device_T -> CommandPool -> CommandPoolResetFlags -> IO Result
vkResetCommandPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) (CommandPool
commandPool) (CommandPoolResetFlags
flags))
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 CommandPoolCreateInfo = CommandPoolCreateInfo
{
CommandPoolCreateInfo -> CommandPoolCreateFlags
flags :: CommandPoolCreateFlags
,
CommandPoolCreateInfo -> Word32
queueFamilyIndex :: Word32
}
deriving (Typeable, CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool
(CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool)
-> (CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool)
-> Eq CommandPoolCreateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool
$c/= :: CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool
== :: CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool
$c== :: CommandPoolCreateInfo -> CommandPoolCreateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (CommandPoolCreateInfo)
#endif
deriving instance Show CommandPoolCreateInfo
instance ToCStruct CommandPoolCreateInfo where
withCStruct :: CommandPoolCreateInfo
-> (("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b) -> IO b
withCStruct x :: CommandPoolCreateInfo
x f :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b
f = Int
-> Int
-> (("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b) -> IO b)
-> (("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p -> ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> CommandPoolCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p CommandPoolCreateInfo
x (("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b
f "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p)
pokeCStruct :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> CommandPoolCreateInfo -> IO b -> IO b
pokeCStruct p :: "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p CommandPoolCreateInfo{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr CommandPoolCreateFlags -> CommandPoolCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr CommandPoolCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr CommandPoolCreateFlags)) (CommandPoolCreateFlags
flags)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32)) (Word32
queueFamilyIndex)
IO b
f
cStructSize :: Int
cStructSize = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> IO b -> IO b
pokeZeroCStruct p :: "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct CommandPoolCreateInfo where
peekCStruct :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> IO CommandPoolCreateInfo
peekCStruct p :: "pCreateInfo" ::: Ptr CommandPoolCreateInfo
p = do
CommandPoolCreateFlags
flags <- Ptr CommandPoolCreateFlags -> IO CommandPoolCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @CommandPoolCreateFlags (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> Int -> Ptr CommandPoolCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr CommandPoolCreateFlags))
Word32
queueFamilyIndex <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pCreateInfo" ::: Ptr CommandPoolCreateInfo
p ("pCreateInfo" ::: Ptr CommandPoolCreateInfo) -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32))
CommandPoolCreateInfo -> IO CommandPoolCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommandPoolCreateInfo -> IO CommandPoolCreateInfo)
-> CommandPoolCreateInfo -> IO CommandPoolCreateInfo
forall a b. (a -> b) -> a -> b
$ CommandPoolCreateFlags -> Word32 -> CommandPoolCreateInfo
CommandPoolCreateInfo
CommandPoolCreateFlags
flags Word32
queueFamilyIndex
instance Storable CommandPoolCreateInfo where
sizeOf :: CommandPoolCreateInfo -> Int
sizeOf ~CommandPoolCreateInfo
_ = 24
alignment :: CommandPoolCreateInfo -> Int
alignment ~CommandPoolCreateInfo
_ = 8
peek :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> IO CommandPoolCreateInfo
peek = ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> IO CommandPoolCreateInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> CommandPoolCreateInfo -> IO ()
poke ptr :: "pCreateInfo" ::: Ptr CommandPoolCreateInfo
ptr poked :: CommandPoolCreateInfo
poked = ("pCreateInfo" ::: Ptr CommandPoolCreateInfo)
-> CommandPoolCreateInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pCreateInfo" ::: Ptr CommandPoolCreateInfo
ptr CommandPoolCreateInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero CommandPoolCreateInfo where
zero :: CommandPoolCreateInfo
zero = CommandPoolCreateFlags -> Word32 -> CommandPoolCreateInfo
CommandPoolCreateInfo
CommandPoolCreateFlags
forall a. Zero a => a
zero
Word32
forall a. Zero a => a
zero