summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/capability
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-04-19 23:18:40 -0400
committerGitHub <noreply@github.com>2024-04-19 20:18:40 -0700
commitf9bcad35562c1f08638e6d3eb397d370d7d2f8f8 (patch)
tree4e2a993689209bd5b597263922af03cb87d07c3d /tests/language-feature/capability
parent2da28c50d9c3699692eccde4b86d0b8d2323e55c (diff)
Initial pass to add capability declarations to stdlib intrinsics. (#3912)
Diffstat (limited to 'tests/language-feature/capability')
-rw-r--r--tests/language-feature/capability/capability-invalid-compute-in-fragment.slang10
-rw-r--r--tests/language-feature/capability/capability-invalid-fragment-in-compute.slang21
-rw-r--r--tests/language-feature/capability/capability3.slang43
-rw-r--r--tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang32
-rw-r--r--tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang34
-rw-r--r--tests/language-feature/capability/cpp-target-missing-cpp-impl.slang34
6 files changed, 149 insertions, 25 deletions
diff --git a/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang b/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang
new file mode 100644
index 000000000..d36a62adf
--- /dev/null
+++ b/tests/language-feature/capability/capability-invalid-compute-in-fragment.slang
@@ -0,0 +1,10 @@
+//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry main -stage fragment -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -entry main -stage fragment -allow-glsl -ignore-capabilities
+// CHECK_IGNORE_CAPS-NOT: error 36107
+// CHECK: error 36107
+
+float4 main()
+{
+ memoryBarrierAtomicCounter();
+ return float4(1.0f);
+}
diff --git a/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang
new file mode 100644
index 000000000..946ba4470
--- /dev/null
+++ b/tests/language-feature/capability/capability-invalid-fragment-in-compute.slang
@@ -0,0 +1,21 @@
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPRE
+//TEST:SIMPLE(filecheck=CHECK): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -DPOST
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPRE
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target hlsl -emit-spirv-directly -entry computeMain -stage compute -allow-glsl -ignore-capabilities -DPOST
+
+// CHECK_IGNORE_CAPS-NOT: error 36107
+// CHECK: error 36107
+SamplerState samplerState;
+Texture2D<int> rw;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+#ifdef PRE
+ rw.Load(0);
+#endif
+ clip(0.0f);
+#ifdef POST
+ rw.Load(0);
+#endif
+} \ No newline at end of file
diff --git a/tests/language-feature/capability/capability3.slang b/tests/language-feature/capability/capability3.slang
index 02eb7d495..96c07a51f 100644
--- a/tests/language-feature/capability/capability3.slang
+++ b/tests/language-feature/capability/capability3.slang
@@ -3,47 +3,40 @@
// CHECK_IGNORE_CAPS-NOT: error 36108
// Test that capabilities can be declared on module.
-
[require(glsl)]
[require(spirv)]
module test;
-void f()
-{
- __require_capability glsl;
-}
-
-// CHECK: ([[# @LINE+1]]): error 36108
-public void g()
-{
- __require_capability spvAtomicFloat16AddEXT;
-}
+RWStructuredBuffer<int> sideEffect;
-void l()
+// CHECK: error 36104
+[require(glsl, _sm_4_0)]
+public void use1()
{
__target_switch
{
case glsl:
- f();
- return;
- case spirv:
- __require_capability spvAtomicFloat16AddEXT;
return;
}
}
-// CHECK: ([[# @LINE+1]]): error 36104: {{.*}}
-public void use()
+void use2Sub()
{
- l(); // Error
+ __target_switch
+ {
+ case glsl:
+ sideEffect[1] = 1;
+ }
}
-
-// CHECK-NOT: ([[# @LINE+1]]): error
-[require(spirv, spvAtomicFloat16AddEXT)]
-public void use1()
+// CHECK: error 36108
+[require(spirv, spirv_1_0)]
+public void use2()
{
- l(); // Error
+ use2Sub();
}
void main()
-{} \ No newline at end of file
+{
+ use1();
+ use2();
+} \ No newline at end of file
diff --git a/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang
new file mode 100644
index 000000000..46ffaf2a7
--- /dev/null
+++ b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default.slang
@@ -0,0 +1,32 @@
+//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl
+
+// CHECK: computeMain(
+
+layout(binding = 0) buffer MyBlockName
+{
+ int v[1];
+} outputBuffer;
+
+// `default` only should try to define `glsl`, but glsl target is
+// present in a `case` statment. Therefore this code should error
+// since cpp is missing a target for a function called
+[require(cpp_glsl)]
+void someInternalFunc()
+{
+ __target_switch
+ {
+ case glsl:
+ outputBuffer.v[0] = 0;
+ default:
+ outputBuffer.v[0] = 0;
+ }
+}
+void someMin()
+{
+ someInternalFunc();
+}
+[numthreads(1,1,1)]
+void computeMain()
+{
+ someMin();
+}
diff --git a/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang
new file mode 100644
index 000000000..fc8983ef1
--- /dev/null
+++ b/tests/language-feature/capability/cpp-target-has-cpp-impl-from-default2.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl
+
+// CHECK: computeMain(
+
+layout(binding = 0) buffer MyBlockName
+{
+ int v[1];
+} outputBuffer;
+
+// `default` only should try to define `glsl`, but glsl target is
+// present in a `case` statment. Therefore this code should error
+// since cpp is missing a target for a function called
+[require(cpp)]
+[require(glsl)]
+[require(spirv)]
+void someInternalFunc()
+{
+ __target_switch
+ {
+ case glsl:
+ outputBuffer.v[0] = 0;
+ default:
+ outputBuffer.v[0] = 0;
+ }
+}
+void someMin()
+{
+ someInternalFunc();
+}
+[numthreads(1,1,1)]
+void computeMain()
+{
+ someMin();
+}
diff --git a/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang b/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang
new file mode 100644
index 000000000..a01993e8f
--- /dev/null
+++ b/tests/language-feature/capability/cpp-target-missing-cpp-impl.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK): -target cpp -entry computeMain -stage compute -allow-glsl
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target cpp -entry computeMain -stage compute -allow-glsl -ignore-capabilities
+// CHECK_IGNORE_CAPS-NOT: error 36107
+// CHECK: error 36107
+
+layout(binding = 0) buffer MyBlockName
+{
+ int v[1];
+} outputBuffer;
+
+// `default` only should try to define `glsl`, but glsl target is
+// present in a `case` statment. Therefore this code should error
+// since cpp is missing a target for a function called
+[require(glsl)]
+void someInternalFunc()
+{
+ __target_switch
+ {
+ case glsl:
+ outputBuffer.v[0] = 0;
+ default:
+ outputBuffer.v[0] = 0;
+ }
+}
+void someMin()
+{
+ someInternalFunc();
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ someMin();
+}