summaryrefslogtreecommitdiffstats
path: root/tests/hlsl
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2025-02-11 19:07:57 +0800
committerGitHub <noreply@github.com>2025-02-11 19:07:57 +0800
commit0b4e463aee4107b383067424007c6a995f1f9f87 (patch)
treee78fc7287a07643b890c0d981bd5ef95520dcf93 /tests/hlsl
parent0bc18d233966fc80cf2c482922d0b773d58394ca (diff)
Add raypayload decoration to ray payload structs (#6164)
* Add raypayload decoration to ray payload structs Closes https://github.com/shader-slang/slang/issues/6104 * Disable PAQs when compiling with DXC See https://github.com/shader-slang/slang/issues/3448
Diffstat (limited to 'tests/hlsl')
-rw-r--r--tests/hlsl/raypayload-attribute-no-struct.slang29
-rw-r--r--tests/hlsl/raypayload-attribute.slang34
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/hlsl/raypayload-attribute-no-struct.slang b/tests/hlsl/raypayload-attribute-no-struct.slang
new file mode 100644
index 000000000..c7ad94593
--- /dev/null
+++ b/tests/hlsl/raypayload-attribute-no-struct.slang
@@ -0,0 +1,29 @@
+//enable when https://github.com/shader-slang/slang/issues/3448 is implemented
+//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA
+
+// CHECK: struct [raypayload]
+
+uniform RWTexture2D resultTexture;
+uniform RaytracingAccelerationStructure sceneBVH;
+
+[shader("raygeneration")]
+void rayGenShaderA()
+{
+ int2 threadIdx = DispatchRaysIndex().xy;
+
+ float3 rayDir = float3(0, 0, 1);
+ float3 rayOrigin = 0;
+ rayOrigin.x = (threadIdx.x * 2) - 1;
+ rayOrigin.y = (threadIdx.y * 2) - 1;
+
+ // Trace the ray.
+ RayDesc ray;
+ ray.Origin = rayOrigin;
+ ray.Direction = rayDir;
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ float4 payload = float4(0, 0, 0, 0);
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ resultTexture[threadIdx.xy] = payload;
+}
diff --git a/tests/hlsl/raypayload-attribute.slang b/tests/hlsl/raypayload-attribute.slang
new file mode 100644
index 000000000..b981589ac
--- /dev/null
+++ b/tests/hlsl/raypayload-attribute.slang
@@ -0,0 +1,34 @@
+//enable when https://github.com/shader-slang/slang/issues/3448 is implemented
+//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA
+
+// CHECK: struct [raypayload]
+
+struct RayPayload
+{
+ float4 color;
+};
+
+uniform RWTexture2D resultTexture;
+uniform RaytracingAccelerationStructure sceneBVH;
+
+[shader("raygeneration")]
+void rayGenShaderA()
+{
+ int2 threadIdx = DispatchRaysIndex().xy;
+
+ float3 rayDir = float3(0, 0, 1);
+ float3 rayOrigin = 0;
+ rayOrigin.x = (threadIdx.x * 2) - 1;
+ rayOrigin.y = (threadIdx.y * 2) - 1;
+
+ // Trace the ray.
+ RayDesc ray;
+ ray.Origin = rayOrigin;
+ ray.Direction = rayDir;
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = { float4(0, 0, 0, 0) };
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ resultTexture[threadIdx.xy] = payload.color;
+}