{-# language CPP #-}
module Vulkan.Core11.Promoted_From_VK_KHR_external_fence  ( ExportFenceCreateInfo(..)
                                                          , StructureType(..)
                                                          , FenceImportFlagBits(..)
                                                          , FenceImportFlags
                                                          ) 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 Foreign.Ptr (Ptr)
import Data.Kind (Type)
import Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits (ExternalFenceHandleTypeFlags)
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_FENCE_CREATE_INFO))
import Vulkan.Core11.Enums.FenceImportFlagBits (FenceImportFlagBits(..))
import Vulkan.Core11.Enums.FenceImportFlagBits (FenceImportFlags)
import Vulkan.Core10.Enums.StructureType (StructureType(..))
-- | VkExportFenceCreateInfo - Structure specifying handle types that can be
-- exported from a fence
--
-- == Valid Usage
--
-- -   The bits in @handleTypes@ /must/ be supported and compatible, as
--     reported by
--     'Vulkan.Core11.Promoted_From_VK_KHR_external_fence_capabilities.ExternalFenceProperties'
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO'
--
-- -   @handleTypes@ /must/ be a valid combination of
--     'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits'
--     values
--
-- = See Also
--
-- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data ExportFenceCreateInfo = ExportFenceCreateInfo
  { -- | @handleTypes@ is a bitmask of
    -- 'Vulkan.Core11.Enums.ExternalFenceHandleTypeFlagBits.ExternalFenceHandleTypeFlagBits'
    -- specifying one or more fence handle types the application /can/ export
    -- from the resulting fence. The application /can/ request multiple handle
    -- types for the same fence.
    ExportFenceCreateInfo -> ExternalFenceHandleTypeFlags
handleTypes :: ExternalFenceHandleTypeFlags }
  deriving (Typeable)
deriving instance Show ExportFenceCreateInfo

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

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

instance Zero ExportFenceCreateInfo where
  zero :: ExportFenceCreateInfo
zero = ExternalFenceHandleTypeFlags -> ExportFenceCreateInfo
ExportFenceCreateInfo
           ExternalFenceHandleTypeFlags
forall a. Zero a => a
zero