summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-28 22:27:23 -0700
committerGitHub <noreply@github.com>2024-08-28 22:27:23 -0700
commit7893b4534a1034a001fd7670f3a2ad6d1db66bad (patch)
treecd69a185a12bba9f8f9f96ad204745758557a2b6
parent69e0f878e02d61280110b379f9d346acde7575a8 (diff)
Add `ReportIntersectionOptix` for optix. (#4949)
-rw-r--r--source/slang/hlsl.meta.slang14
-rw-r--r--tests/cuda/report-hit.slang9
2 files changed, 23 insertions, 0 deletions
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<each T : __BuiltinIntegerType>
+[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