X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Ffinalize.h;h=fd29737a713b3ed331e9ba4b0bddb2e13b9f72a6;hb=8967d38bc578f1653c1dde01dce49a8f7b0c912e;hp=36b349125f51eb236cff061d9c08c0ad49c2a542;hpb=7b03ca83ca6c48b9f8c3f77c13760e7f87e9632d;p=libs%2Fgl.git diff --git a/source/glsl/finalize.h b/source/glsl/finalize.h index 36b34912..fd29737a 100644 --- a/source/glsl/finalize.h +++ b/source/glsl/finalize.h @@ -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 #include "visitor.h" @@ -8,23 +8,54 @@ namespace Msp { namespace GL { namespace SL { +/** Assigns offset layout qualifiers to struct members. */ +class StructOrganizer: private TraversingVisitor +{ +private: + int offset; + +public: + StructOrganizer(); + + void apply(Stage &s) { s.content.visit(*this); } + +private: + virtual void visit(StructDeclaration &); + virtual void visit(VariableDeclaration &); +}; + +/** 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 > used_locations; - std::map uniform_locations; + std::map uniforms; + std::map > used_bindings; std::vector unplaced_variables; + std::vector unbound_textures; + std::vector 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 &, unsigned); + 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(InterfaceBlock &); virtual void visit(FunctionDeclaration &) { } }; @@ -82,6 +113,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;