{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_pipeline_library ( PipelineLibraryCreateInfoKHR(..)
, KHR_PIPELINE_LIBRARY_SPEC_VERSION
, pattern KHR_PIPELINE_LIBRARY_SPEC_VERSION
, KHR_PIPELINE_LIBRARY_EXTENSION_NAME
, pattern KHR_PIPELINE_LIBRARY_EXTENSION_NAME
) where
import Foreign.Marshal.Alloc (allocaBytesAligned)
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 Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
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 (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.Handles (Pipeline)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR))
data PipelineLibraryCreateInfoKHR = PipelineLibraryCreateInfoKHR
{
PipelineLibraryCreateInfoKHR -> Vector Pipeline
libraries :: Vector Pipeline }
deriving (Typeable)
deriving instance Show PipelineLibraryCreateInfoKHR
instance ToCStruct PipelineLibraryCreateInfoKHR where
withCStruct :: PipelineLibraryCreateInfoKHR
-> (Ptr PipelineLibraryCreateInfoKHR -> IO b) -> IO b
withCStruct x :: PipelineLibraryCreateInfoKHR
x f :: Ptr PipelineLibraryCreateInfoKHR -> IO b
f = Int -> Int -> (Ptr PipelineLibraryCreateInfoKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr PipelineLibraryCreateInfoKHR -> IO b) -> IO b)
-> (Ptr PipelineLibraryCreateInfoKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr PipelineLibraryCreateInfoKHR
p -> Ptr PipelineLibraryCreateInfoKHR
-> PipelineLibraryCreateInfoKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PipelineLibraryCreateInfoKHR
p PipelineLibraryCreateInfoKHR
x (Ptr PipelineLibraryCreateInfoKHR -> IO b
f Ptr PipelineLibraryCreateInfoKHR
p)
pokeCStruct :: Ptr PipelineLibraryCreateInfoKHR
-> PipelineLibraryCreateInfoKHR -> IO b -> IO b
pokeCStruct p :: Ptr PipelineLibraryCreateInfoKHR
p PipelineLibraryCreateInfoKHR{..} 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 PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR)
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 PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) ((Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Vector Pipeline -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Pipeline -> Int) -> Vector Pipeline -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Pipeline
libraries)) :: Word32))
Ptr Pipeline
pPLibraries' <- ((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline))
-> ((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr Pipeline -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Pipeline ((Vector Pipeline -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Pipeline
libraries)) 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 -> Pipeline -> IO ()) -> Vector Pipeline -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Pipeline
e -> Ptr Pipeline -> Pipeline -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Pipeline
pPLibraries' Ptr Pipeline -> Int -> Ptr Pipeline
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Pipeline) (Pipeline
e)) (Vector Pipeline
libraries)
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 Pipeline) -> Ptr Pipeline -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr (Ptr Pipeline)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr Pipeline))) (Ptr Pipeline
pPLibraries')
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 PipelineLibraryCreateInfoKHR -> IO b -> IO b
pokeZeroCStruct p :: Ptr PipelineLibraryCreateInfoKHR
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 PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR)
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 PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Pipeline
pPLibraries' <- ((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline))
-> ((Ptr Pipeline -> IO b) -> IO b) -> ContT b IO (Ptr Pipeline)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr Pipeline -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @Pipeline ((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 -> Pipeline -> IO ()) -> Vector Pipeline -> IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: Pipeline
e -> Ptr Pipeline -> Pipeline -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Pipeline
pPLibraries' Ptr Pipeline -> Int -> Ptr Pipeline
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Pipeline) (Pipeline
e)) (Vector Pipeline
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 Pipeline) -> Ptr Pipeline -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr (Ptr Pipeline)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr Pipeline))) (Ptr Pipeline
pPLibraries')
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 FromCStruct PipelineLibraryCreateInfoKHR where
peekCStruct :: Ptr PipelineLibraryCreateInfoKHR -> IO PipelineLibraryCreateInfoKHR
peekCStruct p :: Ptr PipelineLibraryCreateInfoKHR
p = do
Word32
libraryCount <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
Ptr Pipeline
pLibraries <- Ptr (Ptr Pipeline) -> IO (Ptr Pipeline)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr Pipeline) ((Ptr PipelineLibraryCreateInfoKHR
p Ptr PipelineLibraryCreateInfoKHR -> Int -> Ptr (Ptr Pipeline)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr Pipeline)))
Vector Pipeline
pLibraries' <- Int -> (Int -> IO Pipeline) -> IO (Vector Pipeline)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
libraryCount) (\i :: Int
i -> Ptr Pipeline -> IO Pipeline
forall a. Storable a => Ptr a -> IO a
peek @Pipeline ((Ptr Pipeline
pLibraries Ptr Pipeline -> Int -> Ptr Pipeline
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Pipeline)))
PipelineLibraryCreateInfoKHR -> IO PipelineLibraryCreateInfoKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PipelineLibraryCreateInfoKHR -> IO PipelineLibraryCreateInfoKHR)
-> PipelineLibraryCreateInfoKHR -> IO PipelineLibraryCreateInfoKHR
forall a b. (a -> b) -> a -> b
$ Vector Pipeline -> PipelineLibraryCreateInfoKHR
PipelineLibraryCreateInfoKHR
Vector Pipeline
pLibraries'
instance Zero PipelineLibraryCreateInfoKHR where
zero :: PipelineLibraryCreateInfoKHR
zero = Vector Pipeline -> PipelineLibraryCreateInfoKHR
PipelineLibraryCreateInfoKHR
Vector Pipeline
forall a. Monoid a => a
mempty
type KHR_PIPELINE_LIBRARY_SPEC_VERSION = 1
pattern KHR_PIPELINE_LIBRARY_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_PIPELINE_LIBRARY_SPEC_VERSION :: a
$mKHR_PIPELINE_LIBRARY_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_PIPELINE_LIBRARY_SPEC_VERSION = 1
type KHR_PIPELINE_LIBRARY_EXTENSION_NAME = "VK_KHR_pipeline_library"
pattern KHR_PIPELINE_LIBRARY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_PIPELINE_LIBRARY_EXTENSION_NAME :: a
$mKHR_PIPELINE_LIBRARY_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_PIPELINE_LIBRARY_EXTENSION_NAME = "VK_KHR_pipeline_library"