]> git.tdb.fi Git - libs/gl.git/commitdiff
Validate that compute shaders specify a workgroup size
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Sep 2022 12:05:33 +0000 (15:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Sep 2022 12:40:31 +0000 (15:40 +0300)
source/glsl/validate.cpp
source/glsl/validate.h
tests/glsl/missing_workgroup_size.glsl [new file with mode: 0644]

index 4c135892056c1e82b3c33ca0536232202a05ac69..5a28fcb6abca0ec042dda6f41aff0f5d6067053d 100644 (file)
@@ -60,6 +60,11 @@ void DeclarationValidator::apply(Stage &s, const Features &f)
                if(!have_output_vertex_count)
                        error(*global_err_node, "No vertex count qualifier found on output");
        }
+       else if(s.type==Stage::COMPUTE)
+       {
+               if(!have_workgroup_size)
+                       error(*global_err_node, "No workgroup size qualifier found");
+       }
 }
 
 const char *DeclarationValidator::describe_variable(ScopeType scope)
@@ -193,7 +198,11 @@ void DeclarationValidator::visit(Layout &layout)
                        value = false;
                }
                else if(q.name=="local_size_x" || q.name=="local_size_y" || q.name=="local_size_z")
+               {
                        allowed = (stage->type==Stage::COMPUTE && iface_layout && iface_layout->interface=="in");
+                       if(allowed)
+                               have_workgroup_size = true;
+               }
                else if(q.name=="rgba32f" || q.name=="rgba16f" || q.name=="rg32f" || q.name=="rg16f" || q.name=="r32f" || q.name=="r16f" ||
                        q.name=="rgba16" || q.name=="rgba8" || q.name=="rg16" || q.name=="rg8" || q.name=="r16" || q.name=="r8" ||
                        q.name=="rgba16_snorm" || q.name=="rgba8_snorm" || q.name=="rg16_snorm" || q.name=="rg8_snorm" || q.name=="r16_snorm" || q.name=="r8_snorm")
index f562043576e0b8db285b3a9d2a821c78977979c3..3166c39bf9bd304c15067c77984e089fd417b22a 100644 (file)
@@ -47,6 +47,7 @@ private:
        bool have_input_primitive = false;
        bool have_output_primitive = false;
        bool have_output_vertex_count = false;
+       bool have_workgroup_size = false;
 
 public:
        void apply(Stage &, const Features &);
diff --git a/tests/glsl/missing_workgroup_size.glsl b/tests/glsl/missing_workgroup_size.glsl
new file mode 100644 (file)
index 0000000..376ebaa
--- /dev/null
@@ -0,0 +1,10 @@
+#pragma MSP stage(compute)
+layout(r32f) uniform image2D img;
+void main()
+{
+       imageStore(img, ivec2(gl_GlobalInvocationID.xy), vec4(1.0));
+}
+
+/* Expected error:
+<test>:3: No workgroup size qualifier found
+*/