X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Ffinalize.h;h=3db581be732cd3c5ea7e0b40fce67498db9e1e45;hb=8f2713a3f1501e90016bb8069ecd08dde2f90e56;hp=357351b476bd071500847c5653e044025a82c082;hpb=9cfccf5c4e366e033cfd5eebf8955d2b13202b46;p=libs%2Fgl.git diff --git a/source/glsl/finalize.h b/source/glsl/finalize.h index 357351b4..3db581be 100644 --- a/source/glsl/finalize.h +++ b/source/glsl/finalize.h @@ -8,6 +8,39 @@ namespace Msp { namespace GL { namespace SL { +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 > used_locations; + std::map uniforms; + std::map > used_bindings; + std::vector unplaced_variables; + std::vector unbound_textures; + std::vector unbound_blocks; + +public: + void apply(Module &, const Features &); +private: + void apply(Stage &); + + void allocate_locations(const std::string &); + void bind_uniform(RefPtr &, const std::string &, unsigned); + void add_layout_value(RefPtr &, const std::string &, 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 @@ -62,6 +95,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;