{-# language CPP #-}
module Vulkan.Extensions.VK_KHR_incremental_present  ( PresentRegionsKHR(..)
                                                     , PresentRegionKHR(..)
                                                     , RectLayerKHR(..)
                                                     , KHR_INCREMENTAL_PRESENT_SPEC_VERSION
                                                     , pattern KHR_INCREMENTAL_PRESENT_SPEC_VERSION
                                                     , KHR_INCREMENTAL_PRESENT_EXTENSION_NAME
                                                     , pattern KHR_INCREMENTAL_PRESENT_EXTENSION_NAME
                                                     ) where

import Control.Monad (unless)
import Foreign.Marshal.Alloc (allocaBytesAligned)
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 Data.String (IsString)
import Data.Typeable (Typeable)
import Foreign.Storable (Storable(peek))
import Foreign.Storable (Storable(poke))
import GHC.Generics (Generic)
import GHC.IO.Exception (IOErrorType(..))
import GHC.IO.Exception (IOException(..))
import Foreign.Ptr (Ptr)
import Data.Word (Word32)
import Data.Kind (Type)
import Control.Monad.Trans.Cont (ContT(..))
import Data.Vector (Vector)
import Vulkan.CStruct.Utils (advancePtrBytes)
import Vulkan.Core10.SharedTypes (Extent2D)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.Core10.SharedTypes (Offset2D)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PRESENT_REGIONS_KHR))
-- | VkPresentRegionsKHR - Structure hint of rectangular regions changed by
-- vkQueuePresentKHR
--
-- == Valid Usage
--
-- -   @swapchainCount@ /must/ be the same value as
--     'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'::@swapchainCount@,
--     where 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR' is
--     included in the @pNext@ chain of this 'PresentRegionsKHR' structure
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PRESENT_REGIONS_KHR'
--
-- -   If @pRegions@ is not @NULL@, @pRegions@ /must/ be a valid pointer to
--     an array of @swapchainCount@ valid 'PresentRegionKHR' structures
--
-- -   @swapchainCount@ /must/ be greater than @0@
--
-- = See Also
--
-- 'PresentRegionKHR', 'Vulkan.Core10.Enums.StructureType.StructureType'
data PresentRegionsKHR = PresentRegionsKHR
  { -- | @swapchainCount@ is the number of swapchains being presented to by this
    -- command.
    PresentRegionsKHR -> Word32
swapchainCount :: Word32
  , -- | @pRegions@ is @NULL@ or a pointer to an array of 'PresentRegionKHR'
    -- elements with @swapchainCount@ entries. If not @NULL@, each element of
    -- @pRegions@ contains the region that has changed since the last present
    -- to the swapchain in the corresponding entry in the
    -- 'Vulkan.Extensions.VK_KHR_swapchain.PresentInfoKHR'::@pSwapchains@
    -- array.
    PresentRegionsKHR -> Vector PresentRegionKHR
regions :: Vector PresentRegionKHR
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PresentRegionsKHR)
#endif
deriving instance Show PresentRegionsKHR

instance ToCStruct PresentRegionsKHR where
  withCStruct :: PresentRegionsKHR -> (Ptr PresentRegionsKHR -> IO b) -> IO b
