{-# language CPP #-}
module Graphics.Vulkan.Core12.Promoted_From_VK_EXT_separate_stencil_usage  ( ImageStencilUsageCreateInfo(..)
                                                                           , StructureType(..)
                                                                           ) 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 Graphics.Vulkan.CStruct (FromCStruct)
import Graphics.Vulkan.CStruct (FromCStruct(..))
import Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits (ImageUsageFlags)
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType)
import Graphics.Vulkan.CStruct (ToCStruct)
import Graphics.Vulkan.CStruct (ToCStruct(..))
import Graphics.Vulkan.Zero (Zero(..))
import Graphics.Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO))
import Graphics.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 'Graphics.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 'Graphics.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 'Graphics.Vulkan.Core10.Image.ImageCreateInfo', the stencil aspect of
-- an image /must/ only be used as specified
-- 'Graphics.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
-- 'Graphics.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
-- 'Graphics.Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceImageFormatProperties2'.
-- When this structure is not included in the @pNext@ chain of
-- 'Graphics.Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceImageFormatInfo2'
-- then the implicit value of @stencilUsage@ matches that of
-- 'Graphics.Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceImageFormatInfo2'::@usage@.
--
-- == Valid Usage
--
-- -   If @stencilUsage@ includes
--     'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT',
--     it /must/ not include bits other than
--     'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT'
--     or
--     'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.IMAGE_USAGE_INPUT_ATTACHMENT_BIT'
--
-- == Valid Usage (Implicit)
--
-- -   @sType@ /must/ be
--     'Graphics.Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO'
--
-- -   @stencilUsage@ /must/ be a valid combination of
--     'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlagBits'
--     values
--
-- -   @stencilUsage@ /must/ not be @0@
--
-- = See Also
--
-- 'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlags',
-- 'Graphics.Vulkan.Core10.Enums.StructureType.StructureType'
data ImageStencilUsageCreateInfo = ImageStencilUsageCreateInfo
  { -- | @stencilUsage@ is a bitmask of
    -- 'Graphics.Vulkan.Core10.Enums.ImageUsageFlagBits.ImageUsageFlagBits'
    -- describing the intended usage of the stencil aspect of the image.
    stencilUsage :: ImageUsageFlags }
  deriving (Typeable)
deriving instance Show ImageStencilUsageCreateInfo

instance ToCStruct ImageStencilUsageCreateInfo where
  withCStruct x f = allocaBytesAligned 24 8 $ \p -> pokeCStruct p x (f p)
  pokeCStruct p ImageStencilUsageCreateInfo{..} f = do
    poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO)
    poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
    poke ((p `plusPtr` 16 :: Ptr ImageUsageFlags)) (stencilUsage)
    f
  cStructSize = 24
  cStructAlignment = 8
  pokeZeroCStruct p f = do
    poke ((p `plusPtr` 0 :: Ptr StructureType)) (STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO)
    poke ((p `plusPtr` 8 :: Ptr (Ptr ()))) (nullPtr)
    poke ((p `plusPtr` 16 :: Ptr ImageUsageFlags)) (zero)
    f

instance FromCStruct ImageStencilUsageCreateInfo where
  peekCStruct p = do
    stencilUsage <- peek @ImageUsageFlags ((p `plusPtr` 16 :: Ptr ImageUsageFlags))
    pure $ ImageStencilUsageCreateInfo
             stencilUsage

instance Storable ImageStencilUsageCreateInfo where
  sizeOf ~_ = 24
  alignment ~_ = 8
  peek = peekCStruct
  poke ptr poked = pokeCStruct ptr poked (pure ())

instance Zero ImageStencilUsageCreateInfo where
  zero = ImageStencilUsageCreateInfo
           zero