X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fvalidate.cpp;h=4c135892056c1e82b3c33ca0536232202a05ac69;hb=abcd1fa06f9fab27c5934b4069523dd009862b18;hp=d669b2370e08bbb9032d02d308a6377210dd0fa4;hpb=30c7ba8f7fd08c13562c86bf651bdc3ec8d30ab5;p=libs%2Fgl.git diff --git a/source/glsl/validate.cpp b/source/glsl/validate.cpp index d669b237..4c135892 100644 --- a/source/glsl/validate.cpp +++ b/source/glsl/validate.cpp @@ -39,6 +39,27 @@ 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::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"); + } } const char *DeclarationValidator::describe_variable(ScopeType scope) @@ -118,21 +139,36 @@ void DeclarationValidator::visit(Layout &layout) { allowed = (stage->type==Stage::GEOMETRY && iface_layout && (iface_layout->interface=="in" || iface_layout->interface=="out")); value = false; + if(allowed) + { + if(iface_layout->interface=="in") + have_input_primitive = true; + else if(iface_layout->interface=="out") + have_output_primitive = true; + } } else if(q.name=="lines" || q.name=="lines_adjacency" || q.name=="triangles" || q.name=="triangles_adjacency") { allowed = (stage->type==Stage::GEOMETRY && iface_layout && iface_layout->interface=="in"); value = false; + if(allowed) + have_input_primitive = true; } else if(q.name=="line_strip" || q.name=="triangle_strip") { allowed = (stage->type==Stage::GEOMETRY && iface_layout && iface_layout->interface=="out"); value = false; + if(allowed) + have_output_primitive = true; } else if(q.name=="invocations") allowed = (stage->type==Stage::GEOMETRY && iface_layout && iface_layout->interface=="in"); else if(q.name=="max_vertices") + { allowed = (stage->type==Stage::GEOMETRY && iface_layout && iface_layout->interface=="out"); + if(allowed) + have_output_vertex_count = true; + } else if(q.name=="std140" || q.name=="std430") { allowed = (iface_block && !variable && iface_block->interface=="uniform");