{-# 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.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 :: (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 = IO Result -> io Result
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> io Result) -> IO Result -> io Result
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 (Device -> DeviceCmds
deviceCmds (Device
device :: Device))
Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
vkWaitForPresentKHRPtr FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> 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 vkWaitForPresentKHR is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
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 <- String -> IO Result -> IO Result
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))
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))
Result -> IO Result
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Result -> IO Result) -> Result -> IO Result
forall a b. (a -> b) -> a -> b
$ (Result
r)
waitForPresentKHR :: forall io
. (MonadIO io)
=>
Device
->
SwapchainKHR
->
("presentId" ::: Word64)
->
("timeout" ::: Word64)
-> io (Result)
waitForPresentKHR :: Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHR = (FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
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 :: Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
waitForPresentKHRSafe = (FunPtr
(Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> Word64 -> Word64 -> IO Result)
-> Device -> SwapchainKHR -> Word64 -> Word64 -> io Result
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
(PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool)
-> (PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> Bool)
-> Eq PhysicalDevicePresentWaitFeaturesKHR
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 :: PhysicalDevicePresentWaitFeaturesKHR
-> (Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b) -> IO b
withCStruct PhysicalDevicePresentWaitFeaturesKHR
x Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b
f = Int -> (Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b) -> IO b)
-> (Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDevicePresentWaitFeaturesKHR
p -> Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO b -> IO b
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 :: Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p PhysicalDevicePresentWaitFeaturesKHR{Bool
presentWait :: Bool
$sel:presentWait:PhysicalDevicePresentWaitFeaturesKHR :: PhysicalDevicePresentWaitFeaturesKHR -> Bool
..} IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR -> Int -> Ptr Bool32
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 :: Ptr PhysicalDevicePresentWaitFeaturesKHR -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
p IO b
f = do
Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR)
Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
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 <- Ptr Bool32 -> IO Bool32
forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDevicePresentWaitFeaturesKHR
p Ptr PhysicalDevicePresentWaitFeaturesKHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR)
-> PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR
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 = Ptr PhysicalDevicePresentWaitFeaturesKHR
-> IO PhysicalDevicePresentWaitFeaturesKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO ()
poke Ptr PhysicalDevicePresentWaitFeaturesKHR
ptr PhysicalDevicePresentWaitFeaturesKHR
poked = Ptr PhysicalDevicePresentWaitFeaturesKHR
-> PhysicalDevicePresentWaitFeaturesKHR -> IO () -> IO ()
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWaitFeaturesKHR
ptr PhysicalDevicePresentWaitFeaturesKHR
poked (() -> IO ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero PhysicalDevicePresentWaitFeaturesKHR where
zero :: PhysicalDevicePresentWaitFeaturesKHR
zero = Bool -> PhysicalDevicePresentWaitFeaturesKHR
PhysicalDevicePresentWaitFeaturesKHR
Bool
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 :: a
$mKHR_PRESENT_WAIT_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> 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 :: a
$mKHR_PRESENT_WAIT_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_PRESENT_WAIT_EXTENSION_NAME = "VK_KHR_present_wait"