summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/capability
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-08-28 15:06:23 -0400
committerGitHub <noreply@github.com>2024-08-28 12:06:23 -0700
commit65240d074b4ddec55e56962ebf8de46207bcf5fa (patch)
treefa887d3de8ab55c7498eae2d5bf61966818135a1 /tests/language-feature/capability
parent638e5fb000d4e242a91e8b653da4a72daec0efda (diff)
Allow capabilities to be used with `[shader("...")]` (#4928)
* Allow capabilities to be used with `[shader("...")]` Fixes: #4917 Changes: 1. Allow using capabilities instead of `Stage`s with `EntryPointAttribute`. 2. When resolving capabilities for an entrypoint+profile (per entrypoint) in `resolveStageOfProfileWithEntryPoint` add our `EntryPointAttribute` and resolved capability 3. Added tests and some capabilities related clean-up * fix a warning made by a mistake in syntax * change fineStageByName to assume it is passed a stage without a '_' * test with and without prefix '_' * cleanup some profiles and reprisentation to work better with 'Stage' and 'Profile' This use case is why we need to clean all profile-usage into `CapabilityName`s directly. * change how we compare * only change profiles * let all capabilities be resolved by 'shader' profile for now * fix warning checks I accidently broke * meshshading_internal to _meshshading --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests/language-feature/capability')
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-1.slang8
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-2.slang11
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-3.slang8
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-4.slang24
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-5.slang25
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-6.slang25
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-7.slang40
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-8.slang14
-rw-r--r--tests/language-feature/capability/explicit-shader-stage-9.slang25
9 files changed, 180 insertions, 0 deletions
diff --git a/tests/language-feature/capability/explicit-shader-stage-1.slang b/tests/language-feature/capability/explicit-shader-stage-1.slang
new file mode 100644
index 000000000..f8d7d8380
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-1.slang
@@ -0,0 +1,8 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0
+
+//CHECK: main
+[shader("fragment")]
+float4 main()
+{
+ return float4(1.0f);
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-2.slang b/tests/language-feature/capability/explicit-shader-stage-2.slang
new file mode 100644
index 000000000..b4c6d3cfe
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-2.slang
@@ -0,0 +1,11 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -entry main -allow-glsl -profile sm_5_0 -ignore-capabilities
+
+//CHECK: error 36107: entrypoint 'main' does not support compilation target 'hlsl' with stage 'fragment'
+//CHECK_IGNORE_CAPS-NOT: error 36100
+[shader("fragment")]
+float4 main()
+{
+ memoryBarrierAtomicCounter();
+ return float4(1.0f);
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-3.slang b/tests/language-feature/capability/explicit-shader-stage-3.slang
new file mode 100644
index 000000000..5bf143134
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-3.slang
@@ -0,0 +1,8 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage vertex -entry main -allow-glsl -profile sm_5_0
+
+//CHECK: warning 38006
+[shader("fragment")]
+float4 main()
+{
+ return float4(1.0f);
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-4.slang b/tests/language-feature/capability/explicit-shader-stage-4.slang
new file mode 100644
index 000000000..80ad2c206
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-4.slang
@@ -0,0 +1,24 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0
+
+// We do not error since `shader("raygeneration")` implicitly adds raytracing capabilities to our compile
+//CHECK: main
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+[shader("raygeneration")]
+void main()
+{
+ RayDesc ray;
+ ray.Origin = float3(0,0,0);
+ ray.Direction = float3(0,0,0);
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = {};
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ outputBuffer[0] = payload.data;
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-5.slang b/tests/language-feature/capability/explicit-shader-stage-5.slang
new file mode 100644
index 000000000..0c2cd2bd4
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-5.slang
@@ -0,0 +1,25 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_6_5
+
+// Our code compiles here since we specify profile sm_6_5 (supports raytracing)
+//CHECK: warning 36113
+//CHECK: main
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+[shader("_raygen")]
+void main()
+{
+ RayDesc ray;
+ ray.Origin = float3(0,0,0);
+ ray.Direction = float3(0,0,0);
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = {};
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ outputBuffer[0] = payload.data;
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-6.slang b/tests/language-feature/capability/explicit-shader-stage-6.slang
new file mode 100644
index 000000000..4884c7b85
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-6.slang
@@ -0,0 +1,25 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0
+
+// Our code does not warn here since we specify profile 'sm_5_0' and a raygen shader.
+// raygen implicitly uses "raygen + raytracing" capabilities
+//CHECK: warning 36113
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+[shader("_raygen")]
+void main()
+{
+ RayDesc ray;
+ ray.Origin = float3(0,0,0);
+ ray.Direction = float3(0,0,0);
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = {};
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ outputBuffer[0] = payload.data;
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-7.slang b/tests/language-feature/capability/explicit-shader-stage-7.slang
new file mode 100644
index 000000000..729214cb8
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-7.slang
@@ -0,0 +1,40 @@
+//TEST:SIMPLE(filecheck=CHECK_PASS): -target spirv -entry main -allow-glsl -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_WARN): -target spirv -entry main -allow-glsl -profile sm_5_0 -DWARN
+
+// Our code will stillwarn about spirv version being below 'spirv 1.3'. This is Because we are still using `Profile` internally.
+// 'Profile' is an issue which needs to be refactored out since it only stores the info in a single integer through 'profileRaw'
+//CHECK_PASS: warning 50011
+//
+// Our code does not warn about capabilities here since we specify profile 'sm_5_0' and a 'ser_motion_raygen' shader.
+// 'ser_motion_raygen' implicitly uses "raygen + raytracing_motion + ser" capabilities.
+//CHECK_PASS: main
+
+// On the contrary, our code will warn without 'ser_motion_raygen'.
+//CHECK_WARN: warning 41012
+//CHECK_WARN: warning 50011
+
+
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+#ifndef WARN
+[shader("ser_motion_raygen")]
+#else
+[shader("raygen")]
+#endif
+void main()
+{
+ RayDesc ray;
+ ray.Origin = float3(0,0,0);
+ ray.Direction = float3(0,0,0);
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = {};
+ TraceMotionRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, 0, payload);
+
+ outputBuffer[0] = payload.data;
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-8.slang b/tests/language-feature/capability/explicit-shader-stage-8.slang
new file mode 100644
index 000000000..48afacc3d
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-8.slang
@@ -0,0 +1,14 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -profile sm_5_0
+// CHECK: error 36116
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+[shader("compute_fragment")]
+void main()
+{
+ outputBuffer[0] = 0;
+}
diff --git a/tests/language-feature/capability/explicit-shader-stage-9.slang b/tests/language-feature/capability/explicit-shader-stage-9.slang
new file mode 100644
index 000000000..a37498022
--- /dev/null
+++ b/tests/language-feature/capability/explicit-shader-stage-9.slang
@@ -0,0 +1,25 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -allow-glsl -stage raygeneration -profile sm_6_5
+
+// Our code compiles here since 'raygeneration' stage implies 'raygen+raytracing' capabilities
+//CHECK-NOT: warning 36113
+//CHECK: main
+struct RayPayload
+{
+ uint data;
+};
+
+uniform RaytracingAccelerationStructure sceneBVH;
+RWStructuredBuffer<uint> outputBuffer;
+
+void main()
+{
+ RayDesc ray;
+ ray.Origin = float3(0,0,0);
+ ray.Direction = float3(0,0,0);
+ ray.TMin = 0.001;
+ ray.TMax = 10000.0;
+ RayPayload payload = {};
+ TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
+
+ outputBuffer[0] = payload.data;
+}