{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_present_wait ( waitForPresentKHR
, waitForPresentKHRSafe
, PhysicalDevicePresentWaitFeaturesKHR(..)
, KHR_PRESENT_WAIT_SPEC_VERSION
, pattern KHR_PRESENT_WAIT_SPEC_VERSION
, KHR_PRESENT_WAIT_EXTENSION_NAME
, pattern KHR_PRESENT_WAIT_EXTENSION_NAME
, SwapchainKHR(..)
) where
import Vulkan.Internal.Utils (traceAroundEvent)
import Control.Monad (unless)
import Control.Monad.IO.Class (liftIO)
import Foreign.Marshal.Alloc (allocaBytes)
import GHC.Base (when)
import GHC.IO (throwIO)
import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
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 GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import Data.Word (Word64)
import Data.Kind (Type)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.NamedType ((:::))
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkWaitForPresentKHR))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core10.Enums.Result (Result)
import Vulkan.Core10.Enums.Result (Result(..))
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Extensions.Handles (SwapchainKHR)
import Vulkan.Extensions.Handles (SwapchainKHR(..))
import Vulkan.Exception (VulkanException(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Extensions.Handles (SwapchainKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkWaitForPresentKHRUnsafe
:: FunPtr (Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
foreign import ccall
"dynamic" mkVkWaitForPresentKHRSafe
:: FunPtr (Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
waitForPresentKHRSafeOrUnsafe :: forall io
. (MonadIO io)
=> (FunPtr (Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
->
Device
->
SwapchainKHR
->
("presentId" ::: Word64)
->
("timeout" ::: Word64)
-> io (Result)
waitForPresentKHRSafeOrUnsafe :: forall (io :: * -> *).
MonadIO io =>
(FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHRSafeOrUnsafe FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
mkVkWaitForPresentKHR Device
device
SwapchainKHR
swapchain
Word64
presentId
Word64
timeout = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
let vkWaitForPresentKHRPtr :: FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
vkWaitForPresentKHRPtr = DeviceCmds
-> FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
pVkWaitForPresentKHR (case Device
device of Device{DeviceCmds
$sel:deviceCmds:Device :: Device -> DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
vkWaitForPresentKHRPtr 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 vkWaitForPresentKHR is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkWaitForPresentKHR' :: Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
vkWaitForPresentKHR' = FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
mkVkWaitForPresentKHR FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
vkWaitForPresentKHRPtr
Result
r <- forall a. String -> IO a -> IO a
traceAroundEvent String
"vkWaitForPresentKHR" (Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
vkWaitForPresentKHR'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(SwapchainKHR
swapchain)
(Word64
presentId)
(Word64
timeout))
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))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ (Result
r)
waitForPresentKHR :: forall io
. (MonadIO io)
=>
Device
->
SwapchainKHR
->
("presentId" ::: Word64)
->
("timeout" ::: Word64)
-> io (Result)
waitForPresentKHR :: forall (io :: * -> *).
MonadIO io =>
Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHR = forall (io :: * -> *).
MonadIO io =>
(FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHRSafeOrUnsafe FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
mkVkWaitForPresentKHRUnsafe
waitForPresentKHRSafe :: forall io
. (MonadIO io)
=>
Device
->
SwapchainKHR
->
("presentId" ::: Word64)
->
("timeout" ::: Word64)
-> io (Result)
waitForPresentKHRSafe :: forall (io :: * -> *).
MonadIO io =>
Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHRSafe = forall (io :: * -> *).
MonadIO io =>
(FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHRSafeOrUnsafe FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result
mkVkWaitForPresentKHRSafe
data PhysicalDevicePresentWaitFeaturesKHR = PhysicalDevicePresentWaitFeaturesKHR
{
PhysicalDevicePresentWaitFeaturesKHR -> Bool
presentWait :: Bool }
deriving (Typeable, PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool
$c/= :: PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool
== :: PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool
$c== :: PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDevicePresentWaitFeaturesKHR)
#endif
deriving instance Show PhysicalDevicePresentWaitFeaturesKHR
instance ToCStruct PhysicalDevicePresentWaitFeaturesKHR where
withCStruct :: forall b.
PhysicalDevicePresentWaitFeaturesKHR
-> (Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b) -> IO b
withCStruct PhysicalDevicePresentWaitFeaturesKHR
x Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDevicePresentWaitFeaturesKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p PhysicalDevicePresentWaitFeaturesKHR
x (Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b
f Ptr PhysicalDevicePresentWaitFeaturesKHR
p)
pokeCStruct :: forall b.
Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p PhysicalDevicePresentWaitFeaturesKHR{Bool
presentWait :: Bool
$sel:presentWait:PhysicalDevicePresentWaitFeaturesKHR :: PhysicalDevicePresentWaitFeaturesKHR -> Bool
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
presentWait))
IO b
f
cStructSize :: Int
cStructSize = Int
24
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (forall a. Zero a => a
zero))
IO b
f
instance FromCStruct PhysicalDevicePresentWaitFeaturesKHR where
peekCStruct :: Ptr PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR
peekCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p = do
Bool32
presentWait <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Bool -> PhysicalDevicePresentWaitFeaturesKHR
PhysicalDevicePresentWaitFeaturesKHR
(Bool32 -> Bool
bool32ToBool Bool32
presentWait)
instance Storable PhysicalDevicePresentWaitFeaturesKHR where
sizeOf :: PhysicalDevicePresentWaitFeaturesKHR -> Int
sizeOf ~PhysicalDevicePresentWaitFeaturesKHR
_ = Int
24
alignment :: PhysicalDevicePresentWaitFeaturesKHR -> Int
alignment ~PhysicalDevicePresentWaitFeaturesKHR
_ = Int
8
peek :: Ptr PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO ()
poke Ptr PhysicalDevicePresentWaitFeaturesKHR
ptr PhysicalDevicePresentWaitFeaturesKHR
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
ptr PhysicalDevicePresentWaitFeaturesKHR
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero PhysicalDevicePresentWaitFeaturesKHR where
zero :: PhysicalDevicePresentWaitFeaturesKHR
zero = Bool -> PhysicalDevicePresentWaitFeaturesKHR
PhysicalDevicePresentWaitFeaturesKHR
forall a. Zero a => a
zero
type KHR_PRESENT_WAIT_SPEC_VERSION = 1
pattern KHR_PRESENT_WAIT_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_PRESENT_WAIT_SPEC_VERSION :: forall a. Integral a => a
$mKHR_PRESENT_WAIT_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_PRESENT_WAIT_SPEC_VERSION = 1
type KHR_PRESENT_WAIT_EXTENSION_NAME = "VK_KHR_present_wait"
pattern KHR_PRESENT_WAIT_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_PRESENT_WAIT_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mKHR_PRESENT_WAIT_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_PRESENT_WAIT_EXTENSION_NAME = "VK_KHR_present_wait"