{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_external_semaphore  ( ExportSemaphoreCreateInfo(..)
                                                              , StructureType(..)
                                                              , SemaphoreImportFlagBits(..)
                                                              , SemaphoreImportFlags
                                                              ) where

import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
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 Foreign.Ptr (Ptr)
import Data.Kind (Type)
import Vulkan.Core11.Enums.ExternalSemaphoreHandleTypeFlagBits (ExternalSemaphoreHandleTypeFlags)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
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_EXPORT_SEMAPHORE_CREATE_INFO))
import Vulkan.Core11.Enums.SemaphoreImportFlagBits (SemaphoreImportFlagBits(..))
import Vulkan.Core11.Enums.SemaphoreImportFlagBits (SemaphoreImportFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
-- | VkExportSemaphoreCreateInfo - Structure specifying handle types that can
-- be exported from a semaphore
--
-- == Valid Usage
--
-- -   The bits in @handleTypes@ /must/ be supported and compatible, as
--     reported by
--     'Vulkan.Core11.Promoted_From_VK_KHR_external_semaphore_capabilities.ExternalSemaphoreProperties'
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO'
--
-- -   @handleTypes@ /must/ be a valid combination of
--     'Vulkan.Core11.Enums.ExternalSemaphoreHandleTypeFlagBits.ExternalSemaphoreHandleTypeFlagBits'
--     values
--
-- = See Also
--
-- 'Vulkan.Core11.Enums.ExternalSemaphoreHandleTypeFlagBits.ExternalSemaphoreHandleTypeFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data ExportSemaphoreCreateInfo = ExportSemaphoreCreateInfo
  { -- | @handleTypes@ is a bitmask of
    -- 'Vulkan.Core11.Enums.ExternalSemaphoreHandleTypeFlagBits.ExternalSemaphoreHandleTypeFlagBits'
    -- specifying one or more semaphore handle types the application /can/
    -- export from the resulting semaphore. The application /can/ request
    -- multiple handle types for the same semaphore.
    ExportSemaphoreCreateInfo -> ExternalSemaphoreHandleTypeFlags
handleTypes :: ExternalSemaphoreHandleTypeFlags }
  deriving (Typeable, ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool
(ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool)
-> (ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool)
-> Eq ExportSemaphoreCreateInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool
$c/= :: ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool
== :: ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool
$c== :: ExportSemaphoreCreateInfo -> ExportSemaphoreCreateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ExportSemaphoreCreateInfo)
#endif
deriving instance Show ExportSemaphoreCreateInfo

instance ToCStruct ExportSemaphoreCreateInfo where
  withCStruct :: ExportSemaphoreCreateInfo
-> (Ptr ExportSemaphoreCreateInfo -> IO b) -> IO b
withCStruct x :: ExportSemaphoreCreateInfo
x f :: Ptr ExportSemaphoreCreateInfo -> IO b
f = Int -> Int -> (Ptr ExportSemaphoreCreateInfo -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr ExportSemaphoreCreateInfo -> IO b) -> IO b)
-> (Ptr ExportSemaphoreCreateInfo -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr ExportSemaphoreCreateInfo
p -> Ptr ExportSemaphoreCreateInfo
-> ExportSemaphoreCreateInfo -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ExportSemaphoreCreateInfo
p ExportSemaphoreCreateInfo
x (Ptr ExportSemaphoreCreateInfo -> IO b
f Ptr ExportSemaphoreCreateInfo
p)
  pokeCStruct :: Ptr ExportSemaphoreCreateInfo
-> ExportSemaphoreCreateInfo -> IO b -> IO b
pokeCStruct p :: Ptr ExportSemaphoreCreateInfo
p ExportSemaphoreCreateInfo{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr ExternalSemaphoreHandleTypeFlags
-> ExternalSemaphoreHandleTypeFlags -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo
-> Int -> Ptr ExternalSemaphoreHandleTypeFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ExternalSemaphoreHandleTypeFlags)) (ExternalSemaphoreHandleTypeFlags
handleTypes)
    IO b
f
  cStructSize :: Int
cStructSize = 24
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr ExportSemaphoreCreateInfo -> IO b -> IO b
pokeZeroCStruct p :: Ptr ExportSemaphoreCreateInfo
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo -> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo -> 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 ExportSemaphoreCreateInfo where
  peekCStruct :: Ptr ExportSemaphoreCreateInfo -> IO ExportSemaphoreCreateInfo
peekCStruct p :: Ptr ExportSemaphoreCreateInfo
p = do
    ExternalSemaphoreHandleTypeFlags
handleTypes <- Ptr ExternalSemaphoreHandleTypeFlags
-> IO ExternalSemaphoreHandleTypeFlags
forall a. Storable a => Ptr a -> IO a
peek @ExternalSemaphoreHandleTypeFlags ((Ptr ExportSemaphoreCreateInfo
p Ptr ExportSemaphoreCreateInfo
-> Int -> Ptr ExternalSemaphoreHandleTypeFlags
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr ExternalSemaphoreHandleTypeFlags))
    ExportSemaphoreCreateInfo -> IO ExportSemaphoreCreateInfo
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ExportSemaphoreCreateInfo -> IO ExportSemaphoreCreateInfo)
-> ExportSemaphoreCreateInfo -> IO ExportSemaphoreCreateInfo
forall a b. (a -> b) -> a -> b
$ ExternalSemaphoreHandleTypeFlags -> ExportSemaphoreCreateInfo
ExportSemaphoreCreateInfo
             ExternalSemaphoreHandleTypeFlags
handleTypes

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

instance Zero ExportSemaphoreCreateInfo where
  zero :: ExportSemaphoreCreateInfo
zero = ExternalSemaphoreHandleTypeFlags -> ExportSemaphoreCreateInfo
ExportSemaphoreCreateInfo
           ExternalSemaphoreHandleTypeFlags
forall a. Zero a => a
zero