withCStruct x :: PresentRegionsKHR
x f :: Ptr PresentRegionsKHR -> IO b
f = Int -> Int -> (Ptr PresentRegionsKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 32 8 ((Ptr PresentRegionsKHR -> IO b) -> IO b)
-> (Ptr PresentRegionsKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr PresentRegionsKHR
p -> Ptr PresentRegionsKHR -> PresentRegionsKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PresentRegionsKHR
p PresentRegionsKHR
x (Ptr PresentRegionsKHR -> IO b
f Ptr PresentRegionsKHR
p)
  pokeCStruct :: Ptr PresentRegionsKHR -> PresentRegionsKHR -> IO b -> IO b
pokeCStruct p :: Ptr PresentRegionsKHR
p PresentRegionsKHR{..} f :: 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 (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 PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_REGIONS_KHR)
    IO () -> ContT b IO ()
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 PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    let pRegionsLength :: Int
pRegionsLength = Vector PresentRegionKHR -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector PresentRegionKHR -> Int) -> Vector PresentRegionKHR -> Int
forall a b. (a -> b) -> a -> b
$ (Vector PresentRegionKHR
regions)
    Word32
swapchainCount'' <- IO Word32 -> ContT b IO Word32
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
== 0
      then Word32 -> IO Word32
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
pRegionsLength
      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
pRegionsLength Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== (Word32
swapchainCount) Bool -> Bool -> Bool
|| Int
pRegionsLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 0) (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 "" "pRegions 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 (f :: * -> *) a. Applicative f => a -> f a
pure (Word32
swapchainCount)
    IO () -> ContT b IO ()
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
swapchainCount'')
    Ptr PresentRegionKHR
pRegions'' <- if Vector PresentRegionKHR -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector PresentRegionKHR
regions)
      then Ptr PresentRegionKHR -> ContT b IO (Ptr PresentRegionKHR)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr PresentRegionKHR
forall a. Ptr a
nullPtr
      else do
        Ptr PresentRegionKHR
pPRegions <- ((Ptr PresentRegionKHR -> IO b) -> IO b)
-> ContT b IO (Ptr PresentRegionKHR)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr PresentRegionKHR -> IO b) -> IO b)
 -> ContT b IO (Ptr PresentRegionKHR))
-> ((Ptr PresentRegionKHR -> IO b) -> IO b)
-> ContT b IO (Ptr PresentRegionKHR)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr PresentRegionKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @PresentRegionKHR (((Vector PresentRegionKHR -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector PresentRegionKHR
regions))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 16) 8
        (Int -> PresentRegionKHR -> ContT b IO ())
-> Vector PresentRegionKHR -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: PresentRegionKHR
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr PresentRegionKHR -> PresentRegionKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr PresentRegionKHR
pPRegions Ptr PresentRegionKHR -> Int -> Ptr PresentRegionKHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (16 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PresentRegionKHR) (PresentRegionKHR
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) ((Vector PresentRegionKHR
regions))
        Ptr PresentRegionKHR -> ContT b IO (Ptr PresentRegionKHR)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr PresentRegionKHR -> ContT b IO (Ptr PresentRegionKHR))
-> Ptr PresentRegionKHR -> ContT b IO (Ptr PresentRegionKHR)
forall a b. (a -> b) -> a -> b
$ Ptr PresentRegionKHR
pPRegions
    IO () -> ContT b IO ()
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 PresentRegionKHR) -> Ptr PresentRegionKHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr (Ptr PresentRegionKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr PresentRegionKHR))) Ptr PresentRegionKHR
pRegions''
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = 32
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr PresentRegionsKHR -> IO b -> IO b
pokeZeroCStruct p :: Ptr PresentRegionsKHR
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PRESENT_REGIONS_KHR)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    IO b
f

instance FromCStruct PresentRegionsKHR where
  peekCStruct :: Ptr PresentRegionsKHR -> IO PresentRegionsKHR
peekCStruct p :: Ptr PresentRegionsKHR
p = do
    Word32
swapchainCount <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
    Ptr PresentRegionKHR
pRegions <- Ptr (Ptr PresentRegionKHR) -> IO (Ptr PresentRegionKHR)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr PresentRegionKHR) ((Ptr PresentRegionsKHR
p Ptr PresentRegionsKHR -> Int -> Ptr (Ptr PresentRegionKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 24 :: Ptr (Ptr PresentRegionKHR)))
    let pRegionsLength :: Int
pRegionsLength = if Ptr PresentRegionKHR
pRegions Ptr PresentRegionKHR -> Ptr PresentRegionKHR -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr PresentRegionKHR
forall a. Ptr a
nullPtr then 0 else (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
swapchainCount)
    Vector PresentRegionKHR
pRegions' <- Int -> (Int -> IO PresentRegionKHR) -> IO (Vector PresentRegionKHR)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pRegionsLength (\i :: Int
i -> Ptr PresentRegionKHR -> IO PresentRegionKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @PresentRegionKHR ((Ptr PresentRegionKHR
pRegions Ptr PresentRegionKHR -> Int -> Ptr PresentRegionKHR
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (16 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr PresentRegionKHR)))
    PresentRegionsKHR -> IO PresentRegionsKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PresentRegionsKHR -> IO PresentRegionsKHR)
