{-# language CPP #-}
-- | = Name
--
-- VK_QCOM_filter_cubic_clamp - device extension
--
-- == VK_QCOM_filter_cubic_clamp
--
-- [__Name String__]
--     @VK_QCOM_filter_cubic_clamp@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     522
--
-- [__Revision__]
--     1
--
-- [__Ratification Status__]
--     Not ratified
--
-- [__Extension and Version Dependencies__]
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_filter_cubic VK_EXT_filter_cubic>
--     and
--         
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#versions-1.2 Version 1.2>
--          or
--         
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_sampler_filter_minmax VK_EXT_sampler_filter_minmax>
--
-- [__Contact__]
--
--     -   Jeff Leger
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?body=[VK_QCOM_filter_cubic_clamp] @jackohound%0A*Here describe the issue or question you have about the VK_QCOM_filter_cubic_clamp extension* >
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2023-08-02
--
-- [__Contributors__]
--
--     -   Jeff Leger, Qualcomm Technologies, Inc.
--
-- == Description
--
-- This extension extends cubic filtering by adding the ability to enable
-- an anti-ringing clamp. Cubic filtering samples from a 4x4 region of
-- texels and computes a cubic weighted average of the region. In some
-- cases, the resulting value is outside the range of any of the texels in
-- the 4x4 region. This is sometimes referred to as “filter overshoot” or
-- “filter ringing” and can occur when there is a sharp discontinuity in
-- the 4x4 region being filtered. For some use cases this “ringing” can
-- produces unacceptable artifacts.
--
-- The solution to the ringing problem is to clamp the post-cubic-filtered
-- value to be within the max and min of texel values in the 4x4 region.
-- While such “range clamping” can be performed in shader code, the
-- additional texture fetches and clamping ALU operations can be costly.
--
-- Certain Adreno GPUs are able to perform the range clamp in the texture
-- unit during cubic filtering at significant performance\/power savings
-- versus a shader-based clamping approach. This extension exposes such
-- hardware functionality.
--
-- This extension extends
-- 'Vulkan.Core12.Enums.SamplerReductionMode.SamplerReductionMode', adding
-- 'Vulkan.Core12.Enums.SamplerReductionMode.SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM'
-- which enables the range clamp operation.
--
-- == New Structures
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDeviceCubicClampFeaturesQCOM'
--
-- == New Enum Constants
--
-- -   'QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME'
--
-- -   'QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION'
--
-- -   Extending
--     'Vulkan.Core12.Enums.SamplerReductionMode.SamplerReductionMode':
--
--     -   'Vulkan.Core12.Enums.SamplerReductionMode.SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM'
--
-- == Version History
--
-- -   Revision 1, 2023-08-02 (jleger)
--
--     -   Initial version
--
-- == See Also
--
-- 'PhysicalDeviceCubicClampFeaturesQCOM'
--
-- == Document Notes
--
-- For more information, see the
-- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VK_QCOM_filter_cubic_clamp Vulkan Specification>
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_QCOM_filter_cubic_clamp  ( PhysicalDeviceCubicClampFeaturesQCOM(..)
                                                     , QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION
                                                     , pattern QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION
                                                     , QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME
                                                     , pattern QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME
                                                     ) 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.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_CUBIC_CLAMP_FEATURES_QCOM))
