{-# language CPP #-}
-- | = Name
--
-- VK_EXT_direct_mode_display - instance extension
--
-- == VK_EXT_direct_mode_display
--
-- [__Name String__]
--     @VK_EXT_direct_mode_display@
--
-- [__Extension Type__]
--     Instance extension
--
-- [__Registered Extension Number__]
--     89
--
-- [__Revision__]
--     1
--
-- [__Extension and Version Dependencies__]
--
--     -   Requires Vulkan 1.0
--
--     -   Requires @VK_KHR_display@
--
-- [__Contact__]
--
--     -   James Jones
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?title=VK_EXT_direct_mode_display:%20&body=@cubanismo%20 >
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2016-12-13
--
-- [__IP Status__]
--     No known IP claims.
--
-- [__Contributors__]
--
--     -   Pierre Boudier, NVIDIA
--
--     -   James Jones, NVIDIA
--
--     -   Damien Leone, NVIDIA
--
--     -   Pierre-Loup Griffais, Valve
--
--     -   Liam Middlebrook, NVIDIA
--
-- == Description
--
-- This is extension, along with related platform extensions, allows
-- applications to take exclusive control of displays associated with a
-- native windowing system. This is especially useful for virtual reality
-- applications that wish to hide HMDs (head mounted displays) from the
-- native platform’s display management system, desktop, and\/or other
-- applications.
--
-- == New Commands
--
-- -   'releaseDisplayEXT'
--
-- == New Enum Constants
--
-- -   'EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME'
--
-- -   'EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION'
--
-- == Issues
--
-- 1) Should this extension and its related platform-specific extensions
-- leverage @VK_KHR_display@, or provide separate equivalent interfaces.
--
-- __RESOLVED__: Use @VK_KHR_display@ concepts and objects.
-- @VK_KHR_display@ can be used to enumerate all displays on the system,
-- including those attached to\/in use by a window system or native
-- platform, but @VK_KHR_display_swapchain@ will fail to create a swapchain
-- on in-use displays. This extension and its platform-specific children
-- will allow applications to grab in-use displays away from window systems
-- and\/or native platforms, allowing them to be used with
-- @VK_KHR_display_swapchain@.
--
-- 2) Are separate calls needed to acquire displays and enable direct mode?
--
-- __RESOLVED__: No, these operations happen in one combined command.
-- Acquiring a display puts it into direct mode.
--
-- == Version History
--
-- -   Revision 1, 2016-12-13 (James Jones)
--
--     -   Initial draft
--
-- = See Also
--
-- 'releaseDisplayEXT'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_direct_mode_display Vulkan Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_EXT_direct_mode_display  ( releaseDisplayEXT
                                                     , EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION
                                                     , pattern EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION
                                                     , EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME
                                                     , pattern EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME
                                                     , DisplayKHR(..)
                                                     ) where

import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Vulkan.Extensions.Handles (DisplayKHR)
import Vulkan.Extensions.Handles (DisplayKHR(..))
import Vulkan.Dynamic (InstanceCmds(pVkReleaseDisplayEXT))
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.Extensions.Handles (DisplayKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkReleaseDisplayEXT
  :: FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result) -> Ptr PhysicalDevice_T -> DisplayKHR -> IO Result

-- | vkReleaseDisplayEXT - Release access to an acquired VkDisplayKHR
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
-- = See Also
--
-- 'Vulkan.Extensions.Handles.DisplayKHR',
-- 'Vulkan.Core10.Handles.PhysicalDevice'
releaseDisplayEXT :: forall io
                   . (MonadIO io)
                  => -- | @physicalDevice@ The physical device the display is on.
                     --
                     -- #VUID-vkReleaseDisplayEXT-physicalDevice-parameter# @physicalDevice@
                     -- /must/ be a valid 'Vulkan.Core10.Handles.PhysicalDevice' handle
                     PhysicalDevice
                  -> -- | @display@ The display to release control of.
                     --
                     -- #VUID-vkReleaseDisplayEXT-display-parameter# @display@ /must/ be a valid
                     -- 'Vulkan.Extensions.Handles.DisplayKHR' handle
                     --
                     -- #VUID-vkReleaseDisplayEXT-display-parent# @display@ /must/ have been
                     -- created, allocated, or retrieved from @physicalDevice@
                     DisplayKHR
                  -> io ()
releaseDisplayEXT :: PhysicalDevice -> DisplayKHR -> io ()
releaseDisplayEXT physicalDevice :: PhysicalDevice
physicalDevice display :: 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 vkReleaseDisplayEXTPtr :: FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkReleaseDisplayEXTPtr = InstanceCmds
-> FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
pVkReleaseDisplayEXT (PhysicalDevice -> InstanceCmds
instanceCmds (PhysicalDevice
physicalDevice :: PhysicalDevice))
  Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkReleaseDisplayEXTPtr 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 "" "The function pointer for vkReleaseDisplayEXT is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkReleaseDisplayEXT' :: Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
vkReleaseDisplayEXT' = FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
-> Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
mkVkReleaseDisplayEXT FunPtr (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result)
vkReleaseDisplayEXTPtr
  Result
_ <- String -> IO Result -> IO Result
forall a. String -> IO a -> IO a
traceAroundEvent "vkReleaseDisplayEXT" (Ptr PhysicalDevice_T -> DisplayKHR -> IO Result
vkReleaseDisplayEXT' (PhysicalDevice -> Ptr PhysicalDevice_T
physicalDeviceHandle (PhysicalDevice
physicalDevice)) (DisplayKHR
display))
  () -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure (() -> IO ()) -> () -> IO ()
forall a b. (a -> b) -> a -> b
$ ()


type EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION"
pattern EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION :: forall a . Integral a => a
pattern $bEXT_DIRECT_MODE_DISPLAY_SPEC_VERSION :: a
$mEXT_DIRECT_MODE_DISPLAY_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION = 1


type EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME = "VK_EXT_direct_mode_display"

-- No documentation found for TopLevel "VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME"
pattern EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bEXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME :: a
$mEXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME = "VK_EXT_direct_mode_display"