{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_device_groupAndVK_KHR_bind_memory2 ( BindBufferMemoryDeviceGroupInfo(..)
, BindImageMemoryDeviceGroupInfo(..)
, StructureType(..)
, ImageCreateFlagBits(..)
, ImageCreateFlags
) where
import Foreign.Marshal.Alloc (allocaBytes)
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 Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
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.Core10.FundamentalTypes (Rect2D)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlagBits(..))
import Vulkan.Core10.Enums.ImageCreateFlagBits (ImageCreateFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
data BindBufferMemoryDeviceGroupInfo = BindBufferMemoryDeviceGroupInfo
{
BindBufferMemoryDeviceGroupInfo -> Vector Word32
deviceIndices :: Vector Word32 }
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindBufferMemoryDeviceGroupInfo)
#endif
deriving instance Show BindBufferMemoryDeviceGroupInfo
instance ToCStruct BindBufferMemoryDeviceGroupInfo where
withCStruct :: forall b.
BindBufferMemoryDeviceGroupInfo
-> (Ptr BindBufferMemoryDeviceGroupInfo -> IO b) -> IO b
withCStruct BindBufferMemoryDeviceGroupInfo
x Ptr BindBufferMemoryDeviceGroupInfo -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 forall a b. (a -> b) -> a -> b
$ \Ptr BindBufferMemoryDeviceGroupInfo
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr BindBufferMemoryDeviceGroupInfo
p BindBufferMemoryDeviceGroupInfo
x (Ptr BindBufferMemoryDeviceGroupInfo -> IO b
f Ptr BindBufferMemoryDeviceGroupInfo
p)
pokeCStruct :: forall b.
Ptr BindBufferMemoryDeviceGroupInfo
-> BindBufferMemoryDeviceGroupInfo -> IO b -> IO b
pokeCStruct Ptr BindBufferMemoryDeviceGroupInfo
p BindBufferMemoryDeviceGroupInfo{Vector Word32
deviceIndices :: Vector Word32
$sel:deviceIndices:BindBufferMemoryDeviceGroupInfo :: BindBufferMemoryDeviceGroupInfo -> Vector Word32
..} 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 BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO)
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 BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
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 BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ((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
$ (Vector Word32
deviceIndices)) :: Word32))
Ptr Word32
pPDeviceIndices' <- 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 @Word32 ((forall a. Vector a -> Int
Data.Vector.length (Vector Word32
deviceIndices)) forall a. Num a => a -> a -> a
* Int
4)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Word32
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Word32
pPDeviceIndices' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word32) (Word32
e)) (Vector Word32
deviceIndices)
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 BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word32))) (Ptr Word32
pPDeviceIndices')
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
32
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr BindBufferMemoryDeviceGroupInfo -> IO b -> IO b
pokeZeroCStruct Ptr BindBufferMemoryDeviceGroupInfo
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct BindBufferMemoryDeviceGroupInfo where
peekCStruct :: Ptr BindBufferMemoryDeviceGroupInfo
-> IO BindBufferMemoryDeviceGroupInfo
peekCStruct Ptr BindBufferMemoryDeviceGroupInfo
p = do
Word32
deviceIndexCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
Ptr Word32
pDeviceIndices <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word32) ((Ptr BindBufferMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word32)))
Vector Word32
pDeviceIndices' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
deviceIndexCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr Word32
pDeviceIndices forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word32)))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Vector Word32 -> BindBufferMemoryDeviceGroupInfo
BindBufferMemoryDeviceGroupInfo
Vector Word32
pDeviceIndices'
instance Zero BindBufferMemoryDeviceGroupInfo where
zero :: BindBufferMemoryDeviceGroupInfo
zero = Vector Word32 -> BindBufferMemoryDeviceGroupInfo
BindBufferMemoryDeviceGroupInfo
forall a. Monoid a => a
mempty
data BindImageMemoryDeviceGroupInfo = BindImageMemoryDeviceGroupInfo
{
BindImageMemoryDeviceGroupInfo -> Vector Word32
deviceIndices :: Vector Word32
,
BindImageMemoryDeviceGroupInfo -> Vector Rect2D
splitInstanceBindRegions :: Vector Rect2D
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (BindImageMemoryDeviceGroupInfo)
#endif
deriving instance Show BindImageMemoryDeviceGroupInfo
instance ToCStruct BindImageMemoryDeviceGroupInfo where
withCStruct :: forall b.
BindImageMemoryDeviceGroupInfo
-> (Ptr BindImageMemoryDeviceGroupInfo -> IO b) -> IO b
withCStruct BindImageMemoryDeviceGroupInfo
x Ptr BindImageMemoryDeviceGroupInfo -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
48 forall a b. (a -> b) -> a -> b
$ \Ptr BindImageMemoryDeviceGroupInfo
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr BindImageMemoryDeviceGroupInfo
p BindImageMemoryDeviceGroupInfo
x (Ptr BindImageMemoryDeviceGroupInfo -> IO b
f Ptr BindImageMemoryDeviceGroupInfo
p)
pokeCStruct :: forall b.
Ptr BindImageMemoryDeviceGroupInfo
-> BindImageMemoryDeviceGroupInfo -> IO b -> IO b
pokeCStruct Ptr BindImageMemoryDeviceGroupInfo
p BindImageMemoryDeviceGroupInfo{Vector Word32
Vector Rect2D
splitInstanceBindRegions :: Vector Rect2D
deviceIndices :: Vector Word32
$sel:splitInstanceBindRegions:BindImageMemoryDeviceGroupInfo :: BindImageMemoryDeviceGroupInfo -> Vector Rect2D
$sel:deviceIndices:BindImageMemoryDeviceGroupInfo :: BindImageMemoryDeviceGroupInfo -> Vector Word32
..} 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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO)
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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) ((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
$ (Vector Word32
deviceIndices)) :: Word32))
Ptr Word32
pPDeviceIndices' <- 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 @Word32 ((forall a. Vector a -> Int
Data.Vector.length (Vector Word32
deviceIndices)) forall a. Num a => a -> a -> a
* Int
4)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Word32
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Word32
pPDeviceIndices' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word32) (Word32
e)) (Vector Word32
deviceIndices)
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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word32))) (Ptr Word32
pPDeviceIndices')
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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32)) ((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
$ (Vector Rect2D
splitInstanceBindRegions)) :: Word32))
Ptr Rect2D
pPSplitInstanceBindRegions' <- 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 @Rect2D ((forall a. Vector a -> Int
Data.Vector.length (Vector Rect2D
splitInstanceBindRegions)) forall a. Num a => a -> a -> a
* Int
16)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\Int
i Rect2D
e -> forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Rect2D
pPSplitInstanceBindRegions' forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
16 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Rect2D) (Rect2D
e)) (Vector Rect2D
splitInstanceBindRegions)
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 BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Rect2D))) (Ptr Rect2D
pPSplitInstanceBindRegions')
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
48
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr BindImageMemoryDeviceGroupInfo -> IO b -> IO b
pokeZeroCStruct Ptr BindImageMemoryDeviceGroupInfo
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct BindImageMemoryDeviceGroupInfo where
peekCStruct :: Ptr BindImageMemoryDeviceGroupInfo
-> IO BindImageMemoryDeviceGroupInfo
peekCStruct Ptr BindImageMemoryDeviceGroupInfo
p = do
Word32
deviceIndexCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
Ptr Word32
pDeviceIndices <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Word32) ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr (Ptr Word32)))
Vector Word32
pDeviceIndices' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
deviceIndexCount) (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr Word32
pDeviceIndices forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
4 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word32)))
Word32
splitInstanceBindRegionCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
32 :: Ptr Word32))
Ptr Rect2D
pSplitInstanceBindRegions <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr Rect2D) ((Ptr BindImageMemoryDeviceGroupInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
40 :: Ptr (Ptr Rect2D)))
Vector Rect2D
pSplitInstanceBindRegions' <- forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
splitInstanceBindRegionCount) (\Int
i -> forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Rect2D ((Ptr Rect2D
pSplitInstanceBindRegions forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
16 forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Rect2D)))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Vector Word32 -> Vector Rect2D -> BindImageMemoryDeviceGroupInfo
BindImageMemoryDeviceGroupInfo
Vector Word32
pDeviceIndices' Vector Rect2D
pSplitInstanceBindRegions'
instance Zero BindImageMemoryDeviceGroupInfo where
zero :: BindImageMemoryDeviceGroupInfo
zero = Vector Word32 -> Vector Rect2D -> BindImageMemoryDeviceGroupInfo
BindImageMemoryDeviceGroupInfo
forall a. Monoid a => a
mempty
forall a. Monoid a => a
mempty