summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/capability
diff options
context:
space:
mode:
authorArielG-NV <159081215+ArielG-NV@users.noreply.github.com>2024-07-23 09:36:38 -0400
committerGitHub <noreply@github.com>2024-07-23 09:36:38 -0400
commit509bfd8bbaaf021507c4045b5fd9eaf43276dc0a (patch)
tree7adab692d0ec55935d8372d9422b7a653068251a /tests/language-feature/capability
parent15f091aabf5b6f8d37d292dab150395d8a37d644 (diff)
Simplify `CapabilitySet` Diagnostic Printing (#4678)
Fixes: #4675 Fixes: #4683 Fixes: #4443 Fixes: #4585 Fixes: #4172 Made the following changes: 1. All capability diagnostic printing logic tries to simplify before printing. This means that we do not print atoms which imply another atom. 2. Do not print the `_` prefix part of atom names since it is misleading users on what they should use to solve a capability issue encountered. (`_Internal` `External` atom changes are not in this PR) 3. Bundle together printing of all sets which contain exactly the same atoms (excluding abstract atoms). This allows printing the following `vertex/fragment/hull/domain/... + glsl` instead of `vertex + glsl | fragment + glsl | hull + glsl | domain + glsl | ....` 4. Rework how entry-point errors are reported to users (example at bottom of PR comment) 5. Rework how atom-provenance data is collected to be leaner and more useful so we can rework the errors. There are 2 notable changes here: * We no longer store a list which describes where the first of an `CapabilityAtom` comes from. This heavily simplifies AST logic for the capability system. AST parsing of capabilities is much faster. The trade-off is faster AST parsing and correct AST node data for slower diagnostics if an error is found * atom-provenance data now stores a reference to an atom's use-site to provide information on **where** and **what** is wrong with user code versus only sharing **what** and not where.
Diffstat (limited to 'tests/language-feature/capability')
-rw-r--r--tests/language-feature/capability/capability7.slang52
-rw-r--r--tests/language-feature/capability/capabilitySimplification1.slang34
-rw-r--r--tests/language-feature/capability/capabilitySimplification2.slang27
-rw-r--r--tests/language-feature/capability/capabilitySimplification3.slang17
4 files changed, 130 insertions, 0 deletions
diff --git a/tests/language-feature/capability/capability7.slang b/tests/language-feature/capability/capability7.slang
new file mode 100644
index 000000000..21f3d68e4
--- /dev/null
+++ b/tests/language-feature/capability/capability7.slang
@@ -0,0 +1,52 @@
+//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities
+
+// Test that we diagnose simplified capabilities
+// CHECK_IGNORE_CAPS-NOT: error 36104
+// CHECK-NOT: sm_4_0
+// CHECK-NOT: sm_5_0
+// CHECK-NOT: sm_5_1
+// CHECK: error 36104: 'processDataBad' uses undeclared capability 'sm_6_0'
+// CHECK: capability7.slang(28): note: see using of 'processDataBadNested'
+// CHECK: capability7.slang(20): note: see definition of 'processDataBadNested'
+
+
+[require(glsl_hlsl_metal_spirv)]
+void processDataGood()
+{
+}
+
+[require(hlsl, sm_6_0)]
+void processDataBadNested()
+{
+ AllMemoryBarrier();
+}
+
+[require(hlsl)]
+void processDataBad()
+{
+ processDataBadNested();
+}
+
+void myNestedNestedSafeCall()
+{
+ processDataGood();
+}
+
+void myNestedNestedBadCall()
+{
+ processDataGood();
+ processDataBad();
+}
+
+void myNestedCall()
+{
+ myNestedNestedSafeCall();
+ myNestedNestedBadCall();
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ myNestedCall();
+}
diff --git a/tests/language-feature/capability/capabilitySimplification1.slang b/tests/language-feature/capability/capabilitySimplification1.slang
new file mode 100644
index 000000000..b694673e9
--- /dev/null
+++ b/tests/language-feature/capability/capabilitySimplification1.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities
+
+
+// CHECK_IGNORE_CAPS-NOT: error 36107
+
+// CHECK: error 36107
+// CHECK-SAME: entrypoint 'computeMain' does not support compilation target 'glsl' with stage 'compute'
+// CHECK: capabilitySimplification1.slang(21): note: see using of 'WaveMultiPrefixProduct'
+// CHECK-NOT: see using of 'WaveMultiPrefixProduct'
+// CHECK: {{.*}}.meta.slang({{.*}}): note: see definition of 'WaveMultiPrefixProduct'
+// CHECK: {{.*}}.meta.slang({{.*}}): note: see declaration of 'require'
+
+void nestedSafeCall()
+{
+ AllMemoryBarrier();
+}
+
+void nestedBadCall()
+{
+ WaveMultiPrefixProduct(1, 0);
+}
+
+void nestedCall()
+{
+ nestedSafeCall();
+ nestedBadCall();
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ nestedCall();
+}
diff --git a/tests/language-feature/capability/capabilitySimplification2.slang b/tests/language-feature/capability/capabilitySimplification2.slang
new file mode 100644
index 000000000..8d96884ce
--- /dev/null
+++ b/tests/language-feature/capability/capabilitySimplification2.slang
@@ -0,0 +1,27 @@
+//TEST:SIMPLE(filecheck=SPIRV): -target spirv -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=GLSL): -target glsl -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=HLSL): -target hlsl -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target spirv -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities
+
+
+// CHECK_IGNORE_CAPS-NOT: warning 41012
+
+// SPIRV: warning 41012
+// SPIRV-NOT: spirv_1_2
+// SPIRV-NOT: spirv_1_3
+// SPIRV-SAME: spvGroupNonUniformBallot
+
+// GLSL: warning 41012
+// GLSL-NOT: GLSL_400
+// GLSL-NOT: GLSL_430
+// GLSL-SAME: GL_KHR_shader_subgroup_ballot
+
+// HLSL: warning 41012
+// HLSL-NOT: sm_5_1
+// HLSL-SAME: sm_6_0
+
+[require(sm_6_0)]
+[numthreads(1,1,1)]
+void computeMain()
+{
+}
diff --git a/tests/language-feature/capability/capabilitySimplification3.slang b/tests/language-feature/capability/capabilitySimplification3.slang
new file mode 100644
index 000000000..faf161d15
--- /dev/null
+++ b/tests/language-feature/capability/capabilitySimplification3.slang
@@ -0,0 +1,17 @@
+//TEST:SIMPLE(filecheck=CHECK): -target glsl -entry computeMain -stage compute -profile sm_5_0
+//TEST:SIMPLE(filecheck=CHECK_IGNORE_CAPS): -target glsl -emit-spirv-directly -entry computeMain -stage compute -profile sm_5_0 -ignore-capabilities
+
+
+// CHECK_IGNORE_CAPS-NOT: error 36107
+
+// CHECK: error 36107: entrypoint 'computeMain' does not support compilation target 'glsl' with stage 'compute'
+// CHECK: capabilitySimplification3.slang(16): note: see using of 'WaveMultiPrefixProduct'
+// CHECK-NOT: see using of 'WaveMultiPrefixProduct'
+// CHECK: {{.*}}.meta.slang({{.*}}): note: see definition of 'WaveMultiPrefixProduct'
+// CHECK: {{.*}}.meta.slang({{.*}}): note: see declaration of 'require'
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ WaveMultiPrefixProduct(1, 0);
+}