{-# language CPP #-}
-- | = Name
--
-- VK_EXT_shader_float8 - device extension
--
-- = VK_EXT_shader_float8
--
-- [__Name String__]
--     @VK_EXT_shader_float8@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     568
--
-- [__Revision__]
--     1
--
-- [__Ratification Status__]
--     Ratified
--
-- [__Extension and Version Dependencies__]
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_get_physical_device_properties2 VK_KHR_get_physical_device_properties2>
--     or
--     <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#versions-1.1 Vulkan Version 1.1>
--
-- [__API Interactions__]
--
--     -   Interacts with VK_KHR_cooperative_matrix
--
-- [__SPIR-V Dependencies__]
--
--     -   <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/EXT/SPV_EXT_float8.html SPV_EXT_float8>
--
-- [__Contact__]
--
--     -   Kevin Petit
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?body=[VK_EXT_shader_float8] @kpet%0A*Here describe the issue or question you have about the VK_EXT_shader_float8 extension* >
--
-- [__Extension Proposal__]
--     <https://github.com/KhronosGroup/Vulkan-Docs/tree/main/proposals/VK_EXT_shader_float8.adoc VK_EXT_shader_float8>
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2025-04-16
--
-- [__IP Status__]
--     No known IP claims.
--
-- [__Contributors__]
--
--     -   Kévin Petit, Arm Ltd.
--
--     -   Stu Smith, AMD
--
--     -   Jeff Bolz, NVIDIA
--
--     -   Craig Graham, Samsung
--
-- == Description
--
-- This extension enables support for 8-bit floating-point data types as
-- defined in SPV_EXT_float8.
--
-- == New Structures
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDeviceShaderFloat8FeaturesEXT'
--
-- == New Enum Constants
--
-- -   'EXT_SHADER_FLOAT8_EXTENSION_NAME'
--
-- -   'EXT_SHADER_FLOAT8_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT8_FEATURES_EXT'
--
-- If
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_cooperative_matrix VK_KHR_cooperative_matrix>
-- is supported:
--
-- -   Extending
--     'Vulkan.Extensions.VK_NV_cooperative_vector.ComponentTypeKHR':
--
--     -   'Vulkan.Extensions.VK_NV_cooperative_vector.COMPONENT_TYPE_FLOAT8_E4M3_EXT'
--
--     -   'Vulkan.Extensions.VK_NV_cooperative_vector.COMPONENT_TYPE_FLOAT8_E5M2_EXT'
--
-- == New SPIR-V Capabilities
--
-- -   <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#spirvenv-capabilities-table-Float8EXT Float8EXT>
--
-- -   <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#spirvenv-capabilities-table-Float8CooperativeMatrixEXT Float8CooperativeMatrixEXT>
--
-- == Issues
--
-- 1) Resolve interactions with the changes VK_KHR_shader_float16 makes to
-- rules for denorm flushing (always allowed by default for all FP
-- formats). How to describe the requirement to preserve subnormals?
--
-- + __RESOLVED__: Subnormals are always preserved when converting FP8
-- values to IEEE 754 binary 16. In all other cases, subnormals may be
-- flushed to zero.
--
-- +
--
-- == Version History
--
-- -   Revision 1, 2025-04-16 (Kévin Petit)
--
--     -   Initial draft
--
-- == See Also
--
-- No cross-references are available
--
-- == Document Notes
--
-- For more information, see the
-- <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#VK_EXT_shader_float8 Vulkan Specification>.
--
-- This page is a generated document. Fixes and changes should be made to
-- the generator scripts, not directly.
module Vulkan.Extensions.VK_EXT_shader_float8  ( PhysicalDeviceShaderFloat8FeaturesEXT(..)
                                               , EXT_SHADER_FLOAT8_SPEC_VERSION
                                               , pattern EXT_SHADER_FLOAT8_SPEC_VERSION
                                               , EXT_SHADER_FLOAT8_EXTENSION_NAME
                                               , pattern EXT_SHADER_FLOAT8_EXTENSION_NAME
                                               , ComponentTypeKHR(..)
                                               ) 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_SHADER_FLOAT8_FEATURES_EXT))
