{-# language CPP #-}
module Vulkan.Extensions.VK_EXT_image_robustness  ( PhysicalDeviceImageRobustnessFeaturesEXT(..)
                                                  , EXT_IMAGE_ROBUSTNESS_SPEC_VERSION
                                                  , pattern EXT_IMAGE_ROBUSTNESS_SPEC_VERSION
                                                  , EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME
                                                  , pattern EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME
                                                  ) where

import Foreign.Marshal.Alloc (allocaBytesAligned)
import Foreign.Ptr (nullPtr)
import Foreign.Ptr (plusPtr)
import Data.String (IsString)
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.FundamentalTypes (bool32ToBool)
import Vulkan.Core10.FundamentalTypes (boolToBool32)
import Vulkan.Core10.FundamentalTypes (Bool32)
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_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT))
-- | VkPhysicalDeviceImageRobustnessFeaturesEXT - Structure describing the
-- out-of-bounds behavior for an implementation
--
-- = Members
--
-- The members of the 'PhysicalDeviceImageRobustnessFeaturesEXT' structure
-- describe the following features:
--
-- = Description
--
-- If the 'PhysicalDeviceImageRobustnessFeaturesEXT' structure is included
-- in the @pNext@ chain of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
-- it is filled with values indicating whether the feature is supported.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceImageRobustnessFeaturesEXT = PhysicalDeviceImageRobustnessFeaturesEXT
  { -- | @robustImageAccess@ indicates whether image accesses are tightly
    -- bounds-checked against the dimensions of the image view.
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#textures-input-validation Invalid texels>
    -- resulting from out of bounds image loads will be replaced as described
    -- in
    -- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#textures-texel-replacement Texel Replacement>,
    -- with either (0,0,1) or (0,0,0) values inserted for missing G, B, or A
    -- components based on the format.
    PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
robustImageAccess :: Bool }
  deriving (Typeable, PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
(PhysicalDeviceImageRobustnessFeaturesEXT
 -> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool)
-> (PhysicalDeviceImageRobustnessFeaturesEXT
    -> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool)
-> Eq PhysicalDeviceImageRobustnessFeaturesEXT
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
$c/= :: PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
== :: PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
$c== :: PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceImageRobustnessFeaturesEXT)
#endif
deriving instance Show PhysicalDeviceImageRobustnessFeaturesEXT

instance ToCStruct PhysicalDeviceImageRobustnessFeaturesEXT where
  withCStruct :: PhysicalDeviceImageRobustnessFeaturesEXT
-> (Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b) -> IO b
withCStruct x :: PhysicalDeviceImageRobustnessFeaturesEXT
x f :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b
f = Int
-> Int
-> (Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b)
-> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
allocaBytesAligned 24 8 ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b) -> IO b)
-> (Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b) -> IO b
forall a b. (a -> b) -> a -> b
$ \p :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p -> Ptr PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> IO b -> IO b
forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p PhysicalDeviceImageRobustnessFeaturesEXT
x (Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b
f Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p)
  pokeCStruct :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
-> PhysicalDeviceImageRobustnessFeaturesEXT -> IO b -> IO b
pokeCStruct p :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p PhysicalDeviceImageRobustnessFeaturesEXT{..} f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
robustImageAccess))
    IO b
f
  cStructSize :: Int
cStructSize = 24
  cStructAlignment :: Int
cStructAlignment = 8
  pokeZeroCStruct :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> IO b -> IO b
pokeZeroCStruct p :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p f :: IO b
f = do
    Ptr StructureType -> StructureType -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT
-> Int -> Ptr StructureType
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT)
    Ptr (Ptr ()) -> Ptr () -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> Int -> Ptr (Ptr ())
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8 :: Ptr (Ptr ()))) (Ptr ()
forall a. Ptr a
nullPtr)
    Ptr Bool32 -> Bool32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
forall a. Zero a => a
zero))
    IO b
f

instance FromCStruct PhysicalDeviceImageRobustnessFeaturesEXT where
  peekCStruct :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
-> IO PhysicalDeviceImageRobustnessFeaturesEXT
peekCStruct p :: Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p = do
    Bool32
robustImageAccess <- Ptr Bool32 -> IO Bool32
forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDeviceImageRobustnessFeaturesEXT
p Ptr PhysicalDeviceImageRobustnessFeaturesEXT -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16 :: Ptr Bool32))
    PhysicalDeviceImageRobustnessFeaturesEXT
-> IO PhysicalDeviceImageRobustnessFeaturesEXT
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PhysicalDeviceImageRobustnessFeaturesEXT
 -> IO PhysicalDeviceImageRobustnessFeaturesEXT)
-> PhysicalDeviceImageRobustnessFeaturesEXT
-> IO PhysicalDeviceImageRobustnessFeaturesEXT
forall a b. (a -> b) -> a -> b
$ Bool -> PhysicalDeviceImageRobustnessFeaturesEXT
PhysicalDeviceImageRobustnessFeaturesEXT
             (Bool32 -> Bool
bool32ToBool Bool32
robustImageAccess)

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

instance Zero PhysicalDeviceImageRobustnessFeaturesEXT where
  zero :: PhysicalDeviceImageRobustnessFeaturesEXT
zero = Bool -> PhysicalDeviceImageRobustnessFeaturesEXT
PhysicalDeviceImageRobustnessFeaturesEXT
           Bool
forall a. Zero a => a
zero


type EXT_IMAGE_ROBUSTNESS_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_EXT_IMAGE_ROBUSTNESS_SPEC_VERSION"
pattern EXT_IMAGE_ROBUSTNESS_SPEC_VERSION :: forall a . Integral a => a
pattern $bEXT_IMAGE_ROBUSTNESS_SPEC_VERSION :: a
$mEXT_IMAGE_ROBUSTNESS_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
EXT_IMAGE_ROBUSTNESS_SPEC_VERSION = 1


type EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME = "VK_EXT_image_robustness"

-- No documentation found for TopLevel "VK_EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME"
pattern EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bEXT_IMAGE_ROBUSTNESS_EXTENSION_NAME :: a
$mEXT_IMAGE_ROBUSTNESS_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME = "VK_EXT_image_robustness"