{-# language CPP #-}
module Graphics.Vulkan.Extensions.VK_EXT_vertex_attribute_divisor ( VertexInputBindingDivisorDescriptionEXT(..)
, PipelineVertexInputDivisorStateCreateInfoEXT(..)
, PhysicalDeviceVertexAttributeDivisorPropertiesEXT(..)
, PhysicalDeviceVertexAttributeDivisorFeaturesEXT(..)
, EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION
, pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION
, EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME
, pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_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)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Graphics.Vulkan.CStruct.Utils (advancePtrBytes)
import Graphics.Vulkan.Core10.BaseType (bool32ToBool)
import Graphics.Vulkan.Core10.BaseType (boolToBool32)
import Graphics.Vulkan.Core10.BaseType (Bool32)
import Graphics.Vulkan.CStruct (FromCStruct)
import Graphics.Vulkan.CStruct (FromCStruct(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType)
import Graphics.Vulkan.CStruct (ToCStruct)
import Graphics.Vulkan.CStruct (ToCStruct(..))
import Graphics.Vulkan.Zero (Zero(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT))
data VertexInputBindingDivisorDescriptionEXT = VertexInputBindingDivisorDescriptionEXT
{
binding :: Word32
,
divisor :: Word32
}
deriving (Typeable)
deriving instance Show VertexInputBindingDivisorDescriptionEXT
instance ToCStruct VertexInputBindingDivisorDescriptionEXT where
withCStruct x f = allocaBytesAligned 8 4 $ \p -> pokeCStruct p x (f p)
pokeCStruct p VertexInputBindingDivisorDescriptionEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr Word32)) (binding)
poke ((p `plusPtr` 4 :: Ptr Word32)) (divisor)
f
cStructSize = 8
cStructAlignment = 4
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr Word32)) (zero)
poke ((p `plusPtr` 4 :: Ptr Word32)) (zero)
f
instance FromCStruct VertexInputBindingDivisorDescriptionEXT where
peekCStruct p = do
binding <- peek @Word32 ((p `plusPtr` 0 :: Ptr Word32))
divisor <- peek @Word32 ((p `plusPtr` 4 :: Ptr Word32))
pure $ VertexInputBindingDivisorDescriptionEXT
binding divisor
instance Storable VertexInputBindingDivisorDescriptionEXT where
sizeOf ~_ = 8
alignment ~_ = 4
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero VertexInputBindingDivisorDescriptionEXT where
zero = VertexInputBindingDivisorDescriptionEXT
zero
zero
data PipelineVertexInputDivisorStateCreateInfoEXT = PipelineVertexInputDivisorStateCreateInfoEXT
{
vertexBindingDivisors :: Vector VertexInputBindingDivisorDescriptionEXT }
deriving (Typeable)
deriving instance Show PipelineVertexInputDivisorStateCreateInfoEXT
instance ToCStruct PipelineVertexInputDivisorStateCreateInfoEXT where
withCStruct x f = allocaBytesAligned 32 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p PipelineVertexInputDivisorStateCreateInfoEXT{..} f = evalContT $ do
lift $ poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT)
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
lift $ poke ((p `plusPtr` 16 :: Ptr Word32)) ((fromIntegral (Data.Vector.length $ (vertexBindingDivisors)) :: Word32))
pPVertexBindingDivisors' <- ContT $ allocaBytesAligned @VertexInputBindingDivisorDescriptionEXT ((Data.Vector.length (vertexBindingDivisors)) * 8) 4
Data.Vector.imapM_ (\i e -> ContT $ pokeCStruct (pPVertexBindingDivisors' `plusPtr` (8 * (i)) :: Ptr VertexInputBindingDivisorDescriptionEXT) (e) . ($ ())) (vertexBindingDivisors)
lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr VertexInputBindingDivisorDescriptionEXT))) (pPVertexBindingDivisors')
lift $ f
cStructSize = 32
cStructAlignment = 8
pokeZeroCStruct p f = evalContT $ do
lift $ poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT)
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
pPVertexBindingDivisors' <- ContT $ allocaBytesAligned @VertexInputBindingDivisorDescriptionEXT ((Data.Vector.length (mempty)) * 8) 4
Data.Vector.imapM_ (\i e -> ContT $ pokeCStruct (pPVertexBindingDivisors' `plusPtr` (8 * (i)) :: Ptr VertexInputBindingDivisorDescriptionEXT) (e) . ($ ())) (mempty)
lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr VertexInputBindingDivisorDescriptionEXT))) (pPVertexBindingDivisors')
lift $ f
instance FromCStruct PipelineVertexInputDivisorStateCreateInfoEXT where
peekCStruct p = do
vertexBindingDivisorCount <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
pVertexBindingDivisors <- peek @(Ptr VertexInputBindingDivisorDescriptionEXT) ((p `plusPtr` 24 :: Ptr (Ptr VertexInputBindingDivisorDescriptionEXT)))
pVertexBindingDivisors' <- generateM (fromIntegral vertexBindingDivisorCount) (\i -> peekCStruct @VertexInputBindingDivisorDescriptionEXT ((pVertexBindingDivisors `advancePtrBytes` (8 * (i)) :: Ptr VertexInputBindingDivisorDescriptionEXT)))
pure $ PipelineVertexInputDivisorStateCreateInfoEXT
pVertexBindingDivisors'
instance Zero PipelineVertexInputDivisorStateCreateInfoEXT where
zero = PipelineVertexInputDivisorStateCreateInfoEXT
mempty
data PhysicalDeviceVertexAttributeDivisorPropertiesEXT = PhysicalDeviceVertexAttributeDivisorPropertiesEXT
{
maxVertexAttribDivisor :: Word32 }
deriving (Typeable)
deriving instance Show PhysicalDeviceVertexAttributeDivisorPropertiesEXT
instance ToCStruct PhysicalDeviceVertexAttributeDivisorPropertiesEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p PhysicalDeviceVertexAttributeDivisorPropertiesEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (maxVertexAttribDivisor)
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (zero)
f
instance FromCStruct PhysicalDeviceVertexAttributeDivisorPropertiesEXT where
peekCStruct p = do
maxVertexAttribDivisor <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
pure $ PhysicalDeviceVertexAttributeDivisorPropertiesEXT
maxVertexAttribDivisor
instance Storable PhysicalDeviceVertexAttributeDivisorPropertiesEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero PhysicalDeviceVertexAttributeDivisorPropertiesEXT where
zero = PhysicalDeviceVertexAttributeDivisorPropertiesEXT
zero
data PhysicalDeviceVertexAttributeDivisorFeaturesEXT = PhysicalDeviceVertexAttributeDivisorFeaturesEXT
{
vertexAttributeInstanceRateDivisor :: Bool
,
vertexAttributeInstanceRateZeroDivisor :: Bool
}
deriving (Typeable)
deriving instance Show PhysicalDeviceVertexAttributeDivisorFeaturesEXT
instance ToCStruct PhysicalDeviceVertexAttributeDivisorFeaturesEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p PhysicalDeviceVertexAttributeDivisorFeaturesEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Bool32)) (boolToBool32 (vertexAttributeInstanceRateDivisor))
poke ((p `plusPtr` 20 :: Ptr Bool32)) (boolToBool32 (vertexAttributeInstanceRateZeroDivisor))
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Bool32)) (boolToBool32 (zero))
poke ((p `plusPtr` 20 :: Ptr Bool32)) (boolToBool32 (zero))
f
instance FromCStruct PhysicalDeviceVertexAttributeDivisorFeaturesEXT where
peekCStruct p = do
vertexAttributeInstanceRateDivisor <- peek @Bool32 ((p `plusPtr` 16 :: Ptr Bool32))
vertexAttributeInstanceRateZeroDivisor <- peek @Bool32 ((p `plusPtr` 20 :: Ptr Bool32))
pure $ PhysicalDeviceVertexAttributeDivisorFeaturesEXT
(bool32ToBool vertexAttributeInstanceRateDivisor) (bool32ToBool vertexAttributeInstanceRateZeroDivisor)
instance Storable PhysicalDeviceVertexAttributeDivisorFeaturesEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero PhysicalDeviceVertexAttributeDivisorFeaturesEXT where
zero = PhysicalDeviceVertexAttributeDivisorFeaturesEXT
zero
zero
type EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION = 3
pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION :: forall a . Integral a => a
pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION = 3
type EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME = "VK_EXT_vertex_attribute_divisor"
pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME = "VK_EXT_vertex_attribute_divisor"