-- | VkPhysicalDeviceCubicClampFeaturesQCOM - Structure describing cubic
-- clamp features that can be supported by an implementation
--
-- = Members
--
-- This structure describes the following features:
--
-- = Description
--
-- If the 'PhysicalDeviceCubicClampFeaturesQCOM' structure is included in
-- the @pNext@ chain of the
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2'
-- structure passed to
-- 'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.getPhysicalDeviceFeatures2',
-- it is filled in to indicate whether each corresponding feature is
-- supported. 'PhysicalDeviceCubicClampFeaturesQCOM' /can/ also be used in
-- the @pNext@ chain of 'Vulkan.Core10.Device.DeviceCreateInfo' to
-- selectively enable these features.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_QCOM_filter_cubic_clamp VK_QCOM_filter_cubic_clamp>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceCubicClampFeaturesQCOM = PhysicalDeviceCubicClampFeaturesQCOM
  { -- | #features-filter-cubic-range-clamp# @cubicRangeClamp@ indicates that the
    -- implementation supports cubic filtering in combination with a
    -- <https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#textures-texel-range-clamp texel range clamp>.
    PhysicalDeviceCubicClampFeaturesQCOM -> Bool
cubicRangeClamp :: Bool }
  deriving (Typeable, PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> Bool
$c/= :: PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> Bool
== :: PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> Bool
$c== :: PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceCubicClampFeaturesQCOM)
#endif
deriving instance Show PhysicalDeviceCubicClampFeaturesQCOM

instance ToCStruct PhysicalDeviceCubicClampFeaturesQCOM where
  withCStruct :: forall b.
PhysicalDeviceCubicClampFeaturesQCOM
-> (Ptr PhysicalDeviceCubicClampFeaturesQCOM -> IO b) -> IO b
withCStruct PhysicalDeviceCubicClampFeaturesQCOM
x Ptr PhysicalDeviceCubicClampFeaturesQCOM -> IO b
f = forall a b. Int -> (Ptr a -> IO b) -> IO b
allocaBytes Int
24 forall a b. (a -> b) -> a -> b
$ \Ptr PhysicalDeviceCubicClampFeaturesQCOM
p -> forall a b. ToCStruct a => Ptr a -> a -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceCubicClampFeaturesQCOM
p PhysicalDeviceCubicClampFeaturesQCOM
x (Ptr PhysicalDeviceCubicClampFeaturesQCOM -> IO b
f Ptr PhysicalDeviceCubicClampFeaturesQCOM
p)
  pokeCStruct :: forall b.
Ptr PhysicalDeviceCubicClampFeaturesQCOM
-> PhysicalDeviceCubicClampFeaturesQCOM -> IO b -> IO b
pokeCStruct Ptr PhysicalDeviceCubicClampFeaturesQCOM
p PhysicalDeviceCubicClampFeaturesQCOM{Bool
cubicRangeClamp :: Bool
$sel:cubicRangeClamp:PhysicalDeviceCubicClampFeaturesQCOM :: PhysicalDeviceCubicClampFeaturesQCOM -> Bool
..} IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceCubicClampFeaturesQCOM
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceCubicClampFeaturesQCOM
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 PhysicalDeviceCubicClampFeaturesQCOM
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (Bool
cubicRangeClamp))
    IO b
f
  cStructSize :: Int
cStructSize = Int
24
  cStructAlignment :: Int
cStructAlignment = Int
8
  pokeZeroCStruct :: forall b. Ptr PhysicalDeviceCubicClampFeaturesQCOM -> IO b -> IO b
pokeZeroCStruct Ptr PhysicalDeviceCubicClampFeaturesQCOM
p IO b
f = do
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceCubicClampFeaturesQCOM
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0 :: Ptr StructureType)) (StructureType
STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM)
    forall a. Storable a => Ptr a -> a -> IO ()
poke ((Ptr PhysicalDeviceCubicClampFeaturesQCOM
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 PhysicalDeviceCubicClampFeaturesQCOM
p forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32)) (Bool -> Bool32
boolToBool32 (forall a. Zero a => a
zero))
    IO b
f

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

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

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


type QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION"
pattern QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION :: forall a . Integral a => a
pattern $bQCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION :: forall a. Integral a => a
$mQCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION = 1


type QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME = "VK_QCOM_filter_cubic_clamp"

-- No documentation found for TopLevel "VK_QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME"
pattern QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bQCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
$mQCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME = "VK_QCOM_filter_cubic_clamp"