{-# language CPP #-}
module Graphics.Vulkan.Core11.DeviceInitialization (enumerateInstanceVersion) where
import Control.Exception.Base (bracket)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import Foreign.Ptr (castFunPtr)
import Foreign.Ptr (nullPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Control.Monad.IO.Class (MonadIO)
import Foreign.Storable (Storable(peek))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import GHC.Ptr (Ptr(Ptr))
import Data.Word (Word32)
import Control.Monad.Trans.Cont (ContT(..))
import Graphics.Vulkan.Dynamic (getInstanceProcAddr')
import Graphics.Vulkan.NamedType ((:::))
import Graphics.Vulkan.Core10.Enums.Result (Result)
import Graphics.Vulkan.Core10.Enums.Result (Result(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkEnumerateInstanceVersion
:: FunPtr (Ptr Word32 -> IO Result) -> Ptr Word32 -> IO Result
enumerateInstanceVersion :: forall io . MonadIO io => io (("apiVersion" ::: Word32))
enumerateInstanceVersion = liftIO . evalContT $ do
vkEnumerateInstanceVersion' <- lift $ mkVkEnumerateInstanceVersion . castFunPtr @_ @(("pApiVersion" ::: Ptr Word32) -> IO Result) <$> getInstanceProcAddr' nullPtr (Ptr "vkEnumerateInstanceVersion"#)
pPApiVersion <- ContT $ bracket (callocBytes @Word32 4) free
_ <- lift $ vkEnumerateInstanceVersion' (pPApiVersion)
pApiVersion <- lift $ peek @Word32 pPApiVersion
pure $ (pApiVersion)