]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/validate.h
Validate location overlap and type matching for GLSL interfaces
[libs/gl.git] / source / glsl / validate.h
index f1e3f5126eb8422624524979a8768165b5451396..63af3610a3b9a81e7bc3c73921eb6c16c3808964 100644 (file)
@@ -127,6 +127,48 @@ 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 Binding
+       {
+               Node *node;
+               TypeDeclaration *type;
+               std::string name;
+
+               Binding(VariableDeclaration &v): node(&v), type(v.type_declaration), name(v.name) { }
+               Binding(InterfaceBlock &i): node(&i), type(i.struct_declaration), name(i.block_name) { }
+       };
+
+       std::map<unsigned, std::map<unsigned, Binding> > used_bindings;
+
+public:
+       void apply(Module &);
+
+private:
+       void get_binding(const Layout &, unsigned &, int &);
+       void check_binding(const Layout &, const Binding &);
+
+       virtual void visit(VariableDeclaration &);
+       virtual void visit(InterfaceBlock &);
+       virtual void visit(FunctionDeclaration &) { }
+};
+
 } // namespace SL
 } // namespace GL
 } // namespace Msp