{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_shared_presentable_image ( getSwapchainStatusKHR
, SharedPresentSurfaceCapabilitiesKHR(..)
, KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION
, pattern KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION
, KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME
, pattern KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME
, SwapchainKHR(..)
, PresentModeKHR(..)
) 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.Kind (Type)
import Vulkan.Core10.Handles (Device)
import Vulkan.Core10.Handles (Device(..))
import Vulkan.Core10.Handles (Device(Device))
import Vulkan.Dynamic (DeviceCmds(pVkGetSwapchainStatusKHR))
import Vulkan.Core10.Handles (Device_T)
import Vulkan.Core10.Enums.ImageUsageFlagBits (ImageUsageFlags)
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_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Extensions.VK_KHR_surface (PresentModeKHR(..))
import Vulkan.Extensions.Handles (SwapchainKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
unsafe
#endif
"dynamic" mkVkGetSwapchainStatusKHR
:: FunPtr (Ptr Device_T -> SwapchainKHR -> IO Result) -> Ptr Device_T -> SwapchainKHR -> IO Result
getSwapchainStatusKHR :: forall io
. (MonadIO io)
=>
Device
->
SwapchainKHR
-> io (Result)
getSwapchainStatusKHR :: forall (io :: * -> *).
MonadIO io =>
Device -> SwapchainKHR -> io Result
getSwapchainStatusKHR Device
device SwapchainKHR
swapchain = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
let vkGetSwapchainStatusKHRPtr :: FunPtr (Ptr Device_T -> SwapchainKHR -> IO Result)
vkGetSwapchainStatusKHRPtr = DeviceCmds -> FunPtr (Ptr Device_T -> SwapchainKHR -> IO Result)
pVkGetSwapchainStatusKHR (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 -> IO Result)
vkGetSwapchainStatusKHRPtr 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 vkGetSwapchainStatusKHR is null" forall a. Maybe a
Nothing forall a. Maybe a
Nothing
let vkGetSwapchainStatusKHR' :: Ptr Device_T -> SwapchainKHR -> IO Result
vkGetSwapchainStatusKHR' = FunPtr (Ptr Device_T -> SwapchainKHR -> IO Result)
-> Ptr Device_T -> SwapchainKHR -> IO Result
mkVkGetSwapchainStatusKHR FunPtr (Ptr Device_T -> SwapchainKHR -> IO Result)
vkGetSwapchainStatusKHRPtr
Result
r <- forall a. String -> IO a -> IO a
traceAroundEvent String
"vkGetSwapchainStatusKHR" (Ptr Device_T -> SwapchainKHR -> IO Result
vkGetSwapchainStatusKHR'
(Device -> Ptr Device_T
deviceHandle (Device
device))
(SwapchainKHR
swapchain))
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)
data SharedPresentSurfaceCapabilitiesKHR = SharedPresentSurfaceCapabilitiesKHR
{
SharedPresentSurfaceCapabilitiesKHR -> ImageUsageFlags
sharedPresentSupportedUsageFlags :: ImageUsageFlags }
deriving (Typeable, SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> Bool
$c/= :: SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> Bool
== :: SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> Bool
$c== :: SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SharedPresentSurfaceCapabilitiesKHR)
#endif
deriving instance Show SharedPresentSurfaceCapabilitiesKHR
instance ToCStruct SharedPresentSurfaceCapabilitiesKHR where
withCStruct :: forall b.
SharedPresentSurfaceCapabilitiesKHR
-> (Ptr SharedPresentSurfaceCapabilitiesKHR -> IO b) -> IO b
withCStruct SharedPresentSurfaceCapabilitiesKHR
x Ptr SharedPresentSurfaceCapabilitiesKHR -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr SharedPresentSurfaceCapabilitiesKHR
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SharedPresentSurfaceCapabilitiesKHR
p SharedPresentSurfaceCapabilitiesKHR
x (Ptr SharedPresentSurfaceCapabilitiesKHR -> IO b
f Ptr SharedPresentSurfaceCapabilitiesKHR
p)
pokeCStruct :: forall b.
Ptr SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> IO b -> IO b
pokeCStruct Ptr SharedPresentSurfaceCapabilitiesKHR
p SharedPresentSurfaceCapabilitiesKHR{ImageUsageFlags
sharedPresentSupportedUsageFlags :: ImageUsageFlags
$sel:sharedPresentSupportedUsageFlags:SharedPresentSurfaceCapabilitiesKHR :: SharedPresentSurfaceCapabilitiesKHR -> ImageUsageFlags
..} IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SharedPresentSurfaceCapabilitiesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SharedPresentSurfaceCapabilitiesKHR
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 SharedPresentSurfaceCapabilitiesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr ImageUsageFlags)) (ImageUsageFlags
sharedPresentSupportedUsageFlags)
IO b
f
cStructSize :: Int
cStructSize = Int
24
cStructAlignment :: Int
cStructAlignment = Int
8
pokeZeroCStruct :: forall b. Ptr SharedPresentSurfaceCapabilitiesKHR -> IO b -> IO b
pokeZeroCStruct Ptr SharedPresentSurfaceCapabilitiesKHR
p IO b
f = do
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SharedPresentSurfaceCapabilitiesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR)
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SharedPresentSurfaceCapabilitiesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
IO b
f
instance FromCStruct SharedPresentSurfaceCapabilitiesKHR where
peekCStruct :: Ptr SharedPresentSurfaceCapabilitiesKHR
-> IO SharedPresentSurfaceCapabilitiesKHR
peekCStruct Ptr SharedPresentSurfaceCapabilitiesKHR
p = do
ImageUsageFlags
sharedPresentSupportedUsageFlags <- forall a. Storable a => Ptr a -> IO a
peek @ImageUsageFlags ((Ptr SharedPresentSurfaceCapabilitiesKHR
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr ImageUsageFlags))
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ImageUsageFlags -> SharedPresentSurfaceCapabilitiesKHR
SharedPresentSurfaceCapabilitiesKHR
ImageUsageFlags
sharedPresentSupportedUsageFlags
instance Storable SharedPresentSurfaceCapabilitiesKHR where
sizeOf :: SharedPresentSurfaceCapabilitiesKHR -> Int
sizeOf ~SharedPresentSurfaceCapabilitiesKHR
_ = Int
24
alignment :: SharedPresentSurfaceCapabilitiesKHR -> Int
alignment ~SharedPresentSurfaceCapabilitiesKHR
_ = Int
8
peek :: Ptr SharedPresentSurfaceCapabilitiesKHR
-> IO SharedPresentSurfaceCapabilitiesKHR
peek = forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
poke :: Ptr SharedPresentSurfaceCapabilitiesKHR
-> SharedPresentSurfaceCapabilitiesKHR -> IO ()
poke Ptr SharedPresentSurfaceCapabilitiesKHR
ptr SharedPresentSurfaceCapabilitiesKHR
poked = forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SharedPresentSurfaceCapabilitiesKHR
ptr SharedPresentSurfaceCapabilitiesKHR
poked (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
instance Zero SharedPresentSurfaceCapabilitiesKHR where
zero :: SharedPresentSurfaceCapabilitiesKHR
zero = ImageUsageFlags -> SharedPresentSurfaceCapabilitiesKHR
SharedPresentSurfaceCapabilitiesKHR
forall a. Zero a => a
zero
type KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION = 1
pattern KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION :: forall a. Integral a => a
$mKHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION = 1
type KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME = "VK_KHR_shared_presentable_image"
pattern KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mKHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME = "VK_KHR_shared_presentable_image"