diff options
| author | kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> | 2024-01-11 12:10:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-11 12:10:43 -0800 |
| commit | 8e90098419e924980e7d92c28d7c87148b4821a5 (patch) | |
| tree | ff7840a8559fa16d59742b653332d10c3f72c963 /source | |
| parent | 2c08bc4fc7b6e0d0ef4e6ce251673c15de60b54e (diff) | |
Support for gl_HitTriangleVertexPositionsEXT (#3405) (#3442)
* Support for gl_HitTriangleVertexPositionsEXT (#3405)
Adding float3 HitTriangleVertexPositions(uint) to slang stdlib
to support GLSL gl_HitTriangleVertexPositionsEXT builtin variable
under extension of GL_EXT_ray_tracing_position_fetch.
This function support emitting GLSL code and spir-V directly.
* Update the function name
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 144141b79..2f4064c97 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -9861,6 +9861,31 @@ uint GeometryIndex() } } +// Get the vertex positions of the currently hit triangle in any-hit or closest-hit shader. +// https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GLSL_EXT_ray_tracing_position_fetch.txt +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_EXT_ray_tracing_position_fetch) +__glsl_version(460) +[ForceInline] +float3 HitTriangleVertexPosition(uint index) +{ + __target_switch + { + case glsl: + __intrinsic_asm "gl_HitTriangleVertexPositionsEXT[$0]"; + case spirv: + return spirv_asm { + OpCapability RayTracingKHR; + OpCapability RayTracingPositionFetchKHR; + OpExtension "SPV_KHR_ray_tracing"; + OpExtension "SPV_KHR_ray_tracing_position_fetch"; + %_ptr_Input_v3float = OpTypePointer Input $$float3; + %addr : %_ptr_Input_v3float = OpAccessChain builtin(HitTriangleVertexPositionsKHR:float3[3]) $index; + result:$$float3 = OpLoad %addr; + }; + } +} + // Status of whether a (closest) hit has been committed in a `RayQuery`. typedef uint COMMITTED_STATUS; |
