]> 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 21b4e316d0eec52ae34e5c5c050d15e024656bb7..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
@@ -36,7 +56,6 @@ class LegacyConverter: private TraversingVisitor
 private:
        Stage *stage;
        Features features;
-       std::string r_type;
        VariableDeclaration *frag_out;
        NodeList<Statement>::iterator uniform_insert_point;
        std::set<Node *> nodes_to_remove;
@@ -59,10 +78,13 @@ private:
        bool supports_unified_sampling_functions() const;
        virtual void visit(FunctionCall &);
        bool supports_interface_layouts() const;
+       bool supports_stage_interface_layouts() const;
        bool supports_centroid_sampling() const;
        bool supports_sample_sampling() const;
+       bool supports_uniform_location() const;
        virtual void visit(VariableDeclaration &);
        bool supports_interface_blocks(const std::string &) const;
+       bool supports_interface_block_location() const;
        virtual void visit(InterfaceBlock &);
 };