{-# language CPP #-}
-- | = Name
--
-- VK_KHR_present_id2 - device extension
--
-- = VK_KHR_present_id2
--
-- [__Name String__]
--     @VK_KHR_present_id2@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     480
--
-- [__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>
--
-- [__Contact__]
--
--     -   Daniel Stone
--
-- [__Extension Proposal__]
--     <https://github.com/KhronosGroup/Vulkan-Docs/tree/main/proposals/VK_KHR_present_id2.adoc VK_KHR_present_id2>
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2025-01-06
--
-- [__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_id VK_KHR_present_id>\`/
--
-- == Description
--
-- This device extension allows an application that uses the
-- @VK_KHR_swapchain@ extension to provide an identifier for present
-- operations on a swapchain. An application /can/ use this to reference
-- specific present operations in other extensions.
--
-- == New Structures
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDevicePresentId2FeaturesKHR'
--
-- -   Extending 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR':
--
--     -   'PresentId2KHR'
--
-- -   Extending
--     'Vulkan.Extensions.VK_KHR_get_surface_capabilities2.SurfaceCapabilities2KHR':
--
--     -   'SurfaceCapabilitiesPresentId2KHR'
--
-- == New Enum Constants
--
-- -   'KHR_PRESENT_ID_2_EXTENSION_NAME'
--
-- -   'KHR_PRESENT_ID_2_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_2_FEATURES_KHR'
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PRESENT_ID_2_KHR'
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_ID_2_KHR'
--
-- -   Extending
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateFlagBitsKHR':
--
--     -   'Vulkan.Extensions.VK_KHR_swapchain.SWAPCHAIN_CREATE_PRESENT_ID_2_BIT_KHR'
--
-- == Issues
--
-- None.
--
-- == Version History
--
-- -   Revision 1, 2022-05-10 (Daniel Stone)
--
--     -   Repurposed VK_KHR_present_id to be driven by surface
--         capabilities
--
-- == 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_id2 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_id2  ( PhysicalDevicePresentId2FeaturesKHR(..)
                                             , PresentId2KHR(..)
                                             , SurfaceCapabilitiesPresentId2KHR(..)
                                             , KHR_PRESENT_ID_2_SPEC_VERSION
                                             , pattern KHR_PRESENT_ID_2_SPEC_VERSION
                                             , KHR_PRESENT_ID_2_EXTENSION_NAME
                                             , pattern KHR_PRESENT_ID_2_EXTENSION_NAME
                                             , SwapchainCreateFlagBitsKHR(..)
                                             , SwapchainCreateFlagsKHR
                                             ) where

import Control.Monad (unless)
import Foreign.Marshal.Alloc (allocaBytes)
import GHC.IO (throwIO)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Cont (evalContT)
import Data.Vector (generateM)
import qualified Data.Vector (imapM_)
import qualified Data.Vector (length)
import qualified Data.Vector (null)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
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 (Ptr)
import Data.Word (Word32)
import Data.Word (Word64)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.Core10.FundamentalTypes (Bool32)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_2_FEATURES_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PRESENT_ID_2_KHR))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_ID_2_KHR))
import Vulkan.Extensions.VK_KHR_swapchain (SwapchainCreateFlagBitsKHR(..))
import Vulkan.Extensions.VK_KHR_swapchain (SwapchainCreateFlagsKHR)
-- | VkPhysicalDevicePresentId2FeaturesKHR - Structure indicating support for
-- present id 2
--
-- = Members
--
-- This structure describes the following feature:
--
-- = Description
--
-- If the 'PhysicalDevicePresentId2FeaturesKHR' 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
-- 'PhysicalDevicePresentId2FeaturesKHR', 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_id2 VK_KHR_present_id2>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDevicePresentId2FeaturesKHR = PhysicalDevicePresentId2FeaturesKHR
  { -- | #features-presentId2# @presentId2@ indicates that the implementation
    -- supports specifying present ID values in the 'PresentId2KHR' extension
    -- to the 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR' struct.
    PhysicalDevicePresentId2FeaturesKHR -> Bool
presentId2 :: Bool }
  deriving (Typeable, PhysicalDevicePresentId2FeaturesKHR
-> PhysicalDevicePresentId2FeaturesKHR -> Bool
(PhysicalDevicePresentId2FeaturesKHR
 -> PhysicalDevicePresentId2FeaturesKHR -> Bool)
-> (PhysicalDevicePresentId2FeaturesKHR
    -> PhysicalDevicePresentId2FeaturesKHR -> Bool)
-> Eq PhysicalDevicePresentId2FeaturesKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PhysicalDevicePresentId2FeaturesKHR
-> PhysicalDevicePresentId2FeaturesKHR -> Bool
== :: PhysicalDevicePresentId2FeaturesKHR
-> PhysicalDevicePresentId2FeaturesKHR -> Bool
$c/= :: PhysicalDevicePresentId2FeaturesKHR
-> PhysicalDevicePresentId2FeaturesKHR -> Bool
/= :: PhysicalDevicePresentId2FeaturesKHR
-> PhysicalDevicePresentId2FeaturesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDevicePresentId2FeaturesKHR)
#endif
deriving instance Show PhysicalDevicePresentId2FeaturesKHR

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

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

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


-- | VkPresentId2KHR - The list of presentation identifiers
--
-- = Description
--
-- For applications to be able to reference specific presentation events
-- queued by a call to
-- 'Vulkan.Extensions.VK_KHR_swapchain.queuePresentKHR', an identifier
-- needs to be associated with them.
--
-- When the 'SurfaceCapabilitiesPresentId2KHR' surface capability is
-- present for a surface, applications /can/ include the 'PresentId2KHR'
-- structure in the @pNext@ chain of the
-- 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR' structure to
-- associate an identifier with each presentation request. The
-- @pPresentIds@ provides an identifier for the swapchain present at the
-- corresponding index in
-- 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'’s @pSwapchains@
-- array.
--
-- If this presentId is non-zero, then the application /can/ later use this
-- value to refer to that image presentation. A value of zero indicates
-- that this presentation has no associated presentId. A non-zero presentId
-- /must/ be greater than any non-zero presentId passed previously by the
-- application for the same swapchain.
--
-- If a non-zero presentId was provided, this may be used with
-- 'Vulkan.Extensions.VK_KHR_present_wait2.waitForPresent2KHR' for the
-- application to synchronize against the presentation engine’s processing
-- of the presentation request.
--
-- The ID namespace used by this extension /must/ be shared with other
-- extensions that allow the application to provide a 64-bit monotonically
-- increasing presentation ID, such as the original VK_KHR_present_id.
--
-- This is to allow existing extensions that depend on VK_KHR_present_id to
-- use VK_KHR_present_id2 provided IDs without change, as well as to
-- simplify writing future extensions that require application provided
-- presentation IDs.
--
-- == Valid Usage
--
-- -   #VUID-VkPresentId2KHR-swapchainCount-10818# @swapchainCount@ /must/
--     be the same value as
--     'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'::@swapchainCount@,
--     where this 'PresentId2KHR' is in the @pNext@ chain of the
--     'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR' structure
--
-- -   #VUID-VkPresentId2KHR-presentIds-10819# Each non-zero entry in
--     @presentIds@ /must/ be greater than all previously submitted present
--     ids for the associated swapchain in
--     'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'::@pSwapchains@
--
-- -   #VUID-VkPresentId2KHR-None-10820# The swapchain must have been
--     created with
--     'Vulkan.Extensions.VK_KHR_swapchain.SWAPCHAIN_CREATE_PRESENT_ID_2_BIT_KHR'
--     bit set in the
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateFlagBitsKHR'
--     field
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkPresentId2KHR-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PRESENT_ID_2_KHR'
--
-- -   #VUID-VkPresentId2KHR-pPresentIds-parameter# If @pPresentIds@ is not
--     @NULL@, @pPresentIds@ /must/ be a valid pointer to an array of
--     @swapchainCount@ @uint64_t@ values
--
-- -   #VUID-VkPresentId2KHR-swapchainCount-arraylength# @swapchainCount@
--     /must/ be greater than @0@
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_present_id2 VK_KHR_present_id2>,
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PresentId2KHR = PresentId2KHR
  { -- | @swapchainCount@ is the number of swapchains being presented to the
    -- 'Vulkan.Extensions.VK_KHR_swapchain.queuePresentKHR' command.
    PresentId2KHR -> Word32
swapchainCount :: Word32
  , -- | @pPresentIds@ is @NULL@ or a pointer to an array of uint64_t with
    -- @swapchainCount@ entries. If not @NULL@, each non-zero value in
    -- @pPresentIds@ specifies the present id to be associated with the
    -- presentation of the swapchain with the same index in the
    -- 'Vulkan.Extensions.VK_KHR_swapchain.queuePresentKHR' call.
    PresentId2KHR -> Vector Word64
presentIds :: Vector Word64
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PresentId2KHR)
#endif
deriving instance Show PresentId2KHR

instance ToCStruct PresentId2KHR where
  withCStruct :: forall b. PresentId2KHR -> (Ptr PresentId2KHR -> IO b) -> IO b
withCStruct PresentId2KHR
x Ptr PresentId2KHR -> IO b
f = Int -> (Ptr PresentId2KHR -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
32 ((Ptr PresentId2KHR -> IO b) -> IO b)
-> (Ptr PresentId2KHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \Ptr PresentId2KHR
p -> Ptr PresentId2KHR -> PresentId2KHR -> IO b -> IO b
forall b. Ptr PresentId2KHR -> PresentId2KHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PresentId2KHR
p PresentId2KHR
x (Ptr PresentId2KHR -> IO b
f Ptr PresentId2KHR
p)
  pokeCStruct :: forall b. Ptr PresentId2KHR -> PresentId2KHR -> IO b -> IO b
pokeCStruct Ptr PresentId2KHR
p PresentId2KHR{Word32
Vector Word64
swapchainCount :: PresentId2KHR -> Word32
presentIds :: PresentId2KHR -> Vector Word64
swapchainCount :: Word32
presentIds :: Vector Word64
..} IO b
f = ContT b IO b -> IO b
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT b IO b -> IO b) -> ContT b IO b -> IO b
forall a b. (a -> b) -> a -> b
$ do
    IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentId2KHR
p Ptr PresentId2KHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_ID_2_KHR)
    IO () -> ContT b IO ()
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO () -> ContT b IO ()) -> IO () -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentId2KHR
p Ptr PresentId2KHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    let pPresentIdsLength :: Int
pPresentIdsLength = Vector Word64 -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector Word64 -> Int) -> Vector Word64 -> Int
forall a b. (a -> b) -> a -> b
$ (Vector Word64
presentIds)
    swapchainCount'' <- IO Word32 -> ContT b IO Word32
forall (m :: * -> *) a. Monad m => m a -> ContT b m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO Word32 -> ContT b IO Word32) -> IO Word32 -> ContT b IO Word32
forall a b. (a -> b) -> a -> b
$ if (Word32
swapchainCount) Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== Word32
0
      then Word32 -> IO Word32
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32 -> IO Word32) -> Word32 -> IO Word32
forall a b. (a -> b) -> a -> b
$ Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pPresentIdsLength
      else do
        Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pPresentIdsLength Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== (Word32
swapchainCount) Bool -> Bool -> Bool
|| Int
pPresentIdsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0) (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
"pPresentIds must be empty or have 'swapchainCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
        Word32 -> IO Word32
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32
swapchainCount)
    lift $ poke ((p `plusPtr` 16 :: Ptr Word32)) (swapchainCount'')
    pPresentIds'' <- if Data.Vector.null (presentIds)
      then pure nullPtr
      else do
        pPPresentIds <- ContT $ allocaBytes @Word64 (((Data.Vector.length (presentIds))) * 8)
        lift $ Data.Vector.imapM_ (\Int
i Word64
e -> Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr Word64
pPPresentIds Ptr Word64 -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64) (Word64
e)) ((presentIds))
        pure $ pPPresentIds
    lift $ poke ((p `plusPtr` 24 :: Ptr (Ptr Word64))) pPresentIds''
    lift $ f
  cStructSize :: Int
cStructSize = Int
32
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr PresentId2KHR -> IO b -> IO b
pokeZeroCStruct Ptr PresentId2KHR
p IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentId2KHR
p Ptr PresentId2KHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_ID_2_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentId2KHR
p Ptr PresentId2KHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO b
f

instance FromCStruct PresentId2KHR where
  peekCStruct :: Ptr PresentId2KHR -> IO PresentId2KHR
peekCStruct Ptr PresentId2KHR
p = do
    swapchainCount <- forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PresentId2KHR
p Ptr PresentId2KHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Word32))
    pPresentIds <- peek @(Ptr Word64) ((p `plusPtr` 24 :: Ptr (Ptr Word64)))
    let pPresentIdsLength = if Ptr Word64
pPresentIds Ptr Word64 -> Ptr Word64 -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr Word64
forall a. Ptr a
nullPtr then Int
0 else (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
swapchainCount)
    pPresentIds' <- generateM pPresentIdsLength (\Int
i -> forall a. Storable a => Ptr a -> IO a
peek @Word64 ((Ptr Word64
pPresentIds Ptr Word64 -> Int -> Ptr Word64
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (Int
8 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr Word64)))
    pure $ PresentId2KHR
             swapchainCount pPresentIds'

instance Zero PresentId2KHR where
  zero :: PresentId2KHR
zero = Word32 -> Vector Word64 -> PresentId2KHR
PresentId2KHR
           Word32
forall a. Zero a => a
zero
           Vector Word64
forall a. Monoid a => a
mempty


-- | VkSurfaceCapabilitiesPresentId2KHR - Structure describing
-- presentation-ID 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 @presentId2Supported@ is
-- 'Vulkan.Core10.FundamentalTypes.FALSE', it indicates that attaching an
-- ID to presentation requests is not possible for this surface.
--
-- Applications /must/ not attempt to include 'PresentId2KHR' in the
-- @pNext@ chain of a 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'
-- if @presentId2Supported@ 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_id2 VK_KHR_present_id2>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data SurfaceCapabilitiesPresentId2KHR = SurfaceCapabilitiesPresentId2KHR
  { -- | @presentId2Supported@ is a boolean describing whether the surface is
    -- able to support the present-ID extension
    SurfaceCapabilitiesPresentId2KHR -> Bool
presentId2Supported :: Bool }
  deriving (Typeable, SurfaceCapabilitiesPresentId2KHR
-> SurfaceCapabilitiesPresentId2KHR -> Bool
(SurfaceCapabilitiesPresentId2KHR
 -> SurfaceCapabilitiesPresentId2KHR -> Bool)
-> (SurfaceCapabilitiesPresentId2KHR
    -> SurfaceCapabilitiesPresentId2KHR -> Bool)
-> Eq SurfaceCapabilitiesPresentId2KHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SurfaceCapabilitiesPresentId2KHR
-> SurfaceCapabilitiesPresentId2KHR -> Bool
== :: SurfaceCapabilitiesPresentId2KHR
-> SurfaceCapabilitiesPresentId2KHR -> Bool
$c/= :: SurfaceCapabilitiesPresentId2KHR
-> SurfaceCapabilitiesPresentId2KHR -> Bool
/= :: SurfaceCapabilitiesPresentId2KHR
-> SurfaceCapabilitiesPresentId2KHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (SurfaceCapabilitiesPresentId2KHR)
#endif
deriving instance Show SurfaceCapabilitiesPresentId2KHR

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

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

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


type KHR_PRESENT_ID_2_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_PRESENT_ID_2_SPEC_VERSION"
pattern KHR_PRESENT_ID_2_SPEC_VERSION :: forall a . Integral a => a
pattern $mKHR_PRESENT_ID_2_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bKHR_PRESENT_ID_2_SPEC_VERSION :: forall a. Integral a => a
KHR_PRESENT_ID_2_SPEC_VERSION = 1


type KHR_PRESENT_ID_2_EXTENSION_NAME = "VK_KHR_present_id2"

-- No documentation found for TopLevel "VK_KHR_PRESENT_ID_2_EXTENSION_NAME"
pattern KHR_PRESENT_ID_2_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $mKHR_PRESENT_ID_2_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bKHR_PRESENT_ID_2_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
KHR_PRESENT_ID_2_EXTENSION_NAME = "VK_KHR_present_id2"