]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/validate.h
Even more validation for uniform mismatches
[libs/gl.git] / source / glsl / validate.h
index f1e3f5126eb8422624524979a8768165b5451396..acb5b4e4086810972263a03ad5f2cb065fc205d1 100644 (file)
@@ -127,6 +127,53 @@ private:
        virtual void visit(Return &);
 };
 
+class StageInterfaceValidator: private Validator
+{
+private:
+       std::map<std::string, std::map<unsigned, VariableDeclaration *> > used_locations;
+
+public:
+       void apply(Stage &s) { stage = &s; s.content.visit(*this); }
+
+private:
+       int get_location(const Layout &);
+
+       virtual void visit(VariableDeclaration &);
+       virtual void visit(FunctionDeclaration &) { }
+};
+
+class GlobalInterfaceValidator: private Validator
+{
+private:
+       struct Uniform
+       {
+               Node *node;
+               TypeDeclaration *type;
+               std::string name;
+               int location;
+               unsigned loc_count;
+               int desc_set;
+               int bind_point;
+
+               Uniform(): node(0), type(0), location(-1), loc_count(1), desc_set(0), bind_point(-1) { }
+       };
+
+       std::list<Uniform> uniforms;
+       std::map<std::string, const Uniform *> used_names;
+       std::map<unsigned, const Uniform *> used_locations;
+       std::map<unsigned, std::map<unsigned, const Uniform *> > used_bindings;
+
+public:
+       void apply(Module &);
+
+private:
+       void check_uniform(const Uniform &);
+
+       virtual void visit(VariableDeclaration &);
+       virtual void visit(InterfaceBlock &);
+       virtual void visit(FunctionDeclaration &) { }
+};
+
 } // namespace SL
 } // namespace GL
 } // namespace Msp