{-# language CPP #-}
-- No documentation found for Chapter "Promoted_From_VK_EXT_separate_stencil_usage"
module Vulkan.Core12.Promoted_From_VK_EXT_separate_stencil_usage  ( ImageStencilUsageCreateInfo(..)
                                                                  , StructureType(..)
                                                                  ) where

import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Vulkan.CStruct (FromCStruct)
import Vulkan.CStruct (FromCStruct(..))
import Vulkan.CStruct (ToCStruct)
import Vulkan.CStruct (ToCStruct(..))
import Vulkan.Zero (Zero(..))
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.Core10.Enums.ImageUsageFlagBits (ImageUsageFlags)
import Vulkan.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO))
import Vulkan.Core10.Enums.StructureType (StructureType(..))
-- | VkImageStencilUsageCreateInfo - Specify separate usage flags for the
-- stencil aspect of a depth-stencil image
--
-- = Description
--
-- If the @pNext@ chain of 'Vulkan.Core10.Image.ImageCreateInfo' includes a
-- 'ImageStencilUsageCreateInfo' structure, then that structure includes
-- the usage flags specific to the stencil aspect of the image for an image
-- with a depth-stencil format.
--
-- This structure specifies image usages which only apply to the stencil
-- aspect of a depth\/stencil format image. When this structure is included
-- in the @pNext@ chain of 'Vulkan.Core10.Image.ImageCreateInfo', the
-- stencil aspect of the image /must/ only be used as specified by
-- @stencilUsage@. When this structure is not included in the @pNext@ chain
-- of 'Vulkan.Core10.Image.ImageCreateInfo', the stencil aspect of an image
-- /must/ only be used as specified by
-- 'Vulkan.Core10.Image.ImageCreateInfo'::@usage@. Use of other aspects of
-- an image are unaffected by this structure.
--
-- This structure /can/ also be included in the @pNext@ chain of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceImageFormatInfo2'
-- to query additional capabilities specific to image creation parameter
-- combinations including a separate set of usage flags for the stencil
-- aspect of the image using
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceImageFormatProperties2'.
-- When this structure is not included in the @pNext@ chain of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceImageFormatInfo2'
-- then the implicit value of @stencilUsage@ matches that of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceImageFormatInfo2'::@usage@.
--
-- == Valid Usage
--
-- -   #VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539# If
--     @stencilUsage@ includes
--     'Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT',
--     it /must/ not include bits other than
--     'Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT'
--     or
--     'Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_INPUT_ATTACHMENT_BIT'
--
-- == Valid Usage (Implicit)
--
-- -   #VUID-VkImageStencilUsageCreateInfo-sType-sType# @sType@ /must/ be
--     'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO'
--
-- -   #VUID-VkImageStencilUsageCreateInfo-stencilUsage-parameter#
--     @stencilUsage@ /must/ be a valid combination of
--     'Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlagBits' values
--
-- -   #VUID-VkImageStencilUsageCreateInfo-stencilUsage-requiredbitmask#
--     @stencilUsage@ /must/ not be @0@
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_separate_stencil_usage VK_EXT_separate_stencil_usage>,
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_VERSION_1_2 VK_VERSION_1_2>,
-- 'Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlags',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data ImageStencilUsageCreateInfo = ImageStencilUsageCreateInfo
  { -- | @stencilUsage@ is a bitmask of
    -- 'Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlagBits' describing
    -- the intended usage of the stencil aspect of the image.
    ImageStencilUsageCreateInfo -> ImageUsageFlags
stencilUsage :: ImageUsageFlags }
  deriving (Typeable, ImageStencilUsageCreateInfo -> ImageStencilUsageCreateInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageStencilUsageCreateInfo -> ImageStencilUsageCreateInfo -> Bool
$c/= :: ImageStencilUsageCreateInfo -> ImageStencilUsageCreateInfo -> Bool
== :: ImageStencilUsageCreateInfo -> ImageStencilUsageCreateInfo -> Bool
$c== :: ImageStencilUsageCreateInfo -> ImageStencilUsageCreateInfo -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (ImageStencilUsageCreateInfo)
#endif
deriving instance Show ImageStencilUsageCreateInfo

instance ToCStruct ImageStencilUsageCreateInfo where
  withCStruct :: forall b.
ImageStencilUsageCreateInfo
-> (Ptr ImageStencilUsageCreateInfo -> IO b) -> IO b
withCStruct ImageStencilUsageCreateInfo
x Ptr ImageStencilUsageCreateInfo -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr ImageStencilUsageCreateInfo
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr ImageStencilUsageCreateInfo
p ImageStencilUsageCreateInfo
x (Ptr ImageStencilUsageCreateInfo -> IO b
f Ptr ImageStencilUsageCreateInfo
p)
  pokeCStruct :: forall b.
Ptr ImageStencilUsageCreateInfo
-> ImageStencilUsageCreateInfo -> IO b -> IO b
pokeCStruct Ptr ImageStencilUsageCreateInfo
p ImageStencilUsageCreateInfo{ImageUsageFlags
stencilUsage :: ImageUsageFlags
$sel:stencilUsage:ImageStencilUsageCreateInfo :: ImageStencilUsageCreateInfo -> ImageUsageFlags
..} IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr ImageUsageFlags)) (ImageUsageFlags
stencilUsage)
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr ImageStencilUsageCreateInfo -> IO b -> IO b
pokeZeroCStruct Ptr ImageStencilUsageCreateInfo
p IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
8 :: Ptr (Ptr ()))) (forall a. Ptr a
nullPtr)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr ImageUsageFlags)) (forall a. Zero a => a
zero)
    IO b
f

instance FromCStruct ImageStencilUsageCreateInfo where
  peekCStruct :: Ptr ImageStencilUsageCreateInfo -> IO ImageStencilUsageCreateInfo
peekCStruct Ptr ImageStencilUsageCreateInfo
p = do
    ImageUsageFlags
stencilUsage <- forall a. Storable a => Ptr a -> IO a
peek @ImageUsageFlags ((Ptr ImageStencilUsageCreateInfo
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr ImageUsageFlags))
    forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ImageUsageFlags -> ImageStencilUsageCreateInfo
ImageStencilUsageCreateInfo
             ImageUsageFlags
stencilUsage

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

instance Zero ImageStencilUsageCreateInfo where
  zero :: ImageStencilUsageCreateInfo
zero = ImageUsageFlags -> ImageStencilUsageCreateInfo
ImageStencilUsageCreateInfo
           forall a. Zero a => a
zero