summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/diagnostics/raypayload-missing-access-qualifiers.slang37
-rw-r--r--tests/diagnostics/raypayload-missing-access-qualifiers.slang.expected8
-rw-r--r--tests/hlsl/raypayload-attribute-no-struct.slang7
-rw-r--r--tests/hlsl/raypayload-attribute-paq.slang37
-rw-r--r--tests/hlsl/raypayload-attribute.slang9
5 files changed, 91 insertions, 7 deletions
diff --git a/tests/diagnostics/raypayload-missing-access-qualifiers.slang b/tests/diagnostics/raypayload-missing-access-qualifiers.slang
new file mode 100644
index 000000000..d22a6300b
--- /dev/null
+++ b/tests/diagnostics/raypayload-missing-access-qualifiers.slang
@@ -0,0 +1,37 @@
+// raypayload-missing-access-qualifiers.slang
+
+//DIAGNOSTIC_TEST:SIMPLE:
+
+// Test error for field in ray payload struct missing read/write access qualifiers
+
+struct [raypayload] RayPayload
+{
+ float4 color : read(caller, anyhit) : write(caller);
+ float4 colorMissingQualifiers; // Error expected here
+
+};
+
+uniform RWTexture2D<float4> 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) , float4(0, 0, 0, 0)};
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ resultTexture[threadIdx.xy] = payload.color;
+}
diff --git a/tests/diagnostics/raypayload-missing-access-qualifiers.slang.expected b/tests/diagnostics/raypayload-missing-access-qualifiers.slang.expected
new file mode 100644
index 000000000..525e8529c
--- /dev/null
+++ b/tests/diagnostics/raypayload-missing-access-qualifiers.slang.expected
@@ -0,0 +1,8 @@
+result code = -1
+standard error = {
+tests/diagnostics/raypayload-missing-access-qualifiers.slang(10): error 40000: field 'colorMissingQualifiers' in ray payload struct must have either 'read' OR 'write' access qualifiers
+ float4 colorMissingQualifiers; // Error expected here
+ ^~~~~~~~~~~~~~~~~~~~~~
+}
+standard output = {
+}
diff --git a/tests/hlsl/raypayload-attribute-no-struct.slang b/tests/hlsl/raypayload-attribute-no-struct.slang
index c7ad94593..4e4921e14 100644
--- a/tests/hlsl/raypayload-attribute-no-struct.slang
+++ b/tests/hlsl/raypayload-attribute-no-struct.slang
@@ -1,7 +1,8 @@
-//enable when https://github.com/shader-slang/slang/issues/3448 is implemented
-//DISABLE_TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
+//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
-// CHECK: struct [raypayload]
+// CHECK: struct RayPayload
+// DXIL: define void @
uniform RWTexture2D resultTexture;
uniform RaytracingAccelerationStructure sceneBVH;
diff --git a/tests/hlsl/raypayload-attribute-paq.slang b/tests/hlsl/raypayload-attribute-paq.slang
new file mode 100644
index 000000000..3af0556bc
--- /dev/null
+++ b/tests/hlsl/raypayload-attribute-paq.slang
@@ -0,0 +1,37 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_7 -stage raygeneration -entry rayGenShaderA
+//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_7 -stage raygeneration -entry rayGenShaderA
+
+// CHECK: struct [raypayload]
+// CHECK: float4 color_0 : read(caller, anyhit) : write(caller);
+// DXIL: define void @
+// DXIL: !dx.dxrPayloadAnnotations
+
+struct [raypayload] RayPayload
+{
+ float4 color : read(caller, anyhit) : write(caller);
+};
+
+uniform RWTexture2D<float4> 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;
+}
diff --git a/tests/hlsl/raypayload-attribute.slang b/tests/hlsl/raypayload-attribute.slang
index b981589ac..1a9e9a7f5 100644
--- a/tests/hlsl/raypayload-attribute.slang
+++ b/tests/hlsl/raypayload-attribute.slang
@@ -1,8 +1,9 @@
-//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]
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
+//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
+// CHECK: struct RayPayload
+// CHECK: float4 color
+// DXIL: define void @
struct RayPayload
{
float4 color;