{-# language CPP #-}
-- | = Name
--
-- VK_KHR_ray_query - device extension
--
-- == VK_KHR_ray_query
--
-- [__Name String__]
--     @VK_KHR_ray_query@
--
-- [__Extension Type__]
--     Device extension
--
-- [__Registered Extension Number__]
--     349
--
-- [__Revision__]
--     1
--
-- [__Extension and Version Dependencies__]
--
--     -   Requires Vulkan 1.1
--
--     -   Requires @VK_KHR_spirv_1_4@
--
--     -   Requires @VK_KHR_acceleration_structure@
--
-- [__Contact__]
--
--     -   Daniel Koch
--         <https://github.com/KhronosGroup/Vulkan-Docs/issues/new?title=VK_KHR_ray_query:%20&body=@dgkoch%20 >
--
-- == Other Extension Metadata
--
-- [__Last Modified Date__]
--     2020-11-12
--
-- [__Interactions and External Dependencies__]
--
--     -   This extension requires
--         <https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_ray_query.html SPV_KHR_ray_query>
--
--     -   This extension provides API support for
--         <https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GLSL_EXT_ray_query.txt GLSL_EXT_ray_query>
--
-- [__Contributors__]
--
--     -   Matthäus Chajdas, AMD
--
--     -   Greg Grebe, AMD
--
--     -   Nicolai Hähnle, AMD
--
--     -   Tobias Hector, AMD
--
--     -   Dave Oldcorn, AMD
--
--     -   Skyler Saleh, AMD
--
--     -   Mathieu Robart, Arm
--
--     -   Marius Bjorge, Arm
--
--     -   Tom Olson, Arm
--
--     -   Sebastian Tafuri, EA
--
--     -   Henrik Rydgard, Embark
--
--     -   Juan Cañada, Epic Games
--
--     -   Patrick Kelly, Epic Games
--
--     -   Yuriy O’Donnell, Epic Games
--
--     -   Michael Doggett, Facebook\/Oculus
--
--     -   Andrew Garrard, Imagination
--
--     -   Don Scorgie, Imagination
--
--     -   Dae Kim, Imagination
--
--     -   Joshua Barczak, Intel
--
--     -   Slawek Grajewski, Intel
--
--     -   Jeff Bolz, NVIDIA
--
--     -   Pascal Gautron, NVIDIA
--
--     -   Daniel Koch, NVIDIA
--
--     -   Christoph Kubisch, NVIDIA
--
--     -   Ashwin Lele, NVIDIA
--
--     -   Robert Stepinski, NVIDIA
--
--     -   Martin Stich, NVIDIA
--
--     -   Nuno Subtil, NVIDIA
--
--     -   Eric Werness, NVIDIA
--
--     -   Jon Leech, Khronos
--
--     -   Jeroen van Schijndel, OTOY
--
--     -   Juul Joosten, OTOY
--
--     -   Alex Bourd, Qualcomm
--
--     -   Roman Larionov, Qualcomm
--
--     -   David McAllister, Qualcomm
--
--     -   Spencer Fricke, Samsung
--
--     -   Lewis Gordon, Samsung
--
--     -   Ralph Potter, Samsung
--
--     -   Jasper Bekkers, Traverse Research
--
--     -   Jesse Barker, Unity
--
--     -   Baldur Karlsson, Valve
--
-- == Description
--
-- Rasterization has been the dominant method to produce interactive
-- graphics, but increasing performance of graphics hardware has made ray
-- tracing a viable option for interactive rendering. Being able to
-- integrate ray tracing with traditional rasterization makes it easier for
-- applications to incrementally add ray traced effects to existing
-- applications or to do hybrid approaches with rasterization for primary
-- visibility and ray tracing for secondary queries.
--
-- Ray queries are available to all shader types, including graphics,
-- compute and ray tracing pipelines. Ray queries are not able to launch
-- additional shaders, instead returning traversal results to the calling
-- shader.
--
-- This extension adds support for the following SPIR-V extension in
-- Vulkan:
--
-- -   @SPV_KHR_ray_query@
--
-- == New Structures
--
-- -   Extending
--     'Vulkan.Core11.Promoted_From_VK_KHR_get_physical_device_properties2.PhysicalDeviceFeatures2',
--     'Vulkan.Core10.Device.DeviceCreateInfo':
--
--     -   'PhysicalDeviceRayQueryFeaturesKHR'
--
-- == New Enum Constants
--
-- -   'KHR_RAY_QUERY_EXTENSION_NAME'
--
-- -   'KHR_RAY_QUERY_SPEC_VERSION'
--
-- -   Extending 'Vulkan.Core10.Enums.StructureType.StructureType':
--
--     -   'Vulkan.Core10.Enums.StructureType.STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR'
--
-- == New SPIR-V Capabilities
--
-- -   <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#spirvenv-capabilities-table-khr-raytracing RayQueryKHR>
--
-- -   <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#spirvenv-capabilities-table-khr-raytracing RayTraversalPrimitiveCullingKHR>
--
-- == Sample Code
--
-- Example of ray query in a GLSL shader
--
-- > rayQueryEXT rq;
-- >
-- > rayQueryInitializeEXT(rq, accStruct, gl_RayFlagsNoneEXT, 0, origin, tMin, direction, tMax);
-- >
-- > while(rayQueryProceedEXT(rq)) {
-- > 	if (rayQueryGetIntersectionTypeEXT(rq, false) == gl_RayQueryCandidateIntersectionTriangleEXT) {
-- > 		//...
-- > 		rayQueryConfirmIntersectionEXT(rq);
-- > 	}
-- > }
-- >
-- > if (rayQueryGetIntersectionTypeEXT(rq, true) == gl_RayQueryCommittedIntersectionNoneEXT) {
-- > 	//...
-- > }
--
-- == Issues
--
-- (1) What are the changes between the public provisional
-- (VK_KHR_ray_tracing v8) release and the final
-- (VK_KHR_acceleration_structure v11 \/ VK_KHR_ray_query v1) release?
--
-- -   refactor VK_KHR_ray_tracing into 3 extensions, enabling
--     implementation flexibility and decoupling ray query support from ray
--     pipelines:
--
--     -   <VK_KHR_acceleration_structure.html VK_KHR_acceleration_structure>
--         (for acceleration structure operations)
--
--     -   <VK_KHR_ray_tracing_pipeline.html VK_KHR_ray_tracing_pipeline>
--         (for ray tracing pipeline and shader stages)
--
--     -   <VK_KHR_ray_query.html VK_KHR_ray_query> (for ray queries in
--         existing shader stages)
--
-- -   Update SPIRV capabilities to use @RayQueryKHR@
--
-- -   extension is no longer provisional
--
-- == Version History
--
-- -   Revision 1, 2020-11-12 (Mathieu Robart, Daniel Koch, Andrew Garrard)
--
--     -   Decomposition of the specification, from VK_KHR_ray_tracing to
--         VK_KHR_ray_query (#1918,!3912)
--
--     -   update to use @RayQueryKHR@ SPIR-V capability
--
--     -   add numerical limits for ray parameters (#2235,!3960)
--
--     -   relax formula for ray intersection candidate determination
--         (#2322,!4080)
--
--     -   restrict traces to TLAS (#2239,!4141)
--
--     -   require @HitT@ to be in ray interval for
--         @OpRayQueryGenerateIntersectionKHR@ (#2359,!4146)
--
--     -   add ray query shader stages for AS read bit (#2407,!4203)
--
-- = See Also
--
-- 'PhysicalDeviceRayQueryFeaturesKHR'
--
-- = Document Notes
--
-- For more information, see the
-- <https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VK_KHR_ray_query 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_ray_query  ( PhysicalDeviceRayQueryFeaturesKHR(..)
                                           , KHR_RAY_QUERY_SPEC_VERSION
                                           , pattern KHR_RAY_QUERY_SPEC_VERSION
                                           , KHR_RAY_QUERY_EXTENSION_NAME
                                           , pattern KHR_RAY_QUERY_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_RAY_QUERY_FEATURES_KHR))
-- | VkPhysicalDeviceRayQueryFeaturesKHR - Structure describing the ray query
-- features that can be supported by an implementation
--
-- = Members
--
-- The members of the 'PhysicalDeviceRayQueryFeaturesKHR' structure
-- describe the following features:
--
-- = Description
--
-- If the 'PhysicalDeviceRayQueryFeaturesKHR' 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.
-- 'PhysicalDeviceRayQueryFeaturesKHR' /can/ also be used 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 PhysicalDeviceRayQueryFeaturesKHR = PhysicalDeviceRayQueryFeaturesKHR
  { -- | #features-rayQuery# @rayQuery@ indicates whether the implementation
    -- supports ray query (@OpRayQueryProceedKHR@) functionality.
    PhysicalDeviceRayQueryFeaturesKHR -> Bool
rayQuery :: Bool }
  deriving (Typeable, PhysicalDeviceRayQueryFeaturesKHR
-> PhysicalDeviceRayQueryFeaturesKHR -> Bool
(PhysicalDeviceRayQueryFeaturesKHR
 -> PhysicalDeviceRayQueryFeaturesKHR -> Bool)
-> (PhysicalDeviceRayQueryFeaturesKHR
    -> PhysicalDeviceRayQueryFeaturesKHR -> Bool)
-> Eq PhysicalDeviceRayQueryFeaturesKHR
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhysicalDeviceRayQueryFeaturesKHR
-> PhysicalDeviceRayQueryFeaturesKHR -> Bool
$c/= :: PhysicalDeviceRayQueryFeaturesKHR
-> PhysicalDeviceRayQueryFeaturesKHR -> Bool
== :: PhysicalDeviceRayQueryFeaturesKHR
-> PhysicalDeviceRayQueryFeaturesKHR -> Bool
$c== :: PhysicalDeviceRayQueryFeaturesKHR
-> PhysicalDeviceRayQueryFeaturesKHR -> Bool
Eq)
#if defined(GENERIC_INSTANCES)
deriving instance Generic (PhysicalDeviceRayQueryFeaturesKHR)
#endif
deriving instance Show PhysicalDeviceRayQueryFeaturesKHR

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

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

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


type KHR_RAY_QUERY_SPEC_VERSION = 1

-- No documentation found for TopLevel "VK_KHR_RAY_QUERY_SPEC_VERSION"
pattern KHR_RAY_QUERY_SPEC_VERSION :: forall a . Integral a => a
pattern $bKHR_RAY_QUERY_SPEC_VERSION :: a
$mKHR_RAY_QUERY_SPEC_VERSION :: forall r a. Integral a => a -> (Void# -> r) -> (Void# -> r) -> r
KHR_RAY_QUERY_SPEC_VERSION = 1


type KHR_RAY_QUERY_EXTENSION_NAME = "VK_KHR_ray_query"

-- No documentation found for TopLevel "VK_KHR_RAY_QUERY_EXTENSION_NAME"
pattern KHR_RAY_QUERY_EXTENSION_NAME :: forall a . (Eq a, IsString a) => a
pattern $bKHR_RAY_QUERY_EXTENSION_NAME :: a
$mKHR_RAY_QUERY_EXTENSION_NAME :: forall r a.
(Eq a, IsString a) =>
a -> (Void# -> r) -> (Void# -> r) -> r
KHR_RAY_QUERY_EXTENSION_NAME = "VK_KHR_ray_query"