{-# language CPP #-}
module Vulkan.Extensions.VK_EXT_acquire_drm_display ( acquireDrmDisplayEXT
, getDrmDisplayEXT
, EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION
, pattern EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION
, EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME
, pattern EXT_ACQUIRE_DRM_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 Data.Int (Int32)
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(pVkAcquireDrmDisplayEXT))
import Vulkan.Dynamic (InstanceCmds(pVkGetDrmDisplayEXT))
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" mkVkAcquireDrmDisplayEXT
:: FunPtr (Ptr PhysicalDevice_T -> Int32 -> DisplayKHR -> IO Result) -> Ptr PhysicalDevice_T -> Int32 -> DisplayKHR -> IO Result
acquireDrmDisplayEXT :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
("drmFd" ::: Int32)
->
DisplayKHR
-> io ()
acquireDrmDisplayEXT :: forall (io :: * -> *).
MonadIO io =>
PhysicalDevice -> ("drmFd" ::: Int32) -> DisplayKHR -> io ()
acquireDrmDisplayEXT PhysicalDevice
physicalDevice "drmFd" ::: Int32
drmFd DisplayKHR
display = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
let vkAcquireDrmDisplayEXTPtr :: FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result)
vkAcquireDrmDisplayEXTPtr = InstanceCmds
-> FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result)
pVkAcquireDrmDisplayEXT (case PhysicalDevice
physicalDevice of PhysicalDevice{InstanceCmds
$sel:instanceCmds:PhysicalDevice :: PhysicalDevice -> InstanceCmds
instanceCmds :: InstanceCmds
instanceCmds} -> InstanceCmds
instanceCmds)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result)
vkAcquireDrmDisplayEXTPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkAcquireDrmDisplayEXT is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkAcquireDrmDisplayEXT' :: Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result
vkAcquireDrmDisplayEXT' = FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result)
-> Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> DisplayKHR
-> IO Result
mkVkAcquireDrmDisplayEXT FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result)
vkAcquireDrmDisplayEXTPtr
Result
r <- forall a. String -> IO a -> IO a
traceAroundEvent String
"vkAcquireDrmDisplayEXT" (Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32) -> DisplayKHR -> IO Result
vkAcquireDrmDisplayEXT'
(PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice))
("drmFd" ::: Int32
drmFd)
(DisplayKHR
display))
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (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" mkVkGetDrmDisplayEXT
:: FunPtr (Ptr PhysicalDevice_T -> Int32 -> Word32 -> Ptr DisplayKHR -> IO Result) -> Ptr PhysicalDevice_T -> Int32 -> Word32 -> Ptr DisplayKHR -> IO Result
getDrmDisplayEXT :: forall io
. (MonadIO io)
=>
PhysicalDevice
->
("drmFd" ::: Int32)
->
("connectorId" ::: Word32)
-> io (DisplayKHR)
getDrmDisplayEXT :: forall (io :: * -> *).
MonadIO io =>
PhysicalDevice
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> io DisplayKHR
getDrmDisplayEXT PhysicalDevice
physicalDevice "drmFd" ::: Int32
drmFd "connectorId" ::: Word32
connectorId = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT forall a b. (a -> b) -> a -> b
$ do
let vkGetDrmDisplayEXTPtr :: FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result)
vkGetDrmDisplayEXTPtr = InstanceCmds
-> FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result)
pVkGetDrmDisplayEXT (case PhysicalDevice
physicalDevice of PhysicalDevice{InstanceCmds
instanceCmds :: InstanceCmds
$sel:instanceCmds:PhysicalDevice :: PhysicalDevice -> InstanceCmds
instanceCmds} -> InstanceCmds
instanceCmds)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result)
vkGetDrmDisplayEXTPtr forall a. Eq a => a -> a -> Bool
/= forall a. FunPtr a
nullFunPtr) forall a b. (a -> b) -> a -> b
$
forall e a. Exception e => e -> IO a
throwIO forall a b. (a -> b) -> a -> b
$ Maybe Handle
-> IOErrorType
-> String
-> String
-> Maybe CInt
-> Maybe String
-> IOException
IOError forall a. Maybe a
Nothing IOErrorType
InvalidArgument String
"" String
"The function pointer for vkGetDrmDisplayEXT is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkGetDrmDisplayEXT' :: Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result
vkGetDrmDisplayEXT' = FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result)
-> Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result
mkVkGetDrmDisplayEXT FunPtr
(Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result)
vkGetDrmDisplayEXTPtr
Ptr DisplayKHR
pDisplay <- forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT forall a b. (a -> b) -> a -> b
$ forall a b c. IO a -> (a -> IO b) -> (a -> IO c) -> IO c
bracket (forall a. Int -> IO (Ptr a)
callocBytes @DisplayKHR Int
8) forall a. Ptr a -> IO ()
free
Result
r <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetDrmDisplayEXT" (Ptr PhysicalDevice_T
-> ("drmFd" ::: Int32)
-> ("connectorId" ::: Word32)
-> Ptr DisplayKHR
-> IO Result
vkGetDrmDisplayEXT'
(PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice))
("drmFd" ::: Int32
drmFd)
("connectorId" ::: Word32
connectorId)
(Ptr DisplayKHR
pDisplay))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Result
r forall a. Ord a => a -> a -> Bool
< Result
SUCCESS) (forall e a. Exception e => e -> IO a
throwIO (Result -> VulkanException
VulkanException Result
r))
DisplayKHR
display <- forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift forall a b. (a -> b) -> a -> b
$ forall a. Storable a => Ptr a -> IO a
peek @DisplayKHR Ptr DisplayKHR
pDisplay
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (DisplayKHR
display)
type EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION = 1
pattern EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION :: forall a . Integral a => a
pattern $bEXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION :: forall a. Integral a => a
$mEXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION = 1
type EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME = "VK_EXT_acquire_drm_display"
pattern EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bEXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mEXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME = "VK_EXT_acquire_drm_display"