+void DeclarationValidator::apply(Stage &s, const Features &f)
+{
+ stage = &s;
+ features = f;
+ s.content.visit(*this);
+
+ Node *global_err_node = 0;
+ auto i = s.functions.find("main()");
+ if(i!=s.functions.end())
+ global_err_node = i->second;
+ else
+ {
+ for(auto j=s.content.body.begin(); (!global_err_node && j!=s.content.body.end()); ++j)
+ if((*j)->source>0)
+ global_err_node = j->get();
+ }
+
+ if(s.type==Stage::TESS_CONTROL)
+ {
+ if(!have_output_vertex_count)
+ error(*global_err_node, "No vertex count qualifier found on output");
+ }
+ else if(s.type==Stage::TESS_EVAL)
+ {
+ if(!have_input_primitive)
+ error(*global_err_node, "No primitive type qualifier found on input");
+ }
+ else if(s.type==Stage::GEOMETRY)
+ {
+ if(!have_input_primitive)
+ error(*global_err_node, "No primitive type qualifier found on input");
+ if(!have_output_primitive)
+ error(*global_err_node, "No primitive type qualifier found on output");
+ 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");
+ }
+}