{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_bind_memory2 ( bindBufferMemory2
, bindImageMemory2
, BindBufferMemoryInfo(..)
, BindImageMemoryInfo(..)
, StructureType(..)
, ImageCreateFlagBits(..)
, ImageCreateFlags
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytes)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Control.Monad.IO.Class (MonadIO)
import Data.Type.Equality ((:~:)(Refl))
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.CStruct.Extends (pokeSomeCStruct)
import Vulkan.NamedType ((:::))
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_groupAndVK_KHR_bind_memory2 (BindBufferMemoryDeviceGroupInfo)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_device_groupAndVK_KHR_bind_memory2 (BindImageMemoryDeviceGroupInfo)
import {-# SOURCE #-} Vulkan.Extensions.VK_KHR_swapchain (BindImageMemorySwapchainInfoKHR)
import {-# SOURCE #-} Vulkan.Core11.Promoted_From_VK_KHR_sampler_ycbcr_conversion (BindImagePlaneMemoryInfo)
import Vulkan.Core10.Handles (Buffer)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkBindBufferMemory2))
import Vulkan.Dynamic (DeviceCmds(pVkBindImageMemory2))
import Vulkan.Core10.Handles (DeviceMemory)
import Vulkan.Core10.FundamentalTypes (DeviceSize)
import Vulkan.Core10.Handles (Device_T)
import Vulkan.CStruct.Extends (Extends)
import Vulkan.CStruct.Extends (Extendss)
import Vulkan.CStruct.Extends (Extensible(..))
import Vulkan.Core10.Handles (Image)
import Vulkan.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlagBits(..))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkBindBufferMemory2
:: FunPtr (Ptr Device_T -> Word32 -> Ptr (SomeStruct BindBufferMemoryInfo) -> IO Result) -> Ptr Device_T -> Word32 -> Ptr (SomeStruct BindBufferMemoryInfo) -> IO Result
bindBufferMemory2 :: forall io
. (MonadIO io)
=>
Device
->
("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> io ()
bindBufferMemory2 :: forall (io :: * -> *).
MonadIO io =>
Device
-> ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo))
-> io ()
bindBufferMemory2 Device
device "bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkBindBufferMemory2Ptr :: FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
pVkBindBufferMemory2 (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkBindBufferMemory2 is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkBindBufferMemory2' :: Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
vkBindBufferMemory2' = FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
-> Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
mkVkBindBufferMemory2 FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result)
vkBindBufferMemory2Ptr
Ptr (BindBufferMemoryInfo Any)
pPBindInfos <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(BindBufferMemoryInfo _) ((forall a. Vector a -> Int
Data.Vector.length ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)) forall a. Num a => a -> a -> a
* Int
40)
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i SomeStruct BindBufferMemoryInfo
e -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (a :: [*] -> *) b.
(forall (es :: [*]).
(Extendss a es, PokeChain es) =>
ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindBufferMemoryInfo Any)
pPBindInfos forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (BindBufferMemoryInfo _))) (SomeStruct BindBufferMemoryInfo
e) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a b. (a -> b) -> a -> b
$ ())) ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkBindBufferMemory2" (Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindBufferMemoryInfo))
-> IO Result
vkBindBufferMemory2'
(Device -> Ptr Device_T
deviceHandle (Device
device))
((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ ("bindInfos" ::: Vector (SomeStruct BindBufferMemoryInfo)
bindInfos)) :: Word32))
(forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindBufferMemoryInfo Any)
pPBindInfos)))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkBindImageMemory2
:: FunPtr (Ptr Device_T -> Word32 -> Ptr (SomeStruct BindImageMemoryInfo) -> IO Result) -> Ptr Device_T -> Word32 -> Ptr (SomeStruct BindImageMemoryInfo) -> IO Result
bindImageMemory2 :: forall io
. (MonadIO io)
=>
Device
->
("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo))
-> io ()
bindImageMemory2 :: forall (io :: * -> *).
MonadIO io =>
Device
-> ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo))
-> io ()
bindImageMemory2 Device
device "bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkBindImageMemory2Ptr :: FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr = DeviceCmds
-> FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
pVkBindImageMemory2 (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkBindImageMemory2 is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkBindImageMemory2' :: Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
vkBindImageMemory2' = FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
-> Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
mkVkBindImageMemory2 FunPtr
(Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result)
vkBindImageMemory2Ptr
Ptr (BindImageMemoryInfo Any)
pPBindInfos <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes @(BindImageMemoryInfo _) ((forall a. Vector a -> Int
Data.Vector.length ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)) forall a. Num a => a -> a -> a
* Int
40)
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i SomeStruct BindImageMemoryInfo
e -> forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (a :: [*] -> *) b.
(forall (es :: [*]).
(Extendss a es, PokeChain es) =>
ToCStruct (a es)) =>
Ptr (SomeStruct a) -> SomeStruct a -> IO b -> IO b
pokeSomeCStruct (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindImageMemoryInfo Any)
pPBindInfos forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
40 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr (BindImageMemoryInfo _))) (SomeStruct BindImageMemoryInfo
e) forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a b. (a -> b) -> a -> b
$ ())) ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkBindImageMemory2" (Ptr Device_T
-> ("bindInfoCount" ::: Word32)
-> ("pBindInfos" ::: Ptr (SomeStruct BindImageMemoryInfo))
-> IO Result
vkBindImageMemory2'
(Device -> Ptr Device_T
deviceHandle (Device
device))
((forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Vector a -> Int
Data.Vector.length forall a b. (a -> b) -> a -> b
$ ("bindInfos" ::: Vector (SomeStruct BindImageMemoryInfo)
bindInfos)) :: Word32))
(forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (BindImageMemoryInfo Any)
pPBindInfos)))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
data BindBufferMemoryInfo (es :: [Type]) = BindBufferMemoryInfo
{
forall (es :: [*]). BindBufferMemoryInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]). BindBufferMemoryInfo es -> Buffer
buffer :: Buffer
,
forall (es :: [*]). BindBufferMemoryInfo es -> DeviceMemory
memory :: DeviceMemory
,
forall (es :: [*]). BindBufferMemoryInfo es -> DeviceSize
memoryOffset :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindBufferMemoryInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BindBufferMemoryInfo es)
instance Extensible BindBufferMemoryInfo where
extensibleTypeName :: String
extensibleTypeName = String
"BindBufferMemoryInfo"
setNext :: forall (ds :: [*]) (es :: [*]).
BindBufferMemoryInfo ds -> Chain es -> BindBufferMemoryInfo es
setNext BindBufferMemoryInfo{DeviceSize
Chain ds
DeviceMemory
Buffer
memoryOffset :: DeviceSize
memory :: DeviceMemory
buffer :: Buffer
next :: Chain ds
$sel:memoryOffset:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceSize
$sel:memory:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceMemory
$sel:buffer:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Buffer
$sel:next:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Chain es
..} Chain es
next' = BindBufferMemoryInfo{$sel:next:BindBufferMemoryInfo :: Chain es
next = Chain es
next', DeviceSize
DeviceMemory
Buffer
memoryOffset :: DeviceSize
memory :: DeviceMemory
buffer :: Buffer
$sel:memoryOffset:BindBufferMemoryInfo :: DeviceSize
$sel:memory:BindBufferMemoryInfo :: DeviceMemory
$sel:buffer:BindBufferMemoryInfo :: Buffer
..}
getNext :: forall (es :: [*]). BindBufferMemoryInfo es -> Chain es
getNext BindBufferMemoryInfo{DeviceSize
Chain es
DeviceMemory
Buffer
memoryOffset :: DeviceSize
memory :: DeviceMemory
buffer :: Buffer
next :: Chain es
$sel:memoryOffset:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceSize
$sel:memory:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceMemory
$sel:buffer:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Buffer
$sel:next:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Chain es
..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BindBufferMemoryInfo e => b) -> Maybe b
extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends BindBufferMemoryInfo e => b) -> Maybe b
extends proxy e
_ Extends BindBufferMemoryInfo e => b
f
| Just e :~: BindBufferMemoryDeviceGroupInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindBufferMemoryDeviceGroupInfo = forall a. a -> Maybe a
Just Extends BindBufferMemoryInfo e => b
f
| Bool
otherwise = forall a. Maybe a
Nothing
instance ( Extendss BindBufferMemoryInfo es
, PokeChain es ) => ToCStruct (BindBufferMemoryInfo es) where
withCStruct :: forall b.
BindBufferMemoryInfo es
-> (Ptr (BindBufferMemoryInfo es) -> IO b) -> IO b
withCStruct BindBufferMemoryInfo es
x Ptr (BindBufferMemoryInfo es) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 forall a b. (a -> b) -> a -> b
$ \Ptr (BindBufferMemoryInfo es)
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BindBufferMemoryInfo es)
p BindBufferMemoryInfo es
x (Ptr (BindBufferMemoryInfo es) -> IO b
f Ptr (BindBufferMemoryInfo es)
p)
pokeCStruct :: forall b.
Ptr (BindBufferMemoryInfo es)
-> BindBufferMemoryInfo es -> IO b -> IO b
pokeCStruct Ptr (BindBufferMemoryInfo es)
p BindBufferMemoryInfo{DeviceSize
Chain es
DeviceMemory
Buffer
memoryOffset :: DeviceSize
memory :: DeviceMemory
buffer :: Buffer
next :: Chain es
$sel:memoryOffset:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceSize
$sel:memory:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> DeviceMemory
$sel:buffer:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Buffer
$sel:next:BindBufferMemoryInfo :: forall (es :: [*]). BindBufferMemoryInfo es -> Chain es
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO)
Ptr ()
pNext'' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext''
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Buffer)) (Buffer
buffer)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory)) (DeviceMemory
memory)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr (BindBufferMemoryInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (BindBufferMemoryInfo es)
p IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO)
Ptr ()
pNext' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext'
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Buffer)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
instance ( Extendss BindBufferMemoryInfo es
, PeekChain es ) => FromCStruct (BindBufferMemoryInfo es) where
peekCStruct :: Ptr (BindBufferMemoryInfo es) -> IO (BindBufferMemoryInfo es)
peekCStruct Ptr (BindBufferMemoryInfo es)
p = do
Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
Chain es
next <- forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
Buffer
buffer <- forall a. Storable a => Ptr a -> IO a
peek @Buffer ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Buffer))
DeviceMemory
memory <- forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory))
DeviceSize
memoryOffset <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BindBufferMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
BindBufferMemoryInfo
Chain es
next Buffer
buffer DeviceMemory
memory DeviceSize
memoryOffset
instance es ~ '[] => Zero (BindBufferMemoryInfo es) where
zero :: BindBufferMemoryInfo es
zero = forall (es :: [*]).
Chain es
-> Buffer -> DeviceMemory -> DeviceSize -> BindBufferMemoryInfo es
BindBufferMemoryInfo
()
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero
data BindImageMemoryInfo (es :: [Type]) = BindImageMemoryInfo
{
forall (es :: [*]). BindImageMemoryInfo es -> Chain es
next :: Chain es
,
forall (es :: [*]). BindImageMemoryInfo es -> Image
image :: Image
,
forall (es :: [*]). BindImageMemoryInfo es -> DeviceMemory
memory :: DeviceMemory
,
forall (es :: [*]). BindImageMemoryInfo es -> DeviceSize
memoryOffset :: DeviceSize
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindImageMemoryInfo (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (BindImageMemoryInfo es)
instance Extensible BindImageMemoryInfo where
extensibleTypeName :: String
extensibleTypeName = String
"BindImageMemoryInfo"
setNext :: forall (ds :: [*]) (es :: [*]).
BindImageMemoryInfo ds -> Chain es -> BindImageMemoryInfo es
setNext BindImageMemoryInfo{DeviceSize
Chain ds
Image
DeviceMemory
memoryOffset :: DeviceSize
memory :: DeviceMemory
image :: Image
next :: Chain ds
$sel:memoryOffset:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceSize
$sel:memory:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceMemory
$sel:image:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Image
$sel:next:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Chain es
..} Chain es
next' = BindImageMemoryInfo{$sel:next:BindImageMemoryInfo :: Chain es
next = Chain es
next', DeviceSize
Image
DeviceMemory
memoryOffset :: DeviceSize
memory :: DeviceMemory
image :: Image
$sel:memoryOffset:BindImageMemoryInfo :: DeviceSize
$sel:memory:BindImageMemoryInfo :: DeviceMemory
$sel:image:BindImageMemoryInfo :: Image
..}
getNext :: forall (es :: [*]). BindImageMemoryInfo es -> Chain es
getNext BindImageMemoryInfo{DeviceSize
Chain es
Image
DeviceMemory
memoryOffset :: DeviceSize
memory :: DeviceMemory
image :: Image
next :: Chain es
$sel:memoryOffset:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceSize
$sel:memory:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceMemory
$sel:image:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Image
$sel:next:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Chain es
..} = Chain es
next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends BindImageMemoryInfo e => b) -> Maybe b
extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends BindImageMemoryInfo e => b) -> Maybe b
extends proxy e
_ Extends BindImageMemoryInfo e => b
f
| Just e :~: BindImagePlaneMemoryInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImagePlaneMemoryInfo = forall a. a -> Maybe a
Just Extends BindImageMemoryInfo e => b
f
| Just e :~: BindImageMemorySwapchainInfoKHR
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImageMemorySwapchainInfoKHR = forall a. a -> Maybe a
Just Extends BindImageMemoryInfo e => b
f
| Just e :~: BindImageMemoryDeviceGroupInfo
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @BindImageMemoryDeviceGroupInfo = forall a. a -> Maybe a
Just Extends BindImageMemoryInfo e => b
f
| Bool
otherwise = forall a. Maybe a
Nothing
instance ( Extendss BindImageMemoryInfo es
, PokeChain es ) => ToCStruct (BindImageMemoryInfo es) where
withCStruct :: forall b.
BindImageMemoryInfo es
-> (Ptr (BindImageMemoryInfo es) -> IO b) -> IO b
withCStruct BindImageMemoryInfo es
x Ptr (BindImageMemoryInfo es) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
40 forall a b. (a -> b) -> a -> b
$ \Ptr (BindImageMemoryInfo es)
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (BindImageMemoryInfo es)
p BindImageMemoryInfo es
x (Ptr (BindImageMemoryInfo es) -> IO b
f Ptr (BindImageMemoryInfo es)
p)
pokeCStruct :: forall b.
Ptr (BindImageMemoryInfo es)
-> BindImageMemoryInfo es -> IO b -> IO b
pokeCStruct Ptr (BindImageMemoryInfo es)
p BindImageMemoryInfo{DeviceSize
Chain es
Image
DeviceMemory
memoryOffset :: DeviceSize
memory :: DeviceMemory
image :: Image
next :: Chain es
$sel:memoryOffset:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceSize
$sel:memory:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> DeviceMemory
$sel:image:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Image
$sel:next:BindImageMemoryInfo :: forall (es :: [*]). BindImageMemoryInfo es -> Chain es
..} IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO)
Ptr ()
pNext'' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
Chain es -> (Ptr (Chain es) -> IO a) -> IO a
withChain (Chain es
next)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext''
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Image)) (Image
image)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory)) (DeviceMemory
memory)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (DeviceSize
memoryOffset)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
cStructSize :: Int
cStructSize = Int
40
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr (BindImageMemoryInfo es) -> IO b -> IO b
pokeZeroCStruct Ptr (BindImageMemoryInfo es)
p IO b
f = forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO)
Ptr ()
pNext' <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. Ptr a -> Ptr b
castPtr forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall (es :: [*]) a.
PokeChain es =>
(Ptr (Chain es) -> IO a) -> IO a
withZeroChain @es
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) Ptr ()
pNext'
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Image)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ IO b
f
instance ( Extendss BindImageMemoryInfo es
, PeekChain es ) => FromCStruct (BindImageMemoryInfo es) where
peekCStruct :: Ptr (BindImageMemoryInfo es) -> IO (BindImageMemoryInfo es)
peekCStruct Ptr (BindImageMemoryInfo es)
p = do
Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ())))
Chain es
next <- forall (es :: [*]). PeekChain es => Ptr (Chain es) -> IO (Chain es)
peekChain (forall a b. Ptr a -> Ptr b
castPtr Ptr ()
pNext)
Image
image <- forall a. Storable a => Ptr a -> IO a
peek @Image ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Image))
DeviceMemory
memory <- forall a. Storable a => Ptr a -> IO a
peek @DeviceMemory ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceMemory))
DeviceSize
memoryOffset <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr (BindImageMemoryInfo es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr DeviceSize))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
BindImageMemoryInfo
Chain es
next Image
image DeviceMemory
memory DeviceSize
memoryOffset
instance es ~ '[] => Zero (BindImageMemoryInfo es) where
zero :: BindImageMemoryInfo es
zero = forall (es :: [*]).
Chain es
-> Image -> DeviceMemory -> DeviceSize -> BindImageMemoryInfo es
BindImageMemoryInfo
()
forall a. Zero a => a
zero
forall a. Zero a => a
zero
forall a. Zero a => a
zero