import Vulkan.Extensions.VK_NV_cooperative_vector (ComponentTypeKHR(..))
-- | VkPhysicalDeviceShaderFloat8FeaturesEXT - Structure describing float8
-- features that can be supported by the implementation
--
-- = Members
--
-- This structure describes the following features:
--
-- = Description
--
-- If the 'PhysicalDeviceShaderFloat8FeaturesEXT' 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. If the application wishes to use a
-- 'Vulkan.Core10.Handles.Device' with any features described by
-- 'PhysicalDeviceShaderFloat8FeaturesEXT', it /must/ add an instance of
-- the structure, with the desired feature members set to
-- 'Vulkan.Core10.FundamentalTypes.TRUE', to the @pNext@ chain of
-- 'Vulkan.Core10.Device.DeviceCreateInfo' when creating the
-- 'Vulkan.Core10.Handles.Device'.
--
-- == Valid Usage (Implicit)
--
-- = See Also
--
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_EXT_shader_float8 VK_EXT_shader_float8>,
-- 'Vulkan.Core10.FundamentalTypes.Bool32',
-- 'Vulkan.Core10.Enums.StructureType.StructureType'
data PhysicalDeviceShaderFloat8FeaturesEXT = PhysicalDeviceShaderFloat8FeaturesEXT
  { -- | #features-shaderFloat8# @shaderFloat8@ indicates whether the
    -- implementation supports shaders with the @Float8EXT@ capability.
    PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
shaderFloat8 :: Bool
  , -- | #features-shaderFloat8CooperativeMatrix# @shaderFloat8CooperativeMatrix@
    -- indicates whether the implementation supports shaders with the
    -- @Float8CooperativeMatrixEXT@ capability.
    PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
shaderFloat8CooperativeMatrix :: Bool
  }
  deriving (Typeable, PhysicalDeviceShaderFloat8FeaturesEXT
-> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
(PhysicalDeviceShaderFloat8FeaturesEXT
 -> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool)
-> (PhysicalDeviceShaderFloat8FeaturesEXT
    -> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool)
-> Eq PhysicalDeviceShaderFloat8FeaturesEXT
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PhysicalDeviceShaderFloat8FeaturesEXT
-> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
== :: PhysicalDeviceShaderFloat8FeaturesEXT
-> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
$c/= :: PhysicalDeviceShaderFloat8FeaturesEXT
-> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
/= :: PhysicalDeviceShaderFloat8FeaturesEXT
-> PhysicalDeviceShaderFloat8FeaturesEXT -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceShaderFloat8FeaturesEXT)
#endif
deriving instance Show PhysicalDeviceShaderFloat8FeaturesEXT

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

instance FromCStruct PhysicalDeviceShaderFloat8FeaturesEXT where
  peekCStruct :: Ptr PhysicalDeviceShaderFloat8FeaturesEXT
-> IO PhysicalDeviceShaderFloat8FeaturesEXT
peekCStruct Ptr PhysicalDeviceShaderFloat8FeaturesEXT
p = do
    shaderFloat8 <- forall a. Storable a => Ptr a -> IO a
peek @Bool32 ((Ptr PhysicalDeviceShaderFloat8FeaturesEXT
p Ptr PhysicalDeviceShaderFloat8FeaturesEXT -> Int -> Ptr Bool32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: Ptr Bool32))
    shaderFloat8CooperativeMatrix <- peek @Bool32 ((p `plusPtr` 20 :: Ptr Bool32))
    pure $ PhysicalDeviceShaderFloat8FeaturesEXT
             (bool32ToBool shaderFloat8)
             (bool32ToBool shaderFloat8CooperativeMatrix)

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

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


type EXT_SHADER_FLOAT8_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_EXT_SHADER_FLOAT8_SPEC_VERSION"
pattern EXT_SHADER_FLOAT8_SPEC_VERSION :: forall a . Integral a => a
pattern $mEXT_SHADER_FLOAT8_SPEC_VERSION :: forall {r} {a}.
Integral a =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bEXT_SHADER_FLOAT8_SPEC_VERSION :: forall a. Integral a => a
EXT_SHADER_FLOAT8_SPEC_VERSION = 1


type EXT_SHADER_FLOAT8_EXTENSION_NAME = "VK_EXT_shader_float8"

-- No documentation found for TopLevel "VK_EXT_SHADER_FLOAT8_EXTENSION_NAME"
pattern EXT_SHADER_FLOAT8_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $mEXT_SHADER_FLOAT8_EXTENSION_NAME :: forall {r} {a}.
(Eq a, IsString a) =>
a -> ((# #) -> r) -> ((# #) -> r) -> r
$bEXT_SHADER_FLOAT8_EXTENSION_NAME :: forall a. (Eq a, IsString a) => a
EXT_SHADER_FLOAT8_EXTENSION_NAME = "VK_EXT_shader_float8"