{-# language CPP #-}
module Graphics.Vulkan.Core11.Promoted_From_VK_KHR_maintenance3 ( getDescriptorSetLayoutSupport
, PhysicalDeviceMaintenance3Properties(..)
, DescriptorSetLayoutSupport(..)
, StructureType(..)
) where
import Data.Typeable (eqT)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import GHC.Ptr (castPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
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 Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Graphics.Vulkan.Core10.BaseType (bool32ToBool)
import Graphics.Vulkan.Core10.BaseType (boolToBool32)
import Graphics.Vulkan.Core10.BaseType (Bool32)
import Graphics.Vulkan.CStruct.Extends (Chain)
import Graphics.Vulkan.Core10.DescriptorSet (DescriptorSetLayoutCreateInfo)
import {-# SOURCE #-} Graphics.Vulkan.Core12.Promoted_From_VK_EXT_descriptor_indexing (DescriptorSetVariableDescriptorCountLayoutSupport)
import Graphics.Vulkan.Core10.Handles (Device)
import Graphics.Vulkan.Core10.Handles (Device(..))
import Graphics.Vulkan.Dynamic (DeviceCmds(pVkGetDescriptorSetLayoutSupport))
import Graphics.Vulkan.Core10.BaseType (DeviceSize)
import Graphics.Vulkan.Core10.Handles (Device_T)
import Graphics.Vulkan.CStruct.Extends (Extends)
import Graphics.Vulkan.CStruct.Extends (Extensible(..))
import Graphics.Vulkan.CStruct (FromCStruct)
import Graphics.Vulkan.CStruct (FromCStruct(..))
import Graphics.Vulkan.CStruct.Extends (PeekChain)
import Graphics.Vulkan.CStruct.Extends (PeekChain(..))
import Graphics.Vulkan.CStruct.Extends (PokeChain)
import Graphics.Vulkan.CStruct.Extends (PokeChain(..))
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_DESCRIPTOR_SET_LAYOUT_SUPPORT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetDescriptorSetLayoutSupport
:: FunPtr (Ptr Device_T -> Ptr (DescriptorSetLayoutCreateInfo a) -> Ptr (DescriptorSetLayoutSupport b) -> IO ()) -> Ptr Device_T -> Ptr (DescriptorSetLayoutCreateInfo a) -> Ptr (DescriptorSetLayoutSupport b) -> IO ()
getDescriptorSetLayoutSupport :: (PokeChain a, PokeChain b, PeekChain b) => Device -> DescriptorSetLayoutCreateInfo a -> IO (DescriptorSetLayoutSupport b)
getDescriptorSetLayoutSupport device createInfo = evalContT $ do
let vkGetDescriptorSetLayoutSupport' = mkVkGetDescriptorSetLayoutSupport (pVkGetDescriptorSetLayoutSupport (deviceCmds (device :: Device)))
pCreateInfo <- ContT $ withCStruct (createInfo)
pPSupport <- ContT (withZeroCStruct @(DescriptorSetLayoutSupport _))
lift $ vkGetDescriptorSetLayoutSupport' (deviceHandle (device)) pCreateInfo (pPSupport)
pSupport <- lift $ peekCStruct @(DescriptorSetLayoutSupport _) pPSupport
pure $ (pSupport)
data PhysicalDeviceMaintenance3Properties = PhysicalDeviceMaintenance3Properties
{
maxPerSetDescriptors :: Word32
,
maxMemoryAllocationSize :: DeviceSize
}
deriving (Typeable)
deriving instance Show PhysicalDeviceMaintenance3Properties
instance ToCStruct PhysicalDeviceMaintenance3Properties where
withCStruct x f = allocaBytesAligned 32 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p PhysicalDeviceMaintenance3Properties{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (maxPerSetDescriptors)
poke ((p `plusPtr` 24 :: Ptr DeviceSize)) (maxMemoryAllocationSize)
f
cStructSize = 32
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr Word32)) (zero)
poke ((p `plusPtr` 24 :: Ptr DeviceSize)) (zero)
f
instance FromCStruct PhysicalDeviceMaintenance3Properties where
peekCStruct p = do
maxPerSetDescriptors <- peek @Word32 ((p `plusPtr` 16 :: Ptr Word32))
maxMemoryAllocationSize <- peek @DeviceSize ((p `plusPtr` 24 :: Ptr DeviceSize))
pure $ PhysicalDeviceMaintenance3Properties
maxPerSetDescriptors maxMemoryAllocationSize
instance Storable PhysicalDeviceMaintenance3Properties where
sizeOf ~_ = 32
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero PhysicalDeviceMaintenance3Properties where
zero = PhysicalDeviceMaintenance3Properties
zero
zero
data DescriptorSetLayoutSupport (es :: [Type]) = DescriptorSetLayoutSupport
{
next :: Chain es
,
supported :: Bool
}
deriving (Typeable)
deriving instance Show (Chain es) => Show (DescriptorSetLayoutSupport es)
instance Extensible DescriptorSetLayoutSupport where
extensibleType = STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT
setNext x next = x{next = next}
getNext DescriptorSetLayoutSupport{..} = next
extends :: forall e b proxy. Typeable e => proxy e -> (Extends DescriptorSetLayoutSupport e => b) -> Maybe b
extends _ f
| Just Refl <- eqT @e @DescriptorSetVariableDescriptorCountLayoutSupport = Just f
| otherwise = Nothing
instance PokeChain es => ToCStruct (DescriptorSetLayoutSupport es) where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p DescriptorSetLayoutSupport{..} f = evalContT $ do
lift $ poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT)
pNext'' <- fmap castPtr . ContT $ withChain (next)
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext''
lift $ poke ((p `plusPtr` 16 :: Ptr Bool32)) (boolToBool32 (supported))
lift $ f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = evalContT $ do
lift $ poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT)
pNext' <- fmap castPtr . ContT $ withZeroChain @es
lift $ poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) pNext'
lift $ poke ((p `plusPtr` 16 :: Ptr Bool32)) (boolToBool32 (zero))
lift $ f
instance PeekChain es => FromCStruct (DescriptorSetLayoutSupport es) where
peekCStruct p = do
pNext <- peek @(Ptr ()) ((p `plusPtr` 8 :: Ptr (Ptr ())))
next <- peekChain (castPtr pNext)
supported <- peek @Bool32 ((p `plusPtr` 16 :: Ptr Bool32))
pure $ DescriptorSetLayoutSupport
next (bool32ToBool supported)
instance es ~ '[] => Zero (DescriptorSetLayoutSupport es) where
zero = DescriptorSetLayoutSupport
()
zero