{-# language CPP #-}
-- | = Name
--
-- VK_KHR_shader_terminate_invocation - device extension
--
-- == VK_KHR_shader_terminate_invocation
--
-- [__Name String__]
--     @VK_KHR_shader_terminate_invocation@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     216
--
-- [__Revision__]
--     1
--
-- [__Extension and Version Dependencies__]
--
--     -   Requires Vulkan 1.0
--
--     -   Requires @VK_KHR_get_physical_device_properties2@
--
-- [__Contact__]
--
--     -   Jesse Hall
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?title=VK_KHR_shader_terminate_invocation:%20&body=@critsec%20 >
--
-- [__Last Modified Date__]
--     2020-08-11
--
-- [__IP Status__]
--     No known IP claims.
--
-- [__Interactions and External Dependencies__]
--
--     -   Requires the
--         <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_terminate_invocation.html SPV_KHR_terminate_invocation>
--         SPIR-V extension.
--
-- [__Contributors__]
--
--     -   Alan Baker, Google
--
--     -   Jeff Bolz, NVIDIA
--
--     -   Jesse Hall, Google
--
--     -   Ralph Potter, Samsung
--
--     -   Tom Olson, Arm
--
-- == Description
--
-- This extension adds Vulkan support for the
-- <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_terminate_invocation.html SPV_KHR_terminate_invocation>
-- SPIR-V extension. That SPIR-V extension provides a new instruction,
-- @OpTerminateInvocation@, which causes a shader invocation to immediately
-- terminate and sets the coverage of shaded samples to @0@; only
-- previously executed instructions will have observable effects. The
-- @OpTerminateInvocation@ instruction, along with the
-- @OpDemoteToHelperInvocation@ instruction from the
-- <VK_EXT_shader_demote_to_helper_invocation.html VK_EXT_shader_demote_to_helper_invocation>
-- extension, together replace the @OpKill@ instruction, which could behave
-- like either of these instructions. @OpTerminateInvocation@ provides the
-- behavior required by the GLSL @discard@ statement, and should be used
-- when available by GLSL compilers and applications that need the GLSL
-- @discard@ behavior.
--
-- == New Structures
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDeviceShaderTerminateInvocationFeaturesKHR'
--
-- == New Enum Constants
--
-- -   'KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME'
--
-- -   'KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR'
--
-- == Version History
--
-- -   Revision 1, 2020-08-11 (Jesse Hall)
--
-- = See Also
--
-- 'PhysicalDeviceShaderTerminateInvocationFeaturesKHR'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_shader_terminate_invocation Vulkan Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_KHR_shader_terminate_invocation  ( PhysicalDeviceShaderTerminateInvocationFeaturesKHR(..)
                                                             , KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION
                                                             , pattern KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION
                                                             , KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME
                                                             , pattern KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME
                                                             ) where

import Foreign.Marshal.Alloc (allocaBytesAligned)
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.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.Core10.Enums.StructureType (StructureType)
import Vulkan.Core10.Enums.StructureType (StructureType(STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR))
-- | VkPhysicalDeviceShaderTerminateInvocationFeaturesKHR - Structure
-- describing support for the SPIR-V @SPV_KHR_terminate_invocation@
-- extension
--
-- = Members
--
-- The members of the 'PhysicalDeviceShaderTerminateInvocationFeaturesKHR'
-- structure describe the following feature:
--
-- = Description
--
-- If the 'PhysicalDeviceShaderTerminateInvocationFeaturesKHR' structure is
-- included in the @pNext@ chain of
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
-- it is filled with a value indicating whether the feature is supported.
-- 'PhysicalDeviceShaderTerminateInvocationFeaturesKHR' /can/ also be
-- included in the @pNext@ chain of 'Vulkan.Core10.Device.DeviceCreateInfo'
-- to enable the features.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceShaderTerminateInvocationFeaturesKHR = PhysicalDeviceShaderTerminateInvocationFeaturesKHR
  { -- | #features-shaderTerminateInvocation# @shaderTerminateInvocation@
    -- specifies whether the implementation supports SPIR-V modules that use
    -- the @SPV_KHR_terminate_invocation@ extension.
    PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
shaderTerminateInvocation :: Bool }
  deriving (Typeable, PhysicalDeviceShaderTerminateInvocationFeaturesKHR
-> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
(PhysicalDeviceShaderTerminateInvocationFeaturesKHR
 -> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool)
-> (PhysicalDeviceShaderTerminateInvocationFeaturesKHR
    -> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool)
-> Eq PhysicalDeviceShaderTerminateInvocationFeaturesKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceShaderTerminateInvocationFeaturesKHR
-> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
$c/= :: PhysicalDeviceShaderTerminateInvocationFeaturesKHR
-> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
== :: PhysicalDeviceShaderTerminateInvocationFeaturesKHR
-> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
$c== :: PhysicalDeviceShaderTerminateInvocationFeaturesKHR
-> PhysicalDeviceShaderTerminateInvocationFeaturesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceShaderTerminateInvocationFeaturesKHR)
#endif
deriving instance Show PhysicalDeviceShaderTerminateInvocationFeaturesKHR

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

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

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


type KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION"
pattern KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION :: a
$mKHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION = 1


type KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME = "VK_KHR_shader_terminate_invocation"

-- No documentation found for TopLevel "VK_KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME"
pattern KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME :: a
$mKHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME = "VK_KHR_shader_terminate_invocation"