{-# language CPP #-}
module Graphics.Vulkan.Extensions.VK_EXT_display_control ( displayPowerControlEXT
, registerDeviceEventEXT
, registerDisplayEventEXT
, getSwapchainCounterEXT
, DisplayPowerInfoEXT(..)
, DeviceEventInfoEXT(..)
, DisplayEventInfoEXT(..)
, SwapchainCounterCreateInfoEXT(..)
, DisplayPowerStateEXT( DISPLAY_POWER_STATE_OFF_EXT
, DISPLAY_POWER_STATE_SUSPEND_EXT
, DISPLAY_POWER_STATE_ON_EXT
, ..
)
, DeviceEventTypeEXT( DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT
, ..
)
, DisplayEventTypeEXT( DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT
, ..
)
, EXT_DISPLAY_CONTROL_SPEC_VERSION
, pattern EXT_DISPLAY_CONTROL_SPEC_VERSION
, EXT_DISPLAY_CONTROL_EXTENSION_NAME
, pattern EXT_DISPLAY_CONTROL_EXTENSION_NAME
, DisplayKHR(..)
, SwapchainKHR(..)
, SurfaceCounterFlagBitsEXT(..)
, SurfaceCounterFlagsEXT
) where
import Control.Exception.Base (bracket)
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 (nullPtr)
import Foreign.Ptr (plusPtr)
import GHC.Read (choose)
import GHC.Read (expectP)
import GHC.Read (parens)
import GHC.Show (showParen)
import GHC.Show (showString)
import GHC.Show (showsPrec)
import Text.ParserCombinators.ReadPrec ((+++))
import Text.ParserCombinators.ReadPrec (prec)
import Text.ParserCombinators.ReadPrec (step)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Control.Monad.IO.Class (MonadIO)
import Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import qualified Foreign.Storable (Storable(..))
import Data.Int (Int32)
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import GHC.Read (Read(readPrec))
import Data.Word (Word64)
import Text.Read.Lex (Lexeme(Ident))
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Graphics.Vulkan.NamedType ((:::))
import Graphics.Vulkan.Core10.AllocationCallbacks (AllocationCallbacks)
import Graphics.Vulkan.Core10.Handles (Device)
import Graphics.Vulkan.Core10.Handles (Device(..))
import Graphics.Vulkan.Dynamic (DeviceCmds(pVkDisplayPowerControlEXT))
import Graphics.Vulkan.Dynamic (DeviceCmds(pVkGetSwapchainCounterEXT))
import Graphics.Vulkan.Dynamic (DeviceCmds(pVkRegisterDeviceEventEXT))
import Graphics.Vulkan.Dynamic (DeviceCmds(pVkRegisterDisplayEventEXT))
import Graphics.Vulkan.Core10.Handles (Device_T)
import Graphics.Vulkan.Extensions.Handles (DisplayKHR)
import Graphics.Vulkan.Extensions.Handles (DisplayKHR(..))
import Graphics.Vulkan.Core10.Handles (Fence)
import Graphics.Vulkan.Core10.Handles (Fence(..))
import Graphics.Vulkan.CStruct (FromCStruct)
import Graphics.Vulkan.CStruct (FromCStruct(..))
import Graphics.Vulkan.Core10.Enums.Result (Result)
import Graphics.Vulkan.Core10.Enums.Result (Result(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType)
import Graphics.Vulkan.Extensions.VK_EXT_display_surface_counter (SurfaceCounterFlagBitsEXT)
import Graphics.Vulkan.Extensions.VK_EXT_display_surface_counter (SurfaceCounterFlagBitsEXT(..))
import Graphics.Vulkan.Extensions.VK_EXT_display_surface_counter (SurfaceCounterFlagsEXT)
import Graphics.Vulkan.Extensions.Handles (SwapchainKHR)
import Graphics.Vulkan.Extensions.Handles (SwapchainKHR(..))
import Graphics.Vulkan.CStruct (ToCStruct)
import Graphics.Vulkan.CStruct (ToCStruct(..))
import Graphics.Vulkan.Exception (VulkanException(..))
import Graphics.Vulkan.Zero (Zero)
import Graphics.Vulkan.Zero (Zero(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT))
import Graphics.Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Graphics.Vulkan.Extensions.Handles (DisplayKHR(..))
import Graphics.Vulkan.Extensions.VK_EXT_display_surface_counter (SurfaceCounterFlagBitsEXT(..))
import Graphics.Vulkan.Extensions.VK_EXT_display_surface_counter (SurfaceCounterFlagsEXT)
import Graphics.Vulkan.Extensions.Handles (SwapchainKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkDisplayPowerControlEXT
:: FunPtr (Ptr Device_T -> DisplayKHR -> Ptr DisplayPowerInfoEXT -> IO Result) -> Ptr Device_T -> DisplayKHR -> Ptr DisplayPowerInfoEXT -> IO Result
displayPowerControlEXT :: forall io . MonadIO io => Device -> DisplayKHR -> DisplayPowerInfoEXT -> io ()
displayPowerControlEXT device display displayPowerInfo = liftIO . evalContT $ do
let vkDisplayPowerControlEXT' = mkVkDisplayPowerControlEXT (pVkDisplayPowerControlEXT (deviceCmds (device :: Device)))
pDisplayPowerInfo <- ContT $ withCStruct (displayPowerInfo)
_ <- lift $ vkDisplayPowerControlEXT' (deviceHandle (device)) (display) pDisplayPowerInfo
pure $ ()
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkRegisterDeviceEventEXT
:: FunPtr (Ptr Device_T -> Ptr DeviceEventInfoEXT -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result) -> Ptr Device_T -> Ptr DeviceEventInfoEXT -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result
registerDeviceEventEXT :: forall io . MonadIO io => Device -> DeviceEventInfoEXT -> ("allocator" ::: Maybe AllocationCallbacks) -> io (Fence)
registerDeviceEventEXT device deviceEventInfo allocator = liftIO . evalContT $ do
let vkRegisterDeviceEventEXT' = mkVkRegisterDeviceEventEXT (pVkRegisterDeviceEventEXT (deviceCmds (device :: Device)))
pDeviceEventInfo <- ContT $ withCStruct (deviceEventInfo)
pAllocator <- case (allocator) of
Nothing -> pure nullPtr
Just j -> ContT $ withCStruct (j)
pPFence <- ContT $ bracket (callocBytes @Fence 8) free
_ <- lift $ vkRegisterDeviceEventEXT' (deviceHandle (device)) pDeviceEventInfo pAllocator (pPFence)
pFence <- lift $ peek @Fence pPFence
pure $ (pFence)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkRegisterDisplayEventEXT
:: FunPtr (Ptr Device_T -> DisplayKHR -> Ptr DisplayEventInfoEXT -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result) -> Ptr Device_T -> DisplayKHR -> Ptr DisplayEventInfoEXT -> Ptr AllocationCallbacks -> Ptr Fence -> IO Result
registerDisplayEventEXT :: forall io . MonadIO io => Device -> DisplayKHR -> DisplayEventInfoEXT -> ("allocator" ::: Maybe AllocationCallbacks) -> io (Fence)
registerDisplayEventEXT device display displayEventInfo allocator = liftIO . evalContT $ do
let vkRegisterDisplayEventEXT' = mkVkRegisterDisplayEventEXT (pVkRegisterDisplayEventEXT (deviceCmds (device :: Device)))
pDisplayEventInfo <- ContT $ withCStruct (displayEventInfo)
pAllocator <- case (allocator) of
Nothing -> pure nullPtr
Just j -> ContT $ withCStruct (j)
pPFence <- ContT $ bracket (callocBytes @Fence 8) free
_ <- lift $ vkRegisterDisplayEventEXT' (deviceHandle (device)) (display) pDisplayEventInfo pAllocator (pPFence)
pFence <- lift $ peek @Fence pPFence
pure $ (pFence)
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetSwapchainCounterEXT
:: FunPtr (Ptr Device_T -> SwapchainKHR -> SurfaceCounterFlagBitsEXT -> Ptr Word64 -> IO Result) -> Ptr Device_T -> SwapchainKHR -> SurfaceCounterFlagBitsEXT -> Ptr Word64 -> IO Result
getSwapchainCounterEXT :: forall io . MonadIO io => Device -> SwapchainKHR -> SurfaceCounterFlagBitsEXT -> io (("counterValue" ::: Word64))
getSwapchainCounterEXT device swapchain counter = liftIO . evalContT $ do
let vkGetSwapchainCounterEXT' = mkVkGetSwapchainCounterEXT (pVkGetSwapchainCounterEXT (deviceCmds (device :: Device)))
pPCounterValue <- ContT $ bracket (callocBytes @Word64 8) free
r <- lift $ vkGetSwapchainCounterEXT' (deviceHandle (device)) (swapchain) (counter) (pPCounterValue)
lift $ when (r < SUCCESS) (throwIO (VulkanException r))
pCounterValue <- lift $ peek @Word64 pPCounterValue
pure $ (pCounterValue)
data DisplayPowerInfoEXT = DisplayPowerInfoEXT
{
powerState :: DisplayPowerStateEXT }
deriving (Typeable)
deriving instance Show DisplayPowerInfoEXT
instance ToCStruct DisplayPowerInfoEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p DisplayPowerInfoEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DisplayPowerStateEXT)) (powerState)
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DisplayPowerStateEXT)) (zero)
f
instance FromCStruct DisplayPowerInfoEXT where
peekCStruct p = do
powerState <- peek @DisplayPowerStateEXT ((p `plusPtr` 16 :: Ptr DisplayPowerStateEXT))
pure $ DisplayPowerInfoEXT
powerState
instance Storable DisplayPowerInfoEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero DisplayPowerInfoEXT where
zero = DisplayPowerInfoEXT
zero
data DeviceEventInfoEXT = DeviceEventInfoEXT
{
deviceEvent :: DeviceEventTypeEXT }
deriving (Typeable)
deriving instance Show DeviceEventInfoEXT
instance ToCStruct DeviceEventInfoEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p DeviceEventInfoEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DeviceEventTypeEXT)) (deviceEvent)
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DeviceEventTypeEXT)) (zero)
f
instance FromCStruct DeviceEventInfoEXT where
peekCStruct p = do
deviceEvent <- peek @DeviceEventTypeEXT ((p `plusPtr` 16 :: Ptr DeviceEventTypeEXT))
pure $ DeviceEventInfoEXT
deviceEvent
instance Storable DeviceEventInfoEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero DeviceEventInfoEXT where
zero = DeviceEventInfoEXT
zero
data DisplayEventInfoEXT = DisplayEventInfoEXT
{
displayEvent :: DisplayEventTypeEXT }
deriving (Typeable)
deriving instance Show DisplayEventInfoEXT
instance ToCStruct DisplayEventInfoEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p DisplayEventInfoEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DisplayEventTypeEXT)) (displayEvent)
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr DisplayEventTypeEXT)) (zero)
f
instance FromCStruct DisplayEventInfoEXT where
peekCStruct p = do
displayEvent <- peek @DisplayEventTypeEXT ((p `plusPtr` 16 :: Ptr DisplayEventTypeEXT))
pure $ DisplayEventInfoEXT
displayEvent
instance Storable DisplayEventInfoEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero DisplayEventInfoEXT where
zero = DisplayEventInfoEXT
zero
data SwapchainCounterCreateInfoEXT = SwapchainCounterCreateInfoEXT
{
surfaceCounters :: SurfaceCounterFlagsEXT }
deriving (Typeable)
deriving instance Show SwapchainCounterCreateInfoEXT
instance ToCStruct SwapchainCounterCreateInfoEXT where
withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
pokeCStruct p SwapchainCounterCreateInfoEXT{..} f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
poke ((p `plusPtr` 16 :: Ptr SurfaceCounterFlagsEXT)) (surfaceCounters)
f
cStructSize = 24
cStructAlignment = 8
pokeZeroCStruct p f = do
poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT)
poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
f
instance FromCStruct SwapchainCounterCreateInfoEXT where
peekCStruct p = do
surfaceCounters <- peek @SurfaceCounterFlagsEXT ((p `plusPtr` 16 :: Ptr SurfaceCounterFlagsEXT))
pure $ SwapchainCounterCreateInfoEXT
surfaceCounters
instance Storable SwapchainCounterCreateInfoEXT where
sizeOf ~_ = 24
alignment ~_ = 8
peek = peekCStruct
poke ptr poked = pokeCStruct ptr poked (pure ())
instance Zero SwapchainCounterCreateInfoEXT where
zero = SwapchainCounterCreateInfoEXT
zero
newtype DisplayPowerStateEXT = DisplayPowerStateEXT Int32
deriving newtype (Eq, Ord, Storable, Zero)
pattern DISPLAY_POWER_STATE_OFF_EXT = DisplayPowerStateEXT 0
pattern DISPLAY_POWER_STATE_SUSPEND_EXT = DisplayPowerStateEXT 1
pattern DISPLAY_POWER_STATE_ON_EXT = DisplayPowerStateEXT 2
{-# complete DISPLAY_POWER_STATE_OFF_EXT,
DISPLAY_POWER_STATE_SUSPEND_EXT,
DISPLAY_POWER_STATE_ON_EXT :: DisplayPowerStateEXT #-}
instance Show DisplayPowerStateEXT where
showsPrec p = \case
DISPLAY_POWER_STATE_OFF_EXT -> showString "DISPLAY_POWER_STATE_OFF_EXT"
DISPLAY_POWER_STATE_SUSPEND_EXT -> showString "DISPLAY_POWER_STATE_SUSPEND_EXT"
DISPLAY_POWER_STATE_ON_EXT -> showString "DISPLAY_POWER_STATE_ON_EXT"
DisplayPowerStateEXT x -> showParen (p >= 11) (showString "DisplayPowerStateEXT " . showsPrec 11 x)
instance Read DisplayPowerStateEXT where
readPrec = parens (choose [("DISPLAY_POWER_STATE_OFF_EXT", pure DISPLAY_POWER_STATE_OFF_EXT)
, ("DISPLAY_POWER_STATE_SUSPEND_EXT", pure DISPLAY_POWER_STATE_SUSPEND_EXT)
, ("DISPLAY_POWER_STATE_ON_EXT", pure DISPLAY_POWER_STATE_ON_EXT)]
+++
prec 10 (do
expectP (Ident "DisplayPowerStateEXT")
v <- step readPrec
pure (DisplayPowerStateEXT v)))
newtype DeviceEventTypeEXT = DeviceEventTypeEXT Int32
deriving newtype (Eq, Ord, Storable, Zero)
pattern DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT = DeviceEventTypeEXT 0
{-# complete DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT :: DeviceEventTypeEXT #-}
instance Show DeviceEventTypeEXT where
showsPrec p = \case
DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT -> showString "DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT"
DeviceEventTypeEXT x -> showParen (p >= 11) (showString "DeviceEventTypeEXT " . showsPrec 11 x)
instance Read DeviceEventTypeEXT where
readPrec = parens (choose [("DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT", pure DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT)]
+++
prec 10 (do
expectP (Ident "DeviceEventTypeEXT")
v <- step readPrec
pure (DeviceEventTypeEXT v)))
newtype DisplayEventTypeEXT = DisplayEventTypeEXT Int32
deriving newtype (Eq, Ord, Storable, Zero)
pattern DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT = DisplayEventTypeEXT 0
{-# complete DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT :: DisplayEventTypeEXT #-}
instance Show DisplayEventTypeEXT where
showsPrec p = \case
DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT -> showString "DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT"
DisplayEventTypeEXT x -> showParen (p >= 11) (showString "DisplayEventTypeEXT " . showsPrec 11 x)
instance Read DisplayEventTypeEXT where
readPrec = parens (choose [("DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT", pure DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT)]
+++
prec 10 (do
expectP (Ident "DisplayEventTypeEXT")
v <- step readPrec
pure (DisplayEventTypeEXT v)))
type EXT_DISPLAY_CONTROL_SPEC_VERSION = 1
pattern EXT_DISPLAY_CONTROL_SPEC_VERSION :: forall a . Integral a => a
pattern EXT_DISPLAY_CONTROL_SPEC_VERSION = 1
type EXT_DISPLAY_CONTROL_EXTENSION_NAME = "VK_EXT_display_control"
pattern EXT_DISPLAY_CONTROL_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern EXT_DISPLAY_CONTROL_EXTENSION_NAME = "VK_EXT_display_control"