-> PresentRegionsKHR -> IO PresentRegionsKHR
forall a b. (a -> b) -> a -> b
$ Word32 -> Vector PresentRegionKHR -> PresentRegionsKHR
PresentRegionsKHR
             Word32
swapchainCount Vector PresentRegionKHR
pRegions'

instance Zero PresentRegionsKHR where
  zero :: PresentRegionsKHR
zero = Word32 -> Vector PresentRegionKHR -> PresentRegionsKHR
PresentRegionsKHR
           Word32
forall a. Zero a => a
zero
           Vector PresentRegionKHR
forall a. Monoid a => a
mempty


-- | VkPresentRegionKHR - Structure containing rectangular region changed by
-- vkQueuePresentKHR for a given VkImage
--
-- == Valid Usage (Implicit)
--
-- -   If @rectangleCount@ is not @0@, and @pRectangles@ is not @NULL@,
--     @pRectangles@ /must/ be a valid pointer to an array of
--     @rectangleCount@ valid 'RectLayerKHR' structures
--
-- = See Also
--
-- 'PresentRegionsKHR', 'RectLayerKHR'
data PresentRegionKHR = PresentRegionKHR
  { -- | @rectangleCount@ is the number of rectangles in @pRectangles@, or zero
    -- if the entire image has changed and should be presented.
    PresentRegionKHR -> Word32
rectangleCount :: Word32
  , -- | @pRectangles@ is either @NULL@ or a pointer to an array of
    -- 'RectLayerKHR' structures. The 'RectLayerKHR' structure is the
    -- framebuffer coordinates, plus layer, of a portion of a presentable image
    -- that has changed and /must/ be presented. If non-@NULL@, each entry in
    -- @pRectangles@ is a rectangle of the given image that has changed since
    -- the last image was presented to the given swapchain.
    PresentRegionKHR -> Vector RectLayerKHR
rectangles :: Vector RectLayerKHR
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PresentRegionKHR)
#endif
deriving instance Show PresentRegionKHR

instance ToCStruct PresentRegionKHR where
  withCStruct :: PresentRegionKHR -> (Ptr PresentRegionKHR -> IO b) -> IO b
withCStruct x :: PresentRegionKHR
x f :: Ptr PresentRegionKHR -> IO b
f = Int -> Int -> (Ptr PresentRegionKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 16 8 ((Ptr PresentRegionKHR -> IO b) -> IO b)
-> (Ptr PresentRegionKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr PresentRegionKHR
p -> Ptr PresentRegionKHR -> PresentRegionKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PresentRegionKHR
p PresentRegionKHR
x (Ptr PresentRegionKHR -> IO b
f Ptr PresentRegionKHR
p)
  pokeCStruct :: Ptr PresentRegionKHR -> PresentRegionKHR -> IO b -> IO b
pokeCStruct p :: Ptr PresentRegionKHR
p PresentRegionKHR{..} f :: 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
    let pRectanglesLength :: Int
pRectanglesLength = Vector RectLayerKHR -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector RectLayerKHR -> Int) -> Vector RectLayerKHR -> Int
forall a b. (a -> b) -> a -> b
$ (Vector RectLayerKHR
rectangles)
    Word32
rectangleCount'' <- IO Word32 -> ContT b IO Word32
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
rectangleCount) Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== 0
      then Word32 -> IO Word32
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
pRectanglesLength
      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
