See Issues list in the Khronos SPIRV-Registry repository: https://github.com/KhronosGroup/SPIRV-Registry
-
Contributors to SPV_KHR_ray_tracing
-
Tobias Hector, AMD
-
Nicolai Haehnle, AMD
-
Eric Werness, NVIDIA
-
Joshua Barczak, Intel
-
Ashwin Lele, NVIDIA
-
Daniel Koch, NVIDIA
-
Hans-Kristian Arntzen, Valve
-
David McAllister, Qualcomm
-
Dae Kim, Imagination
-
Alan Baker, Google
-
Aleksandra Krstic, Qualcomm
This extension is written against the Unified SPIR-V Specification, Version 1.5, Revision 1.
This extension requires SPIR-V 1.0.
This extension interacts with SPV_KHR_ray_tracing.
To use this extension within a SPIR-V module, the following OpExtension must be present in the module:
OpExtension "SPV_KHR_ray_query"
This extension introduces new capabilities:
RayQueryKHR RayTraversalPrimitiveCullingKHR
Instructions added under the RayQueryKHR capability
OpTypeAccelerationStructureKHR OpTypeRayQueryKHR OpRayQueryInitializeKHR OpRayQueryTerminateKHR OpRayQueryGenerateIntersectionKHR OpRayQueryConfirmIntersectionKHR OpRayQueryProceedKHR OpRayQueryGetIntersectionTypeKHR OpRayQueryGetRayTMinKHR OpRayQueryGetRayFlagsKHR OpRayQueryGetWorldRayDirectionKHR OpRayQueryGetWorldRayOriginKHR OpRayQueryGetIntersectionTKHR OpRayQueryGetIntersectionInstanceCustomIndexKHR OpRayQueryGetIntersectionInstanceIdKHR OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR OpRayQueryGetIntersectionGeometryIndexKHR OpRayQueryGetIntersectionPrimitiveIndexKHR OpRayQueryGetIntersectionBarycentricsKHR OpRayQueryGetIntersectionFrontFaceKHR OpRayQueryGetIntersectionCandidateAABBOpaqueKHR OpRayQueryGetIntersectionObjectRayDirectionKHR OpRayQueryGetIntersectionObjectRayOriginKHR OpRayQueryGetIntersectionObjectToWorldKHR OpRayQueryGetIntersectionWorldToObjectKHR OpConvertUToAccelerationStructureKHR
- (Add the following terminology to section 2.2.2, Types)
-
Ray query type: The type returned by OpTypeRayQueryKHR.
- (Add to the list of opaque types in section 2.2.2, Types)
-
-
OpTypeAccelerationStructureKHR
-
OpTypeRayQueryKHR
-
- (Modify Section 2.16.1, Universal Validation Rules)
- (Add a new sub-section 3.RQIntersection, Ray Query Intersection, adding a new table)
-
Identifies which intersection should be returned from a ray query.
Ray Query Intersection Enabling Capabilities 0
RayQueryCandidateIntersectionKHR
Identifies the current candidate intersection being considered, valid when OpRayQueryProceedKHR returns true.RayQueryKHR
1
RayQueryCommittedIntersectionKHR
Identifies the last intersection committed that is being considered, valid when OpRayQueryGetCommittedIntersectionTypeKHR does not return RayQueryCommittedIntersectionNoneKHR.RayQueryKHR
- (Add a new sub-section 3.RQCommitted, Ray Query Committed Intersection Type, adding a new table)
-
Describes the type of the intersection currently committed in a ray query.
Ray Query Committed Intersection Type Enabling Capabilities 0
RayQueryCommittedIntersectionNoneKHR
No intersection is committed.RayQueryKHR
1
RayQueryCommittedIntersectionTriangleKHR
An intersection with a triangle has been committed.RayQueryKHR
2
RayQueryCommittedIntersectionGeneratedKHR
A user-generated intersection has been committed.RayQueryKHR
- (Add a new sub-section 3.RQCandidate, Ray Query Candidate Intersection Type, adding a new table)
-
Describes the type of the intersection which is currently the candidate in a ray query.
Ray Query Candidate Intersection Type Enabling Capabilities 0
RayQueryCandidateIntersectionTriangleKHR
A potential intersection with a triangle is being considered.RayQueryKHR
1
RayQueryCandidateIntersectionAABBKHR
A potential intersection with an axis-aligned bounding box is being considered.RayQueryKHR
- (Modify Section 3.31, Capability, adding a row to the Capability table)
-
Capability Implicitly Declares 4472
RayQueryKHR
Uses Ray QueryShader role=include
- (Modify Section 3.36.6, Type-Declaration Instructions, adding two new tables)
- (Add the following line to the description of OpTypePointer, in Section 3.32.6, Type-Declaration Instructions)
-
If Type is OpTypeRayQueryKHR, Storage Class must be Private or Function.
- (Add the following line to the description of OpStore and OpLoad, in Section 3.32.8, Memory Instructions)
-
The Type operand to the OpTypePointer used for Pointer must not be OpTypeRayQueryKHR.
- (Add the following line to the description of OpCopyMemory and OpCopyMemorySized, in Section 3.32.8, Memory Instructions)
-
The Type operand to the OpTypePointer used for Target or Source must not be OpTypeRayQueryKHR.
- (Modify Section 3.36.11, Conversion Instructions, adding a new table)
- (Add a new sub section 3.36.RQInstructions, Ray Query Instructions)
-
OpRayQueryInitializeKHR
Initialize a ray query object, defining parameters of traversal. After this call, a new ray trace can be performed with OpRayQueryProceedKHR. Any previous traversal state stored in the object is lost.
Ray Query is a pointer to the ray query to initialize.
Acceleration Structure is the descriptor for the acceleration structure to trace into.
Ray Flags contains one or more of the Ray Flag values.
Cull Mask is the mask to test against the instance mask.
Ray Origin, Ray Tmin, Ray Direction, and Ray Tmax control the basic parameters of the ray to be traced.
Ray Flags and Cull Mask must be a 32-bit integer type scalar.
Only the 8 least-significant bits of Cull Mask are used by this instruction - other bits are ignored.
Ray Origin and Ray Direction must be a 32-bit floating-point type 3-component vector.
Ray Tmin and Ray Tmax must be a 32-bit floating-point type scalar.Capability:
RayQueryKHR9
4473
<id> Ray Query
<id> Acceleration Structure
<id> Ray Flags
<id> Cull Mask
<id> Ray Origin
<id> Ray Tmin
<id> Ray Direction
<id> Ray Tmax
OpRayQueryGetIntersectionTypeKHR
Returns the type of the current candidate or committed intersection.
Result describes the type of the intersection in the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, it returns one of the Ray Query Candidate Intersection Types.
If Intersection is RayQueryCommittedIntersectionKHR, it returns one of the Ray Query Committed Intersection Types.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true.Capability:
RayQueryKHR5
4479
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetRayFlagsKHR
Returns the Ray Flags used by the ray query.
Result returns the Ray Flag values used by the ray query.
Result Type must be a 32-bit integer type scalar.
Ray Query is a pointer to the ray query object.Capability:
RayQueryKHR4
6017
<id> Result Type
Result <id>
<id> Ray Query
OpRayQueryGetIntersectionTKHR
Gets the T value for the current or previous intersection considered in a ray query.
Result is the returned T value.
Result Type must be a 32-bit floating-point type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, if the last value returned by such an execution of OpRayQueryProceedKHR was not true, or the current intersection candidate does not have a Ray Query Candidate Intersection Type of RayQueryCandidateIntersectionTriangleKHR. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6018
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionInstanceCustomIndexKHR
Gets the custom index of the instance for the current intersection considered in a ray query.
Result is the returned custom instance index.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6019
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionInstanceIdKHR
Gets the id of the instance for the current intersection considered in a ray query.
Result is the returned instance id.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6020
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR
Gets the shader binding table record offset for the current intersection considered in a ray query.
Result is the returned instance id.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6021
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionGeometryIndexKHR
Gets the geometry index for the current intersection considered in a ray query.
Result is the returned geometry index.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6022
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionPrimitiveIndexKHR
Gets the primitive index for the current intersection considered in a ray query.
Result is the returned primitive index.
Result Type must be a 32-bit integer type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6023
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionBarycentricsKHR
Gets the second and third barycentric coordinates of the current intersection considered in a ray query against the primitive it hit.
Result is the returned barycentric coordinates.
Result Type must be a 32-bit floating-point type 2-component vector.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, if the last value returned by such an execution of OpRayQueryProceedKHR was not true, or the current intersection candidate does not have a Ray Query Candidate Intersection Type of RayQueryCandidateIntersectionTriangleKHR. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR), or if the Ray Query Committed Intersection Type is not RayQueryCommittedIntersectionTriangleKHR.Capability:
RayQueryKHR5
6024
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionFrontFaceKHR
Gets a boolean indicating whether the current intersection considered in a ray query was with the front face or back face of a primitive.
Result is true if the intersection was with the front face of a primitive, or false otherwise.
Result Type must be a boolean type scalar.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, if the last value returned by such an execution of OpRayQueryProceedKHR was not true, or the current intersection candidate does not have a Ray Query Candidate Intersection Type of RayQueryCandidateIntersectionTriangleKHR. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR), or if the Ray Query Committed Intersection Type is not RayQueryCommittedIntersectionTriangleKHR.Capability:
RayQueryKHR5
6025
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionObjectRayDirectionKHR
Gets the object-space ray direction for the current intersection considered in a ray query.
Result is the returned ray direction.
Result Type must be a 32-bit floating-point type 3-component vector.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6027
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionObjectRayOriginKHR
Gets the object-space ray origin for the current intersection considered in a ray query.
Result is the returned ray origin.
Result Type must be a 32-bit floating-point type 3-component vector.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6028
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionObjectToWorldKHR
Gets a matrix that transforms values to world-space from the object-space of the current intersection considered in a ray query.
Result is the returned matrix.
Result Type must be a matrix with a Column Count of 4, and a Column Type that is a vector type with a Component Type that is a 32-bit floating-point type and a Component Count of 3.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6031
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
OpRayQueryGetIntersectionWorldToObjectKHR
Gets a matrix that transforms values from world-space to the object-space of the current intersection considered in a ray query.
Result is the returned matrix.
Result Type must be a matrix with a Column Count of 4, and a Column Type that is a vector type with a Component Type that is a 32-bit floating-point type and a Component Count of 3.
Intersection must be the <id> of a constant instruction with a 32-bit scalar integer type.
Intersection identifies which intersection values should be returned for, either the current candidate or the closest recorded hit so far; see Ray Query Intersection.
Ray Query is a pointer to the ray query object.
If Intersection is RayQueryCandidateIntersectionKHR, behavior is undefined if OpRayQueryProceedKHR was not executed on the same ray query object, or if the last value returned by such an execution of OpRayQueryProceedKHR was not true. If Intersection is RayQueryCommittedIntersectionKHR, behavior is undefined if there is no current committed intersection (see OpRayQueryGetIntersectionTypeKHR).Capability:
RayQueryKHR5
6032
<id> Result Type
Result <id>
<id> Ray Query
<id> Intersection
An OpExtension must be added to the SPIR-V for validation layers to check legal use of this extension:
OpExtension "SPV_KHR_ray_query"
OpTypeAccelerationStructureKHR, RayTraversalPrimitiveCullingKHR,
OpConvertUToAccelerationStructureKHR and the Ray Flags
are added by both
this extension and SPV_KHR_ray_tracing
; they
are intended to have identical definitions, and can be enabled by either
extension’s capability, for use with the instructions under that same
capability.
If SPV_KHR_ray_tracing
is not supported, ignore any references to
OpTraceRayKHR.
1) What are the differences between provisional and final?
Discussion:
-
rename OpTypeRayQueryProvisionalKHR to OpTypeRayQueryKHR as was originally intended. Seems like it fell victim to an overreaching seach and replace when this was made provisional.
-
change RayQueryProvisionalKHR to RayQueryKHR and assign new token (4472)
-
add OpConvertUToAccelerationStructureKHR (4447) instruction to convert 64-bit integer to OpTypeAccelerationStructureKHR to enable query by handle
Rev | Date | Author | Changes |
---|---|---|---|
1 |
2019-12-05 |
Tobias Hector |
First draft |
2 |
2019-12-11 |
Daniel Koch |
add Provisional string to capabilities. |
3 |
2020-03-06 |
Ashwin Lele |
Reorder operands and rename builtins (!170) |
4 |
2020-04-14 |
Jeff Bolz |
Fix return type of OpRayQueryGetIntersectionTKHR |
5 |
2020-06-03 |
Daniel Koch |
Update capabilities tables to match SPIR-V 1.5. |
6 |
2020-06-05 |
Hans-Kristian Arntzen |
Add conversion from 64-bit acceleration structure pointer to OpTypeAccelerationStructureKHR |
7 |
2020-06-12 |
Daniel Koch |
rename OpTypeRayQueryProvisionalKHR → OpTypeRayQueryKHR refactored common code to include files |
8 |
2020-07-03 |
Daniel Koch |
Remove provisional notices and update capabilities |
9 |
2020-07-10 |
Tobias Hector |
Clarify that subset of bits are used for cull mask |
10 |
2020-07-22 |
David McAllister |
Disallow querying candidate T value for AABB primitives (!191) |
11 |
2021-02-19 |
Dae Kim |
Fix barycentric coordinates retrieved for OpRayQueryGetIntersectionBarycentricsKHR (!203) |
12 |
2021-09-08 |
Daniel Koch |
replace references to nonexistent OpRayQueryCommittedTypeKHR (GH#128) |
13 |
2022-05-27 |
Daniel Koch |
disallow more combinations of ray flags (vk-gl-cts#3647) |
14 |
2023-01-13 |
Daniel Koch |
Follow SPIR-V conventions for undefined behavior. |