From 7893b4534a1034a001fd7670f3a2ad6d1db66bad Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 28 Aug 2024 22:27:23 -0700 Subject: Add `ReportIntersectionOptix` for optix. (#4949) --- source/slang/hlsl.meta.slang | 14 ++++++++++++++ tests/cuda/report-hit.slang | 9 +++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/cuda/report-hit.slang diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 21cb9ef18..10a6254c1 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -15881,6 +15881,20 @@ bool ReportHit(float tHit, uint hitKind, A attributes) } } +__generic +[ForceInline] +[require(cuda_glsl_hlsl_spirv, raytracing_intersection)] +bool ReportHitOptix(float tHit, uint hitKind, expand each T attribs) +{ + __target_switch + { + case cuda: + __intrinsic_asm "optixReportIntersection"; + default: + return ReportHit(tHit, hitKind, makeTuple(expand each attribs)); + } +} + // 10.3.4 [require(cuda_glsl_hlsl_spirv, raytracing_anyhit)] void IgnoreHit() diff --git a/tests/cuda/report-hit.slang b/tests/cuda/report-hit.slang new file mode 100644 index 000000000..12b6d8c4b --- /dev/null +++ b/tests/cuda/report-hit.slang @@ -0,0 +1,9 @@ +//TEST:SIMPLE(filecheck=CHECK): -target cuda + +// CHECK: optixReportIntersection(3.0f, 2U, int(1), int(2), int(3)) + +[shader("intersection")] +void test() +{ + ReportHitOptix(3.0f, 2, 1, 2, 3); +} \ No newline at end of file -- cgit v1.2.3