{-# language CPP #-}
module Vulkan.Core10.ExtensionDiscovery ( enumerateInstanceExtensionProperties
, enumerateDeviceExtensionProperties
, ExtensionProperties(..)
) where
import Vulkan.CStruct.Utils (FixedArray)
import Vulkan.Internal.Utils (traceAroundEvent)
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 Data.ByteString (useAsCString)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import Foreign.C.Types (CChar(..))
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.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.Dynamic (InstanceCmds(pVkEnumerateDeviceExtensionProperties))
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.Exception (VulkanException(..))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkEnumerateInstanceExtensionProperties
:: FunPtr (Ptr CChar -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result) -> Ptr CChar -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result
enumerateInstanceExtensionProperties :: forall io
. (MonadIO io)
=>
("layerName" ::: Maybe ByteString)
-> io (Result, ("properties" ::: Vector ExtensionProperties))
enumerateInstanceExtensionProperties :: ("layerName" ::: Maybe ByteString)
-> io (Result, "properties" ::: Vector ExtensionProperties)
enumerateInstanceExtensionProperties layerName :: "layerName" ::: Maybe ByteString
layerName = IO (Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties))
-> (ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ do
FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateInstanceExtensionPropertiesPtr <- IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)))
-> IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
forall a b. (a -> b) -> a -> b
$ FunPtr FN_vkVoidFunction
-> FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
forall a b. FunPtr a -> FunPtr b
castFunPtr @_ @(("pLayerName" ::: Ptr CChar) -> ("pPropertyCount" ::: Ptr Word32) -> ("pProperties" ::: Ptr ExtensionProperties) -> IO Result) (FunPtr FN_vkVoidFunction
-> FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
-> IO (FunPtr FN_vkVoidFunction)
-> IO
(FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr Instance_T
-> ("pLayerName" ::: Ptr CChar) -> IO (FunPtr FN_vkVoidFunction)
getInstanceProcAddr' Ptr Instance_T
forall a. Ptr a
nullPtr (Addr# -> "pLayerName" ::: Ptr CChar
forall a. Addr# -> Ptr a
Ptr "vkEnumerateInstanceExtensionProperties"#)
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateInstanceExtensionPropertiesPtr FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> 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 vkEnumerateInstanceExtensionProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkEnumerateInstanceExtensionProperties' :: ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateInstanceExtensionProperties' = FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
mkVkEnumerateInstanceExtensionProperties FunPtr
(("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateInstanceExtensionPropertiesPtr
"pLayerName" ::: Ptr CChar
pLayerName <- case ("layerName" ::: Maybe ByteString
layerName) of
Nothing -> ("pLayerName" ::: Ptr CChar)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pLayerName" ::: Ptr CChar
forall a. Ptr a
nullPtr
Just j :: ByteString
j -> ((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar))
-> ((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ByteString
-> (("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a.
ByteString -> (("pLayerName" ::: Ptr CChar) -> IO a) -> IO a
useAsCString (ByteString
j)
"pPropertyCount" ::: Ptr Word32
pPPropertyCount <- ((("pPropertyCount" ::: Ptr Word32)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pPropertyCount" ::: Ptr Word32))
-> ((("pPropertyCount" ::: Ptr Word32)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkEnumerateInstanceExtensionProperties" (("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateInstanceExtensionProperties' "pLayerName" ::: Ptr CChar
pLayerName ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) ("pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a
nullPtr))
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Word32)
-> IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties
pPProperties <- ((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties))
-> ((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ IO ("pProperties" ::: Ptr ExtensionProperties)
-> (("pProperties" ::: Ptr ExtensionProperties) -> IO ())
-> (("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pProperties" ::: Ptr ExtensionProperties)
forall a. Int -> IO (Ptr a)
callocBytes @ExtensionProperties ((Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 260)) ("pProperties" ::: Ptr ExtensionProperties) -> IO ()
forall a. Ptr a -> IO ()
free
[()]
_ <- (Int
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> [Int]
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> ((()
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ ("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct ("pProperties" ::: Ptr ExtensionProperties
pPProperties ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 260) :: Ptr ExtensionProperties) (IO (Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ((()
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> (() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> () -> IO (Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkEnumerateInstanceExtensionProperties" (("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateInstanceExtensionProperties' "pLayerName" ::: Ptr CChar
pLayerName ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) (("pProperties" ::: Ptr ExtensionProperties
pPProperties)))
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Word32)
-> IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties
pProperties' <- IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties)
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 ExtensionProperties)
-> IO ExtensionProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ExtensionProperties ((("pProperties" ::: Ptr ExtensionProperties
pPProperties) ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (260 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ExtensionProperties)))
(Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties))
-> (Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "properties" ::: Vector ExtensionProperties
pProperties')
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkEnumerateDeviceExtensionProperties
:: FunPtr (Ptr PhysicalDevice_T -> Ptr CChar -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result) -> Ptr PhysicalDevice_T -> Ptr CChar -> Ptr Word32 -> Ptr ExtensionProperties -> IO Result
enumerateDeviceExtensionProperties :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
("layerName" ::: Maybe ByteString)
-> io (Result, ("properties" ::: Vector ExtensionProperties))
enumerateDeviceExtensionProperties :: PhysicalDevice
-> ("layerName" ::: Maybe ByteString)
-> io (Result, "properties" ::: Vector ExtensionProperties)
enumerateDeviceExtensionProperties physicalDevice :: PhysicalDevice
physicalDevice layerName :: "layerName" ::: Maybe ByteString
layerName = IO (Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties))
-> (ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
-> io (Result, "properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ do
let vkEnumerateDeviceExtensionPropertiesPtr :: FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateDeviceExtensionPropertiesPtr = InstanceCmds
-> FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
pVkEnumerateDeviceExtensionProperties (PhysicalDevice -> InstanceCmds
instanceCmds (PhysicalDevice
physicalDevice :: PhysicalDevice))
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateDeviceExtensionPropertiesPtr FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> 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 vkEnumerateDeviceExtensionProperties is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkEnumerateDeviceExtensionProperties' :: Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateDeviceExtensionProperties' = FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
-> Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
mkVkEnumerateDeviceExtensionProperties FunPtr
(Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result)
vkEnumerateDeviceExtensionPropertiesPtr
let physicalDevice' :: Ptr PhysicalDevice_T
physicalDevice' = PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)
"pLayerName" ::: Ptr CChar
pLayerName <- case ("layerName" ::: Maybe ByteString
layerName) of
Nothing -> ("pLayerName" ::: Ptr CChar)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall (f :: * -> *) a. Applicative f => a -> f a
pure "pLayerName" ::: Ptr CChar
forall a. Ptr a
nullPtr
Just j :: ByteString
j -> ((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar))
-> ((("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pLayerName" ::: Ptr CChar)
forall a b. (a -> b) -> a -> b
$ ByteString
-> (("pLayerName" ::: Ptr CChar)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a.
ByteString -> (("pLayerName" ::: Ptr CChar) -> IO a) -> IO a
useAsCString (ByteString
j)
"pPropertyCount" ::: Ptr Word32
pPPropertyCount <- ((("pPropertyCount" ::: Ptr Word32)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pPropertyCount" ::: Ptr Word32))
-> ((("pPropertyCount" ::: Ptr Word32)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkEnumerateDeviceExtensionProperties" (Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateDeviceExtensionProperties' Ptr PhysicalDevice_T
physicalDevice' "pLayerName" ::: Ptr CChar
pLayerName ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) ("pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a
nullPtr))
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Word32)
-> IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties
pPProperties <- ((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties))
-> ((("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("pProperties" ::: Ptr ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ IO ("pProperties" ::: Ptr ExtensionProperties)
-> (("pProperties" ::: Ptr ExtensionProperties) -> IO ())
-> (("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pProperties" ::: Ptr ExtensionProperties)
forall a. Int -> IO (Ptr a)
callocBytes @ExtensionProperties ((Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
pPropertyCount)) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 260)) ("pProperties" ::: Ptr ExtensionProperties) -> IO ()
forall a. Ptr a -> IO ()
free
[()]
_ <- (Int
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> [Int]
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> ((()
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall a b. (a -> b) -> a -> b
$ ("pProperties" ::: Ptr ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall a b. ToCStruct a => Ptr a -> IO b -> IO b
pokeZeroCStruct ("pProperties" ::: Ptr ExtensionProperties
pPProperties ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* 260) :: Ptr ExtensionProperties) (IO (Result, "properties" ::: Vector ExtensionProperties)
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> ((()
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties))
-> (() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> IO (Result, "properties" ::: Vector ExtensionProperties)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO (Result, "properties" ::: Vector ExtensionProperties))
-> () -> IO (Result, "properties" ::: Vector ExtensionProperties)
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 ExtensionProperties) IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result)
-> IO Result
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkEnumerateDeviceExtensionProperties" (Ptr PhysicalDevice_T
-> ("pLayerName" ::: Ptr CChar)
-> ("pPropertyCount" ::: Ptr Word32)
-> ("pProperties" ::: Ptr ExtensionProperties)
-> IO Result
vkEnumerateDeviceExtensionProperties' Ptr PhysicalDevice_T
physicalDevice' "pLayerName" ::: Ptr CChar
pLayerName ("pPropertyCount" ::: Ptr Word32
pPPropertyCount) (("pProperties" ::: Ptr ExtensionProperties
pPProperties)))
IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO ())
-> IO ()
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties) IO Word32
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) IO Word32)
-> IO Word32
-> ContT
(Result, "properties" ::: Vector ExtensionProperties) 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 ExtensionProperties
pProperties' <- IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties))
-> IO ("properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
("properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ Int
-> (Int -> IO ExtensionProperties)
-> IO ("properties" ::: Vector ExtensionProperties)
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 ExtensionProperties)
-> IO ExtensionProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @ExtensionProperties ((("pProperties" ::: Ptr ExtensionProperties
pPProperties) ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pProperties" ::: Ptr ExtensionProperties
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (260 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr ExtensionProperties)))
(Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties))
-> (Result, "properties" ::: Vector ExtensionProperties)
-> ContT
(Result, "properties" ::: Vector ExtensionProperties)
IO
(Result, "properties" ::: Vector ExtensionProperties)
forall a b. (a -> b) -> a -> b
$ ((Result
r'), "properties" ::: Vector ExtensionProperties
pProperties')
data ExtensionProperties = ExtensionProperties
{
ExtensionProperties -> ByteString
extensionName :: ByteString
,
ExtensionProperties -> Word32
specVersion :: Word32
}
deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ExtensionProperties)
#endif
deriving instance Show ExtensionProperties
instance ToCStruct ExtensionProperties where
withCStruct :: ExtensionProperties
-> (("pProperties" ::: Ptr ExtensionProperties) -> IO b) -> IO b
withCStruct x :: ExtensionProperties
x f :: ("pProperties" ::: Ptr ExtensionProperties) -> IO b
f = Int
-> Int
-> (("pProperties" ::: Ptr ExtensionProperties) -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 260 4 ((("pProperties" ::: Ptr ExtensionProperties) -> IO b) -> IO b)
-> (("pProperties" ::: Ptr ExtensionProperties) -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: "pProperties" ::: Ptr ExtensionProperties
p -> ("pProperties" ::: Ptr ExtensionProperties)
-> ExtensionProperties -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pProperties" ::: Ptr ExtensionProperties
p ExtensionProperties
x (("pProperties" ::: Ptr ExtensionProperties) -> IO b
f "pProperties" ::: Ptr ExtensionProperties
p)
pokeCStruct :: ("pProperties" ::: Ptr ExtensionProperties)
-> ExtensionProperties -> IO b -> IO b
pokeCStruct p :: "pProperties" ::: Ptr ExtensionProperties
p ExtensionProperties{..} 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 ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> 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
extensionName)
("pPropertyCount" ::: Ptr Word32) -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (("pProperties" ::: Ptr ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32)) (Word32
specVersion)
IO b
f
cStructSize :: Int
cStructSize = 260
cStructAlignment :: Int
cStructAlignment = 4
pokeZeroCStruct :: ("pProperties" ::: Ptr ExtensionProperties) -> IO b -> IO b
pokeZeroCStruct p :: "pProperties" ::: Ptr ExtensionProperties
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 ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> 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 ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
IO b
f
instance FromCStruct ExtensionProperties where
peekCStruct :: ("pProperties" ::: Ptr ExtensionProperties)
-> IO ExtensionProperties
peekCStruct p :: "pProperties" ::: Ptr ExtensionProperties
p = do
ByteString
extensionName <- ("pLayerName" ::: Ptr CChar) -> IO ByteString
packCString (Ptr (FixedArray MAX_EXTENSION_NAME_SIZE CChar)
-> "pLayerName" ::: Ptr CChar
forall a (n :: Nat). Ptr (FixedArray n a) -> Ptr a
lowerArrayPtr (("pProperties" ::: Ptr ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> 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 ExtensionProperties
p ("pProperties" ::: Ptr ExtensionProperties)
-> Int -> "pPropertyCount" ::: Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 256 :: Ptr Word32))
ExtensionProperties -> IO ExtensionProperties
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExtensionProperties -> IO ExtensionProperties)
-> ExtensionProperties -> IO ExtensionProperties
forall a b. (a -> b) -> a -> b
$ ByteString -> Word32 -> ExtensionProperties
ExtensionProperties
ByteString
extensionName Word32
specVersion
instance Storable ExtensionProperties where
sizeOf :: ExtensionProperties -> Int
sizeOf ~ExtensionProperties
_ = 260
alignment :: ExtensionProperties -> Int
alignment ~ExtensionProperties
_ = 4
peek :: ("pProperties" ::: Ptr ExtensionProperties)
-> IO ExtensionProperties
peek = ("pProperties" ::: Ptr ExtensionProperties)
-> IO ExtensionProperties
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: ("pProperties" ::: Ptr ExtensionProperties)
-> ExtensionProperties -> IO ()
poke ptr :: "pProperties" ::: Ptr ExtensionProperties
ptr poked :: ExtensionProperties
poked = ("pProperties" ::: Ptr ExtensionProperties)
-> ExtensionProperties -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct "pProperties" ::: Ptr ExtensionProperties
ptr ExtensionProperties
poked (FN_vkVoidFunction
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero ExtensionProperties where
zero :: ExtensionProperties
zero = ByteString -> Word32 -> ExtensionProperties
ExtensionProperties
ByteString
forall a. Monoid a => a
mempty
Word32
forall a. Zero a => a
zero