summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pipeline/ray-tracing/ray-query-subroutine.slang40
-rw-r--r--tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl26
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/pipeline/ray-tracing/ray-query-subroutine.slang b/tests/pipeline/ray-tracing/ray-query-subroutine.slang
new file mode 100644
index 000000000..501071717
--- /dev/null
+++ b/tests/pipeline/ray-tracing/ray-query-subroutine.slang
@@ -0,0 +1,40 @@
+// ray-query-subroutine.slang
+
+// Regression test for passing a `RayQuery` value into a subroutine.
+
+//TEST:CROSS_COMPILE: -profile sm_6_5 -stage compute -entry computeMain -target dxil-assembly
+
+RWStructuredBuffer<int> gOutput;
+RaytracingAccelerationStructure gScene;
+
+int helper<let N : int>(RayQuery<N> q)
+{
+ RayDesc ray;
+ ray.Origin = 0;
+ ray.Direction = 0;
+ ray.TMin = 0;
+ ray.TMax = 1000.0;
+ q.TraceRayInline(
+ /* accellerationStructure: */ gScene,
+ /* rayFlags: */ N,
+ /* instanceInclusionmask: */ 0xFFFFFFFF,
+ /* ray: */ ray );
+
+ return 1;
+}
+
+[shader("compute")]
+void computeMain(uint tid : SV_DispatchThreadID)
+{
+ // Note: The original issue was due to "folding" of an instruction
+ // into use sites as part of emitting high-level-language code.
+ //
+ // In this case, the initial value of `rayQuery` has only a single
+ // use (in the call to `helper()`) and as a result was subject to
+ // "folding" during emit, because it had no side-effects.
+
+ RayQuery<0> rayQuery;
+ let result = helper(rayQuery);
+
+ gOutput[tid.x] = result;
+}
diff --git a/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl b/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl
new file mode 100644
index 000000000..5906823e5
--- /dev/null
+++ b/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl
@@ -0,0 +1,26 @@
+//TEST_IGNORE_FILE:
+
+RaytracingAccelerationStructure gScene_0 : register(t0);
+
+int helper_0(RayQuery<int(0) > q_0)
+{
+ RayDesc ray_0;
+ ray_0.Origin = (vector<float,3>) int(0);
+ ray_0.Direction = (vector<float,3>) int(0);
+ ray_0.TMin = (float) int(0);
+ ray_0.TMax = 1000.00000000000000000000;
+ q_0.TraceRayInline(gScene_0, (uint) int(0), (uint) int(-1), ray_0);
+ return int(1);
+}
+
+RWStructuredBuffer<int > gOutput_0 : register(u0);
+
+[shader("compute")][numthreads(1, 1, 1)]
+void computeMain(uint tid_0 : SV_DISPATCHTHREADID)
+{
+ RayQuery<int(0) > rayQuery_0;
+ int _S1 = helper_0(rayQuery_0);
+
+ gOutput_0[tid_0.x] = _S1;
+ return;
+}