pRectanglesLength Word32 -> Word32 -> Bool
forall a. Eq a => a -> a -> Bool
== (Word32
rectangleCount) Bool -> Bool -> Bool
|| Int
pRectanglesLength Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== 0) (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 "" "pRectangles must be empty or have 'rectangleCount' elements" Maybe CInt
forall a. Maybe a
Nothing Maybe String
forall a. Maybe a
Nothing
        Word32 -> IO Word32
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32
rectangleCount)
    IO () -> ContT b IO ()
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionKHR
p Ptr PresentRegionKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Word32)) (Word32
rectangleCount'')
    Ptr RectLayerKHR
pRectangles'' <- if Vector RectLayerKHR -> Bool
forall a. Vector a -> Bool
Data.Vector.null (Vector RectLayerKHR
rectangles)
      then Ptr RectLayerKHR -> ContT b IO (Ptr RectLayerKHR)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ptr RectLayerKHR
forall a. Ptr a
nullPtr
      else do
        Ptr RectLayerKHR
pPRectangles <- ((Ptr RectLayerKHR -> IO b) -> IO b)
-> ContT b IO (Ptr RectLayerKHR)
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((Ptr RectLayerKHR -> IO b) -> IO b)
 -> ContT b IO (Ptr RectLayerKHR))
