{-# language CPP #-}
module Vulkan.Core10.DescriptorSet ( createDescriptorSetLayout
, withDescriptorSetLayout
, destroyDescriptorSetLayout
, createDescriptorPool
, withDescriptorPool
, destroyDescriptorPool
, resetDescriptorPool
, allocateDescriptorSets
, withDescriptorSets
, freeDescriptorSets
, updateDescriptorSets
, DescriptorBufferInfo(..)
, DescriptorImageInfo(..)
, WriteDescriptorSet(..)
, CopyDescriptorSet(..)
, DescriptorSetLayoutBinding(..)
, DescriptorSetLayoutCreateInfo(..)
, DescriptorPoolSize(..)
, DescriptorPoolCreateInfo(..)
, DescriptorSetAllocateInfo(..)
) where
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 Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import qualified Data.Vector (null)
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
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.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (pokeSomeCStruct)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Vulkan.Core10.Handles (Buffer)
import Vulkan.Core10.Handles (BufferView)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (DescriptorPool)
import Vulkan.Core10.Handles (DescriptorPool(..))
import Vulkan.Core10.Enums.DescriptorPoolCreateFlagBits (DescriptorPoolCreateFlags)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_inline_uniform_block (DescriptorPoolInlineUniformBlockCreateInfoEXT)
import Vulkan.Core10.Enums.DescriptorPoolResetFlags (DescriptorPoolResetFlags)
import Vulkan.Core10.Enums.DescriptorPoolResetFlags (DescriptorPoolResetFlags(..))
import Vulkan.Core10.Handles (DescriptorSet)
import Vulkan.Core10.Handles (DescriptorSet(..))
import Vulkan.Core10.Handles (DescriptorSetLayout)
import Vulkan.Core10.Handles (DescriptorSetLayout(..))
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_EXT_descriptor_indexing (DescriptorSetLayoutBindingFlagsCreateInfo)
import Vulkan.Core10.Enums.DescriptorSetLayoutCreateFlagBits (DescriptorSetLayoutCreateFlags)
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_EXT_descriptor_indexing (DescriptorSetVariableDescriptorCountAllocateInfo)
import Vulkan.Core10.Enums.DescriptorType (DescriptorType)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Dynamic (DeviceCmds(pVkAllocateDescriptorSets))
import Vulkan.Dynamic (DeviceCmds(pVkCreateDescriptorPool))
import Vulkan.Dynamic (DeviceCmds(pVkCreateDescriptorSetLayout))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyDescriptorPool))
import Vulkan.Dynamic (DeviceCmds(pVkDestroyDescriptorSetLayout))
import Vulkan.Dynamic (DeviceCmds(pVkFreeDescriptorSets))
import Vulkan.Dynamic (DeviceCmds(pVkResetDescriptorPool))
import Vulkan.Dynamic (DeviceCmds(pVkUpdateDescriptorSets))
import Vulkan.Core10.BaseType (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.Enums.ImageLayout (ImageLayout)
import Vulkan.Core10.Handles (ImageView)
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.Core10.Handles (Sampler)
import Vulkan.Core10.Enums.ShaderStageFlagBits (ShaderStageFlags)
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Exception (VulkanException(..))
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_ray_tracing (WriteDescriptorSetAccelerationStructureKHR)
import {-# SOURCE #-} Vulkan.Extensions.VK_EXT_inline_uniform_block (WriteDescriptorSetInlineUniformBlockEXT)
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_COPY_DESCRIPTOR_SET))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkCreateDescriptorSetLayout
:: FunPtr (Ptr Device_T -> Ptr (DescriptorSetLayoutCreateInfo a) -> Ptr AllocationCallbacks -> Ptr DescriptorSetLayout -> IO Result) -> Ptr Device_T -> Ptr (DescriptorSetLayoutCreateInfo a) -> Ptr AllocationCallbacks -> Ptr DescriptorSetLayout -> IO Result
createDescriptorSetLayout :: forall a io . (Extendss DescriptorSetLayoutCreateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorSetLayoutCreateInfo a -> ("allocator" ::: Maybe AllocationCallbacks) -> io (DescriptorSetLayout)
createDescriptorSetLayout :: Device
-> DescriptorSetLayoutCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorSetLayout
createDescriptorSetLayout device :: Device
device createInfo :: DescriptorSetLayoutCreateInfo a
createInfo allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO DescriptorSetLayout -> io DescriptorSetLayout
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DescriptorSetLayout -> io DescriptorSetLayout)
-> (ContT DescriptorSetLayout IO DescriptorSetLayout
-> IO DescriptorSetLayout)
-> ContT DescriptorSetLayout IO DescriptorSetLayout
-> io DescriptorSetLayout
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT DescriptorSetLayout IO DescriptorSetLayout
-> IO DescriptorSetLayout
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT DescriptorSetLayout IO DescriptorSetLayout
-> io DescriptorSetLayout)
-> ContT DescriptorSetLayout IO DescriptorSetLayout
-> io DescriptorSetLayout
forall a b. (a -> b) -> a -> b
$ do
let vkCreateDescriptorSetLayoutPtr :: FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
vkCreateDescriptorSetLayoutPtr = DeviceCmds
-> forall (a :: [*]).
FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
pVkCreateDescriptorSetLayout (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT DescriptorSetLayout IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DescriptorSetLayout IO ())
-> IO () -> ContT DescriptorSetLayout 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 (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
vkCreateDescriptorSetLayoutPtr FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> 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 vkCreateDescriptorSetLayout is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkCreateDescriptorSetLayout' :: Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result
vkCreateDescriptorSetLayout' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result
forall (a :: [*]).
FunPtr
(Ptr Device_T
-> Ptr (DescriptorSetLayoutCreateInfo a)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
-> Ptr Device_T
-> Ptr (DescriptorSetLayoutCreateInfo a)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result
mkVkCreateDescriptorSetLayout FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result)
vkCreateDescriptorSetLayoutPtr
"pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a)
pCreateInfo <- ((("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout
IO
("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout
IO
("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a)))
-> ((("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout
IO
("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
forall a b. (a -> b) -> a -> b
$ DescriptorSetLayoutCreateInfo a
-> (("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DescriptorSetLayoutCreateInfo a
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT
DescriptorSetLayout 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 DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout 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 DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayout <- ((("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout IO ("pSetLayout" ::: Ptr DescriptorSetLayout))
-> ((("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> ContT
DescriptorSetLayout IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. (a -> b) -> a -> b
$ IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> (("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO ())
-> (("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout)
-> IO DescriptorSetLayout
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a. Int -> IO (Ptr a)
callocBytes @DescriptorSetLayout 8) ("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT DescriptorSetLayout IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT DescriptorSetLayout IO Result)
-> IO Result -> ContT DescriptorSetLayout IO Result
forall a b. (a -> b) -> a -> b
$ Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO Result
vkCreateDescriptorSetLayout' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pCreateInfo" ::: Ptr (DescriptorSetLayoutCreateInfo a)
pCreateInfo "pAllocator" ::: Ptr AllocationCallbacks
pAllocator ("pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayout)
IO () -> ContT DescriptorSetLayout IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DescriptorSetLayout IO ())
-> IO () -> ContT DescriptorSetLayout 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))
DescriptorSetLayout
pSetLayout <- IO DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout)
-> IO DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout
forall a b. (a -> b) -> a -> b
$ ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSetLayout "pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayout
DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout)
-> DescriptorSetLayout
-> ContT DescriptorSetLayout IO DescriptorSetLayout
forall a b. (a -> b) -> a -> b
$ (DescriptorSetLayout
pSetLayout)
withDescriptorSetLayout :: forall a io r . (Extendss DescriptorSetLayoutCreateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorSetLayoutCreateInfo a -> Maybe AllocationCallbacks -> (io (DescriptorSetLayout) -> ((DescriptorSetLayout) -> io ()) -> r) -> r
withDescriptorSetLayout :: Device
-> DescriptorSetLayoutCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io DescriptorSetLayout -> (DescriptorSetLayout -> io ()) -> r)
-> r
withDescriptorSetLayout device :: Device
device pCreateInfo :: DescriptorSetLayoutCreateInfo a
pCreateInfo pAllocator :: "allocator" ::: Maybe AllocationCallbacks
pAllocator b :: io DescriptorSetLayout -> (DescriptorSetLayout -> io ()) -> r
b =
io DescriptorSetLayout -> (DescriptorSetLayout -> io ()) -> r
b (Device
-> DescriptorSetLayoutCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorSetLayout
forall (a :: [*]) (io :: * -> *).
(Extendss DescriptorSetLayoutCreateInfo a, PokeChain a,
MonadIO io) =>
Device
-> DescriptorSetLayoutCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorSetLayout
createDescriptorSetLayout Device
device DescriptorSetLayoutCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(DescriptorSetLayout
o0) -> Device
-> DescriptorSetLayout
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> DescriptorSetLayout
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyDescriptorSetLayout Device
device DescriptorSetLayout
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDestroyDescriptorSetLayout
:: FunPtr (Ptr Device_T -> DescriptorSetLayout -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> DescriptorSetLayout -> Ptr AllocationCallbacks -> IO ()
destroyDescriptorSetLayout :: forall io . MonadIO io => Device -> DescriptorSetLayout -> ("allocator" ::: Maybe AllocationCallbacks) -> io ()
destroyDescriptorSetLayout :: Device
-> DescriptorSetLayout
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyDescriptorSetLayout device :: Device
device descriptorSetLayout :: DescriptorSetLayout
descriptorSetLayout 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 vkDestroyDescriptorSetLayoutPtr :: FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorSetLayoutPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkDestroyDescriptorSetLayout (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
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorSetLayoutPtr FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("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 vkDestroyDescriptorSetLayout is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkDestroyDescriptorSetLayout' :: Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyDescriptorSetLayout' = FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkDestroyDescriptorSetLayout FunPtr
(Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorSetLayoutPtr
"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
$ Ptr Device_T
-> DescriptorSetLayout
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyDescriptorSetLayout' (Device -> Ptr Device_T
deviceHandle (Device
device)) (DescriptorSetLayout
descriptorSetLayout) "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" mkVkCreateDescriptorPool
:: FunPtr (Ptr Device_T -> Ptr (DescriptorPoolCreateInfo a) -> Ptr AllocationCallbacks -> Ptr DescriptorPool -> IO Result) -> Ptr Device_T -> Ptr (DescriptorPoolCreateInfo a) -> Ptr AllocationCallbacks -> Ptr DescriptorPool -> IO Result
createDescriptorPool :: forall a io . (Extendss DescriptorPoolCreateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorPoolCreateInfo a -> ("allocator" ::: Maybe AllocationCallbacks) -> io (DescriptorPool)
createDescriptorPool :: Device
-> DescriptorPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorPool
createDescriptorPool device :: Device
device createInfo :: DescriptorPoolCreateInfo a
createInfo allocator :: "allocator" ::: Maybe AllocationCallbacks
allocator = IO DescriptorPool -> io DescriptorPool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DescriptorPool -> io DescriptorPool)
-> (ContT DescriptorPool IO DescriptorPool -> IO DescriptorPool)
-> ContT DescriptorPool IO DescriptorPool
-> io DescriptorPool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT DescriptorPool IO DescriptorPool -> IO DescriptorPool
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT DescriptorPool IO DescriptorPool -> io DescriptorPool)
-> ContT DescriptorPool IO DescriptorPool -> io DescriptorPool
forall a b. (a -> b) -> a -> b
$ do
let vkCreateDescriptorPoolPtr :: FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
vkCreateDescriptorPoolPtr = DeviceCmds
-> forall (a :: [*]).
FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
pVkCreateDescriptorPool (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT DescriptorPool IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DescriptorPool IO ())
-> IO () -> ContT DescriptorPool 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 (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
vkCreateDescriptorPoolPtr FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> 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 vkCreateDescriptorPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkCreateDescriptorPool' :: Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result
vkCreateDescriptorPool' = FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
-> Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result
forall (a :: [*]).
FunPtr
(Ptr Device_T
-> Ptr (DescriptorPoolCreateInfo a)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
-> Ptr Device_T
-> Ptr (DescriptorPoolCreateInfo a)
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result
mkVkCreateDescriptorPool FunPtr
(Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result)
vkCreateDescriptorPoolPtr
"pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a)
pCreateInfo <- ((("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool
IO
("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool
IO
("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a)))
-> ((("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool
IO
("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
forall a b. (a -> b) -> a -> b
$ DescriptorPoolCreateInfo a
-> (("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> IO DescriptorPool)
-> IO DescriptorPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DescriptorPoolCreateInfo a
createInfo)
"pAllocator" ::: Ptr AllocationCallbacks
pAllocator <- case ("allocator" ::: Maybe AllocationCallbacks
allocator) of
Nothing -> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ContT
DescriptorPool 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 DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool 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 DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool IO ("pAllocator" ::: Ptr AllocationCallbacks))
-> ((("pAllocator" ::: Ptr AllocationCallbacks)
-> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool IO ("pAllocator" ::: Ptr AllocationCallbacks)
forall a b. (a -> b) -> a -> b
$ AllocationCallbacks
-> (("pAllocator" ::: Ptr AllocationCallbacks)
-> IO DescriptorPool)
-> IO DescriptorPool
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (AllocationCallbacks
j)
"pDescriptorPool" ::: Ptr DescriptorPool
pPDescriptorPool <- ((("pDescriptorPool" ::: Ptr DescriptorPool) -> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool IO ("pDescriptorPool" ::: Ptr DescriptorPool)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDescriptorPool" ::: Ptr DescriptorPool) -> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool IO ("pDescriptorPool" ::: Ptr DescriptorPool))
-> ((("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO DescriptorPool)
-> IO DescriptorPool)
-> ContT
DescriptorPool IO ("pDescriptorPool" ::: Ptr DescriptorPool)
forall a b. (a -> b) -> a -> b
$ IO ("pDescriptorPool" ::: Ptr DescriptorPool)
-> (("pDescriptorPool" ::: Ptr DescriptorPool) -> IO ())
-> (("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO DescriptorPool)
-> IO DescriptorPool
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pDescriptorPool" ::: Ptr DescriptorPool)
forall a. Int -> IO (Ptr a)
callocBytes @DescriptorPool 8) ("pDescriptorPool" ::: Ptr DescriptorPool) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT DescriptorPool IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT DescriptorPool IO Result)
-> IO Result -> ContT DescriptorPool IO Result
forall a b. (a -> b) -> a -> b
$ Ptr Device_T
-> ("pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a))
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> ("pDescriptorPool" ::: Ptr DescriptorPool)
-> IO Result
vkCreateDescriptorPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pCreateInfo" ::: Ptr (DescriptorPoolCreateInfo a)
pCreateInfo "pAllocator" ::: Ptr AllocationCallbacks
pAllocator ("pDescriptorPool" ::: Ptr DescriptorPool
pPDescriptorPool)
IO () -> ContT DescriptorPool IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DescriptorPool IO ())
-> IO () -> ContT DescriptorPool 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))
DescriptorPool
pDescriptorPool <- IO DescriptorPool -> ContT DescriptorPool IO DescriptorPool
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO DescriptorPool -> ContT DescriptorPool IO DescriptorPool)
-> IO DescriptorPool -> ContT DescriptorPool IO DescriptorPool
forall a b. (a -> b) -> a -> b
$ ("pDescriptorPool" ::: Ptr DescriptorPool) -> IO DescriptorPool
forall a. Storable a => Ptr a -> IO a
peek @DescriptorPool "pDescriptorPool" ::: Ptr DescriptorPool
pPDescriptorPool
DescriptorPool -> ContT DescriptorPool IO DescriptorPool
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorPool -> ContT DescriptorPool IO DescriptorPool)
-> DescriptorPool -> ContT DescriptorPool IO DescriptorPool
forall a b. (a -> b) -> a -> b
$ (DescriptorPool
pDescriptorPool)
withDescriptorPool :: forall a io r . (Extendss DescriptorPoolCreateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorPoolCreateInfo a -> Maybe AllocationCallbacks -> (io (DescriptorPool) -> ((DescriptorPool) -> io ()) -> r) -> r
withDescriptorPool :: Device
-> DescriptorPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> (io DescriptorPool -> (DescriptorPool -> io ()) -> r)
-> r
withDescriptorPool device :: Device
device pCreateInfo :: DescriptorPoolCreateInfo a
pCreateInfo pAllocator :: "allocator" ::: Maybe AllocationCallbacks
pAllocator b :: io DescriptorPool -> (DescriptorPool -> io ()) -> r
b =
io DescriptorPool -> (DescriptorPool -> io ()) -> r
b (Device
-> DescriptorPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorPool
forall (a :: [*]) (io :: * -> *).
(Extendss DescriptorPoolCreateInfo a, PokeChain a, MonadIO io) =>
Device
-> DescriptorPoolCreateInfo a
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io DescriptorPool
createDescriptorPool Device
device DescriptorPoolCreateInfo a
pCreateInfo "allocator" ::: Maybe AllocationCallbacks
pAllocator)
(\(DescriptorPool
o0) -> Device
-> DescriptorPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> DescriptorPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyDescriptorPool Device
device DescriptorPool
o0 "allocator" ::: Maybe AllocationCallbacks
pAllocator)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDestroyDescriptorPool
:: FunPtr (Ptr Device_T -> DescriptorPool -> Ptr AllocationCallbacks -> IO ()) -> Ptr Device_T -> DescriptorPool -> Ptr AllocationCallbacks -> IO ()
destroyDescriptorPool :: forall io . MonadIO io => Device -> DescriptorPool -> ("allocator" ::: Maybe AllocationCallbacks) -> io ()
destroyDescriptorPool :: Device
-> DescriptorPool
-> ("allocator" ::: Maybe AllocationCallbacks)
-> io ()
destroyDescriptorPool device :: Device
device descriptorPool :: DescriptorPool
descriptorPool 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 vkDestroyDescriptorPoolPtr :: FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorPoolPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
pVkDestroyDescriptorPool (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
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorPoolPtr FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("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 vkDestroyDescriptorPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkDestroyDescriptorPool' :: Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyDescriptorPool' = FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
-> Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
mkVkDestroyDescriptorPool FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ())
vkDestroyDescriptorPoolPtr
"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
$ Ptr Device_T
-> DescriptorPool
-> ("pAllocator" ::: Ptr AllocationCallbacks)
-> IO ()
vkDestroyDescriptorPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) (DescriptorPool
descriptorPool) "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" mkVkResetDescriptorPool
:: FunPtr (Ptr Device_T -> DescriptorPool -> DescriptorPoolResetFlags -> IO Result) -> Ptr Device_T -> DescriptorPool -> DescriptorPoolResetFlags -> IO Result
resetDescriptorPool :: forall io . MonadIO io => Device -> DescriptorPool -> DescriptorPoolResetFlags -> io ()
resetDescriptorPool :: Device -> DescriptorPool -> DescriptorPoolResetFlags -> io ()
resetDescriptorPool device :: Device
device descriptorPool :: DescriptorPool
descriptorPool flags :: DescriptorPoolResetFlags
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 vkResetDescriptorPoolPtr :: FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
vkResetDescriptorPoolPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
pVkResetDescriptorPool (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
vkResetDescriptorPoolPtr FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
-> FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> 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 vkResetDescriptorPool is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkResetDescriptorPool' :: Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result
vkResetDescriptorPool' = FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
-> Ptr Device_T
-> DescriptorPool
-> DescriptorPoolResetFlags
-> IO Result
mkVkResetDescriptorPool FunPtr
(Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result)
vkResetDescriptorPoolPtr
Result
_ <- Ptr Device_T
-> DescriptorPool -> DescriptorPoolResetFlags -> IO Result
vkResetDescriptorPool' (Device -> Ptr Device_T
deviceHandle (Device
device)) (DescriptorPool
descriptorPool) (DescriptorPoolResetFlags
flags)
() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkAllocateDescriptorSets
:: FunPtr (Ptr Device_T -> Ptr (DescriptorSetAllocateInfo a) -> Ptr DescriptorSet -> IO Result) -> Ptr Device_T -> Ptr (DescriptorSetAllocateInfo a) -> Ptr DescriptorSet -> IO Result
allocateDescriptorSets :: forall a io . (Extendss DescriptorSetAllocateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorSetAllocateInfo a -> io (("descriptorSets" ::: Vector DescriptorSet))
allocateDescriptorSets :: Device
-> DescriptorSetAllocateInfo a
-> io ("descriptorSets" ::: Vector DescriptorSet)
allocateDescriptorSets device :: Device
device allocateInfo :: DescriptorSetAllocateInfo a
allocateInfo = IO ("descriptorSets" ::: Vector DescriptorSet)
-> io ("descriptorSets" ::: Vector DescriptorSet)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ("descriptorSets" ::: Vector DescriptorSet)
-> io ("descriptorSets" ::: Vector DescriptorSet))
-> (ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
-> io ("descriptorSets" ::: Vector DescriptorSet)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
-> io ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
-> io ("descriptorSets" ::: Vector DescriptorSet)
forall a b. (a -> b) -> a -> b
$ do
let vkAllocateDescriptorSetsPtr :: FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkAllocateDescriptorSetsPtr = DeviceCmds
-> forall (a :: [*]).
FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
pVkAllocateDescriptorSets (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) IO ())
-> IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkAllocateDescriptorSetsPtr FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> 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 vkAllocateDescriptorSets is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkAllocateDescriptorSets' :: Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
vkAllocateDescriptorSets' = FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
forall (a :: [*]).
FunPtr
(Ptr Device_T
-> Ptr (DescriptorSetAllocateInfo a)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> Ptr Device_T
-> Ptr (DescriptorSetAllocateInfo a)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
mkVkAllocateDescriptorSets FunPtr
(Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkAllocateDescriptorSetsPtr
"pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a)
pAllocateInfo <- ((("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a)))
-> ((("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
forall a b. (a -> b) -> a -> b
$ DescriptorSetAllocateInfo a
-> (("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet)
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DescriptorSetAllocateInfo a
allocateInfo)
"pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets <- ((("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pDescriptorSets" ::: Ptr DescriptorSet)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pDescriptorSets" ::: Ptr DescriptorSet))
-> ((("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("pDescriptorSets" ::: Ptr DescriptorSet)
forall a b. (a -> b) -> a -> b
$ IO ("pDescriptorSets" ::: Ptr DescriptorSet)
-> (("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ())
-> (("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pDescriptorSets" ::: Ptr DescriptorSet)
forall a. Int -> IO (Ptr a)
callocBytes @DescriptorSet ((Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int)
-> (DescriptorSetAllocateInfo a -> Int)
-> DescriptorSetAllocateInfo a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector DescriptorSetLayout -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayout -> Int)
-> (DescriptorSetAllocateInfo a -> Vector DescriptorSetLayout)
-> DescriptorSetAllocateInfo a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DescriptorSetAllocateInfo a -> Vector DescriptorSetLayout
forall (es :: [*]).
DescriptorSetAllocateInfo es -> Vector DescriptorSetLayout
setLayouts (DescriptorSetAllocateInfo a -> Int)
-> DescriptorSetAllocateInfo a -> Int
forall a b. (a -> b) -> a -> b
$ (DescriptorSetAllocateInfo a
allocateInfo)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8)) ("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result
-> ContT ("descriptorSets" ::: Vector DescriptorSet) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT ("descriptorSets" ::: Vector DescriptorSet) IO Result)
-> IO Result
-> ContT ("descriptorSets" ::: Vector DescriptorSet) IO Result
forall a b. (a -> b) -> a -> b
$ Ptr Device_T
-> ("pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a))
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
vkAllocateDescriptorSets' (Device -> Ptr Device_T
deviceHandle (Device
device)) "pAllocateInfo" ::: Ptr (DescriptorSetAllocateInfo a)
pAllocateInfo ("pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets)
IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) IO ())
-> IO () -> ContT ("descriptorSets" ::: Vector DescriptorSet) 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))
"descriptorSets" ::: Vector DescriptorSet
pDescriptorSets <- IO ("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet))
-> IO ("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO DescriptorSet)
-> IO ("descriptorSets" ::: Vector DescriptorSet)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Int -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int)
-> (DescriptorSetAllocateInfo a -> Int)
-> DescriptorSetAllocateInfo a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Vector DescriptorSetLayout -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayout -> Int)
-> (DescriptorSetAllocateInfo a -> Vector DescriptorSetLayout)
-> DescriptorSetAllocateInfo a
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DescriptorSetAllocateInfo a -> Vector DescriptorSetLayout
forall (es :: [*]).
DescriptorSetAllocateInfo es -> Vector DescriptorSetLayout
setLayouts (DescriptorSetAllocateInfo a -> Int)
-> DescriptorSetAllocateInfo a -> Int
forall a b. (a -> b) -> a -> b
$ (DescriptorSetAllocateInfo a
allocateInfo)) (\i :: Int
i -> ("pDescriptorSets" ::: Ptr DescriptorSet) -> IO DescriptorSet
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSet (("pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets ("pDescriptorSets" ::: Ptr DescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSet)))
("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet))
-> ("descriptorSets" ::: Vector DescriptorSet)
-> ContT
("descriptorSets" ::: Vector DescriptorSet)
IO
("descriptorSets" ::: Vector DescriptorSet)
forall a b. (a -> b) -> a -> b
$ ("descriptorSets" ::: Vector DescriptorSet
pDescriptorSets)
withDescriptorSets :: forall a io r . (Extendss DescriptorSetAllocateInfo a, PokeChain a, MonadIO io) => Device -> DescriptorSetAllocateInfo a -> (io (Vector DescriptorSet) -> ((Vector DescriptorSet) -> io ()) -> r) -> r
withDescriptorSets :: Device
-> DescriptorSetAllocateInfo a
-> (io ("descriptorSets" ::: Vector DescriptorSet)
-> (("descriptorSets" ::: Vector DescriptorSet) -> io ()) -> r)
-> r
withDescriptorSets device :: Device
device pAllocateInfo :: DescriptorSetAllocateInfo a
pAllocateInfo b :: io ("descriptorSets" ::: Vector DescriptorSet)
-> (("descriptorSets" ::: Vector DescriptorSet) -> io ()) -> r
b =
io ("descriptorSets" ::: Vector DescriptorSet)
-> (("descriptorSets" ::: Vector DescriptorSet) -> io ()) -> r
b (Device
-> DescriptorSetAllocateInfo a
-> io ("descriptorSets" ::: Vector DescriptorSet)
forall (a :: [*]) (io :: * -> *).
(Extendss DescriptorSetAllocateInfo a, PokeChain a, MonadIO io) =>
Device
-> DescriptorSetAllocateInfo a
-> io ("descriptorSets" ::: Vector DescriptorSet)
allocateDescriptorSets Device
device DescriptorSetAllocateInfo a
pAllocateInfo)
(\("descriptorSets" ::: Vector DescriptorSet
o0) -> Device
-> DescriptorPool
-> ("descriptorSets" ::: Vector DescriptorSet)
-> io ()
forall (io :: * -> *).
MonadIO io =>
Device
-> DescriptorPool
-> ("descriptorSets" ::: Vector DescriptorSet)
-> io ()
freeDescriptorSets Device
device (DescriptorSetAllocateInfo a -> DescriptorPool
forall (es :: [*]). DescriptorSetAllocateInfo es -> DescriptorPool
descriptorPool (DescriptorSetAllocateInfo a
pAllocateInfo :: DescriptorSetAllocateInfo a)) "descriptorSets" ::: Vector DescriptorSet
o0)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkFreeDescriptorSets
:: FunPtr (Ptr Device_T -> DescriptorPool -> Word32 -> Ptr DescriptorSet -> IO Result) -> Ptr Device_T -> DescriptorPool -> Word32 -> Ptr DescriptorSet -> IO Result
freeDescriptorSets :: forall io . MonadIO io => Device -> DescriptorPool -> ("descriptorSets" ::: Vector DescriptorSet) -> io ()
freeDescriptorSets :: Device
-> DescriptorPool
-> ("descriptorSets" ::: Vector DescriptorSet)
-> io ()
freeDescriptorSets device :: Device
device descriptorPool :: DescriptorPool
descriptorPool descriptorSets :: "descriptorSets" ::: Vector DescriptorSet
descriptorSets = 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 vkFreeDescriptorSetsPtr :: FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkFreeDescriptorSetsPtr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
pVkFreeDescriptorSets (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
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkFreeDescriptorSetsPtr FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> 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 vkFreeDescriptorSets is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkFreeDescriptorSets' :: Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
vkFreeDescriptorSets' = FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
-> Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
mkVkFreeDescriptorSets FunPtr
(Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result)
vkFreeDescriptorSetsPtr
"pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets <- ((("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ()) -> IO ())
-> ContT () IO ("pDescriptorSets" ::: Ptr DescriptorSet)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ()) -> IO ())
-> ContT () IO ("pDescriptorSets" ::: Ptr DescriptorSet))
-> ((("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ()) -> IO ())
-> ContT () IO ("pDescriptorSets" ::: Ptr DescriptorSet)
forall a b. (a -> b) -> a -> b
$ Int
-> Int
-> (("pDescriptorSets" ::: Ptr DescriptorSet) -> IO ())
-> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorSet ((("descriptorSets" ::: Vector DescriptorSet) -> Int
forall a. Vector a -> Int
Data.Vector.length ("descriptorSets" ::: Vector DescriptorSet
descriptorSets)) 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 -> DescriptorSet -> IO ())
-> ("descriptorSets" ::: Vector DescriptorSet) -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorSet
e -> ("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets ("pDescriptorSets" ::: Ptr DescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSet) (DescriptorSet
e)) ("descriptorSets" ::: Vector DescriptorSet
descriptorSets)
Result
_ <- 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
$ Ptr Device_T
-> DescriptorPool
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorSets" ::: Ptr DescriptorSet)
-> IO Result
vkFreeDescriptorSets' (Device -> Ptr Device_T
deviceHandle (Device
device)) (DescriptorPool
descriptorPool) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("descriptorSets" ::: Vector DescriptorSet) -> Int
forall a. Vector a -> Int
Data.Vector.length (("descriptorSets" ::: Vector DescriptorSet) -> Int)
-> ("descriptorSets" ::: Vector DescriptorSet) -> Int
forall a b. (a -> b) -> a -> b
$ ("descriptorSets" ::: Vector DescriptorSet
descriptorSets)) :: Word32)) ("pDescriptorSets" ::: Ptr DescriptorSet
pPDescriptorSets)
() -> 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" mkVkUpdateDescriptorSets
:: FunPtr (Ptr Device_T -> Word32 -> Ptr (WriteDescriptorSet a) -> Word32 -> Ptr CopyDescriptorSet -> IO ()) -> Ptr Device_T -> Word32 -> Ptr (WriteDescriptorSet a) -> Word32 -> Ptr CopyDescriptorSet -> IO ()
updateDescriptorSets :: forall io . MonadIO io => Device -> ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet)) -> ("descriptorCopies" ::: Vector CopyDescriptorSet) -> io ()
updateDescriptorSets :: Device
-> ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> ("descriptorCopies" ::: Vector CopyDescriptorSet)
-> io ()
updateDescriptorSets device :: Device
device descriptorWrites :: "descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet)
descriptorWrites descriptorCopies :: "descriptorCopies" ::: Vector CopyDescriptorSet
descriptorCopies = 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 vkUpdateDescriptorSetsPtr :: FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
vkUpdateDescriptorSetsPtr = DeviceCmds
-> forall (a :: [*]).
FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet a))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
pVkUpdateDescriptorSets (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
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
vkUpdateDescriptorSetsPtr FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
-> FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> 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 vkUpdateDescriptorSets is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkUpdateDescriptorSets' :: Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ()
vkUpdateDescriptorSets' = FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
-> Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ()
forall (a :: [*]).
FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> Ptr (WriteDescriptorSet a)
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
-> Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> Ptr (WriteDescriptorSet a)
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ()
mkVkUpdateDescriptorSets FunPtr
(Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ())
vkUpdateDescriptorSetsPtr
"pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)
pPDescriptorWrites <- ((("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)) -> IO ())
-> IO ())
-> ContT
() IO ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)) -> IO ())
-> IO ())
-> ContT
() IO ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)))
-> ((("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> IO ())
-> IO ())
-> ContT
() IO ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
forall a b. (a -> b) -> a -> b
$ Int
-> Int
-> (("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> IO ())
-> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @(WriteDescriptorSet _) ((("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> Int
forall a. Vector a -> Int
Data.Vector.length ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet)
descriptorWrites)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 64) 8
(Int -> SomeStruct WriteDescriptorSet -> ContT () IO ())
-> ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> ContT () IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: SomeStruct WriteDescriptorSet
e -> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ()) -> IO ()) -> ContT () IO ())
-> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (SomeStruct WriteDescriptorSet)
-> SomeStruct WriteDescriptorSet -> IO () -> IO ()
forall (a :: [*] -> *) b.
(forall (es :: [*]).
(Extendss a es, PokeChain es) =>
ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> Ptr (SomeStruct WriteDescriptorSet)
forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)
pPDescriptorWrites ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> Int -> Ptr (WriteDescriptorSet _)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (64 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (WriteDescriptorSet _))) (SomeStruct WriteDescriptorSet
e) (IO () -> IO ())
-> ((() -> IO ()) -> IO ()) -> (() -> IO ()) -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ())) ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet)
descriptorWrites)
"pDescriptorCopies" ::: Ptr CopyDescriptorSet
pPDescriptorCopies <- ((("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO ())
-> IO ())
-> ContT () IO ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO ())
-> IO ())
-> ContT () IO ("pDescriptorCopies" ::: Ptr CopyDescriptorSet))
-> ((("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO ())
-> IO ())
-> ContT () IO ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
forall a b. (a -> b) -> a -> b
$ Int
-> Int
-> (("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO ())
-> IO ()
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @CopyDescriptorSet ((("descriptorCopies" ::: Vector CopyDescriptorSet) -> Int
forall a. Vector a -> Int
Data.Vector.length ("descriptorCopies" ::: Vector CopyDescriptorSet
descriptorCopies)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 56) 8
(Int -> CopyDescriptorSet -> ContT () IO ())
-> ("descriptorCopies" ::: Vector CopyDescriptorSet)
-> ContT () IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: CopyDescriptorSet
e -> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO ()) -> IO ()) -> ContT () IO ())
-> ((() -> IO ()) -> IO ()) -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> CopyDescriptorSet -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct ("pDescriptorCopies" ::: Ptr CopyDescriptorSet
pPDescriptorCopies ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorCopies" ::: Ptr CopyDescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (56 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr CopyDescriptorSet) (CopyDescriptorSet
e) (IO () -> IO ())
-> ((() -> IO ()) -> IO ()) -> (() -> IO ()) -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ())) ("descriptorCopies" ::: Vector CopyDescriptorSet
descriptorCopies)
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
$ Ptr Device_T
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any))
-> ("descriptorSetCount" ::: Word32)
-> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO ()
vkUpdateDescriptorSets' (Device -> Ptr Device_T
deviceHandle (Device
device)) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> Int
forall a. Vector a -> Int
Data.Vector.length (("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> Int)
-> ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet))
-> Int
forall a b. (a -> b) -> a -> b
$ ("descriptorWrites" ::: Vector (SomeStruct WriteDescriptorSet)
descriptorWrites)) :: Word32)) ("pDescriptorWrites" ::: Ptr (WriteDescriptorSet Any)
pPDescriptorWrites) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (("descriptorCopies" ::: Vector CopyDescriptorSet) -> Int
forall a. Vector a -> Int
Data.Vector.length (("descriptorCopies" ::: Vector CopyDescriptorSet) -> Int)
-> ("descriptorCopies" ::: Vector CopyDescriptorSet) -> Int
forall a b. (a -> b) -> a -> b
$ ("descriptorCopies" ::: Vector CopyDescriptorSet
descriptorCopies)) :: Word32)) ("pDescriptorCopies" ::: Ptr CopyDescriptorSet
pPDescriptorCopies)
() -> ContT () IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> ContT () IO ()) -> () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ ()
data DescriptorBufferInfo = DescriptorBufferInfo
{
DescriptorBufferInfo -> Buffer
buffer :: Buffer
,
DescriptorBufferInfo -> DeviceSize
offset :: DeviceSize
,
DescriptorBufferInfo -> DeviceSize
range :: DeviceSize
}
deriving (Typeable)
deriving instance Show DescriptorBufferInfo
instance ToCStruct DescriptorBufferInfo where
withCStruct :: DescriptorBufferInfo -> (Ptr DescriptorBufferInfo -> IO b) -> IO b
withCStruct x :: DescriptorBufferInfo
x f :: Ptr DescriptorBufferInfo -> IO b
f = Int -> Int -> (Ptr DescriptorBufferInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr DescriptorBufferInfo -> IO b) -> IO b)
-> (Ptr DescriptorBufferInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr DescriptorBufferInfo
p -> Ptr DescriptorBufferInfo -> DescriptorBufferInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorBufferInfo
p DescriptorBufferInfo
x (Ptr DescriptorBufferInfo -> IO b
f Ptr DescriptorBufferInfo
p)
pokeCStruct :: Ptr DescriptorBufferInfo -> DescriptorBufferInfo -> IO b -> IO b
pokeCStruct p :: Ptr DescriptorBufferInfo
p DescriptorBufferInfo{..} f :: IO b
f = do
Ptr Buffer -> Buffer -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Buffer)) (Buffer
buffer)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr DeviceSize)) (DeviceSize
offset)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DeviceSize)) (DeviceSize
range)
IO b
f
cStructSize :: Int
cStructSize = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr DescriptorBufferInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr DescriptorBufferInfo
p f :: IO b
f = do
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
Ptr DeviceSize -> DeviceSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DeviceSize)) (DeviceSize
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct DescriptorBufferInfo where
peekCStruct :: Ptr DescriptorBufferInfo -> IO DescriptorBufferInfo
peekCStruct p :: Ptr DescriptorBufferInfo
p = do
Buffer
buffer <- Ptr Buffer -> IO Buffer
forall a. Storable a => Ptr a -> IO a
peek @Buffer ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr Buffer
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Buffer))
DeviceSize
offset <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr DeviceSize))
DeviceSize
range <- Ptr DeviceSize -> IO DeviceSize
forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr DescriptorBufferInfo
p Ptr DescriptorBufferInfo -> Int -> Ptr DeviceSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DeviceSize))
DescriptorBufferInfo -> IO DescriptorBufferInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorBufferInfo -> IO DescriptorBufferInfo)
-> DescriptorBufferInfo -> IO DescriptorBufferInfo
forall a b. (a -> b) -> a -> b
$ Buffer -> DeviceSize -> DeviceSize -> DescriptorBufferInfo
DescriptorBufferInfo
Buffer
buffer DeviceSize
offset DeviceSize
range
instance Storable DescriptorBufferInfo where
sizeOf :: DescriptorBufferInfo -> Int
sizeOf ~DescriptorBufferInfo
_ = 24
alignment :: DescriptorBufferInfo -> Int
alignment ~DescriptorBufferInfo
_ = 8
peek :: Ptr DescriptorBufferInfo -> IO DescriptorBufferInfo
peek = Ptr DescriptorBufferInfo -> IO DescriptorBufferInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr DescriptorBufferInfo -> DescriptorBufferInfo -> IO ()
poke ptr :: Ptr DescriptorBufferInfo
ptr poked :: DescriptorBufferInfo
poked = Ptr DescriptorBufferInfo -> DescriptorBufferInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorBufferInfo
ptr DescriptorBufferInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero DescriptorBufferInfo where
zero :: DescriptorBufferInfo
zero = Buffer -> DeviceSize -> DeviceSize -> DescriptorBufferInfo
DescriptorBufferInfo
Buffer
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
DeviceSize
forall a. Zero a => a
zero
data DescriptorImageInfo = DescriptorImageInfo
{
DescriptorImageInfo -> Sampler
sampler :: Sampler
,
DescriptorImageInfo -> ImageView
imageView :: ImageView
,
DescriptorImageInfo -> ImageLayout
imageLayout :: ImageLayout
}
deriving (Typeable)
deriving instance Show DescriptorImageInfo
instance ToCStruct DescriptorImageInfo where
withCStruct :: DescriptorImageInfo -> (Ptr DescriptorImageInfo -> IO b) -> IO b
withCStruct x :: DescriptorImageInfo
x f :: Ptr DescriptorImageInfo -> IO b
f = Int -> Int -> (Ptr DescriptorImageInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr DescriptorImageInfo -> IO b) -> IO b)
-> (Ptr DescriptorImageInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr DescriptorImageInfo
p -> Ptr DescriptorImageInfo -> DescriptorImageInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorImageInfo
p DescriptorImageInfo
x (Ptr DescriptorImageInfo -> IO b
f Ptr DescriptorImageInfo
p)
pokeCStruct :: Ptr DescriptorImageInfo -> DescriptorImageInfo -> IO b -> IO b
pokeCStruct p :: Ptr DescriptorImageInfo
p DescriptorImageInfo{..} f :: IO b
f = do
Ptr Sampler -> Sampler -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr Sampler
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Sampler)) (Sampler
sampler)
Ptr ImageView -> ImageView -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageView
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr ImageView)) (ImageView
imageView)
Ptr ImageLayout -> ImageLayout -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageLayout
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ImageLayout)) (ImageLayout
imageLayout)
IO b
f
cStructSize :: Int
cStructSize = 24
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr DescriptorImageInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr DescriptorImageInfo
p f :: IO b
f = do
Ptr Sampler -> Sampler -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr Sampler
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Sampler)) (Sampler
forall a. Zero a => a
zero)
Ptr ImageView -> ImageView -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageView
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr ImageView)) (ImageView
forall a. Zero a => a
zero)
Ptr ImageLayout -> ImageLayout -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageLayout
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ImageLayout)) (ImageLayout
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct DescriptorImageInfo where
peekCStruct :: Ptr DescriptorImageInfo -> IO DescriptorImageInfo
peekCStruct p :: Ptr DescriptorImageInfo
p = do
Sampler
sampler <- Ptr Sampler -> IO Sampler
forall a. Storable a => Ptr a -> IO a
peek @Sampler ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr Sampler
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Sampler))
ImageView
imageView <- Ptr ImageView -> IO ImageView
forall a. Storable a => Ptr a -> IO a
peek @ImageView ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageView
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr ImageView))
ImageLayout
imageLayout <- Ptr ImageLayout -> IO ImageLayout
forall a. Storable a => Ptr a -> IO a
peek @ImageLayout ((Ptr DescriptorImageInfo
p Ptr DescriptorImageInfo -> Int -> Ptr ImageLayout
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ImageLayout))
DescriptorImageInfo -> IO DescriptorImageInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorImageInfo -> IO DescriptorImageInfo)
-> DescriptorImageInfo -> IO DescriptorImageInfo
forall a b. (a -> b) -> a -> b
$ Sampler -> ImageView -> ImageLayout -> DescriptorImageInfo
DescriptorImageInfo
Sampler
sampler ImageView
imageView ImageLayout
imageLayout
instance Storable DescriptorImageInfo where
sizeOf :: DescriptorImageInfo -> Int
sizeOf ~DescriptorImageInfo
_ = 24
alignment :: DescriptorImageInfo -> Int
alignment ~DescriptorImageInfo
_ = 8
peek :: Ptr DescriptorImageInfo -> IO DescriptorImageInfo
peek = Ptr DescriptorImageInfo -> IO DescriptorImageInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr DescriptorImageInfo -> DescriptorImageInfo -> IO ()
poke ptr :: Ptr DescriptorImageInfo
ptr poked :: DescriptorImageInfo
poked = Ptr DescriptorImageInfo -> DescriptorImageInfo -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorImageInfo
ptr DescriptorImageInfo
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero DescriptorImageInfo where
zero :: DescriptorImageInfo
zero = Sampler -> ImageView -> ImageLayout -> DescriptorImageInfo
DescriptorImageInfo
Sampler
forall a. Zero a => a
zero
ImageView
forall a. Zero a => a
zero
ImageLayout
forall a. Zero a => a
zero
data WriteDescriptorSet (es :: [Type]) = WriteDescriptorSet
{
WriteDescriptorSet es -> Chain es
next :: Chain es
,
WriteDescriptorSet es -> DescriptorSet
dstSet :: DescriptorSet
,
WriteDescriptorSet es -> "descriptorSetCount" ::: Word32
dstBinding :: Word32
,
WriteDescriptorSet es -> "descriptorSetCount" ::: Word32
dstArrayElement :: Word32
,
WriteDescriptorSet es -> "descriptorSetCount" ::: Word32
descriptorCount :: Word32
,
WriteDescriptorSet es -> DescriptorType
descriptorType :: DescriptorType
,
WriteDescriptorSet es -> Vector DescriptorImageInfo
imageInfo :: Vector DescriptorImageInfo
,
WriteDescriptorSet es -> Vector DescriptorBufferInfo
bufferInfo :: Vector DescriptorBufferInfo
,
WriteDescriptorSet es -> Vector BufferView
texelBufferView :: Vector BufferView
}
deriving (Typeable)
deriving instance Show (Chain es) => Show (WriteDescriptorSet es)
instance Extensible WriteDescriptorSet where
extensibleType :: StructureType
extensibleType = StructureType
STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
setNext :: WriteDescriptorSet ds -> Chain es -> WriteDescriptorSet es
setNext x :: WriteDescriptorSet ds
x next :: Chain es
next = WriteDescriptorSet ds
x{$sel:next:WriteDescriptorSet :: Chain es
next = Chain es
next}
getNext :: WriteDescriptorSet es -> Chain es
getNext WriteDescriptorSet{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends WriteDescriptorSet e => b) -> Maybe b
extends :: proxy e -> (Extends WriteDescriptorSet e => b) -> Maybe b
extends _ f :: Extends WriteDescriptorSet e => b
f
| Just Refl <- (Typeable e,
Typeable WriteDescriptorSetAccelerationStructureKHR) =>
Maybe (e :~: WriteDescriptorSetAccelerationStructureKHR)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @WriteDescriptorSetAccelerationStructureKHR = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends WriteDescriptorSet e => b
f
| Just Refl <- (Typeable e, Typeable WriteDescriptorSetInlineUniformBlockEXT) =>
Maybe (e :~: WriteDescriptorSetInlineUniformBlockEXT)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @WriteDescriptorSetInlineUniformBlockEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends WriteDescriptorSet e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss WriteDescriptorSet es, PokeChain es) => ToCStruct (WriteDescriptorSet es) where
withCStruct :: WriteDescriptorSet es
-> (Ptr (WriteDescriptorSet es) -> IO b) -> IO b
withCStruct x :: WriteDescriptorSet es
x f :: Ptr (WriteDescriptorSet es) -> IO b
f = Int -> Int -> (Ptr (WriteDescriptorSet es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 64 8 ((Ptr (WriteDescriptorSet es) -> IO b) -> IO b)
-> (Ptr (WriteDescriptorSet es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (WriteDescriptorSet es)
p -> Ptr (WriteDescriptorSet es)
-> WriteDescriptorSet es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (WriteDescriptorSet es)
p WriteDescriptorSet es
x (Ptr (WriteDescriptorSet es) -> IO b
f Ptr (WriteDescriptorSet es)
p)
pokeCStruct :: Ptr (WriteDescriptorSet es)
-> WriteDescriptorSet es -> IO b -> IO b
pokeCStruct p :: Ptr (WriteDescriptorSet es)
p WriteDescriptorSet{..} 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 (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET)
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 (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet 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
$ ("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet)) (DescriptorSet
dstSet)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
dstBinding)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
dstArrayElement)
let pImageInfoLength :: Int
pImageInfoLength = Vector DescriptorImageInfo -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorImageInfo -> Int)
-> Vector DescriptorImageInfo -> Int
forall a b. (a -> b) -> a -> b
$ (Vector DescriptorImageInfo
imageInfo)
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 (Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pImageInfoLength ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> Bool
forall a. Eq a => a -> a -> Bool
== ("descriptorSetCount" ::: Word32
descriptorCount) Bool -> Bool -> Bool
|| Int
pImageInfoLength 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 "" "pImageInfo must be empty or have 'descriptorCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let pBufferInfoLength :: Int
pBufferInfoLength = Vector DescriptorBufferInfo -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorBufferInfo -> Int)
-> Vector DescriptorBufferInfo -> Int
forall a b. (a -> b) -> a -> b
$ (Vector DescriptorBufferInfo
bufferInfo)
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 (Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pBufferInfoLength ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> Bool
forall a. Eq a => a -> a -> Bool
== ("descriptorSetCount" ::: Word32
descriptorCount) Bool -> Bool -> Bool
|| Int
pBufferInfoLength 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 "" "pBufferInfo must be empty or have 'descriptorCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let pTexelBufferViewLength :: Int
pTexelBufferViewLength = Vector BufferView -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector BufferView -> Int) -> Vector BufferView -> Int
forall a b. (a -> b) -> a -> b
$ (Vector BufferView
texelBufferView)
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 (Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pTexelBufferViewLength ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> Bool
forall a. Eq a => a -> a -> Bool
== ("descriptorSetCount" ::: Word32
descriptorCount) Bool -> Bool -> Bool
|| Int
pTexelBufferViewLength 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 "" "pTexelBufferView must be empty or have 'descriptorCount' elements" 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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Word32)) (("descriptorSetCount" ::: Word32
descriptorCount))
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 DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 36 :: Ptr DescriptorType)) (DescriptorType
descriptorType)
Ptr DescriptorImageInfo
pImageInfo'' <- if Vector DescriptorImageInfo -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector DescriptorImageInfo
imageInfo)
then Ptr DescriptorImageInfo -> ContT b IO (Ptr DescriptorImageInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr DescriptorImageInfo
forall a. Ptr a
nullPtr
else do
Ptr DescriptorImageInfo
pPImageInfo <- ((Ptr DescriptorImageInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorImageInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorImageInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorImageInfo))
-> ((Ptr DescriptorImageInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorImageInfo)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorImageInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorImageInfo (((Vector DescriptorImageInfo -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorImageInfo
imageInfo))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 24) 8
(Int -> DescriptorImageInfo -> ContT b IO ())
-> Vector DescriptorImageInfo -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorImageInfo
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorImageInfo -> DescriptorImageInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorImageInfo
pPImageInfo Ptr DescriptorImageInfo -> Int -> Ptr DescriptorImageInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorImageInfo) (DescriptorImageInfo
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) ((Vector DescriptorImageInfo
imageInfo))
Ptr DescriptorImageInfo -> ContT b IO (Ptr DescriptorImageInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr DescriptorImageInfo -> ContT b IO (Ptr DescriptorImageInfo))
-> Ptr DescriptorImageInfo -> ContT b IO (Ptr DescriptorImageInfo)
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorImageInfo
pPImageInfo
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 DescriptorImageInfo) -> Ptr DescriptorImageInfo -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr (Ptr DescriptorImageInfo)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr (Ptr DescriptorImageInfo))) Ptr DescriptorImageInfo
pImageInfo''
Ptr DescriptorBufferInfo
pBufferInfo'' <- if Vector DescriptorBufferInfo -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector DescriptorBufferInfo
bufferInfo)
then Ptr DescriptorBufferInfo -> ContT b IO (Ptr DescriptorBufferInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr DescriptorBufferInfo
forall a. Ptr a
nullPtr
else do
Ptr DescriptorBufferInfo
pPBufferInfo <- ((Ptr DescriptorBufferInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorBufferInfo)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorBufferInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorBufferInfo))
-> ((Ptr DescriptorBufferInfo -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorBufferInfo)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorBufferInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorBufferInfo (((Vector DescriptorBufferInfo -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorBufferInfo
bufferInfo))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 24) 8
(Int -> DescriptorBufferInfo -> ContT b IO ())
-> Vector DescriptorBufferInfo -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorBufferInfo
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorBufferInfo -> DescriptorBufferInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorBufferInfo
pPBufferInfo Ptr DescriptorBufferInfo -> Int -> Ptr DescriptorBufferInfo
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorBufferInfo) (DescriptorBufferInfo
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) ((Vector DescriptorBufferInfo
bufferInfo))
Ptr DescriptorBufferInfo -> ContT b IO (Ptr DescriptorBufferInfo)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr DescriptorBufferInfo -> ContT b IO (Ptr DescriptorBufferInfo))
-> Ptr DescriptorBufferInfo
-> ContT b IO (Ptr DescriptorBufferInfo)
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorBufferInfo
pPBufferInfo
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 DescriptorBufferInfo) -> Ptr DescriptorBufferInfo -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr (Ptr DescriptorBufferInfo)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr (Ptr DescriptorBufferInfo))) Ptr DescriptorBufferInfo
pBufferInfo''
Ptr BufferView
pTexelBufferView'' <- if Vector BufferView -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector BufferView
texelBufferView)
then Ptr BufferView -> ContT b IO (Ptr BufferView)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr BufferView
forall a. Ptr a
nullPtr
else do
Ptr BufferView
pPTexelBufferView <- ((Ptr BufferView -> IO b) -> IO b) -> ContT b IO (Ptr BufferView)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr BufferView -> IO b) -> IO b) -> ContT b IO (Ptr BufferView))
-> ((Ptr BufferView -> IO b) -> IO b)
-> ContT b IO (Ptr BufferView)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr BufferView -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @BufferView (((Vector BufferView -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector BufferView
texelBufferView))) 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 -> BufferView -> IO ()) -> Vector BufferView -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: BufferView
e -> Ptr BufferView -> BufferView -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr BufferView
pPTexelBufferView Ptr BufferView -> Int -> Ptr BufferView
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr BufferView) (BufferView
e)) ((Vector BufferView
texelBufferView))
Ptr BufferView -> ContT b IO (Ptr BufferView)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr BufferView -> ContT b IO (Ptr BufferView))
-> Ptr BufferView -> ContT b IO (Ptr BufferView)
forall a b. (a -> b) -> a -> b
$ Ptr BufferView
pPTexelBufferView
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 BufferView) -> Ptr BufferView -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr (Ptr BufferView)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 56 :: Ptr (Ptr BufferView))) Ptr BufferView
pTexelBufferView''
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 = 64
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (WriteDescriptorSet es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (WriteDescriptorSet 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 (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET)
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 (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet 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
$ ("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet)) (DescriptorSet
forall a. Zero a => a
zero)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
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 DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 36 :: Ptr DescriptorType)) (DescriptorType
forall a. Zero a => a
zero)
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 WriteDescriptorSet es, PeekChain es) => FromCStruct (WriteDescriptorSet es) where
peekCStruct :: Ptr (WriteDescriptorSet es) -> IO (WriteDescriptorSet es)
peekCStruct p :: Ptr (WriteDescriptorSet es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet 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)
DescriptorSet
dstSet <- ("pDescriptorSets" ::: Ptr DescriptorSet) -> IO DescriptorSet
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSet ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet))
"descriptorSetCount" ::: Word32
dstBinding <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32))
"descriptorSetCount" ::: Word32
dstArrayElement <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32))
"descriptorSetCount" ::: Word32
descriptorCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr Word32))
DescriptorType
descriptorType <- Ptr DescriptorType -> IO DescriptorType
forall a. Storable a => Ptr a -> IO a
peek @DescriptorType ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 36 :: Ptr DescriptorType))
Ptr DescriptorImageInfo
pImageInfo <- Ptr (Ptr DescriptorImageInfo) -> IO (Ptr DescriptorImageInfo)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DescriptorImageInfo) ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr (Ptr DescriptorImageInfo)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr (Ptr DescriptorImageInfo)))
let pImageInfoLength :: Int
pImageInfoLength = if Ptr DescriptorImageInfo
pImageInfo Ptr DescriptorImageInfo -> Ptr DescriptorImageInfo -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr DescriptorImageInfo
forall a. Ptr a
nullPtr then 0 else (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
descriptorCount)
Vector DescriptorImageInfo
pImageInfo' <- Int
-> (Int -> IO DescriptorImageInfo)
-> IO (Vector DescriptorImageInfo)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pImageInfoLength (\i :: Int
i -> Ptr DescriptorImageInfo -> IO DescriptorImageInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DescriptorImageInfo ((Ptr DescriptorImageInfo
pImageInfo Ptr DescriptorImageInfo -> Int -> Ptr DescriptorImageInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorImageInfo)))
Ptr DescriptorBufferInfo
pBufferInfo <- Ptr (Ptr DescriptorBufferInfo) -> IO (Ptr DescriptorBufferInfo)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DescriptorBufferInfo) ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es)
-> Int -> Ptr (Ptr DescriptorBufferInfo)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr (Ptr DescriptorBufferInfo)))
let pBufferInfoLength :: Int
pBufferInfoLength = if Ptr DescriptorBufferInfo
pBufferInfo Ptr DescriptorBufferInfo -> Ptr DescriptorBufferInfo -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr DescriptorBufferInfo
forall a. Ptr a
nullPtr then 0 else (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
descriptorCount)
Vector DescriptorBufferInfo
pBufferInfo' <- Int
-> (Int -> IO DescriptorBufferInfo)
-> IO (Vector DescriptorBufferInfo)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pBufferInfoLength (\i :: Int
i -> Ptr DescriptorBufferInfo -> IO DescriptorBufferInfo
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DescriptorBufferInfo ((Ptr DescriptorBufferInfo
pBufferInfo Ptr DescriptorBufferInfo -> Int -> Ptr DescriptorBufferInfo
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorBufferInfo)))
Ptr BufferView
pTexelBufferView <- Ptr (Ptr BufferView) -> IO (Ptr BufferView)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr BufferView) ((Ptr (WriteDescriptorSet es)
p Ptr (WriteDescriptorSet es) -> Int -> Ptr (Ptr BufferView)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 56 :: Ptr (Ptr BufferView)))
let pTexelBufferViewLength :: Int
pTexelBufferViewLength = if Ptr BufferView
pTexelBufferView Ptr BufferView -> Ptr BufferView -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr BufferView
forall a. Ptr a
nullPtr then 0 else (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
descriptorCount)
Vector BufferView
pTexelBufferView' <- Int -> (Int -> IO BufferView) -> IO (Vector BufferView)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pTexelBufferViewLength (\i :: Int
i -> Ptr BufferView -> IO BufferView
forall a. Storable a => Ptr a -> IO a
peek @BufferView ((Ptr BufferView
pTexelBufferView Ptr BufferView -> Int -> Ptr BufferView
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr BufferView)))
WriteDescriptorSet es -> IO (WriteDescriptorSet es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WriteDescriptorSet es -> IO (WriteDescriptorSet es))
-> WriteDescriptorSet es -> IO (WriteDescriptorSet es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> Vector DescriptorImageInfo
-> Vector DescriptorBufferInfo
-> Vector BufferView
-> WriteDescriptorSet es
forall (es :: [*]).
Chain es
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> Vector DescriptorImageInfo
-> Vector DescriptorBufferInfo
-> Vector BufferView
-> WriteDescriptorSet es
WriteDescriptorSet
Chain es
next DescriptorSet
dstSet "descriptorSetCount" ::: Word32
dstBinding "descriptorSetCount" ::: Word32
dstArrayElement "descriptorSetCount" ::: Word32
descriptorCount DescriptorType
descriptorType Vector DescriptorImageInfo
pImageInfo' Vector DescriptorBufferInfo
pBufferInfo' Vector BufferView
pTexelBufferView'
instance es ~ '[] => Zero (WriteDescriptorSet es) where
zero :: WriteDescriptorSet es
zero = Chain es
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> Vector DescriptorImageInfo
-> Vector DescriptorBufferInfo
-> Vector BufferView
-> WriteDescriptorSet es
forall (es :: [*]).
Chain es
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> Vector DescriptorImageInfo
-> Vector DescriptorBufferInfo
-> Vector BufferView
-> WriteDescriptorSet es
WriteDescriptorSet
()
DescriptorSet
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
DescriptorType
forall a. Zero a => a
zero
Vector DescriptorImageInfo
forall a. Monoid a => a
mempty
Vector DescriptorBufferInfo
forall a. Monoid a => a
mempty
Vector BufferView
forall a. Monoid a => a
mempty
data CopyDescriptorSet = CopyDescriptorSet
{
CopyDescriptorSet -> DescriptorSet
srcSet :: DescriptorSet
,
CopyDescriptorSet -> "descriptorSetCount" ::: Word32
srcBinding :: Word32
,
CopyDescriptorSet -> "descriptorSetCount" ::: Word32
srcArrayElement :: Word32
,
CopyDescriptorSet -> DescriptorSet
dstSet :: DescriptorSet
,
CopyDescriptorSet -> "descriptorSetCount" ::: Word32
dstBinding :: Word32
,
CopyDescriptorSet -> "descriptorSetCount" ::: Word32
dstArrayElement :: Word32
,
CopyDescriptorSet -> "descriptorSetCount" ::: Word32
descriptorCount :: Word32
}
deriving (Typeable)
deriving instance Show CopyDescriptorSet
instance ToCStruct CopyDescriptorSet where
withCStruct :: CopyDescriptorSet
-> (("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b)
-> IO b
withCStruct x :: CopyDescriptorSet
x f :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b
f = Int
-> Int
-> (("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 56 8 ((("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b) -> IO b)
-> (("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b)
-> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p -> ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> CopyDescriptorSet -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p CopyDescriptorSet
x (("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b
f "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p)
pokeCStruct :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> CopyDescriptorSet -> IO b -> IO b
pokeCStruct p :: "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p CopyDescriptorSet{..} f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COPY_DESCRIPTOR_SET)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet)) (DescriptorSet
srcSet)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
srcBinding)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
srcArrayElement)
("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DescriptorSet)) (DescriptorSet
dstSet)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
dstBinding)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 44 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
dstArrayElement)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
descriptorCount)
IO b
f
cStructSize :: Int
cStructSize = 56
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet) -> IO b -> IO b
pokeZeroCStruct p :: "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p f :: IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_COPY_DESCRIPTOR_SET)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet)) (DescriptorSet
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
("pDescriptorSets" ::: Ptr DescriptorSet) -> DescriptorSet -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DescriptorSet)) (DescriptorSet
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 44 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct CopyDescriptorSet where
peekCStruct :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO CopyDescriptorSet
peekCStruct p :: "pDescriptorCopies" ::: Ptr CopyDescriptorSet
p = do
DescriptorSet
srcSet <- ("pDescriptorSets" ::: Ptr DescriptorSet) -> IO DescriptorSet
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSet (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSet))
"descriptorSetCount" ::: Word32
srcBinding <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32))
"descriptorSetCount" ::: Word32
srcArrayElement <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 28 :: Ptr Word32))
DescriptorSet
dstSet <- ("pDescriptorSets" ::: Ptr DescriptorSet) -> IO DescriptorSet
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSet (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> "pDescriptorSets" ::: Ptr DescriptorSet
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr DescriptorSet))
"descriptorSetCount" ::: Word32
dstBinding <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 40 :: Ptr Word32))
"descriptorSetCount" ::: Word32
dstArrayElement <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 44 :: Ptr Word32))
"descriptorSetCount" ::: Word32
descriptorCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pDescriptorCopies" ::: Ptr CopyDescriptorSet
p ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 48 :: Ptr Word32))
CopyDescriptorSet -> IO CopyDescriptorSet
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CopyDescriptorSet -> IO CopyDescriptorSet)
-> CopyDescriptorSet -> IO CopyDescriptorSet
forall a b. (a -> b) -> a -> b
$ DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> CopyDescriptorSet
CopyDescriptorSet
DescriptorSet
srcSet "descriptorSetCount" ::: Word32
srcBinding "descriptorSetCount" ::: Word32
srcArrayElement DescriptorSet
dstSet "descriptorSetCount" ::: Word32
dstBinding "descriptorSetCount" ::: Word32
dstArrayElement "descriptorSetCount" ::: Word32
descriptorCount
instance Storable CopyDescriptorSet where
sizeOf :: CopyDescriptorSet -> Int
sizeOf ~CopyDescriptorSet
_ = 56
alignment :: CopyDescriptorSet -> Int
alignment ~CopyDescriptorSet
_ = 8
peek :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO CopyDescriptorSet
peek = ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> IO CopyDescriptorSet
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> CopyDescriptorSet -> IO ()
poke ptr :: "pDescriptorCopies" ::: Ptr CopyDescriptorSet
ptr poked :: CopyDescriptorSet
poked = ("pDescriptorCopies" ::: Ptr CopyDescriptorSet)
-> CopyDescriptorSet -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pDescriptorCopies" ::: Ptr CopyDescriptorSet
ptr CopyDescriptorSet
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero CopyDescriptorSet where
zero :: CopyDescriptorSet
zero = DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> DescriptorSet
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32)
-> CopyDescriptorSet
CopyDescriptorSet
DescriptorSet
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
DescriptorSet
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
data DescriptorSetLayoutBinding = DescriptorSetLayoutBinding
{
DescriptorSetLayoutBinding -> "descriptorSetCount" ::: Word32
binding :: Word32
,
DescriptorSetLayoutBinding -> DescriptorType
descriptorType :: DescriptorType
,
DescriptorSetLayoutBinding -> "descriptorSetCount" ::: Word32
descriptorCount :: Word32
,
DescriptorSetLayoutBinding -> ShaderStageFlags
stageFlags :: ShaderStageFlags
,
DescriptorSetLayoutBinding -> Vector Sampler
immutableSamplers :: Vector Sampler
}
deriving (Typeable)
deriving instance Show DescriptorSetLayoutBinding
instance ToCStruct DescriptorSetLayoutBinding where
withCStruct :: DescriptorSetLayoutBinding
-> (Ptr DescriptorSetLayoutBinding -> IO b) -> IO b
withCStruct x :: DescriptorSetLayoutBinding
x f :: Ptr DescriptorSetLayoutBinding -> IO b
f = Int -> Int -> (Ptr DescriptorSetLayoutBinding -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> (Ptr DescriptorSetLayoutBinding -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr DescriptorSetLayoutBinding
p -> Ptr DescriptorSetLayoutBinding
-> DescriptorSetLayoutBinding -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorSetLayoutBinding
p DescriptorSetLayoutBinding
x (Ptr DescriptorSetLayoutBinding -> IO b
f Ptr DescriptorSetLayoutBinding
p)
pokeCStruct :: Ptr DescriptorSetLayoutBinding
-> DescriptorSetLayoutBinding -> IO b -> IO b
pokeCStruct p :: Ptr DescriptorSetLayoutBinding
p DescriptorSetLayoutBinding{..} 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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
binding)
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 DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr DescriptorType)) (DescriptorType
descriptorType)
let pImmutableSamplersLength :: Int
pImmutableSamplersLength = Vector Sampler -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Sampler -> Int) -> Vector Sampler -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Sampler
immutableSamplers)
"descriptorSetCount" ::: Word32
descriptorCount'' <- IO ("descriptorSetCount" ::: Word32)
-> ContT b IO ("descriptorSetCount" ::: Word32)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("descriptorSetCount" ::: Word32)
-> ContT b IO ("descriptorSetCount" ::: Word32))
-> IO ("descriptorSetCount" ::: Word32)
-> ContT b IO ("descriptorSetCount" ::: Word32)
forall a b. (a -> b) -> a -> b
$ if ("descriptorSetCount" ::: Word32
descriptorCount) ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> Bool
forall a. Eq a => a -> a -> Bool
== 0
then ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32))
-> ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a b. (a -> b) -> a -> b
$ Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pImmutableSamplersLength
else do
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pImmutableSamplersLength ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> Bool
forall a. Eq a => a -> a -> Bool
== ("descriptorSetCount" ::: Word32
descriptorCount) Bool -> Bool -> Bool
|| Int
pImmutableSamplersLength 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 "" "pImmutableSamplers must be empty or have 'descriptorCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ("descriptorSetCount" ::: Word32
descriptorCount)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
descriptorCount'')
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 ShaderStageFlags -> ShaderStageFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr ShaderStageFlags)) (ShaderStageFlags
stageFlags)
Ptr Sampler
pImmutableSamplers'' <- if Vector Sampler -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector Sampler
immutableSamplers)
then Ptr Sampler -> ContT b IO (Ptr Sampler)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr Sampler
forall a. Ptr a
nullPtr
else do
Ptr Sampler
pPImmutableSamplers <- ((Ptr Sampler -> IO b) -> IO b) -> ContT b IO (Ptr Sampler)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Sampler -> IO b) -> IO b) -> ContT b IO (Ptr Sampler))
-> ((Ptr Sampler -> IO b) -> IO b) -> ContT b IO (Ptr Sampler)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr Sampler -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Sampler (((Vector Sampler -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Sampler
immutableSamplers))) 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 -> Sampler -> IO ()) -> Vector Sampler -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Sampler
e -> Ptr Sampler -> Sampler -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Sampler
pPImmutableSamplers Ptr Sampler -> Int -> Ptr Sampler
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Sampler) (Sampler
e)) ((Vector Sampler
immutableSamplers))
Ptr Sampler -> ContT b IO (Ptr Sampler)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr Sampler -> ContT b IO (Ptr Sampler))
-> Ptr Sampler -> ContT b IO (Ptr Sampler)
forall a b. (a -> b) -> a -> b
$ Ptr Sampler
pPImmutableSamplers
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 Sampler) -> Ptr Sampler -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr (Ptr Sampler)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Sampler))) Ptr Sampler
pImmutableSamplers''
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 DescriptorSetLayoutBinding -> IO b -> IO b
pokeZeroCStruct p :: Ptr DescriptorSetLayoutBinding
p f :: IO b
f = do
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
Ptr DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr DescriptorType)) (DescriptorType
forall a. Zero a => a
zero)
Ptr ShaderStageFlags -> ShaderStageFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr ShaderStageFlags)) (ShaderStageFlags
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct DescriptorSetLayoutBinding where
peekCStruct :: Ptr DescriptorSetLayoutBinding -> IO DescriptorSetLayoutBinding
peekCStruct p :: Ptr DescriptorSetLayoutBinding
p = do
"descriptorSetCount" ::: Word32
binding <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Word32))
DescriptorType
descriptorType <- Ptr DescriptorType -> IO DescriptorType
forall a. Storable a => Ptr a -> IO a
peek @DescriptorType ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr DescriptorType))
"descriptorSetCount" ::: Word32
descriptorCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr Word32))
ShaderStageFlags
stageFlags <- Ptr ShaderStageFlags -> IO ShaderStageFlags
forall a. Storable a => Ptr a -> IO a
peek @ShaderStageFlags ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr ShaderStageFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 12 :: Ptr ShaderStageFlags))
Ptr Sampler
pImmutableSamplers <- Ptr (Ptr Sampler) -> IO (Ptr Sampler)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Sampler) ((Ptr DescriptorSetLayoutBinding
p Ptr DescriptorSetLayoutBinding -> Int -> Ptr (Ptr Sampler)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr (Ptr Sampler)))
let pImmutableSamplersLength :: Int
pImmutableSamplersLength = if Ptr Sampler
pImmutableSamplers Ptr Sampler -> Ptr Sampler -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Sampler
forall a. Ptr a
nullPtr then 0 else (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
descriptorCount)
Vector Sampler
pImmutableSamplers' <- Int -> (Int -> IO Sampler) -> IO (Vector Sampler)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pImmutableSamplersLength (\i :: Int
i -> Ptr Sampler -> IO Sampler
forall a. Storable a => Ptr a -> IO a
peek @Sampler ((Ptr Sampler
pImmutableSamplers Ptr Sampler -> Int -> Ptr Sampler
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Sampler)))
DescriptorSetLayoutBinding -> IO DescriptorSetLayoutBinding
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorSetLayoutBinding -> IO DescriptorSetLayoutBinding)
-> DescriptorSetLayoutBinding -> IO DescriptorSetLayoutBinding
forall a b. (a -> b) -> a -> b
$ ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> ("descriptorSetCount" ::: Word32)
-> ShaderStageFlags
-> Vector Sampler
-> DescriptorSetLayoutBinding
DescriptorSetLayoutBinding
"descriptorSetCount" ::: Word32
binding DescriptorType
descriptorType "descriptorSetCount" ::: Word32
descriptorCount ShaderStageFlags
stageFlags Vector Sampler
pImmutableSamplers'
instance Zero DescriptorSetLayoutBinding where
zero :: DescriptorSetLayoutBinding
zero = ("descriptorSetCount" ::: Word32)
-> DescriptorType
-> ("descriptorSetCount" ::: Word32)
-> ShaderStageFlags
-> Vector Sampler
-> DescriptorSetLayoutBinding
DescriptorSetLayoutBinding
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
DescriptorType
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
ShaderStageFlags
forall a. Zero a => a
zero
Vector Sampler
forall a. Monoid a => a
mempty
data DescriptorSetLayoutCreateInfo (es :: [Type]) = DescriptorSetLayoutCreateInfo
{
DescriptorSetLayoutCreateInfo es -> Chain es
next :: Chain es
,
DescriptorSetLayoutCreateInfo es -> DescriptorSetLayoutCreateFlags
flags :: DescriptorSetLayoutCreateFlags
,
DescriptorSetLayoutCreateInfo es
-> Vector DescriptorSetLayoutBinding
bindings :: Vector DescriptorSetLayoutBinding
}
deriving (Typeable)
deriving instance Show (Chain es) => Show (DescriptorSetLayoutCreateInfo es)
instance Extensible DescriptorSetLayoutCreateInfo where
extensibleType :: StructureType
extensibleType = StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
setNext :: DescriptorSetLayoutCreateInfo ds
-> Chain es -> DescriptorSetLayoutCreateInfo es
setNext x :: DescriptorSetLayoutCreateInfo ds
x next :: Chain es
next = DescriptorSetLayoutCreateInfo ds
x{$sel:next:DescriptorSetLayoutCreateInfo :: Chain es
next = Chain es
next}
getNext :: DescriptorSetLayoutCreateInfo es -> Chain es
getNext DescriptorSetLayoutCreateInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends DescriptorSetLayoutCreateInfo e => b) -> Maybe b
extends :: proxy e
-> (Extends DescriptorSetLayoutCreateInfo e => b) -> Maybe b
extends _ f :: Extends DescriptorSetLayoutCreateInfo e => b
f
| Just Refl <- (Typeable e, Typeable DescriptorSetLayoutBindingFlagsCreateInfo) =>
Maybe (e :~: DescriptorSetLayoutBindingFlagsCreateInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DescriptorSetLayoutBindingFlagsCreateInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends DescriptorSetLayoutCreateInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss DescriptorSetLayoutCreateInfo es, PokeChain es) => ToCStruct (DescriptorSetLayoutCreateInfo es) where
withCStruct :: DescriptorSetLayoutCreateInfo es
-> (Ptr (DescriptorSetLayoutCreateInfo es) -> IO b) -> IO b
withCStruct x :: DescriptorSetLayoutCreateInfo es
x f :: Ptr (DescriptorSetLayoutCreateInfo es) -> IO b
f = Int
-> Int -> (Ptr (DescriptorSetLayoutCreateInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr (DescriptorSetLayoutCreateInfo es) -> IO b) -> IO b)
-> (Ptr (DescriptorSetLayoutCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (DescriptorSetLayoutCreateInfo es)
p -> Ptr (DescriptorSetLayoutCreateInfo es)
-> DescriptorSetLayoutCreateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (DescriptorSetLayoutCreateInfo es)
p DescriptorSetLayoutCreateInfo es
x (Ptr (DescriptorSetLayoutCreateInfo es) -> IO b
f Ptr (DescriptorSetLayoutCreateInfo es)
p)
pokeCStruct :: Ptr (DescriptorSetLayoutCreateInfo es)
-> DescriptorSetLayoutCreateInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (DescriptorSetLayoutCreateInfo es)
p DescriptorSetLayoutCreateInfo{..} 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 (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_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 (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo 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 DescriptorSetLayoutCreateFlags
-> DescriptorSetLayoutCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr DescriptorSetLayoutCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSetLayoutCreateFlags)) (DescriptorSetLayoutCreateFlags
flags)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32)) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector DescriptorSetLayoutBinding -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayoutBinding -> Int)
-> Vector DescriptorSetLayoutBinding -> Int
forall a b. (a -> b) -> a -> b
$ (Vector DescriptorSetLayoutBinding
bindings)) :: Word32))
Ptr DescriptorSetLayoutBinding
pPBindings' <- ((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding))
-> ((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorSetLayoutBinding -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorSetLayoutBinding ((Vector DescriptorSetLayoutBinding -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayoutBinding
bindings)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 24) 8
(Int -> DescriptorSetLayoutBinding -> ContT b IO ())
-> Vector DescriptorSetLayoutBinding -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorSetLayoutBinding
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorSetLayoutBinding
-> DescriptorSetLayoutBinding -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorSetLayoutBinding
pPBindings' Ptr DescriptorSetLayoutBinding
-> Int -> Ptr DescriptorSetLayoutBinding
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayoutBinding) (DescriptorSetLayoutBinding
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (Vector DescriptorSetLayoutBinding
bindings)
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 DescriptorSetLayoutBinding)
-> Ptr DescriptorSetLayoutBinding -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr (Ptr DescriptorSetLayoutBinding)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr DescriptorSetLayoutBinding))) (Ptr DescriptorSetLayoutBinding
pPBindings')
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 = 32
cStructAlignment :: Int
cStructAlignment = 8
pokeZeroCStruct :: Ptr (DescriptorSetLayoutCreateInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (DescriptorSetLayoutCreateInfo 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 (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_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 (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es) -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) Ptr ()
pNext'
Ptr DescriptorSetLayoutBinding
pPBindings' <- ((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding))
-> ((Ptr DescriptorSetLayoutBinding -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorSetLayoutBinding)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorSetLayoutBinding -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorSetLayoutBinding ((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
* 24) 8
(Int -> DescriptorSetLayoutBinding -> ContT b IO ())
-> Vector DescriptorSetLayoutBinding -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorSetLayoutBinding
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorSetLayoutBinding
-> DescriptorSetLayoutBinding -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorSetLayoutBinding
pPBindings' Ptr DescriptorSetLayoutBinding
-> Int -> Ptr DescriptorSetLayoutBinding
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayoutBinding) (DescriptorSetLayoutBinding
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (Vector DescriptorSetLayoutBinding
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 DescriptorSetLayoutBinding)
-> Ptr DescriptorSetLayoutBinding -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr (Ptr DescriptorSetLayoutBinding)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr DescriptorSetLayoutBinding))) (Ptr DescriptorSetLayoutBinding
pPBindings')
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 DescriptorSetLayoutCreateInfo es, PeekChain es) => FromCStruct (DescriptorSetLayoutCreateInfo es) where
peekCStruct :: Ptr (DescriptorSetLayoutCreateInfo es)
-> IO (DescriptorSetLayoutCreateInfo es)
peekCStruct p :: Ptr (DescriptorSetLayoutCreateInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo 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)
DescriptorSetLayoutCreateFlags
flags <- Ptr DescriptorSetLayoutCreateFlags
-> IO DescriptorSetLayoutCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSetLayoutCreateFlags ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr DescriptorSetLayoutCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorSetLayoutCreateFlags))
"descriptorSetCount" ::: Word32
bindingCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32))
Ptr DescriptorSetLayoutBinding
pBindings <- Ptr (Ptr DescriptorSetLayoutBinding)
-> IO (Ptr DescriptorSetLayoutBinding)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DescriptorSetLayoutBinding) ((Ptr (DescriptorSetLayoutCreateInfo es)
p Ptr (DescriptorSetLayoutCreateInfo es)
-> Int -> Ptr (Ptr DescriptorSetLayoutBinding)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr DescriptorSetLayoutBinding)))
Vector DescriptorSetLayoutBinding
pBindings' <- Int
-> (Int -> IO DescriptorSetLayoutBinding)
-> IO (Vector DescriptorSetLayoutBinding)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
bindingCount) (\i :: Int
i -> Ptr DescriptorSetLayoutBinding -> IO DescriptorSetLayoutBinding
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DescriptorSetLayoutBinding ((Ptr DescriptorSetLayoutBinding
pBindings Ptr DescriptorSetLayoutBinding
-> Int -> Ptr DescriptorSetLayoutBinding
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (24 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayoutBinding)))
DescriptorSetLayoutCreateInfo es
-> IO (DescriptorSetLayoutCreateInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorSetLayoutCreateInfo es
-> IO (DescriptorSetLayoutCreateInfo es))
-> DescriptorSetLayoutCreateInfo es
-> IO (DescriptorSetLayoutCreateInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> DescriptorSetLayoutCreateFlags
-> Vector DescriptorSetLayoutBinding
-> DescriptorSetLayoutCreateInfo es
forall (es :: [*]).
Chain es
-> DescriptorSetLayoutCreateFlags
-> Vector DescriptorSetLayoutBinding
-> DescriptorSetLayoutCreateInfo es
DescriptorSetLayoutCreateInfo
Chain es
next DescriptorSetLayoutCreateFlags
flags Vector DescriptorSetLayoutBinding
pBindings'
instance es ~ '[] => Zero (DescriptorSetLayoutCreateInfo es) where
zero :: DescriptorSetLayoutCreateInfo es
zero = Chain es
-> DescriptorSetLayoutCreateFlags
-> Vector DescriptorSetLayoutBinding
-> DescriptorSetLayoutCreateInfo es
forall (es :: [*]).
Chain es
-> DescriptorSetLayoutCreateFlags
-> Vector DescriptorSetLayoutBinding
-> DescriptorSetLayoutCreateInfo es
DescriptorSetLayoutCreateInfo
()
DescriptorSetLayoutCreateFlags
forall a. Zero a => a
zero
Vector DescriptorSetLayoutBinding
forall a. Monoid a => a
mempty
data DescriptorPoolSize = DescriptorPoolSize
{
DescriptorPoolSize -> DescriptorType
type' :: DescriptorType
,
DescriptorPoolSize -> "descriptorSetCount" ::: Word32
descriptorCount :: Word32
}
deriving (Typeable)
deriving instance Show DescriptorPoolSize
instance ToCStruct DescriptorPoolSize where
withCStruct :: DescriptorPoolSize -> (Ptr DescriptorPoolSize -> IO b) -> IO b
withCStruct x :: DescriptorPoolSize
x f :: Ptr DescriptorPoolSize -> IO b
f = Int -> Int -> (Ptr DescriptorPoolSize -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 8 4 ((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> (Ptr DescriptorPoolSize -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr DescriptorPoolSize
p -> Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorPoolSize
p DescriptorPoolSize
x (Ptr DescriptorPoolSize -> IO b
f Ptr DescriptorPoolSize
p)
pokeCStruct :: Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO b -> IO b
pokeCStruct p :: Ptr DescriptorPoolSize
p DescriptorPoolSize{..} f :: IO b
f = do
Ptr DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr DescriptorType)) (DescriptorType
type')
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
descriptorCount)
IO b
f
cStructSize :: Int
cStructSize = 8
cStructAlignment :: Int
cStructAlignment = 4
pokeZeroCStruct :: Ptr DescriptorPoolSize -> IO b -> IO b
pokeZeroCStruct p :: Ptr DescriptorPoolSize
p f :: IO b
f = do
Ptr DescriptorType -> DescriptorType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr DescriptorType)) (DescriptorType
forall a. Zero a => a
zero)
Ptr ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct DescriptorPoolSize where
peekCStruct :: Ptr DescriptorPoolSize -> IO DescriptorPoolSize
peekCStruct p :: Ptr DescriptorPoolSize
p = do
DescriptorType
type' <- Ptr DescriptorType -> IO DescriptorType
forall a. Storable a => Ptr a -> IO a
peek @DescriptorType ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize -> Int -> Ptr DescriptorType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr DescriptorType))
"descriptorSetCount" ::: Word32
descriptorCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr DescriptorPoolSize
p Ptr DescriptorPoolSize
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 4 :: Ptr Word32))
DescriptorPoolSize -> IO DescriptorPoolSize
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorPoolSize -> IO DescriptorPoolSize)
-> DescriptorPoolSize -> IO DescriptorPoolSize
forall a b. (a -> b) -> a -> b
$ DescriptorType
-> ("descriptorSetCount" ::: Word32) -> DescriptorPoolSize
DescriptorPoolSize
DescriptorType
type' "descriptorSetCount" ::: Word32
descriptorCount
instance Storable DescriptorPoolSize where
sizeOf :: DescriptorPoolSize -> Int
sizeOf ~DescriptorPoolSize
_ = 8
alignment :: DescriptorPoolSize -> Int
alignment ~DescriptorPoolSize
_ = 4
peek :: Ptr DescriptorPoolSize -> IO DescriptorPoolSize
peek = Ptr DescriptorPoolSize -> IO DescriptorPoolSize
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO ()
poke ptr :: Ptr DescriptorPoolSize
ptr poked :: DescriptorPoolSize
poked = Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr DescriptorPoolSize
ptr DescriptorPoolSize
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero DescriptorPoolSize where
zero :: DescriptorPoolSize
zero = DescriptorType
-> ("descriptorSetCount" ::: Word32) -> DescriptorPoolSize
DescriptorPoolSize
DescriptorType
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
data DescriptorPoolCreateInfo (es :: [Type]) = DescriptorPoolCreateInfo
{
DescriptorPoolCreateInfo es -> Chain es
next :: Chain es
,
DescriptorPoolCreateInfo es -> DescriptorPoolCreateFlags
flags :: DescriptorPoolCreateFlags
,
DescriptorPoolCreateInfo es -> "descriptorSetCount" ::: Word32
maxSets :: Word32
,
DescriptorPoolCreateInfo es -> Vector DescriptorPoolSize
poolSizes :: Vector DescriptorPoolSize
}
deriving (Typeable)
deriving instance Show (Chain es) => Show (DescriptorPoolCreateInfo es)
instance Extensible DescriptorPoolCreateInfo where
extensibleType :: StructureType
extensibleType = StructureType
STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO
setNext :: DescriptorPoolCreateInfo ds
-> Chain es -> DescriptorPoolCreateInfo es
setNext x :: DescriptorPoolCreateInfo ds
x next :: Chain es
next = DescriptorPoolCreateInfo ds
x{$sel:next:DescriptorPoolCreateInfo :: Chain es
next = Chain es
next}
getNext :: DescriptorPoolCreateInfo es -> Chain es
getNext DescriptorPoolCreateInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends DescriptorPoolCreateInfo e => b) -> Maybe b
extends :: proxy e -> (Extends DescriptorPoolCreateInfo e => b) -> Maybe b
extends _ f :: Extends DescriptorPoolCreateInfo e => b
f
| Just Refl <- (Typeable e,
Typeable DescriptorPoolInlineUniformBlockCreateInfoEXT) =>
Maybe (e :~: DescriptorPoolInlineUniformBlockCreateInfoEXT)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DescriptorPoolInlineUniformBlockCreateInfoEXT = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends DescriptorPoolCreateInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss DescriptorPoolCreateInfo es, PokeChain es) => ToCStruct (DescriptorPoolCreateInfo es) where
withCStruct :: DescriptorPoolCreateInfo es
-> (Ptr (DescriptorPoolCreateInfo es) -> IO b) -> IO b
withCStruct x :: DescriptorPoolCreateInfo es
x f :: Ptr (DescriptorPoolCreateInfo es) -> IO b
f = Int -> Int -> (Ptr (DescriptorPoolCreateInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((Ptr (DescriptorPoolCreateInfo es) -> IO b) -> IO b)
-> (Ptr (DescriptorPoolCreateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (DescriptorPoolCreateInfo es)
p -> Ptr (DescriptorPoolCreateInfo es)
-> DescriptorPoolCreateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (DescriptorPoolCreateInfo es)
p DescriptorPoolCreateInfo es
x (Ptr (DescriptorPoolCreateInfo es) -> IO b
f Ptr (DescriptorPoolCreateInfo es)
p)
pokeCStruct :: Ptr (DescriptorPoolCreateInfo es)
-> DescriptorPoolCreateInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (DescriptorPoolCreateInfo es)
p DescriptorPoolCreateInfo{..} 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 (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_POOL_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 (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo 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 DescriptorPoolCreateFlags -> DescriptorPoolCreateFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr DescriptorPoolCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorPoolCreateFlags)) (DescriptorPoolCreateFlags
flags)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
maxSets)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector DescriptorPoolSize -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorPoolSize -> Int)
-> Vector DescriptorPoolSize -> Int
forall a b. (a -> b) -> a -> b
$ (Vector DescriptorPoolSize
poolSizes)) :: Word32))
Ptr DescriptorPoolSize
pPPoolSizes' <- ((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize))
-> ((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorPoolSize -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorPoolSize ((Vector DescriptorPoolSize -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorPoolSize
poolSizes)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 8) 4
(Int -> DescriptorPoolSize -> ContT b IO ())
-> Vector DescriptorPoolSize -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorPoolSize
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorPoolSize
pPPoolSizes' Ptr DescriptorPoolSize -> Int -> Ptr DescriptorPoolSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorPoolSize) (DescriptorPoolSize
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (Vector DescriptorPoolSize
poolSizes)
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 DescriptorPoolSize) -> Ptr DescriptorPoolSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr (Ptr DescriptorPoolSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorPoolSize))) (Ptr DescriptorPoolSize
pPPoolSizes')
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 (DescriptorPoolCreateInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (DescriptorPoolCreateInfo 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 (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_POOL_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 (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo 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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32)) ("descriptorSetCount" ::: Word32
forall a. Zero a => a
zero)
Ptr DescriptorPoolSize
pPPoolSizes' <- ((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize))
-> ((Ptr DescriptorPoolSize -> IO b) -> IO b)
-> ContT b IO (Ptr DescriptorPoolSize)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr DescriptorPoolSize -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorPoolSize ((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) 4
(Int -> DescriptorPoolSize -> ContT b IO ())
-> Vector DescriptorPoolSize -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorPoolSize
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr DescriptorPoolSize -> DescriptorPoolSize -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr DescriptorPoolSize
pPPoolSizes' Ptr DescriptorPoolSize -> Int -> Ptr DescriptorPoolSize
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorPoolSize) (DescriptorPoolSize
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) (Vector DescriptorPoolSize
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 DescriptorPoolSize) -> Ptr DescriptorPoolSize -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr (Ptr DescriptorPoolSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorPoolSize))) (Ptr DescriptorPoolSize
pPPoolSizes')
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 DescriptorPoolCreateInfo es, PeekChain es) => FromCStruct (DescriptorPoolCreateInfo es) where
peekCStruct :: Ptr (DescriptorPoolCreateInfo es)
-> IO (DescriptorPoolCreateInfo es)
peekCStruct p :: Ptr (DescriptorPoolCreateInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo 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)
DescriptorPoolCreateFlags
flags <- Ptr DescriptorPoolCreateFlags -> IO DescriptorPoolCreateFlags
forall a. Storable a => Ptr a -> IO a
peek @DescriptorPoolCreateFlags ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr DescriptorPoolCreateFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorPoolCreateFlags))
"descriptorSetCount" ::: Word32
maxSets <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 20 :: Ptr Word32))
"descriptorSetCount" ::: Word32
poolSizeCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32))
Ptr DescriptorPoolSize
pPoolSizes <- Ptr (Ptr DescriptorPoolSize) -> IO (Ptr DescriptorPoolSize)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DescriptorPoolSize) ((Ptr (DescriptorPoolCreateInfo es)
p Ptr (DescriptorPoolCreateInfo es)
-> Int -> Ptr (Ptr DescriptorPoolSize)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorPoolSize)))
Vector DescriptorPoolSize
pPoolSizes' <- Int
-> (Int -> IO DescriptorPoolSize) -> IO (Vector DescriptorPoolSize)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
poolSizeCount) (\i :: Int
i -> Ptr DescriptorPoolSize -> IO DescriptorPoolSize
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @DescriptorPoolSize ((Ptr DescriptorPoolSize
pPoolSizes Ptr DescriptorPoolSize -> Int -> Ptr DescriptorPoolSize
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorPoolSize)))
DescriptorPoolCreateInfo es -> IO (DescriptorPoolCreateInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorPoolCreateInfo es -> IO (DescriptorPoolCreateInfo es))
-> DescriptorPoolCreateInfo es -> IO (DescriptorPoolCreateInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> DescriptorPoolCreateFlags
-> ("descriptorSetCount" ::: Word32)
-> Vector DescriptorPoolSize
-> DescriptorPoolCreateInfo es
forall (es :: [*]).
Chain es
-> DescriptorPoolCreateFlags
-> ("descriptorSetCount" ::: Word32)
-> Vector DescriptorPoolSize
-> DescriptorPoolCreateInfo es
DescriptorPoolCreateInfo
Chain es
next DescriptorPoolCreateFlags
flags "descriptorSetCount" ::: Word32
maxSets Vector DescriptorPoolSize
pPoolSizes'
instance es ~ '[] => Zero (DescriptorPoolCreateInfo es) where
zero :: DescriptorPoolCreateInfo es
zero = Chain es
-> DescriptorPoolCreateFlags
-> ("descriptorSetCount" ::: Word32)
-> Vector DescriptorPoolSize
-> DescriptorPoolCreateInfo es
forall (es :: [*]).
Chain es
-> DescriptorPoolCreateFlags
-> ("descriptorSetCount" ::: Word32)
-> Vector DescriptorPoolSize
-> DescriptorPoolCreateInfo es
DescriptorPoolCreateInfo
()
DescriptorPoolCreateFlags
forall a. Zero a => a
zero
"descriptorSetCount" ::: Word32
forall a. Zero a => a
zero
Vector DescriptorPoolSize
forall a. Monoid a => a
mempty
data DescriptorSetAllocateInfo (es :: [Type]) = DescriptorSetAllocateInfo
{
DescriptorSetAllocateInfo es -> Chain es
next :: Chain es
,
DescriptorSetAllocateInfo es -> DescriptorPool
descriptorPool :: DescriptorPool
,
DescriptorSetAllocateInfo es -> Vector DescriptorSetLayout
setLayouts :: Vector DescriptorSetLayout
}
deriving (Typeable)
deriving instance Show (Chain es) => Show (DescriptorSetAllocateInfo es)
instance Extensible DescriptorSetAllocateInfo where
extensibleType :: StructureType
extensibleType = StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
setNext :: DescriptorSetAllocateInfo ds
-> Chain es -> DescriptorSetAllocateInfo es
setNext x :: DescriptorSetAllocateInfo ds
x next :: Chain es
next = DescriptorSetAllocateInfo ds
x{$sel:next:DescriptorSetAllocateInfo :: Chain es
next = Chain es
next}
getNext :: DescriptorSetAllocateInfo es -> Chain es
getNext DescriptorSetAllocateInfo{..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends DescriptorSetAllocateInfo e => b) -> Maybe b
extends :: proxy e -> (Extends DescriptorSetAllocateInfo e => b) -> Maybe b
extends _ f :: Extends DescriptorSetAllocateInfo e => b
f
| Just Refl <- (Typeable e,
Typeable DescriptorSetVariableDescriptorCountAllocateInfo) =>
Maybe (e :~: DescriptorSetVariableDescriptorCountAllocateInfo)
forall k (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DescriptorSetVariableDescriptorCountAllocateInfo = b -> Maybe b
forall a. a -> Maybe a
Just b
Extends DescriptorSetAllocateInfo e => b
f
| Bool
otherwise = Maybe b
forall a. Maybe a
Nothing
instance (Extendss DescriptorSetAllocateInfo es, PokeChain es) => ToCStruct (DescriptorSetAllocateInfo es) where
withCStruct :: DescriptorSetAllocateInfo es
-> (Ptr (DescriptorSetAllocateInfo es) -> IO b) -> IO b
withCStruct x :: DescriptorSetAllocateInfo es
x f :: Ptr (DescriptorSetAllocateInfo es) -> IO b
f = Int -> Int -> (Ptr (DescriptorSetAllocateInfo es) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 40 8 ((Ptr (DescriptorSetAllocateInfo es) -> IO b) -> IO b)
-> (Ptr (DescriptorSetAllocateInfo es) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr (DescriptorSetAllocateInfo es)
p -> Ptr (DescriptorSetAllocateInfo es)
-> DescriptorSetAllocateInfo es -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (DescriptorSetAllocateInfo es)
p DescriptorSetAllocateInfo es
x (Ptr (DescriptorSetAllocateInfo es) -> IO b
f Ptr (DescriptorSetAllocateInfo es)
p)
pokeCStruct :: Ptr (DescriptorSetAllocateInfo es)
-> DescriptorSetAllocateInfo es -> IO b -> IO b
pokeCStruct p :: Ptr (DescriptorSetAllocateInfo es)
p DescriptorSetAllocateInfo{..} 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 (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_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 (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo 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
$ ("pDescriptorPool" ::: Ptr DescriptorPool)
-> DescriptorPool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> "pDescriptorPool" ::: Ptr DescriptorPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorPool)) (DescriptorPool
descriptorPool)
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 ("descriptorSetCount" ::: Word32)
-> ("descriptorSetCount" ::: Word32) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32)) ((Int -> "descriptorSetCount" ::: Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector DescriptorSetLayout -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayout -> Int)
-> Vector DescriptorSetLayout -> Int
forall a b. (a -> b) -> a -> b
$ (Vector DescriptorSetLayout
setLayouts)) :: Word32))
"pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts' <- ((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout))
-> ((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. (a -> b) -> a -> b
$ Int
-> Int
-> (("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorSetLayout ((Vector DescriptorSetLayout -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector DescriptorSetLayout
setLayouts)) 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 -> DescriptorSetLayout -> IO ())
-> Vector DescriptorSetLayout -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorSetLayout
e -> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> DescriptorSetLayout -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts' ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> Int -> "pSetLayout" ::: Ptr DescriptorSetLayout
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayout) (DescriptorSetLayout
e)) (Vector DescriptorSetLayout
setLayouts)
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 ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> Ptr ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorSetLayout))) ("pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts')
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 (DescriptorSetAllocateInfo es) -> IO b -> IO b
pokeZeroCStruct p :: Ptr (DescriptorSetAllocateInfo 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 (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es) -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_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 (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo 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
$ ("pDescriptorPool" ::: Ptr DescriptorPool)
-> DescriptorPool -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> "pDescriptorPool" ::: Ptr DescriptorPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorPool)) (DescriptorPool
forall a. Zero a => a
zero)
"pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts' <- ((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout))
-> ((("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b) -> IO b)
-> ContT b IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. (a -> b) -> a -> b
$ Int
-> Int
-> (("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @DescriptorSetLayout ((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 -> DescriptorSetLayout -> IO ())
-> Vector DescriptorSetLayout -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: DescriptorSetLayout
e -> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> DescriptorSetLayout -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ("pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts' ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> Int -> "pSetLayout" ::: Ptr DescriptorSetLayout
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayout) (DescriptorSetLayout
e)) (Vector DescriptorSetLayout
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 ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> ("pSetLayout" ::: Ptr DescriptorSetLayout) -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> Ptr ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorSetLayout))) ("pSetLayout" ::: Ptr DescriptorSetLayout
pPSetLayouts')
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 DescriptorSetAllocateInfo es, PeekChain es) => FromCStruct (DescriptorSetAllocateInfo es) where
peekCStruct :: Ptr (DescriptorSetAllocateInfo es)
-> IO (DescriptorSetAllocateInfo es)
peekCStruct p :: Ptr (DescriptorSetAllocateInfo es)
p = do
Ptr ()
pNext <- Ptr (Ptr ()) -> IO (Ptr ())
forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo 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)
DescriptorPool
descriptorPool <- ("pDescriptorPool" ::: Ptr DescriptorPool) -> IO DescriptorPool
forall a. Storable a => Ptr a -> IO a
peek @DescriptorPool ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> "pDescriptorPool" ::: Ptr DescriptorPool
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr DescriptorPool))
"descriptorSetCount" ::: Word32
descriptorSetCount <- Ptr ("descriptorSetCount" ::: Word32)
-> IO ("descriptorSetCount" ::: Word32)
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> Ptr ("descriptorSetCount" ::: Word32)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr Word32))
"pSetLayout" ::: Ptr DescriptorSetLayout
pSetLayouts <- Ptr ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr DescriptorSetLayout) ((Ptr (DescriptorSetAllocateInfo es)
p Ptr (DescriptorSetAllocateInfo es)
-> Int -> Ptr ("pSetLayout" ::: Ptr DescriptorSetLayout)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 32 :: Ptr (Ptr DescriptorSetLayout)))
Vector DescriptorSetLayout
pSetLayouts' <- Int
-> (Int -> IO DescriptorSetLayout)
-> IO (Vector DescriptorSetLayout)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (("descriptorSetCount" ::: Word32) -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral "descriptorSetCount" ::: Word32
descriptorSetCount) (\i :: Int
i -> ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> IO DescriptorSetLayout
forall a. Storable a => Ptr a -> IO a
peek @DescriptorSetLayout (("pSetLayout" ::: Ptr DescriptorSetLayout
pSetLayouts ("pSetLayout" ::: Ptr DescriptorSetLayout)
-> Int -> "pSetLayout" ::: Ptr DescriptorSetLayout
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr DescriptorSetLayout)))
DescriptorSetAllocateInfo es -> IO (DescriptorSetAllocateInfo es)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DescriptorSetAllocateInfo es -> IO (DescriptorSetAllocateInfo es))
-> DescriptorSetAllocateInfo es
-> IO (DescriptorSetAllocateInfo es)
forall a b. (a -> b) -> a -> b
$ Chain es
-> DescriptorPool
-> Vector DescriptorSetLayout
-> DescriptorSetAllocateInfo es
forall (es :: [*]).
Chain es
-> DescriptorPool
-> Vector DescriptorSetLayout
-> DescriptorSetAllocateInfo es
DescriptorSetAllocateInfo
Chain es
next DescriptorPool
descriptorPool Vector DescriptorSetLayout
pSetLayouts'
instance es ~ '[] => Zero (DescriptorSetAllocateInfo es) where
zero :: DescriptorSetAllocateInfo es
zero = Chain es
-> DescriptorPool
-> Vector DescriptorSetLayout
-> DescriptorSetAllocateInfo es
forall (es :: [*]).
Chain es
-> DescriptorPool
-> Vector DescriptorSetLayout
-> DescriptorSetAllocateInfo es
DescriptorSetAllocateInfo
()
DescriptorPool
forall a. Zero a => a
zero
Vector DescriptorSetLayout
forall a. Monoid a => a
mempty