{-# language CPP #-}
-- | = Name
--
-- VK_KHR_present_wait2 - device extension
--
-- = VK_KHR_present_wait2
--
-- [__Name String__]
--     @VK_KHR_present_wait2@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     481
--
-- [__Revision__]
--     1
--
-- [__Ratification Status__]
--     Ratified
--
-- [__Extension and Version Dependencies__]
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_get_surface_capabilities2 VK_KHR_get_surface_capabilities2>
--     and
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_surface VK_KHR_surface>
--     and
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_swapchain VK_KHR_swapchain>
--     and
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_id2 VK_KHR_present_id2>
--
-- [__Contact__]
--
--     -   Daniel Stone
--
-- [__Extension Proposal__]
--     <https://github.com/KhronosGroup/Vulkan-Docs/tree/main/proposals/VK_KHR_present_wait2.adoc VK_KHR_present_wait2>
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2025-05-30
--
-- [__IP Status__]
--     No known IP claims.
--
-- [__Contributors__]
--
--     -   Hans-Kristian Arntzen, Valve
--
--     -   James Jones, NVIDIA
--
--     -   Daniel Stone, Collabora
--
--     -   Derek Foreman, Collabora
--
--     -   /contributors to
--         \`<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_wait VK_KHR_present_wait>\`/
--
-- == Description
--
-- This device extension allows an application that uses the
-- @VK_KHR_swapchain@ extension to wait for present operations to complete.
-- An application can use this to monitor and control the pacing of the
-- application by managing the number of outstanding images yet to be
-- presented.
--
-- == New Commands
--
-- -   'waitForPresent2KHR'
--
-- == New Structures
--
-- -   'PresentWait2InfoKHR'
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDevicePresentWait2FeaturesKHR'
--
-- -   Extending
--     'Vulkan.Extensions.VK_KHR_get_surface_capabilities2.SurfaceCapabilities2KHR':
--
--     -   'SurfaceCapabilitiesPresentWait2KHR'
--
-- == New Enum Constants
--
-- -   'KHR_PRESENT_WAIT_2_EXTENSION_NAME'
--
-- -   'KHR_PRESENT_WAIT_2_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_2_FEATURES_KHR'
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PRESENT_WAIT_2_INFO_KHR'
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_WAIT_2_KHR'
--
-- -   Extending
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateFlagBitsKHR':
--
--     -   'Vulkan.Extensions.VK_KHR_swapchain.SWAPCHAIN_CREATE_PRESENT_WAIT_2_BIT_KHR'
--
-- == Issues
--
-- 1) When does the wait finish?
--
-- __RESOLVED__. The wait request will complete when the timeout expires,
-- or after the corresponding presentation request has either taken effect
-- within the presentation engine or has been replaced without
-- presentation. Additionally, a wait may complete immediately if the
-- swapchain becomes out of date.
--
-- In circumstances outside the application’s control, this wait may be
-- particularly long. For example, a user session may have the display
-- locked and switched off for multiple days. During this time, the latest
-- image presented through the WSI will never be presented to the user
-- (because nothing is being presented), or replaced (because nothing newer
-- has been queued by the application). Each operating system may have a
-- separate mechanism to inform the application of states such as these,
-- however it is out of scope of the Vulkan WSI.
--
-- There is no requirement for any precise timing relationship between the
-- presentation of the image to the user and the end of the wait.
--
-- This extension is not intended for time-to-light estimation, which is
-- better solved by a separate extension dedicated to present-timing
-- feedback for audio\/visual\/input synchronization.
--
-- 2) Should this use fences or other existing synchronization mechanism?
--
-- __RESOLVED__. VkFence is a legacy primitive. Building a new API around a
-- legacy primitive is undesirable.
--
-- Other existing synchronization mechanisms may lack a platform-provided
-- framework for sharing synchronization objects between display and render
-- drivers.
--
-- For these reasons, this extension will provide a separate
-- synchronization API.
--
-- 3) Should this extension share present identification with other
-- extensions?
--
-- __RESOLVED__. Yes. A new extension, @VK_KHR_present_id2@, should be
-- created to provide a shared structure for presentation identifiers.
--
-- 4) What happens when presentations complete out of order with respect to
-- calls to vkQueuePresent? This could happen if the semaphores for the
-- presentations were ready out of order.
--
-- __OPTION A__: Require that when a PresentId is set that the driver
-- ensure that images are always presented in the order of calls to
-- vkQueuePresent.
--
-- __OPTION B__: Finish both waits when the earliest present completes.
-- This will complete the later present wait earlier than the actual
-- presentation. This should be the easiest to implement as the driver need
-- only track the largest present ID completed. This is also the
-- \'natural\' consequence of interpreting the existing vkWaitForPresentKHR
-- specification.
--
-- __OPTION C__: Finish both waits when both have completed. This will
-- complete the earlier presentation later than the actual presentation
-- time. This is allowed by the current specification as there is no
-- precise timing requirement for when the presentId value is updated. This
-- requires slightly more complexity in the driver as it will need to track
-- all outstanding presentId values.
--
-- __OPTION D__: The order of completion between outstanding
-- 'waitForPresent2KHR' calls is always undefined. However, a
-- 'Vulkan.Core10.Enums.Result.SUCCESS' return value in
-- 'PresentWait2InfoKHR'::@presentId@ implies that future calls to
-- 'waitForPresent2KHR' where 'PresentWait2InfoKHR'::@presentId@ is less
-- than or equal to N will complete immediately.
--
-- __RESOLVED__. __OPTION D__: This option ensures implementations do not
-- need to create complex internal queues to generate signals in the right
-- order.
--
-- 5) Should this extension deviate from @VK_KHR_present_wait@ and require
-- the presentation engine to provide the presentId values?
--
-- __RESOLVED__. No. This extension is intended to be a bugfix of
-- @VK_KHR_present_wait@, and existing low-latency apis require an
-- application provided id. At least on some platforms, a mapping mechanism
-- would be required to translate between presentation engine and
-- application ids. This exceeds the intended scope of this extension.
--
-- When needed in the future, we can introduce an independent presentation
-- engine driven id and a mechanism for mapping presentation engine ids to
-- application provided ids.
--
-- == Version History
--
-- -   Revision 1, 2022-10-05 (Daniel Stone)
--
--     -   Repurposed from VK_KHR_present_wait to be based on surface
--         capabilities
--
--     -   Reworded wait finish section to avoid time-to-light
--
-- == See Also
--
-- No cross-references are available
--
-- == Document Notes
--
-- For more information, see the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VK_KHR_present_wait2 Vulkan Specification>.
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_KHR_present_wait2  ( waitForPresent2KHR
                                               , waitForPresent2KHRSafe
                                               , PresentWait2InfoKHR(..)
                                               , PhysicalDevicePresentWait2FeaturesKHR(..)
                                               , SurfaceCapabilitiesPresentWait2KHR(..)
                                               , KHR_PRESENT_WAIT_2_SPEC_VERSION
                                               , pattern KHR_PRESENT_WAIT_2_SPEC_VERSION
                                               , KHR_PRESENT_WAIT_2_EXTENSION_NAME
                                               , pattern KHR_PRESENT_WAIT_2_EXTENSION_NAME
                                               , SwapchainKHR(..)
                                               , SwapchainCreateFlagBitsKHR(..)
                                               , SwapchainCreateFlagsKHR
                                               ) 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 Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
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 Control.Monad.Trans.Cont (ContT(..))
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
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(pVkWaitForPresent2KHR))
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_2_FEATURES_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PRESENT_WAIT_2_INFO_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_WAIT_2_KHR))
import Vulkan.Core10.Enums.Result (Result(SUCCESS))
import Vulkan.Extensions.VK_KHR_swapchain (SwapchainCreateFlagBitsKHR(..))
import Vulkan.Extensions.VK_KHR_swapchain (SwapchainCreateFlagsKHR)
import Vulkan.Extensions.Handles (SwapchainKHR(..))
foreign import ccall
#if !defined(SAFE_FOREIGN_CALLS)
  unsafe
#endif
  "dynamic" mkVkWaitForPresent2KHRUnsafe
  :: FunPtr (Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result

foreign import ccall
  "dynamic" mkVkWaitForPresent2KHRSafe
  :: FunPtr (Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result

-- | waitForPresent2KHR with selectable safeness
waitForPresent2KHRSafeOrUnsafe :: forall io
                                . (MonadIO io)
                               => (FunPtr (Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result) -> Ptr Device_T -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
                               -> -- | @device@ is the device associated with @swapchain@.
                                  Device
                               -> -- | @swapchain@ is the non-retired swapchain on which an image was queued
                                  -- for presentation.
                                  SwapchainKHR
                               -> -- | @pPresentWait2Info@ is a pointer to a 'PresentWait2InfoKHR' structure
                                  -- specifying the parameters of the wait.
                                  PresentWait2InfoKHR
                               -> io (Result)
waitForPresent2KHRSafeOrUnsafe :: forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
 -> Ptr Device_T
 -> SwapchainKHR
 -> Ptr PresentWait2InfoKHR
 -> IO Result)
-> Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
waitForPresent2KHRSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> Ptr Device_T
-> SwapchainKHR
-> Ptr PresentWait2InfoKHR
-> IO Result
mkVkWaitForPresent2KHR Device
device
                                                        SwapchainKHR
swapchain
                                                        PresentWait2InfoKHR
presentWait2Info = IO Result -> io Result
forall a. IO a -> io a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Result -> io Result)
-> (ContT Result IO Result -> IO Result)
-> ContT Result IO Result
-> io Result
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ContT Result IO Result -> IO Result
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT Result IO Result -> io Result)
-> ContT Result IO Result -> io Result
forall a b. (a -> b) -> a -> b
$ do
  let vkWaitForPresent2KHRPtr :: FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
vkWaitForPresent2KHRPtr = DeviceCmds
-> FunPtr
     (Ptr Device_T
      -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
pVkWaitForPresent2KHR (case Device
device of Device{DeviceCmds
deviceCmds :: DeviceCmds
deviceCmds :: Device -> DeviceCmds
deviceCmds} -> DeviceCmds
deviceCmds)
  IO () -> ContT Result IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT Result m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT Result IO ()) -> IO () -> ContT Result IO ()
forall a b. (a -> b) -> a -> b
$ Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
vkWaitForPresent2KHRPtr FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> FunPtr
     (Ptr Device_T
      -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> Bool
forall a. Eq a => a -> a -> Bool
/= FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
forall a. FunPtr a
nullFunPtr) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
    IOException -> IO ()
forall e a. (HasCallStack, 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 vkWaitForPresent2KHR is null" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
  let vkWaitForPresent2KHR' :: Ptr Device_T
-> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result
vkWaitForPresent2KHR' = FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> Ptr Device_T
-> SwapchainKHR
-> Ptr PresentWait2InfoKHR
-> IO Result
mkVkWaitForPresent2KHR FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
vkWaitForPresent2KHRPtr
  pPresentWait2Info <- ((Ptr PresentWait2InfoKHR -> IO Result) -> IO Result)
-> ContT Result IO (Ptr PresentWait2InfoKHR)
forall {k} (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr PresentWait2InfoKHR -> IO Result) -> IO Result)
 -> ContT Result IO (Ptr PresentWait2InfoKHR))
-> ((Ptr PresentWait2InfoKHR -> IO Result) -> IO Result)
-> ContT Result IO (Ptr PresentWait2InfoKHR)
forall a b. (a -> b) -> a -> b
$ PresentWait2InfoKHR
-> (Ptr PresentWait2InfoKHR -> IO Result) -> IO Result
forall a b. ToCStruct a => a -> (Ptr a -> IO b) -> IO b
forall b.
PresentWait2InfoKHR -> (Ptr PresentWait2InfoKHR -> IO b) -> IO b
withCStruct (PresentWait2InfoKHR
presentWait2Info)
  r <- lift $ traceAroundEvent "vkWaitForPresent2KHR" (vkWaitForPresent2KHR'
                                                         (deviceHandle (device))
                                                         (swapchain)
                                                         pPresentWait2Info)
  lift $ when (r < SUCCESS) (throwIO (VulkanException r))
  pure $ (r)

-- | vkWaitForPresent2KHR - Wait for presentation
--
-- = Description
--
-- 'waitForPresent2KHR' waits for the presentation engine to have begun
-- presentation of the presentation request associated with the
-- 'PresentWait2InfoKHR'::@presentId@ on @swapchain@, or for
-- 'PresentWait2InfoKHR'::@timeout@ to have expired.
--
-- The wait request will complete when the timeout expires, or after the
-- corresponding presentation request has either taken effect within the
-- presentation engine or has been replaced without presentation.
--
-- The timing relationship between the presentation of the image to the
-- user and the wait request completing is implementation-dependent due to
-- variations in window system implementations.
--
-- If the @swapchain@ becomes
-- 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DATE_KHR' either before or
-- during this call, the call /may/ either return
-- 'Vulkan.Core10.Enums.Result.SUCCESS' (if the image was delivered to the
-- presentation engine and /may/ have been presented to the user) or return
-- early with status 'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DATE_KHR' (if
-- the image could not be presented to the user).
--
-- As an exception to the normal rules for objects which are externally
-- synchronized, the @swapchain@ passed to 'waitForPresent2KHR' /may/ be
-- simultaneously used by other threads in calls to functions other than
-- 'Vulkan.Extensions.VK_KHR_swapchain.destroySwapchainKHR'. Access to the
-- swapchain data associated with this extension /must/ be atomic within
-- the implementation.
--
-- == Valid Usage
--
-- -   #VUID-vkWaitForPresent2KHR-presentWait2-10814# The
--     <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#features-presentWait2 presentWait2>
--     feature /must/ be enabled
--
-- -   #VUID-vkWaitForPresent2KHR-None-10815# The
--     'SurfaceCapabilitiesPresentWait2KHR' surface capability /must/ be
--     present for the underlying surface
--
-- -   #VUID-vkWaitForPresent2KHR-None-10816# The swapchain must have been
--     created with
--     'Vulkan.Extensions.VK_KHR_swapchain.SWAPCHAIN_CREATE_PRESENT_WAIT_2_BIT_KHR'
--     bit set in the
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateFlagBitsKHR'
--     field
--
-- -   #VUID-vkWaitForPresent2KHR-presentId-10817# The @presentId@ value
--     /must/ have been associated with a
--     'Vulkan.Extensions.VK_KHR_swapchain.queuePresentKHR' request on the
--     @swapchain@ which returned a non-error value
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-vkWaitForPresent2KHR-device-parameter# @device@ /must/ be a
--     valid 'Vulkan.Core10.Handles.Device' handle
--
-- -   #VUID-vkWaitForPresent2KHR-swapchain-parameter# @swapchain@ /must/
--     be a valid 'Vulkan.Extensions.Handles.SwapchainKHR' handle
--
-- -   #VUID-vkWaitForPresent2KHR-pPresentWait2Info-parameter#
--     @pPresentWait2Info@ /must/ be a valid pointer to a valid
--     'PresentWait2InfoKHR' structure
--
-- -   #VUID-vkWaitForPresent2KHR-swapchain-parent# @swapchain@ /must/ have
--     been created, allocated, or retrieved from @device@
--
-- == Host Synchronization
--
-- -   Host access to @swapchain@ /must/ be externally synchronized
--
-- == Return Codes
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-successcodes Success>]
--
--     -   'Vulkan.Core10.Enums.Result.SUBOPTIMAL_KHR'
--
--     -   'Vulkan.Core10.Enums.Result.SUCCESS'
--
--     -   'Vulkan.Core10.Enums.Result.TIMEOUT'
--
-- [<https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#fundamentals-errorcodes Failure>]
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_DEVICE_LOST'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DATE_KHR'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_DEVICE_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_OUT_OF_HOST_MEMORY'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_SURFACE_LOST_KHR'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_UNKNOWN'
--
--     -   'Vulkan.Core10.Enums.Result.ERROR_VALIDATION_FAILED'
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_wait2 VK_KHR_present_wait2>,
-- 'Vulkan.Core10.Handles.Device', 'PresentWait2InfoKHR',
-- 'Vulkan.Extensions.Handles.SwapchainKHR'
waitForPresent2KHR :: forall io
                    . (MonadIO io)
                   => -- | @device@ is the device associated with @swapchain@.
                      Device
                   -> -- | @swapchain@ is the non-retired swapchain on which an image was queued
                      -- for presentation.
                      SwapchainKHR
                   -> -- | @pPresentWait2Info@ is a pointer to a 'PresentWait2InfoKHR' structure
                      -- specifying the parameters of the wait.
                      PresentWait2InfoKHR
                   -> io (Result)
waitForPresent2KHR :: forall (io :: * -> *).
MonadIO io =>
Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
waitForPresent2KHR = (FunPtr
   (Ptr Device_T
    -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
 -> Ptr Device_T
 -> SwapchainKHR
 -> Ptr PresentWait2InfoKHR
 -> IO Result)
-> Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
 -> Ptr Device_T
 -> SwapchainKHR
 -> Ptr PresentWait2InfoKHR
 -> IO Result)
-> Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
waitForPresent2KHRSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> Ptr Device_T
-> SwapchainKHR
-> Ptr PresentWait2InfoKHR
-> IO Result
mkVkWaitForPresent2KHRUnsafe

-- | A variant of 'waitForPresent2KHR' which makes a *safe* FFI call
waitForPresent2KHRSafe :: forall io
                        . (MonadIO io)
                       => -- | @device@ is the device associated with @swapchain@.
                          Device
                       -> -- | @swapchain@ is the non-retired swapchain on which an image was queued
                          -- for presentation.
                          SwapchainKHR
                       -> -- | @pPresentWait2Info@ is a pointer to a 'PresentWait2InfoKHR' structure
                          -- specifying the parameters of the wait.
                          PresentWait2InfoKHR
                       -> io (Result)
waitForPresent2KHRSafe :: forall (io :: * -> *).
MonadIO io =>
Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
waitForPresent2KHRSafe = (FunPtr
   (Ptr Device_T
    -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
 -> Ptr Device_T
 -> SwapchainKHR
 -> Ptr PresentWait2InfoKHR
 -> IO Result)
-> Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
forall (io :: * -> *).
MonadIO io =>
(FunPtr
   (Ptr Device_T
    -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
 -> Ptr Device_T
 -> SwapchainKHR
 -> Ptr PresentWait2InfoKHR
 -> IO Result)
-> Device -> SwapchainKHR -> PresentWait2InfoKHR -> io Result
waitForPresent2KHRSafeOrUnsafe FunPtr
  (Ptr Device_T
   -> SwapchainKHR -> Ptr PresentWait2InfoKHR -> IO Result)
-> Ptr Device_T
-> SwapchainKHR
-> Ptr PresentWait2InfoKHR
-> IO Result
mkVkWaitForPresent2KHRSafe


-- | VkPresentWait2InfoKHR - Structure describing parameters of a
-- presentation wait
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_wait2 VK_KHR_present_wait2>,
-- 'Vulkan.Core10.Enums.StructureType.StructureType', 'waitForPresent2KHR'
data PresentWait2InfoKHR = PresentWait2InfoKHR
  { -- | @presentId@ is the presentation presentId to wait for.
    PresentWait2InfoKHR -> Word64
presentId :: Word64
  , -- | @timeout@ is the timeout period in units of nanoseconds. @timeout@ is
    -- adjusted to the closest value allowed by the implementation-dependent
    -- timeout accuracy, which /may/ be substantially longer than one
    -- nanosecond, and /may/ be longer than the requested period.
    PresentWait2InfoKHR -> Word64
timeout :: Word64
  }
  deriving (Typeable, PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool
(PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool)
-> (PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool)
-> Eq PresentWait2InfoKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool
== :: PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool
$c/= :: PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool
/= :: PresentWait2InfoKHR -> PresentWait2InfoKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PresentWait2InfoKHR)
#endif
deriving instance Show PresentWait2InfoKHR

instance ToCStruct PresentWait2InfoKHR where
  withCStruct :: forall b.
PresentWait2InfoKHR -> (Ptr PresentWait2InfoKHR -> IO b) -> IO b
withCStruct PresentWait2InfoKHR
x Ptr PresentWait2InfoKHR -> IO b
f = Int -> (Ptr PresentWait2InfoKHR -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr PresentWait2InfoKHR -> IO b) -> IO b)
-> (Ptr PresentWait2InfoKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PresentWait2InfoKHR
p -> Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO b -> IO b
forall b.
Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PresentWait2InfoKHR
p PresentWait2InfoKHR
x (Ptr PresentWait2InfoKHR -> IO b
f Ptr PresentWait2InfoKHR
p)
  pokeCStruct :: forall b.
Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO b -> IO b
pokeCStruct Ptr PresentWait2InfoKHR
p PresentWait2InfoKHR{Word64
presentId :: PresentWait2InfoKHR -> Word64
timeout :: PresentWait2InfoKHR -> Word64
presentId :: Word64
timeout :: Word64
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_WAIT_2_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64)) (Word64
presentId)
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) (Word64
timeout)
    IO b
f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr PresentWait2InfoKHR -> IO b -> IO b
pokeZeroCStruct Ptr PresentWait2InfoKHR
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_WAIT_2_INFO_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64)) (Word64
forall a. Zero a => a
zero)
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
24 :: Ptr Word64)) (Word64
forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct PresentWait2InfoKHR where
  peekCStruct :: Ptr PresentWait2InfoKHR -> IO PresentWait2InfoKHR
peekCStruct Ptr PresentWait2InfoKHR
p = do
    presentId <- forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr PresentWait2InfoKHR
p Ptr PresentWait2InfoKHR -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word64))
    timeout <- peek @Word64 ((p `plusPtr` 24 :: Ptr Word64))
    pure $ PresentWait2InfoKHR
             presentId timeout

instance Storable PresentWait2InfoKHR where
  sizeOf :: PresentWait2InfoKHR -> Int
sizeOf ~PresentWait2InfoKHR
_ = Int
32
  alignment :: PresentWait2InfoKHR -> Int
alignment ~PresentWait2InfoKHR
_ = Int
8
  peek :: Ptr PresentWait2InfoKHR -> IO PresentWait2InfoKHR
peek = Ptr PresentWait2InfoKHR -> IO PresentWait2InfoKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO ()
poke Ptr PresentWait2InfoKHR
ptr PresentWait2InfoKHR
poked = Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO () -> IO ()
forall b.
Ptr PresentWait2InfoKHR -> PresentWait2InfoKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PresentWait2InfoKHR
ptr PresentWait2InfoKHR
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PresentWait2InfoKHR where
  zero :: PresentWait2InfoKHR
zero = Word64 -> Word64 -> PresentWait2InfoKHR
PresentWait2InfoKHR
           Word64
forall a. Zero a => a
zero
           Word64
forall a. Zero a => a
zero


-- | VkPhysicalDevicePresentWait2FeaturesKHR - Structure indicating support
-- for present wait 2
--
-- = Members
--
-- This structure describes the following feature:
--
-- = Description
--
-- If the 'PhysicalDevicePresentWait2FeaturesKHR' structure is included in
-- the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceFeatures2',
-- it is filled in to indicate whether each corresponding feature is
-- supported. If the application wishes to use a
-- 'Vulkan.Core10.Handles.Device' with any features described by
-- 'PhysicalDevicePresentWait2FeaturesKHR', it /must/ add an instance of
-- the structure, with the desired feature members set to
-- 'Vulkan.Core10.FundamentalTypes.TRUE', to the @pNext@ chain of
-- 'Vulkan.Core10.Device.DeviceCreateInfo' when creating the
-- 'Vulkan.Core10.Handles.Device'.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_wait2 VK_KHR_present_wait2>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDevicePresentWait2FeaturesKHR = PhysicalDevicePresentWait2FeaturesKHR
  { -- | #features-presentWait2# @presentWait2@ indicates that the implementation
    -- supports 'waitForPresent2KHR'.
    PhysicalDevicePresentWait2FeaturesKHR -> Bool
presentWait2 :: Bool }
  deriving (Typeable, PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> Bool
(PhysicalDevicePresentWait2FeaturesKHR
 -> PhysicalDevicePresentWait2FeaturesKHR -> Bool)
-> (PhysicalDevicePresentWait2FeaturesKHR
    -> PhysicalDevicePresentWait2FeaturesKHR -> Bool)
-> Eq PhysicalDevicePresentWait2FeaturesKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> Bool
== :: PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> Bool
$c/= :: PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> Bool
/= :: PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDevicePresentWait2FeaturesKHR)
#endif
deriving instance Show PhysicalDevicePresentWait2FeaturesKHR

instance ToCStruct PhysicalDevicePresentWait2FeaturesKHR where
  withCStruct :: forall b.
PhysicalDevicePresentWait2FeaturesKHR
-> (Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b) -> IO b
withCStruct PhysicalDevicePresentWait2FeaturesKHR
x Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b
f = Int -> (Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b) -> IO b)
-> (Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDevicePresentWait2FeaturesKHR
p -> Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO b -> IO b
forall b.
Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWait2FeaturesKHR
p PhysicalDevicePresentWait2FeaturesKHR
x (Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b
f Ptr PhysicalDevicePresentWait2FeaturesKHR
p)
  pokeCStruct :: forall b.
Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWait2FeaturesKHR
p PhysicalDevicePresentWait2FeaturesKHR{Bool
presentWait2 :: PhysicalDevicePresentWait2FeaturesKHR -> Bool
presentWait2 :: Bool
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_2_FEATURES_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR -> 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 PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
presentWait2))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr PhysicalDevicePresentWait2FeaturesKHR -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDevicePresentWait2FeaturesKHR
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_2_FEATURES_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR -> 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 PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR -> 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 PhysicalDevicePresentWait2FeaturesKHR where
  peekCStruct :: Ptr PhysicalDevicePresentWait2FeaturesKHR
-> IO PhysicalDevicePresentWait2FeaturesKHR
peekCStruct Ptr PhysicalDevicePresentWait2FeaturesKHR
p = do
    presentWait2 <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDevicePresentWait2FeaturesKHR
p Ptr PhysicalDevicePresentWait2FeaturesKHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    pure $ PhysicalDevicePresentWait2FeaturesKHR
             (bool32ToBool presentWait2)

instance Storable PhysicalDevicePresentWait2FeaturesKHR where
  sizeOf :: PhysicalDevicePresentWait2FeaturesKHR -> Int
sizeOf ~PhysicalDevicePresentWait2FeaturesKHR
_ = Int
24
  alignment :: PhysicalDevicePresentWait2FeaturesKHR -> Int
alignment ~PhysicalDevicePresentWait2FeaturesKHR
_ = Int
8
  peek :: Ptr PhysicalDevicePresentWait2FeaturesKHR
-> IO PhysicalDevicePresentWait2FeaturesKHR
peek = Ptr PhysicalDevicePresentWait2FeaturesKHR
-> IO PhysicalDevicePresentWait2FeaturesKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO ()
poke Ptr PhysicalDevicePresentWait2FeaturesKHR
ptr PhysicalDevicePresentWait2FeaturesKHR
poked = Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO () -> IO ()
forall b.
Ptr PhysicalDevicePresentWait2FeaturesKHR
-> PhysicalDevicePresentWait2FeaturesKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDevicePresentWait2FeaturesKHR
ptr PhysicalDevicePresentWait2FeaturesKHR
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero PhysicalDevicePresentWait2FeaturesKHR where
  zero :: PhysicalDevicePresentWait2FeaturesKHR
zero = Bool -> PhysicalDevicePresentWait2FeaturesKHR
PhysicalDevicePresentWait2FeaturesKHR
           Bool
forall a. Zero a => a
zero


-- | VkSurfaceCapabilitiesPresentWait2KHR - Structure describing
-- presentation-wait capabilities of a surface
--
-- = Description
--
-- This structure /can/ be included in the @pNext@ chain of
-- 'Vulkan.Extensions.VK_KHR_get_surface_capabilities2.SurfaceCapabilities2KHR'
-- to determine support for present-wait. If @presentWait2Supported@ is
-- 'Vulkan.Core10.FundamentalTypes.FALSE', it indicates that waiting for
-- presentation is not possible for this surface.
--
-- Applications /must/ not attempt to call 'waitForPresent2KHR' on a
-- swapchain if @presentWait2Supported@ is
-- 'Vulkan.Core10.FundamentalTypes.FALSE'.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_wait2 VK_KHR_present_wait2>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data SurfaceCapabilitiesPresentWait2KHR = SurfaceCapabilitiesPresentWait2KHR
  { -- | @presentWait2Supported@ is a boolean describing whether the surface is
    -- able to support the present-wait extension
    SurfaceCapabilitiesPresentWait2KHR -> Bool
presentWait2Supported :: Bool }
  deriving (Typeable, SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> Bool
(SurfaceCapabilitiesPresentWait2KHR
 -> SurfaceCapabilitiesPresentWait2KHR -> Bool)
-> (SurfaceCapabilitiesPresentWait2KHR
    -> SurfaceCapabilitiesPresentWait2KHR -> Bool)
-> Eq SurfaceCapabilitiesPresentWait2KHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> Bool
== :: SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> Bool
$c/= :: SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> Bool
/= :: SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SurfaceCapabilitiesPresentWait2KHR)
#endif
deriving instance Show SurfaceCapabilitiesPresentWait2KHR

instance ToCStruct SurfaceCapabilitiesPresentWait2KHR where
  withCStruct :: forall b.
SurfaceCapabilitiesPresentWait2KHR
-> (Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b) -> IO b
withCStruct SurfaceCapabilitiesPresentWait2KHR
x Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b
f = Int -> (Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 ((Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b) -> IO b)
-> (Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr SurfaceCapabilitiesPresentWait2KHR
p -> Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO b -> IO b
forall b.
Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SurfaceCapabilitiesPresentWait2KHR
p SurfaceCapabilitiesPresentWait2KHR
x (Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b
f Ptr SurfaceCapabilitiesPresentWait2KHR
p)
  pokeCStruct :: forall b.
Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO b -> IO b
pokeCStruct Ptr SurfaceCapabilitiesPresentWait2KHR
p SurfaceCapabilitiesPresentWait2KHR{Bool
presentWait2Supported :: SurfaceCapabilitiesPresentWait2KHR -> Bool
presentWait2Supported :: Bool
..} IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_WAIT_2_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> 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 SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
presentWait2Supported))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr SurfaceCapabilitiesPresentWait2KHR -> IO b -> IO b
pokeZeroCStruct Ptr SurfaceCapabilitiesPresentWait2KHR
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_WAIT_2_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> 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 SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> 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 SurfaceCapabilitiesPresentWait2KHR where
  peekCStruct :: Ptr SurfaceCapabilitiesPresentWait2KHR
-> IO SurfaceCapabilitiesPresentWait2KHR
peekCStruct Ptr SurfaceCapabilitiesPresentWait2KHR
p = do
    presentWait2Supported <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr SurfaceCapabilitiesPresentWait2KHR
p Ptr SurfaceCapabilitiesPresentWait2KHR -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    pure $ SurfaceCapabilitiesPresentWait2KHR
             (bool32ToBool presentWait2Supported)

instance Storable SurfaceCapabilitiesPresentWait2KHR where
  sizeOf :: SurfaceCapabilitiesPresentWait2KHR -> Int
sizeOf ~SurfaceCapabilitiesPresentWait2KHR
_ = Int
24
  alignment :: SurfaceCapabilitiesPresentWait2KHR -> Int
alignment ~SurfaceCapabilitiesPresentWait2KHR
_ = Int
8
  peek :: Ptr SurfaceCapabilitiesPresentWait2KHR
-> IO SurfaceCapabilitiesPresentWait2KHR
peek = Ptr SurfaceCapabilitiesPresentWait2KHR
-> IO SurfaceCapabilitiesPresentWait2KHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct
  poke :: Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO ()
poke Ptr SurfaceCapabilitiesPresentWait2KHR
ptr SurfaceCapabilitiesPresentWait2KHR
poked = Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO () -> IO ()
forall b.
Ptr SurfaceCapabilitiesPresentWait2KHR
-> SurfaceCapabilitiesPresentWait2KHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr SurfaceCapabilitiesPresentWait2KHR
ptr SurfaceCapabilitiesPresentWait2KHR
poked (() -> IO ()
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ())

instance Zero SurfaceCapabilitiesPresentWait2KHR where
  zero :: SurfaceCapabilitiesPresentWait2KHR
zero = Bool -> SurfaceCapabilitiesPresentWait2KHR
SurfaceCapabilitiesPresentWait2KHR
           Bool
forall a. Zero a => a
zero


type KHR_PRESENT_WAIT_2_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_PRESENT_WAIT_2_SPEC_VERSION"
pattern KHR_PRESENT_WAIT_2_SPEC_VERSION :: forall a . Integral a => a
pattern $mKHR_PRESENT_WAIT_2_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bKHR_PRESENT_WAIT_2_SPEC_VERSION :: forall a. Integral a => a
KHR_PRESENT_WAIT_2_SPEC_VERSION = 1


type KHR_PRESENT_WAIT_2_EXTENSION_NAME = "VK_KHR_present_wait2"

-- No documentation found for TopLevel "VK_KHR_PRESENT_WAIT_2_EXTENSION_NAME"
pattern KHR_PRESENT_WAIT_2_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $mKHR_PRESENT_WAIT_2_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bKHR_PRESENT_WAIT_2_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
KHR_PRESENT_WAIT_2_EXTENSION_NAME = "VK_KHR_present_wait2"