]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/finalize.h
Allocate locations to interface variables
[libs/gl.git] / source / glsl / finalize.h
index 357351b476bd071500847c5653e044025a82c082..36b349125f51eb236cff061d9c08c0ad49c2a542 100644 (file)
@@ -8,6 +8,26 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
+class LocationAllocator: private TraversingVisitor
+{
+private:
+       std::map<std::string, std::set<unsigned> > used_locations;
+       std::map<std::string, unsigned> uniform_locations;
+       std::vector<VariableDeclaration *> unplaced_variables;
+
+public:
+       void apply(Module &);
+private:
+       void apply(Stage &);
+
+       void allocate_locations(const std::string &);
+       void add_location(RefPtr<Layout> &, unsigned);
+
+       virtual void visit(VariableDeclaration &);
+       virtual void visit(InterfaceBlock &) { }
+       virtual void visit(FunctionDeclaration &) { }
+};
+
 /** Generates default precision declarations or removes precision declarations
 according to the requirements of the target API. */
 class PrecisionConverter: private TraversingVisitor