{-# language CPP #-}
module Vulkan.Extensions.VK_NV_acquire_winrt_display ( acquireWinrtDisplayNV
, getWinrtDisplayNV
, NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION
, pattern NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION
, NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME
, pattern NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME
, DisplayKHR(..)
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Exception.Base (bracket)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (callocBytes)
import Foreign.Marshal.Alloc (free)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import Foreign.Storable (Storable(peek))
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Control.Monad.Trans.Cont (ContT(..))
import Vulkan.NamedType ((:::))
import Vulkan.Extensions.Handles (DisplayKHR)
import Vulkan.Extensions.Handles (DisplayKHR(..))
import Vulkan.Dynamic (InstanceCmds(pVkAcquireWinrtDisplayNV))
import Vulkan.Dynamic (InstanceCmds(pVkGetWinrtDisplayNV))
import Vulkan.Core10.Handles (PhysicalDevice)
import Vulkan.Core10.Handles (PhysicalDevice(..))
import Vulkan.Core10.Handles (PhysicalDevice(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))
import Vulkan.Extensions.Handles (DisplayKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkAcquireWinrtDisplayNV
:: FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result) -> Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
acquireWinrtDisplayNV :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
DisplayKHR
-> io ()
acquireWinrtDisplayNV :: PhysicalDevice -> DisplayKHR -> io ()
acquireWinrtDisplayNV PhysicalDevice
physicalDevice DisplayKHR
display = IO () -> io ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> io ()) -> IO () -> io ()
forall a b. (a -> b) -> a -> b
$ do
let vkAcquireWinrtDisplayNVPtr :: FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkAcquireWinrtDisplayNVPtr = InstanceCmds
-> FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
pVkAcquireWinrtDisplayNV (case PhysicalDevice
physicalDevice of PhysicalDevice{InstanceCmds
$sel:instanceCmds:PhysicalDevice :: PhysicalDevice -> InstanceCmds
instanceCmds :: InstanceCmds
instanceCmds} -> InstanceCmds
instanceCmds)
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkAcquireWinrtDisplayNVPtr FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
-> FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result) -> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> 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 String
"" String
"The function pointer for vkAcquireWinrtDisplayNV is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkAcquireWinrtDisplayNV' :: Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
vkAcquireWinrtDisplayNV' = FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
-> Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
mkVkAcquireWinrtDisplayNV FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkAcquireWinrtDisplayNVPtr
Result
r <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkAcquireWinrtDisplayNV" (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
vkAcquireWinrtDisplayNV' (PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)) (DisplayKHR
display))
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))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetWinrtDisplayNV
:: FunPtr (Ptr PhysicalDevice_T -> Word32 -> Ptr DisplayKHR -> IO Result) -> Ptr PhysicalDevice_T -> Word32 -> Ptr DisplayKHR -> IO Result
getWinrtDisplayNV :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
("deviceRelativeId" ::: Word32)
-> io (DisplayKHR)
getWinrtDisplayNV :: PhysicalDevice -> ("deviceRelativeId" ::: Word32) -> io DisplayKHR
getWinrtDisplayNV PhysicalDevice
physicalDevice "deviceRelativeId" ::: Word32
deviceRelativeId = IO DisplayKHR -> io DisplayKHR
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DisplayKHR -> io DisplayKHR)
-> (ContT DisplayKHR IO DisplayKHR -> IO DisplayKHR)
-> ContT DisplayKHR IO DisplayKHR
-> io DisplayKHR
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT DisplayKHR IO DisplayKHR -> IO DisplayKHR
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT DisplayKHR IO DisplayKHR -> io DisplayKHR)
-> ContT DisplayKHR IO DisplayKHR -> io DisplayKHR
forall a b. (a -> b) -> a -> b
$ do
let vkGetWinrtDisplayNVPtr :: FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
vkGetWinrtDisplayNVPtr = InstanceCmds
-> FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
pVkGetWinrtDisplayNV (case PhysicalDevice
physicalDevice of PhysicalDevice{InstanceCmds
instanceCmds :: InstanceCmds
$sel:instanceCmds:PhysicalDevice :: PhysicalDevice -> InstanceCmds
instanceCmds} -> InstanceCmds
instanceCmds)
IO () -> ContT DisplayKHR IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DisplayKHR IO ())
-> IO () -> ContT DisplayKHR IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
vkGetWinrtDisplayNVPtr FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
-> FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> 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 String
"" String
"The function pointer for vkGetWinrtDisplayNV is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
let vkGetWinrtDisplayNV' :: Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result
vkGetWinrtDisplayNV' = FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
-> Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result
mkVkGetWinrtDisplayNV FunPtr
(Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result)
vkGetWinrtDisplayNVPtr
"pDisplay" ::: Ptr DisplayKHR
pPDisplay <- ((("pDisplay" ::: Ptr DisplayKHR) -> IO DisplayKHR)
-> IO DisplayKHR)
-> ContT DisplayKHR IO ("pDisplay" ::: Ptr DisplayKHR)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((("pDisplay" ::: Ptr DisplayKHR) -> IO DisplayKHR)
-> IO DisplayKHR)
-> ContT DisplayKHR IO ("pDisplay" ::: Ptr DisplayKHR))
-> ((("pDisplay" ::: Ptr DisplayKHR) -> IO DisplayKHR)
-> IO DisplayKHR)
-> ContT DisplayKHR IO ("pDisplay" ::: Ptr DisplayKHR)
forall a b. (a -> b) -> a -> b
$ IO ("pDisplay" ::: Ptr DisplayKHR)
-> (("pDisplay" ::: Ptr DisplayKHR) -> IO ())
-> (("pDisplay" ::: Ptr DisplayKHR) -> IO DisplayKHR)
-> IO DisplayKHR
forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (Int -> IO ("pDisplay" ::: Ptr DisplayKHR)
forall a. Int -> IO (Ptr a)
callocBytes @DisplayKHR Int
8) ("pDisplay" ::: Ptr DisplayKHR) -> IO ()
forall a. Ptr a -> IO ()
free
Result
r <- IO Result -> ContT DisplayKHR IO Result
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Result -> ContT DisplayKHR IO Result)
-> IO Result -> ContT DisplayKHR IO Result
forall a b. (a -> b) -> a -> b
$ String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetWinrtDisplayNV" (Ptr PhysicalDevice_T
-> ("deviceRelativeId" ::: Word32)
-> ("pDisplay" ::: Ptr DisplayKHR)
-> IO Result
vkGetWinrtDisplayNV' (PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)) ("deviceRelativeId" ::: Word32
deviceRelativeId) ("pDisplay" ::: Ptr DisplayKHR
pPDisplay))
IO () -> ContT DisplayKHR IO ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT DisplayKHR IO ())
-> IO () -> ContT DisplayKHR 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))
DisplayKHR
pDisplay <- IO DisplayKHR -> ContT DisplayKHR IO DisplayKHR
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO DisplayKHR -> ContT DisplayKHR IO DisplayKHR)
-> IO DisplayKHR -> ContT DisplayKHR IO DisplayKHR
forall a b. (a -> b) -> a -> b
$ ("pDisplay" ::: Ptr DisplayKHR) -> IO DisplayKHR
forall a. Storable a => Ptr a -> IO a
peek @DisplayKHR "pDisplay" ::: Ptr DisplayKHR
pPDisplay
DisplayKHR -> ContT DisplayKHR IO DisplayKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DisplayKHR -> ContT DisplayKHR IO DisplayKHR)
-> DisplayKHR -> ContT DisplayKHR IO DisplayKHR
forall a b. (a -> b) -> a -> b
$ (DisplayKHR
pDisplay)
type NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION = 1
pattern NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION :: forall a . Integral a => a
pattern $bNV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION :: a
$mNV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION = 1
type NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME = "VK_NV_acquire_winrt_display"
pattern NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bNV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME :: a
$mNV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME = "VK_NV_acquire_winrt_display"