]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/finalize.h
Rearrange some utility struct constructors
[libs/gl.git] / source / glsl / finalize.h
index 36b349125f51eb236cff061d9c08c0ad49c2a542..0638026dba207f2e7d48a209d2a2f3d6ea49c11c 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef MSP_GL_SL_COMPATIBILITY_H_
-#define MSP_GL_SL_COMPATIBILITY_H_
+#ifndef MSP_GL_SL_FINALIZE_H_
+#define MSP_GL_SL_FINALIZE_H_
 
 #include <string>
 #include "visitor.h"
@@ -8,23 +8,38 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
+/** Assigns location and binding layout qualifiers to interface variables and
+blocks. */
 class LocationAllocator: private TraversingVisitor
 {
 private:
+       struct Uniform
+       {
+               int location;
+               int desc_set;
+               int bind_point;
+
+               Uniform(): location(-1), desc_set(-1), bind_point(-1) { }
+       };
+
        std::map<std::string, std::set<unsigned> > used_locations;
-       std::map<std::string, unsigned> uniform_locations;
+       std::map<std::string, Uniform> uniforms;
+       std::map<unsigned, std::set<unsigned> > used_bindings;
        std::vector<VariableDeclaration *> unplaced_variables;
+       std::vector<VariableDeclaration *> unbound_textures;
+       std::vector<InterfaceBlock *> unbound_blocks;
 
 public:
-       void apply(Module &);
+       void apply(Module &, const Features &);
 private:
        void apply(Stage &);
 
        void allocate_locations(const std::string &);
-       void add_location(RefPtr<Layout> &, unsigned);
+       void bind_uniform(RefPtr<Layout> &, const std::string &, unsigned);
+       void add_layout_value(RefPtr<Layout> &, const std::string &, unsigned);
 
        virtual void visit(VariableDeclaration &);
-       virtual void visit(InterfaceBlock &) { }
+       virtual void visit(InterfaceBlock &);
        virtual void visit(FunctionDeclaration &) { }
 };
 
@@ -82,6 +97,7 @@ private:
        bool supports_centroid_sampling() const;
        bool supports_sample_sampling() const;
        bool supports_uniform_location() const;
+       bool supports_binding() const;
        virtual void visit(VariableDeclaration &);
        bool supports_interface_blocks(const std::string &) const;
        bool supports_interface_block_location() const;