-> ((Ptr RectLayerKHR -> IO b) -> IO b)
-> ContT b IO (Ptr RectLayerKHR)
forall a b. (a -> b) -> a -> b
$ Int -> Int -> (Ptr RectLayerKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned @RectLayerKHR (((Vector RectLayerKHR -> Int
forall a. Vector a -> Int
Data.Vector.length (Vector RectLayerKHR
rectangles))) Int -> Int -> Int
forall a. Num a => a -> a -> a
* 20) 4
        (Int -> RectLayerKHR -> ContT b IO ())
-> Vector RectLayerKHR -> ContT b IO ()
forall (m :: * -> *) a b.
Monad m =>
(Int -> a -> m b) -> Vector a -> m ()
Data.Vector.imapM_ (\i :: Int
i e :: RectLayerKHR
e -> ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr RectLayerKHR -> RectLayerKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct (Ptr RectLayerKHR
pPRectangles Ptr RectLayerKHR -> Int -> Ptr RectLayerKHR
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` (20 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr RectLayerKHR) (RectLayerKHR
e) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())) ((Vector RectLayerKHR
rectangles))
        Ptr RectLayerKHR -> ContT b IO (Ptr RectLayerKHR)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Ptr RectLayerKHR -> ContT b IO (Ptr RectLayerKHR))
-> Ptr RectLayerKHR -> ContT b IO (Ptr RectLayerKHR)
forall a b. (a -> b) -> a -> b
$ Ptr RectLayerKHR
pPRectangles
    IO () -> ContT b IO ()
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 RectLayerKHR) -> Ptr RectLayerKHR -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PresentRegionKHR
p Ptr PresentRegionKHR -> Int -> Ptr (Ptr RectLayerKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr RectLayerKHR))) Ptr RectLayerKHR
pRectangles''
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = 16
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr PresentRegionKHR -> IO b -> IO b
pokeZeroCStruct _ f :: IO b
f = IO b
f

instance FromCStruct PresentRegionKHR where
  peekCStruct :: Ptr PresentRegionKHR -> IO PresentRegionKHR
peekCStruct p :: Ptr PresentRegionKHR
p = do
    Word32
rectangleCount <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr PresentRegionKHR
p Ptr PresentRegionKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Word32))
    Ptr RectLayerKHR
pRectangles <- Ptr (Ptr RectLayerKHR) -> IO (Ptr RectLayerKHR)
forall a. Storable a => Ptr a -> IO a
peek @(Ptr RectLayerKHR) ((Ptr PresentRegionKHR
p Ptr PresentRegionKHR -> Int -> Ptr (Ptr RectLayerKHR)
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr RectLayerKHR)))
    let pRectanglesLength :: Int
pRectanglesLength = if Ptr RectLayerKHR
pRectangles Ptr RectLayerKHR -> Ptr RectLayerKHR -> Bool
forall a. Eq a => a -> a -> Bool
== Ptr RectLayerKHR
forall a. Ptr a
nullPtr then 0 else (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
rectangleCount)
    Vector RectLayerKHR
pRectangles' <- Int -> (Int -> IO RectLayerKHR) -> IO (Vector RectLayerKHR)
forall (m :: * -> *) a.
Monad m =>
Int -> (Int -> m a) -> m (Vector a)
generateM Int
pRectanglesLength (\i :: Int
i -> Ptr RectLayerKHR -> IO RectLayerKHR
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @RectLayerKHR ((Ptr RectLayerKHR
pRectangles Ptr RectLayerKHR -> Int -> Ptr RectLayerKHR
forall a. Ptr a -> Int -> Ptr a
`advancePtrBytes` (20 Int -> Int -> Int
forall a. Num a => a -> a -> a
* (Int
i)) :: Ptr RectLayerKHR)))
    PresentRegionKHR -> IO PresentRegionKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PresentRegionKHR -> IO PresentRegionKHR)
-> PresentRegionKHR -> IO PresentRegionKHR
forall a b. (a -> b) -> a -> b
$ Word32 -> Vector RectLayerKHR -> PresentRegionKHR
PresentRegionKHR
             Word32
rectangleCount Vector RectLayerKHR
pRectangles'

instance Zero PresentRegionKHR where
  zero :: PresentRegionKHR
zero = Word32 -> Vector RectLayerKHR -> PresentRegionKHR
PresentRegionKHR
           Word32
forall a. Zero a => a
zero
           Vector RectLayerKHR
forall a. Monoid a => a
mempty


-- | VkRectLayerKHR - Structure containing a rectangle, including layer,
-- changed by vkQueuePresentKHR for a given VkImage
--
-- == Valid Usage
--
-- -   The sum of @offset@ and @extent@ /must/ be no greater than the
--     @imageExtent@ member of the
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateInfoKHR'
--     structure passed to
--     'Vulkan.Extensions.VK_KHR_swapchain.createSwapchainKHR'
--
-- -   @layer@ /must/ be less than the @imageArrayLayers@ member of the
--     'Vulkan.Extensions.VK_KHR_swapchain.SwapchainCreateInfoKHR'
--     structure passed to
--     'Vulkan.Extensions.VK_KHR_swapchain.createSwapchainKHR'
--
-- Some platforms allow the size of a surface to change, and then scale the
-- pixels of the image to fit the surface. 'RectLayerKHR' specifies pixels
-- of the swapchain’s image(s), which will be constant for the life of the
-- swapchain.
--
-- = See Also
--
-- 'Vulkan.Core10.SharedTypes.Extent2D',
-- 'Vulkan.Core10.SharedTypes.Offset2D', 'PresentRegionKHR'
data RectLayerKHR = RectLayerKHR
  { -- | @offset@ is the origin of the rectangle, in pixels.
    RectLayerKHR -> Offset2D
offset :: Offset2D
  , -- | @extent@ is the size of the rectangle, in pixels.
    RectLayerKHR -> Extent2D
extent :: Extent2D
  , -- | @layer@ is the layer of the image. For images with only one layer, the
    -- value of @layer@ /must/ be 0.
    RectLayerKHR -> Word32
layer :: Word32
  }
  deriving (Typeable)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (RectLayerKHR)
#endif
deriving instance Show RectLayerKHR

instance ToCStruct RectLayerKHR where
  withCStruct :: RectLayerKHR -> (Ptr RectLayerKHR -> IO b) -> IO b
withCStruct x :: RectLayerKHR
x f :: Ptr RectLayerKHR -> IO b
f = Int -> Int -> (Ptr RectLayerKHR -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 20 4 ((Ptr RectLayerKHR -> IO b) -> IO b)
-> (Ptr RectLayerKHR -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr RectLayerKHR
p -> Ptr RectLayerKHR -> RectLayerKHR -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr RectLayerKHR
p RectLayerKHR
x (Ptr RectLayerKHR -> IO b
f Ptr RectLayerKHR
p)
  pokeCStruct :: Ptr RectLayerKHR -> RectLayerKHR -> IO b -> IO b
pokeCStruct p :: Ptr RectLayerKHR
p RectLayerKHR{..} f :: 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 b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Offset2D -> Offset2D -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Offset2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Offset2D)) (Offset2D
offset) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())
    ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Extent2D -> Extent2D -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Extent2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr Extent2D)) (Extent2D
extent) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())
    IO () -> ContT b IO ()
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
layer)
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f
  cStructSize :: Int
cStructSize = 20
  cStructAlignment :: Int
cStructAlignment = 4
  pokeZeroCStruct :: Ptr RectLayerKHR -> IO b -> IO b
pokeZeroCStruct p :: Ptr RectLayerKHR
p f :: 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 b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Offset2D -> Offset2D -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Offset2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Offset2D)) (Offset2D
forall a. Zero a => a
zero) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())
    ((() -> IO b) -> IO b) -> ContT b IO ()
forall k (r :: k) (m :: k -> *) a.
((a -> m r) -> m r) -> ContT r m a
ContT (((() -> IO b) -> IO b) -> ContT b IO ())
-> ((() -> IO b) -> IO b) -> ContT b IO ()
forall a b. (a -> b) -> a -> b
$ Ptr Extent2D -> Extent2D -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Extent2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr Extent2D)) (Extent2D
forall a. Zero a => a
zero) (IO b -> IO b) -> ((() -> IO b) -> IO b) -> (() -> IO b) -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((() -> IO b) -> () -> IO b
forall a b. (a -> b) -> a -> b
$ ())
    IO () -> ContT b IO ()
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 Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32)) (Word32
forall a. Zero a => a
zero)
    IO b -> ContT b IO b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (IO b -> ContT b IO b) -> IO b -> ContT b IO b
forall a b. (a -> b) -> a -> b
$ IO b
f

instance FromCStruct RectLayerKHR where
  peekCStruct :: Ptr RectLayerKHR -> IO RectLayerKHR
peekCStruct p :: Ptr RectLayerKHR
p = do
    Offset2D
offset <- Ptr Offset2D -> IO Offset2D
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Offset2D ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Offset2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr Offset2D))
    Extent2D
extent <- Ptr Extent2D -> IO Extent2D
forall a. FromCStruct a => Ptr a -> IO a
peekCStruct @Extent2D ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Extent2D
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr Extent2D))
    Word32
layer <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek @Word32 ((Ptr RectLayerKHR
p Ptr RectLayerKHR -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Word32))
    RectLayerKHR -> IO RectLayerKHR
forall (f :: * -> *) a. Applicative f => a -> f a
pure (RectLayerKHR -> IO RectLayerKHR)
-> RectLayerKHR -> IO RectLayerKHR
forall a b. (a -> b) -> a -> b
$ Offset2D -> Extent2D -> Word32 -> RectLayerKHR
RectLayerKHR
             Offset2D
offset Extent2D
extent Word32
layer

instance Zero RectLayerKHR where
  zero :: RectLayerKHR
zero = Offset2D -> Extent2D -> Word32 -> RectLayerKHR
RectLayerKHR
           Offset2D
forall a. Zero a => a
zero
           Extent2D
forall a. Zero a => a
zero
           Word32
forall a. Zero a => a
zero


type KHR_INCREMENTAL_PRESENT_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION"
pattern KHR_INCREMENTAL_PRESENT_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_INCREMENTAL_PRESENT_SPEC_VERSION :: a
$mKHR_INCREMENTAL_PRESENT_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_INCREMENTAL_PRESENT_SPEC_VERSION = 1


type KHR_INCREMENTAL_PRESENT_EXTENSION_NAME = "VK_KHR_incremental_present"

-- No documentation found for TopLevel "VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME"
pattern KHR_INCREMENTAL_PRESENT_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_INCREMENTAL_PRESENT_EXTENSION_NAME :: a
$mKHR_INCREMENTAL_PRESENT_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_INCREMENTAL_PRESENT_EXTENSION_NAME = "VK_KHR_incremental_present"