{-# language CPP #-}
module Vulkan.Core10.LayerDiscovery  ( enumerateInstanceLayerProperties
                                     , enumerateDeviceLayerProperties
                                     , LayerProperties(..)
                                     ) where

import Vulkan.CStruct.Utils (FixedArray)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import Foreign.Ptr (castFunPtr)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.ByteString (packCString)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import Control.Monad.IO.Class (MonadIO)
import Data.Typeable (Typeable)
import Foreign.C.Types (CChar)
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 GHC.Ptr (Ptr(Ptr))
import Data.Word (Word32)
import Data.ByteString (ByteString)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Dynamic (getInstanceProcAddr')
import Vulkan.CStruct.Utils (lowerArrayPtr)
import Vulkan.CStruct.Utils (pokeFixedLengthNullTerminatedByteString)
import Vulkan.NamedType ((:::))
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Dynamic (InstanceCmds(pVkEnumerateDeviceLayerProperties))
import Vulkan.Core10.APIConstants (MAX_DESCRIPTION_SIZE)
import Vulkan.Core10.APIConstants (MAX_EXTENSION_NAME_SIZE)
import Vulkan.Core10.Handles (PhysicalDevice)
import Vulkan.Core10.Handles (PhysicalDevice(..))
import Vulkan.Core10.Handles (PhysicalDevice_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Exception (VulkanException(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkEnumerateInstanceLayerProperties
  :: FunPtr (Ptr Word32 -> Ptr LayerProperties -> IO Result) -> Ptr Word32 -> Ptr LayerProperties -> IO Result

-- | vkEnumerateInstanceLayerProperties - Returns up to requested number of
-- global layer properties
--
-- = Description
--
-- If @pProperties@ is @NULL@, then the number of layer properties
-- available is returned in @pPropertyCount@. Otherwise, @pPropertyCount@
-- /must/ point to a variable set by the user to the number of elements in
-- the @pProperties@ array, and on return the variable is overwritten with
-- the number of structures actually written to @pProperties@. If
-- @pPropertyCount@ is less than the number of layer properties available,
-- at most @pPropertyCount@ structures will be written. If @pPropertyCount@
-- is smaller than the number of layers available,
-- 'Vulkan.Core10.Enums.Result.INCOMPLETE' will be returned instead of
-- 'Vulkan.Core10.Enums.Result.SUCCESS', to indicate that not all the
-- available layer properties were returned.
--
-- The list of available layers may change at any time due to actions
-- outside of the Vulkan implementation, so two calls to
-- 'enumerateInstanceLayerProperties' with the same parameters /may/ return
-- different results, or retrieve different @pPropertyCount@ values or
-- @pProperties@ contents. Once an instance has been created, the layers
-- enabled for that instance will continue to be enabled and valid for the
-- lifetime of that instance, even if some of them become unavailable for
-- future instances.
--
-- == Valid Usage (Implicit)
--
-- -   @pPropertyCount@ /must/ be a valid pointer to a @uint32_t@ value
--
-- -   If the value referenced by @pPropertyCount@ is not @0@, and
--     @pProperties@ is not @NULL@, @pProperties@ /must/ be a valid pointer
--     to an array of @pPropertyCount@ 'LayerProperties' structures
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
--     -   'Vulkan.Core10.Enums.Result.INCOMPLETE'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
-- = See Also
--
-- 'LayerProperties'
enumerateInstanceLayerProperties :: forall io
                                  . (MonadIO io)
                                 => io (Result, ("properties" ::: Vector LayerProperties))
enumerateInstanceLayerProperties :: io (Result, "properties" ::: Vector LayerProperties)
enumerateInstanceLayerProperties  = IO (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "properties" ::: Vector LayerProperties)
 -> io (Result, "properties" ::: Vector LayerProperties))
-> (ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      (Result, "properties" ::: Vector LayerProperties)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result, "properties" ::: Vector LayerProperties)
  IO
  (Result, "properties" ::: Vector LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result, "properties" ::: Vector LayerProperties)
   IO
   (Result, "properties" ::: Vector LayerProperties)
 -> io (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ do
  FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
vkEnumerateInstanceLayerPropertiesPtr <- IO
  (FunPtr
     (("pPropertyCount" ::: Ptr Word32)
      -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (FunPtr
        (("pPropertyCount" ::: Ptr Word32)
         -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
   (FunPtr
      (("pPropertyCount" ::: Ptr Word32)
       -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      (FunPtr
         (("pPropertyCount" ::: Ptr Word32)
          -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)))
-> IO
     (FunPtr
        (("pPropertyCount" ::: Ptr Word32)
         -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (FunPtr
        (("pPropertyCount" ::: Ptr Word32)
         -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
forall a b. (a -> b) -> a -> b
$ FunPtr FN_vkVoidFunction
-> FunPtr
     (("pPropertyCount" ::: Ptr Word32)
      -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
forall a b. FunPtr a -> FunPtr b
castFunPtr @_ @(("pPropertyCount" ::: Ptr Word32) -> ("pProperties" ::: Ptr LayerProperties) -> IO Result) (FunPtr FN_vkVoidFunction
 -> FunPtr
      (("pPropertyCount" ::: Ptr Word32)
       -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
-> IO (FunPtr FN_vkVoidFunction)
-> IO
     (FunPtr
        (("pPropertyCount" ::: Ptr Word32)
         -> ("pProperties" ::: Ptr LayerProperties) -> IO Result))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T
-> ("pName" ::: Ptr CChar) -> IO (FunPtr FN_vkVoidFunction)
getInstanceProcAddr' Ptr Instance_T
forall a. Ptr a
nullPtr (Addr# -> "pName" ::: Ptr CChar
forall a. Addr# -> Ptr a
Ptr "vkEnumerateInstanceLayerProperties"#)
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
vkEnumerateInstanceLayerPropertiesPtr FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
-> FunPtr
     (("pPropertyCount" ::: Ptr Word32)
      -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for vkEnumerateInstanceLayerProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkEnumerateInstanceLayerProperties' :: ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties) -> IO Result
vkEnumerateInstanceLayerProperties' = FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties)
-> IO Result
mkVkEnumerateInstanceLayerProperties FunPtr
  (("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties) -> IO Result)
vkEnumerateInstanceLayerPropertiesPtr
  "pPropertyCount" ::: Ptr Word32
pPPropertyCount <- ((("pPropertyCount" ::: Ptr Word32)
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pPropertyCount" ::: Ptr Word32)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pPropertyCount" ::: Ptr Word32)
   -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("pPropertyCount" ::: Ptr Word32))
-> ((("pPropertyCount" ::: Ptr Word32)
     -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pPropertyCount" ::: Ptr Word32)
forall a b. (a -> b) -> a -> b
$ IO ("pPropertyCount" ::: Ptr Word32)
-> (("pPropertyCount" ::: Ptr Word32) -> IO ())
-> (("pPropertyCount" ::: Ptr Word32)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pPropertyCount" ::: Ptr Word32)
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("pPropertyCount" ::: Ptr Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Result)
-> IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties) -> IO Result
vkEnumerateInstanceLayerProperties' ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) ("pProperties" ::: Ptr LayerProperties
forall a. Ptr a
nullPtr)
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Word32
pPropertyCount <- IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Word32)
-> IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPropertyCount" ::: Ptr Word32
pPPropertyCount
  "pProperties" ::: Ptr LayerProperties
pPProperties <- ((("pProperties" ::: Ptr LayerProperties)
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pProperties" ::: Ptr LayerProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pProperties" ::: Ptr LayerProperties)
   -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("pProperties" ::: Ptr LayerProperties))
-> ((("pProperties" ::: Ptr LayerProperties)
     -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pProperties" ::: Ptr LayerProperties)
forall a b. (a -> b) -> a -> b
$ IO ("pProperties" ::: Ptr LayerProperties)
-> (("pProperties" ::: Ptr LayerProperties) -> IO ())
-> (("pProperties" ::: Ptr LayerProperties)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pProperties" ::: Ptr LayerProperties)
forall a. Int -> IO (Ptr a)
callocBytes @LayerProperties ((Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 520)) ("pProperties" ::: Ptr LayerProperties) -> IO ()
forall a. Ptr a -> IO ()
free
  [()]
_ <- (Int
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> [Int]
-> ContT (Result, "properties" ::: Vector LayerProperties) IO [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\i :: Int
i -> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ ("pProperties" ::: Ptr LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct ("pProperties" ::: Ptr LayerProperties
pPProperties ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pProperties" ::: Ptr LayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 520) :: Ptr LayerProperties) (IO (Result, "properties" ::: Vector LayerProperties)
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> (() -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO (Result, "properties" ::: Vector LayerProperties))
-> () -> IO (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1]
  Result
r' <- IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Result)
-> IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties) -> IO Result
vkEnumerateInstanceLayerProperties' ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) (("pProperties" ::: Ptr LayerProperties
pPProperties))
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r' Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r'))
  Word32
pPropertyCount' <- IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Word32)
-> IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPropertyCount" ::: Ptr Word32
pPPropertyCount
  "properties" ::: Vector LayerProperties
pProperties' <- IO ("properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("properties" ::: Vector LayerProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector LayerProperties)
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("properties" ::: Vector LayerProperties))
-> IO ("properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO LayerProperties)
-> IO ("properties" ::: Vector LayerProperties)
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
pPropertyCount')) (\i :: Int
i -> ("pProperties" ::: Ptr LayerProperties) -> IO LayerProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @LayerProperties ((("pProperties" ::: Ptr LayerProperties
pPProperties) ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pProperties" ::: Ptr LayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (520 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr LayerProperties)))
  (Result, "properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "properties" ::: Vector LayerProperties)
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      (Result, "properties" ::: Vector LayerProperties))
-> (Result, "properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "properties" ::: Vector LayerProperties
pProperties')


foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkEnumerateDeviceLayerProperties
  :: FunPtr (Ptr PhysicalDevice_T -> Ptr Word32 -> Ptr LayerProperties -> IO Result) -> Ptr PhysicalDevice_T -> Ptr Word32 -> Ptr LayerProperties -> IO Result

-- | vkEnumerateDeviceLayerProperties - Returns properties of available
-- physical device layers
--
-- = Description
--
-- If @pProperties@ is @NULL@, then the number of layer properties
-- available is returned in @pPropertyCount@. Otherwise, @pPropertyCount@
-- /must/ point to a variable set by the user to the number of elements in
-- the @pProperties@ array, and on return the variable is overwritten with
-- the number of structures actually written to @pProperties@. If
-- @pPropertyCount@ is less than the number of layer properties available,
-- at most @pPropertyCount@ structures will be written. If @pPropertyCount@
-- is smaller than the number of layers available,
-- 'Vulkan.Core10.Enums.Result.INCOMPLETE' will be returned instead of
-- 'Vulkan.Core10.Enums.Result.SUCCESS', to indicate that not all the
-- available layer properties were returned.
--
-- The list of layers enumerated by 'enumerateDeviceLayerProperties' /must/
-- be exactly the sequence of layers enabled for the instance. The members
-- of 'LayerProperties' for each enumerated layer /must/ be the same as the
-- properties when the layer was enumerated by
-- 'enumerateInstanceLayerProperties'.
--
-- == Valid Usage (Implicit)
--
-- -   @physicalDevice@ /must/ be a valid
--     'Vulkan.Core10.Handles.PhysicalDevice' handle
--
-- -   @pPropertyCount@ /must/ be a valid pointer to a @uint32_t@ value
--
-- -   If the value referenced by @pPropertyCount@ is not @0@, and
--     @pProperties@ is not @NULL@, @pProperties@ /must/ be a valid pointer
--     to an array of @pPropertyCount@ 'LayerProperties' structures
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
--     -   'Vulkan.Core10.Enums.Result.INCOMPLETE'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
-- = See Also
--
-- 'LayerProperties', 'Vulkan.Core10.Handles.PhysicalDevice'
enumerateDeviceLayerProperties :: forall io
                                . (MonadIO io)
                               => -- No documentation found for Nested "vkEnumerateDeviceLayerProperties" "physicalDevice"
                                  PhysicalDevice
                               -> io (Result, ("properties" ::: Vector LayerProperties))
enumerateDeviceLayerProperties :: PhysicalDevice
-> io (Result, "properties" ::: Vector LayerProperties)
enumerateDeviceLayerProperties physicalDevice :: PhysicalDevice
physicalDevice = IO (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "properties" ::: Vector LayerProperties)
 -> io (Result, "properties" ::: Vector LayerProperties))
-> (ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      (Result, "properties" ::: Vector LayerProperties)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
  (Result, "properties" ::: Vector LayerProperties)
  IO
  (Result, "properties" ::: Vector LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
   (Result, "properties" ::: Vector LayerProperties)
   IO
   (Result, "properties" ::: Vector LayerProperties)
 -> io (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
-> io (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ do
  let vkEnumerateDeviceLayerPropertiesPtr :: FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
vkEnumerateDeviceLayerPropertiesPtr = InstanceCmds
-> FunPtr
     (Ptr PhysicalDevice_T
      -> ("pPropertyCount" ::: Ptr Word32)
      -> ("pProperties" ::: Ptr LayerProperties)
      -> IO Result)
pVkEnumerateDeviceLayerProperties (PhysicalDevice -> InstanceCmds
instanceCmds (PhysicalDevice
physicalDevice :: PhysicalDevice))
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
vkEnumerateDeviceLayerPropertiesPtr FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
-> FunPtr
     (Ptr PhysicalDevice_T
      -> ("pPropertyCount" ::: Ptr Word32)
      -> ("pProperties" ::: Ptr LayerProperties)
      -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (IOException -> IO ()) -> IOException -> IO ()
forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError Maybe Handle
forall a. Maybe a
Nothing IOErrorType
InvalidArgument "" "The function pointer for vkEnumerateDeviceLayerProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkEnumerateDeviceLayerProperties' :: Ptr PhysicalDevice_T
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties)
-> IO Result
vkEnumerateDeviceLayerProperties' = FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
-> Ptr PhysicalDevice_T
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties)
-> IO Result
mkVkEnumerateDeviceLayerProperties FunPtr
  (Ptr PhysicalDevice_T
   -> ("pPropertyCount" ::: Ptr Word32)
   -> ("pProperties" ::: Ptr LayerProperties)
   -> IO Result)
vkEnumerateDeviceLayerPropertiesPtr
  let physicalDevice' :: Ptr PhysicalDevice_T
physicalDevice' = PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)
  "pPropertyCount" ::: Ptr Word32
pPPropertyCount <- ((("pPropertyCount" ::: Ptr Word32)
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pPropertyCount" ::: Ptr Word32)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pPropertyCount" ::: Ptr Word32)
   -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("pPropertyCount" ::: Ptr Word32))
-> ((("pPropertyCount" ::: Ptr Word32)
     -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pPropertyCount" ::: Ptr Word32)
forall a b. (a -> b) -> a -> b
$ IO ("pPropertyCount" ::: Ptr Word32)
-> (("pPropertyCount" ::: Ptr Word32) -> IO ())
-> (("pPropertyCount" ::: Ptr Word32)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pPropertyCount" ::: Ptr Word32)
forall a. Int -> IO (Ptr a)
callocBytes @Word32 4) ("pPropertyCount" ::: Ptr Word32) -> IO ()
forall a. Ptr a -> IO ()
free
  Result
r <- IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Result)
-> IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ Ptr PhysicalDevice_T
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties)
-> IO Result
vkEnumerateDeviceLayerProperties' Ptr PhysicalDevice_T
physicalDevice' ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) ("pProperties" ::: Ptr LayerProperties
forall a. Ptr a
nullPtr)
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
  Word32
pPropertyCount <- IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Word32)
-> IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPropertyCount" ::: Ptr Word32
pPPropertyCount
  "pProperties" ::: Ptr LayerProperties
pPProperties <- ((("pProperties" ::: Ptr LayerProperties)
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pProperties" ::: Ptr LayerProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pProperties" ::: Ptr LayerProperties)
   -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("pProperties" ::: Ptr LayerProperties))
-> ((("pProperties" ::: Ptr LayerProperties)
     -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("pProperties" ::: Ptr LayerProperties)
forall a b. (a -> b) -> a -> b
$ IO ("pProperties" ::: Ptr LayerProperties)
-> (("pProperties" ::: Ptr LayerProperties) -> IO ())
-> (("pProperties" ::: Ptr LayerProperties)
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pProperties" ::: Ptr LayerProperties)
forall a. Int -> IO (Ptr a)
callocBytes @LayerProperties ((Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 520)) ("pProperties" ::: Ptr LayerProperties) -> IO ()
forall a. Ptr a -> IO ()
free
  [()]
_ <- (Int
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> [Int]
-> ContT (Result, "properties" ::: Vector LayerProperties) IO [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (\i :: Int
i -> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO (Result, "properties" ::: Vector LayerProperties))
  -> IO (Result, "properties" ::: Vector LayerProperties))
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ ("pProperties" ::: Ptr LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
-> IO (Result, "properties" ::: Vector LayerProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct ("pProperties" ::: Ptr LayerProperties
pPProperties ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pProperties" ::: Ptr LayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 520) :: Ptr LayerProperties) (IO (Result, "properties" ::: Vector LayerProperties)
 -> IO (Result, "properties" ::: Vector LayerProperties))
-> ((() -> IO (Result, "properties" ::: Vector LayerProperties))
    -> IO (Result, "properties" ::: Vector LayerProperties))
-> (() -> IO (Result, "properties" ::: Vector LayerProperties))
-> IO (Result, "properties" ::: Vector LayerProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO (Result, "properties" ::: Vector LayerProperties))
-> () -> IO (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ ())) [0..(Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
- 1]
  Result
r' <- IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Result)
-> IO Result
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Result
forall a b. (a -> b) -> a -> b
$ Ptr PhysicalDevice_T
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr LayerProperties)
-> IO Result
vkEnumerateDeviceLayerProperties' Ptr PhysicalDevice_T
physicalDevice' ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) (("pProperties" ::: Ptr LayerProperties
pPProperties))
  IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
 -> ContT (Result, "properties" ::: Vector LayerProperties) IO ())
-> IO ()
-> ContT (Result, "properties" ::: Vector LayerProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r' Result -> Result -> Bool
forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (VulkanException -> IO ()
forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r'))
  Word32
pPropertyCount' <- IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
 -> ContT
      (Result, "properties" ::: Vector LayerProperties) IO Word32)
-> IO Word32
-> ContT
     (Result, "properties" ::: Vector LayerProperties) IO Word32
forall a b. (a -> b) -> a -> b
$ ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 "pPropertyCount" ::: Ptr Word32
pPPropertyCount
  "properties" ::: Vector LayerProperties
pProperties' <- IO ("properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("properties" ::: Vector LayerProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector LayerProperties)
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      ("properties" ::: Vector LayerProperties))
-> IO ("properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     ("properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO LayerProperties)
-> IO ("properties" ::: Vector LayerProperties)
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
pPropertyCount')) (\i :: Int
i -> ("pProperties" ::: Ptr LayerProperties) -> IO LayerProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @LayerProperties ((("pProperties" ::: Ptr LayerProperties
pPProperties) ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pProperties" ::: Ptr LayerProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (520 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr LayerProperties)))
  (Result, "properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "properties" ::: Vector LayerProperties)
 -> ContT
      (Result, "properties" ::: Vector LayerProperties)
      IO
      (Result, "properties" ::: Vector LayerProperties))
-> (Result, "properties" ::: Vector LayerProperties)
-> ContT
     (Result, "properties" ::: Vector LayerProperties)
     IO
     (Result, "properties" ::: Vector LayerProperties)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "properties" ::: Vector LayerProperties
pProperties')


-- | VkLayerProperties - Structure specifying layer properties
--
-- = See Also
--
-- 'enumerateDeviceLayerProperties', 'enumerateInstanceLayerProperties'
data LayerProperties = LayerProperties
  { -- | @layerName@ is an array of
    -- 'Vulkan.Core10.APIConstants.MAX_EXTENSION_NAME_SIZE' @char@ containing a
    -- null-terminated UTF-8 string which is the name of the layer. Use this
    -- name in the @ppEnabledLayerNames@ array passed in the
    -- 'Vulkan.Core10.DeviceInitialization.InstanceCreateInfo' structure to
    -- enable this layer for an instance.
    LayerProperties -> ByteString
layerName :: ByteString
  , -- | @specVersion@ is the Vulkan version the layer was written to, encoded as
    -- described in
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#extendingvulkan-coreversions-versionnumbers>.
    LayerProperties -> Word32
specVersion :: Word32
  , -- | @implementationVersion@ is the version of this layer. It is an integer,
    -- increasing with backward compatible changes.
    LayerProperties -> Word32
implementationVersion :: Word32
  , -- | @description@ is an array of
    -- 'Vulkan.Core10.APIConstants.MAX_DESCRIPTION_SIZE' @char@ containing a
    -- null-terminated UTF-8 string which provides additional details that
    -- /can/ be used by the application to identify the layer.
    LayerProperties -> ByteString
description :: ByteString
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (LayerProperties)
#endif
deriving instance Show LayerProperties

instance ToCStruct LayerProperties where
  withCStruct :: LayerProperties
-> (("pProperties" ::: Ptr LayerProperties) -> IO b) -> IO b
withCStruct x :: LayerProperties
x f :: ("pProperties" ::: Ptr LayerProperties) -> IO b
f = Int
-> Int -> (("pProperties" ::: Ptr LayerProperties) -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 520 4 ((("pProperties" ::: Ptr LayerProperties) -> IO b) -> IO b)
-> (("pProperties" ::: Ptr LayerProperties) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pProperties" ::: Ptr LayerProperties
p -> ("pProperties" ::: Ptr LayerProperties)
-> LayerProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pProperties" ::: Ptr LayerProperties
p LayerProperties
x (("pProperties" ::: Ptr LayerProperties) -> IO b
f "pProperties" ::: Ptr LayerProperties
p)
  pokeCStruct :: ("pProperties" ::: Ptr LayerProperties)
-> LayerProperties -> IO b -> IO b
pokeCStruct p :: "pProperties" ::: Ptr LayerProperties
p LayerProperties{..} f :: IO b
f = do
    Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ByteString -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ByteString -> IO ()
pokeFixedLengthNullTerminatedByteString (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))) (ByteString
layerName)
    ("pPropertyCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32)) (Word32
specVersion)
    ("pPropertyCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32)) (Word32
implementationVersion)
    Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ByteString -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ByteString -> IO ()
pokeFixedLengthNullTerminatedByteString (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr (FixedArray MAX_DESCRIPTION_SIZE CChar))) (ByteString
description)
    IO b
f
  cStructSize :: Int
cStructSize = 520
  cStructAlignment :: Int
cStructAlignment = 4
  pokeZeroCStruct :: ("pProperties" ::: Ptr LayerProperties) -> IO b -> IO b
pokeZeroCStruct p :: "pProperties" ::: Ptr LayerProperties
p f :: IO b
f = do
    Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ByteString -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ByteString -> IO ()
pokeFixedLengthNullTerminatedByteString (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))) (ByteString
forall a. Monoid a => a
mempty)
    ("pPropertyCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    ("pPropertyCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> ByteString -> IO ()
forall (n :: Nat).
KnownNat n =>
Ptr (FixedArray n CChar) -> ByteString -> IO ()
pokeFixedLengthNullTerminatedByteString (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr (FixedArray MAX_DESCRIPTION_SIZE CChar))) (ByteString
forall a. Monoid a => a
mempty)
    IO b
f

instance FromCStruct LayerProperties where
  peekCStruct :: ("pProperties" ::: Ptr LayerProperties) -> IO LayerProperties
peekCStruct p :: "pProperties" ::: Ptr LayerProperties
p = do
    ByteString
layerName <- ("pName" ::: Ptr CChar) -> IO ByteString
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "pName" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar))))
    Word32
specVersion <- ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32))
    Word32
implementationVersion <- ("pPropertyCount" ::: Ptr Word32) -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 260 :: Ptr Word32))
    ByteString
description <- ("pName" ::: Ptr CChar) -> IO ByteString
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "pName" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr (("pProperties" ::: Ptr LayerProperties
p ("pProperties" ::: Ptr LayerProperties)
-> Int -> Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 264 :: Ptr (FixedArray MAX_DESCRIPTION_SIZE CChar))))
    LayerProperties -> IO LayerProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (LayerProperties -> IO LayerProperties)
-> LayerProperties -> IO LayerProperties
forall a b. (a -> b) -> a -> b
$ ByteString -> Word32 -> Word32 -> ByteString -> LayerProperties
LayerProperties
             ByteString
layerName Word32
specVersion Word32
implementationVersion ByteString
description

instance Storable LayerProperties where
  sizeOf :: LayerProperties -> Int
sizeOf ~LayerProperties
_ = 520
  alignment :: LayerProperties -> Int
alignment ~LayerProperties
_ = 4
  peek :: ("pProperties" ::: Ptr LayerProperties) -> IO LayerProperties
peek = ("pProperties" ::: Ptr LayerProperties) -> IO LayerProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: ("pProperties" ::: Ptr LayerProperties) -> LayerProperties -> IO ()
poke ptr :: "pProperties" ::: Ptr LayerProperties
ptr poked :: LayerProperties
poked = ("pProperties" ::: Ptr LayerProperties)
-> LayerProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pProperties" ::: Ptr LayerProperties
ptr LayerProperties
poked (FN_vkVoidFunction
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero LayerProperties where
  zero :: LayerProperties
zero = ByteString -> Word32 -> Word32 -> ByteString -> LayerProperties
LayerProperties
           ByteString
forall a. Monoid a => a
mempty
           Word32
forall a. Zero a => a
zero
           Word32
forall a. Zero a => a
zero
           ByteString
forall a. Monoid a => a
mempty