{-# language CPP #-}
-- No documentation found for Chapter "Promoted_From_VK_KHR_maintenance3"
module Vulkan.Core11.Promoted_From_VK_KHR_maintenance3  ( getDescriptorSetLayoutSupport
                                                        , PhysicalDeviceMaintenance3Properties(..)
                                                        , DescriptorSetLayoutSupport(..)
                                                        , StructureType(..)
                                                        ) 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.IO (throwIO)
import GHC.Ptr (castPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
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)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
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 Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.CStruct.Extends (forgetExtensions)
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.CStruct.Extends (Chain)
import Vulkan.Core10.DescriptorSet (DescriptorSetLayoutCreateInfo)
import {-# SOURCE #-} Vulkan.Core12.Promoted_From_VK_EXT_descriptor_indexing (DescriptorSetVariableDescriptorCountLayoutSupport)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkGetDescriptorSetLayoutSupport))
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.CStruct.Extends (PeekChain)
import Vulkan.CStruct.Extends (PeekChain(..))
import Vulkan.CStruct.Extends (PokeChain)
import Vulkan.CStruct.Extends (PokeChain(..))
import Vulkan.CStruct.Extends (SomeStruct)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES))
import Vulkan.Core10.Enums.StructureType (StructureType(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkGetDescriptorSetLayoutSupport
  :: FunPtr (Ptr Device_T -> Ptr (SomeStruct DescriptorSetLayoutCreateInfo) -> Ptr (SomeStruct DescriptorSetLayoutSupport) -> IO ()) -> Ptr Device_T -> Ptr (SomeStruct DescriptorSetLayoutCreateInfo) -> Ptr (SomeStruct DescriptorSetLayoutSupport) -> IO ()

-- | vkGetDescriptorSetLayoutSupport - Query whether a descriptor set layout
-- can be created
--
-- = Description
--
-- Some implementations have limitations on what fits in a descriptor set
-- which are not easily expressible in terms of existing limits like
-- @maxDescriptorSet@*, for example if all descriptor types share a limited
-- space in memory but each descriptor is a different size or alignment.
-- This command returns information about whether a descriptor set
-- satisfies this limit. If the descriptor set layout satisfies the
-- 'PhysicalDeviceMaintenance3Properties'::@maxPerSetDescriptors@ limit,
-- this command is guaranteed to return
-- 'Vulkan.Core10.FundamentalTypes.TRUE' in
-- 'DescriptorSetLayoutSupport'::@supported@. If the descriptor set layout
-- exceeds the
-- 'PhysicalDeviceMaintenance3Properties'::@maxPerSetDescriptors@ limit,
-- whether the descriptor set layout is supported is
-- implementation-dependent and /may/ depend on whether the descriptor
-- sizes and alignments cause the layout to exceed an internal limit.
--
-- This command does not consider other limits such as
-- @maxPerStageDescriptor@*, and so a descriptor set layout that is
-- supported according to this command /must/ still satisfy the pipeline
-- layout limits such as @maxPerStageDescriptor@* in order to be used in a
-- pipeline layout.
--
-- Note
--
-- This is a 'Vulkan.Core10.Handles.Device' query rather than
-- 'Vulkan.Core10.Handles.PhysicalDevice' because the answer /may/ depend
-- on enabled features.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_1 VK_VERSION_1_1>,
-- 'Vulkan.Core10.DescriptorSet.DescriptorSetLayoutCreateInfo',
-- 'DescriptorSetLayoutSupport', 'Vulkan.Core10.Handles.Device'
getDescriptorSetLayoutSupport :: forall a b io
                               . ( Extendss DescriptorSetLayoutCreateInfo a
                                 , PokeChain a
                                 , Extendss DescriptorSetLayoutSupport b
                                 , PokeChain b
                                 , PeekChain b
                                 , MonadIO io )
                              => -- | @device@ is the logical device that would create the descriptor set
                                 -- layout.
                                 --
                                 -- #VUID-vkGetDescriptorSetLayoutSupport-device-parameter# @device@ /must/
                                 -- be a valid 'Vulkan.Core10.Handles.Device' handle
                                 Device
                              -> -- | @pCreateInfo@ is a pointer to a
                                 -- 'Vulkan.Core10.DescriptorSet.DescriptorSetLayoutCreateInfo' structure
                                 -- specifying the state of the descriptor set layout object.
                                 --
                                 -- #VUID-vkGetDescriptorSetLayoutSupport-pCreateInfo-parameter#
                                 -- @pCreateInfo@ /must/ be a valid pointer to a valid
                                 -- 'Vulkan.Core10.DescriptorSet.DescriptorSetLayoutCreateInfo' structure
                                 (DescriptorSetLayoutCreateInfo a)
                              -> io (DescriptorSetLayoutSupport b)
getDescriptorSetLayoutSupport :: forall (a :: [*]) (b :: [*]) (io :: * -> *).
(Extendss DescriptorSetLayoutCreateInfo a, PokeChain a,
 Extendss DescriptorSetLayoutSupport b, PokeChain b, PeekChain b,
 MonadIO io) =>
Device
-> DescriptorSetLayoutCreateInfo a
-> io (DescriptorSetLayoutSupport b)
getDescriptorSetLayoutSupport Device
device DescriptorSetLayoutCreateInfo a
createInfo = 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 vkGetDescriptorSetLayoutSupportPtr :: FunPtr
  (Ptr Device_T
   -> ("pCreateInfo"
       ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
   -> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
   -> IO ())
vkGetDescriptorSetLayoutSupportPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> ("pCreateInfo"
          ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
      -> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
      -> IO ())
pVkGetDescriptorSetLayoutSupport (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
   -> ("pCreateInfo"
       ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
   -> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
   -> IO ())
vkGetDescriptorSetLayoutSupportPtr 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 vkGetDescriptorSetLayoutSupport is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
  let vkGetDescriptorSetLayoutSupport' :: Ptr Device_T
-> ("pCreateInfo"
    ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
-> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
-> IO ()
vkGetDescriptorSetLayoutSupport' = FunPtr
  (Ptr Device_T
   -> ("pCreateInfo"
       ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
   -> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
   -> IO ())
-> Ptr Device_T
-> ("pCreateInfo"
    ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
-> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
-> IO ()
mkVkGetDescriptorSetLayoutSupport FunPtr
  (Ptr Device_T
   -> ("pCreateInfo"
       ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
   -> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
   -> IO ())
vkGetDescriptorSetLayoutSupportPtr
  Ptr (DescriptorSetLayoutCreateInfo a)
pCreateInfo <- 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. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
withCStruct (DescriptorSetLayoutCreateInfo a
createInfo)
  Ptr (DescriptorSetLayoutSupport b)
pPSupport <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (forall a b. ToCStruct a => (Ptr a -> IO b) -> IO b
withZeroCStruct @(DescriptorSetLayoutSupport _))
  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
"vkGetDescriptorSetLayoutSupport" (Ptr Device_T
-> ("pCreateInfo"
    ::: Ptr (SomeStruct DescriptorSetLayoutCreateInfo))
-> ("pSupport" ::: Ptr (SomeStruct DescriptorSetLayoutSupport))
-> IO ()
vkGetDescriptorSetLayoutSupport'
                                                               (Device -> Ptr Device_T
deviceHandle (Device
device))
                                                               (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions Ptr (DescriptorSetLayoutCreateInfo a)
pCreateInfo)
                                                               (forall (a :: [*] -> *) (es :: [*]).
Ptr (a es) -> Ptr (SomeStruct a)
forgetExtensions (Ptr (DescriptorSetLayoutSupport b)
pPSupport)))
  DescriptorSetLayoutSupport b
pSupport <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @(DescriptorSetLayoutSupport _) Ptr (DescriptorSetLayoutSupport b)
pPSupport
  forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (DescriptorSetLayoutSupport b
pSupport)


-- | VkPhysicalDeviceMaintenance3Properties - Structure describing descriptor
-- set properties
--
-- = Description
--
-- If the 'PhysicalDeviceMaintenance3Properties' structure is included in
-- the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceProperties2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceProperties2',
-- it is filled in with each corresponding implementation-dependent
-- property.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_1 VK_VERSION_1_1>,
-- 'Vulkan.Core10.FundamentalTypes.DeviceSize',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceMaintenance3Properties = PhysicalDeviceMaintenance3Properties
  { -- | #extension-limits-maxPerSetDescriptors# @maxPerSetDescriptors@ is a
    -- maximum number of descriptors (summed over all descriptor types) in a
    -- single descriptor set that is guaranteed to satisfy any
    -- implementation-dependent constraints on the size of a descriptor set
    -- itself. Applications /can/ query whether a descriptor set that goes
    -- beyond this limit is supported using 'getDescriptorSetLayoutSupport'.
    PhysicalDeviceMaintenance3Properties -> Word32
maxPerSetDescriptors :: Word32
  , -- | #extension-limits-maxMemoryAllocationSize# @maxMemoryAllocationSize@ is
    -- the maximum size of a memory allocation that /can/ be created, even if
    -- there is more space available in the heap.
    PhysicalDeviceMaintenance3Properties -> DeviceSize
maxMemoryAllocationSize :: DeviceSize
  }
  deriving (Typeable, PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> Bool
$c/= :: PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> Bool
== :: PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> Bool
$c== :: PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceMaintenance3Properties)
#endif
deriving instance Show PhysicalDeviceMaintenance3Properties

instance ToCStruct PhysicalDeviceMaintenance3Properties where
  withCStruct :: forall b.
PhysicalDeviceMaintenance3Properties
-> (Ptr PhysicalDeviceMaintenance3Properties -> IO b) -> IO b
withCStruct PhysicalDeviceMaintenance3Properties
x Ptr PhysicalDeviceMaintenance3Properties -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDeviceMaintenance3Properties
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMaintenance3Properties
p PhysicalDeviceMaintenance3Properties
x (Ptr PhysicalDeviceMaintenance3Properties -> IO b
f Ptr PhysicalDeviceMaintenance3Properties
p)
  pokeCStruct :: forall b.
Ptr PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMaintenance3Properties
p PhysicalDeviceMaintenance3Properties{Word32
DeviceSize
maxMemoryAllocationSize :: DeviceSize
maxPerSetDescriptors :: Word32
$sel:maxMemoryAllocationSize:PhysicalDeviceMaintenance3Properties :: PhysicalDeviceMaintenance3Properties -> DeviceSize
$sel:maxPerSetDescriptors:PhysicalDeviceMaintenance3Properties :: PhysicalDeviceMaintenance3Properties -> Word32
..} IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) (Word32
maxPerSetDescriptors)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (DeviceSize
maxMemoryAllocationSize)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr PhysicalDeviceMaintenance3Properties -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDeviceMaintenance3Properties
p IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32)) (forall a. Zero a => a
zero)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize)) (forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct PhysicalDeviceMaintenance3Properties where
  peekCStruct :: Ptr PhysicalDeviceMaintenance3Properties
-> IO PhysicalDeviceMaintenance3Properties
peekCStruct Ptr PhysicalDeviceMaintenance3Properties
p = do
    Word32
maxPerSetDescriptors <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    DeviceSize
maxMemoryAllocationSize <- forall a. Storable a => Ptr a -> IO a
peek @DeviceSize ((Ptr PhysicalDeviceMaintenance3Properties
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr DeviceSize))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Word32 -> DeviceSize -> PhysicalDeviceMaintenance3Properties
PhysicalDeviceMaintenance3Properties
             Word32
maxPerSetDescriptors DeviceSize
maxMemoryAllocationSize

instance Storable PhysicalDeviceMaintenance3Properties where
  sizeOf :: PhysicalDeviceMaintenance3Properties -> Int
sizeOf ~PhysicalDeviceMaintenance3Properties
_ = Int
32
  alignment :: PhysicalDeviceMaintenance3Properties -> Int
alignment ~PhysicalDeviceMaintenance3Properties
_ = Int
8
  peek :: Ptr PhysicalDeviceMaintenance3Properties
-> IO PhysicalDeviceMaintenance3Properties
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PhysicalDeviceMaintenance3Properties
-> PhysicalDeviceMaintenance3Properties -> IO ()
poke Ptr PhysicalDeviceMaintenance3Properties
ptr PhysicalDeviceMaintenance3Properties
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceMaintenance3Properties
ptr PhysicalDeviceMaintenance3Properties
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PhysicalDeviceMaintenance3Properties where
  zero :: PhysicalDeviceMaintenance3Properties
zero = Word32 -> DeviceSize -> PhysicalDeviceMaintenance3Properties
PhysicalDeviceMaintenance3Properties
           forall a. Zero a => a
zero
           forall a. Zero a => a
zero


-- | VkDescriptorSetLayoutSupport - Structure returning information about
-- whether a descriptor set layout can be supported
--
-- = Description
--
-- @supported@ is set to 'Vulkan.Core10.FundamentalTypes.TRUE' if the
-- descriptor set /can/ be created, or else is set to
-- 'Vulkan.Core10.FundamentalTypes.FALSE'.
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkDescriptorSetLayoutSupport-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT'
--
-- -   #VUID-VkDescriptorSetLayoutSupport-pNext-pNext# @pNext@ /must/ be
--     @NULL@ or a pointer to a valid instance of
--     'Vulkan.Core12.Promoted_From_VK_EXT_descriptor_indexing.DescriptorSetVariableDescriptorCountLayoutSupport'
--
-- -   #VUID-VkDescriptorSetLayoutSupport-sType-unique# The @sType@ value
--     of each struct in the @pNext@ chain /must/ be unique
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_1 VK_VERSION_1_1>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType',
-- 'getDescriptorSetLayoutSupport',
-- 'Vulkan.Extensions.VK_KHR_maintenance3.getDescriptorSetLayoutSupportKHR'
data DescriptorSetLayoutSupport (es :: [Type]) = DescriptorSetLayoutSupport
  { -- | @pNext@ is @NULL@ or a pointer to a structure extending this structure.
    forall (es :: [*]). DescriptorSetLayoutSupport es -> Chain es
next :: Chain es
  , -- | @supported@ specifies whether the descriptor set layout /can/ be
    -- created.
    forall (es :: [*]). DescriptorSetLayoutSupport es -> Bool
supported :: Bool
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (DescriptorSetLayoutSupport (es :: [Type]))
#endif
deriving instance Show (Chain es) => Show (DescriptorSetLayoutSupport es)

instance Extensible DescriptorSetLayoutSupport where
  extensibleTypeName :: String
extensibleTypeName = String
"DescriptorSetLayoutSupport"
  setNext :: forall (ds :: [*]) (es :: [*]).
DescriptorSetLayoutSupport ds
-> Chain es -> DescriptorSetLayoutSupport es
setNext DescriptorSetLayoutSupport{Bool
Chain ds
supported :: Bool
next :: Chain ds
$sel:supported:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Bool
$sel:next:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Chain es
..} Chain es
next' = DescriptorSetLayoutSupport{$sel:next:DescriptorSetLayoutSupport :: Chain es
next = Chain es
next', Bool
supported :: Bool
$sel:supported:DescriptorSetLayoutSupport :: Bool
..}
  getNext :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Chain es
getNext DescriptorSetLayoutSupport{Bool
Chain es
supported :: Bool
next :: Chain es
$sel:supported:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Bool
$sel:next:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Chain es
..} = Chain es
next
  extends :: forall e b proxy. Typeable e => proxy e -> (Extends DescriptorSetLayoutSupport e => b) -> Maybe b
  extends :: forall e b (proxy :: * -> *).
Typeable e =>
proxy e -> (Extends DescriptorSetLayoutSupport e => b) -> Maybe b
extends proxy e
_ Extends DescriptorSetLayoutSupport e => b
f
    | Just e :~: DescriptorSetVariableDescriptorCountLayoutSupport
Refl <- forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT @e @DescriptorSetVariableDescriptorCountLayoutSupport = forall a. a -> Maybe a
Just Extends DescriptorSetLayoutSupport e => b
f
    | Bool
otherwise = forall a. Maybe a
Nothing

instance ( Extendss DescriptorSetLayoutSupport es
         , PokeChain es ) => ToCStruct (DescriptorSetLayoutSupport es) where
  withCStruct :: forall b.
DescriptorSetLayoutSupport es
-> (Ptr (DescriptorSetLayoutSupport es) -> IO b) -> IO b
withCStruct DescriptorSetLayoutSupport es
x Ptr (DescriptorSetLayoutSupport es) -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr (DescriptorSetLayoutSupport es)
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr (DescriptorSetLayoutSupport es)
p DescriptorSetLayoutSupport es
x (Ptr (DescriptorSetLayoutSupport es) -> IO b
f Ptr (DescriptorSetLayoutSupport es)
p)
  pokeCStruct :: forall b.
Ptr (DescriptorSetLayoutSupport es)
-> DescriptorSetLayoutSupport es -> IO b -> IO b
pokeCStruct Ptr (DescriptorSetLayoutSupport es)
p DescriptorSetLayoutSupport{Bool
Chain es
supported :: Bool
next :: Chain es
$sel:supported:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport es -> Bool
$sel:next:DescriptorSetLayoutSupport :: forall (es :: [*]). DescriptorSetLayoutSupport 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 (DescriptorSetLayoutSupport es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT)
    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 (DescriptorSetLayoutSupport 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 (DescriptorSetLayoutSupport es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
supported))
    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
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr (DescriptorSetLayoutSupport es) -> IO b -> IO b
pokeZeroCStruct Ptr (DescriptorSetLayoutSupport 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 (DescriptorSetLayoutSupport es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT)
    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 (DescriptorSetLayoutSupport 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 (DescriptorSetLayoutSupport es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (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 DescriptorSetLayoutSupport es
         , PeekChain es ) => FromCStruct (DescriptorSetLayoutSupport es) where
  peekCStruct :: Ptr (DescriptorSetLayoutSupport es)
-> IO (DescriptorSetLayoutSupport es)
peekCStruct Ptr (DescriptorSetLayoutSupport es)
p = do
    Ptr ()
pNext <- forall a. Storable a => Ptr a -> IO a
peek @(Ptr ()) ((Ptr (DescriptorSetLayoutSupport 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)
    Bool32
supported <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr (DescriptorSetLayoutSupport es)
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall (es :: [*]).
Chain es -> Bool -> DescriptorSetLayoutSupport es
DescriptorSetLayoutSupport
             Chain es
next (Bool32 -> Bool
bool32ToBool Bool32
supported)

instance es ~ '[] => Zero (DescriptorSetLayoutSupport es) where
  zero :: DescriptorSetLayoutSupport es
zero = forall (es :: [*]).
Chain es -> Bool -> DescriptorSetLayoutSupport es
DescriptorSetLayoutSupport
           ()
           forall a. Zero a => a
zero