diff options
| author | Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> | 2025-05-12 13:05:34 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-12 07:35:34 +0000 |
| commit | 64a43b17a76d7a8269f55cbe67ef708cd464774c (patch) | |
| tree | 089fc256a8c10eba17873c5458804ad1714dd5e9 /source/slang/hlsl.meta.slang | |
| parent | 03f9242489d5598c9c7594ac12e269f57a018cda (diff) | |
cluster acceleration structure optix 6431 (#7028)
* Add cluster geometry intrinsics for ray tracing
- Added GetClusterID() method to HitObject class
- Added CandidateClusterID() and CommittedClusterID() methods to
RayQuery class
- Added SPV_NV_cluster_acceleration_structure extension support
- Added GL_NV_cluster_acceleration_structure extension support
- Added test files for RayQuery and HitObject cluster methods
Fixes #6431
* OpRayQueryGetIntersectionClusterIdNV - unrecognized spirv
Disabling spirv backend for SPV_NV_cluster_acceleration_structure
hlsl.meta.slang(18674): error 29100: unrecognized spirv opcode:
OpRayQueryGetIntersectionClusterIdNV
result:$$int = OpRayQueryGetIntersectionClusterIdNV
&this $iCandidateOrCommitted;
^~~~~~
hlsl.meta.slang(18670): error 30019: expected an expression of type
'int', got 'void'
return spirv_asm
^~~~~~~~~
ninja: build stopped: subcommand failed.
* 6431 - Fix spirv opcode
* Remove tests
* Add relevant tests
* Review - Simplify tests
Diffstat (limited to 'source/slang/hlsl.meta.slang')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 99eba0a42..34423d4f3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -17889,6 +17889,26 @@ float RayCurrentTime() } } +/// @category raytracing +[__requiresNVAPI] +__glsl_extension(GL_NV_cluster_acceleration_structure) +__glsl_extension(GL_EXT_ray_tracing) +[NonUniformReturn] +[require(cuda_glsl_hlsl_spirv, raytracing_anyhit_closesthit)] +int GetClusterID() +{ + __target_switch + { + case hlsl: __intrinsic_asm "NvRtGetClusterID"; + case glsl: __intrinsic_asm "(gl_ClusterIDNV)"; + case cuda: __intrinsic_asm "optixGetClusterId"; + case spirv: + return spirv_asm + { + result:$$int = OpLoad builtin(ClusterIDNV:int); + }; + } +} // Note: The provisional DXR spec included these unadorned // `ObjectToWorld()` and `WorldToObject()` functions, so // we will forward them to the new names as a convience @@ -18683,6 +18703,31 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE> } } + /// Gets the cluster ID of the candidate hit. + /// @return Cluster ID for the candidate hit + /// @remarks HLSL/GLSL/SPIRV + [__requiresNVAPI] + __glsl_extension(GL_NV_cluster_acceleration_structure) + __glsl_extension(GL_EXT_ray_query) + [__NoSideEffect] + [require(glsl_hlsl_spirv, rayquery)] + int CandidateClusterID() + { + __target_switch + { + case hlsl: __intrinsic_asm "NvRtGetCandidateClusterID"; + case glsl: __intrinsic_asm "rayQueryGetIntersectionClusterIdNV($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + OpExtension "SPV_NV_cluster_acceleration_structure"; + OpCapability RayTracingClusterAccelerationStructureNV; + result:$$int = OpRayQueryGetClusterIdNV &this $iCandidateOrCommitted; + }; + } + } + /// Gets the custom index of the instance containing the committed hit. /// @return User-provided instance identifier /// @remarks GLSL/SPIRV only @@ -18698,7 +18743,32 @@ struct RayQuery <let rayFlagsGeneric : RAY_FLAG = RAY_FLAG_NONE> uint iCandidateOrCommitted = 1; return spirv_asm { - result:$$int = OpRayQueryGetIntersectionInstanceCustomIndexKHR &this $iCandidateOrCommitted; + result:$$int = OpRayQueryGetClusterIdNV &this $iCandidateOrCommitted; + }; + } + } + + /// Gets the cluster ID of the committed hit. + /// @return Cluster ID for the committed hit + /// @remarks HLSL/GLSL/SPIRV + [__requiresNVAPI] + __glsl_extension(GL_NV_cluster_acceleration_structure) + __glsl_extension(GL_EXT_ray_query) + [__NoSideEffect] + [require(glsl_hlsl_spirv, rayquery)] + int CommittedClusterID() + { + __target_switch + { + case hlsl: __intrinsic_asm "NvRtGetCommittedClusterID"; + case glsl: __intrinsic_asm "rayQueryGetIntersectionClusterIdNV($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; // 1 for committed + return spirv_asm + { + OpExtension "SPV_NV_cluster_acceleration_structure"; + OpCapability RayTracingClusterAccelerationStructureNV; + result:$$int = OpRayQueryGetClusterIdNV &this $iCandidateOrCommitted; }; } } @@ -20354,6 +20424,29 @@ struct HitObject } } + /// Returns the cluster ID of the current hit. Valid if the hit object represents a hit. + [__requiresNVAPI] + __glsl_extension(GL_NV_cluster_acceleration_structure) + __glsl_extension(GL_EXT_ray_tracing) + [ForceInline] + [require(cuda_glsl_hlsl_spirv, ser_raygen_closesthit_miss)] + int GetClusterID() + { + __target_switch + { + case hlsl: __intrinsic_asm ".GetClusterID"; + case glsl: __intrinsic_asm "hitObjectGetClusterIdNV($0)"; + case cuda: __intrinsic_asm "optixHitObjectGetClusterId"; + case spirv: + return spirv_asm + { + OpExtension "SPV_NV_cluster_acceleration_structure"; + OpCapability RayTracingClusterAccelerationStructureNV; + result:$$int = OpHitObjectGetClusterIdNV &this; + }; + } + } + [__requiresNVAPI] __glsl_extension(GL_EXT_ray_tracing) [ForceInline] |
