X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=162ed9c0b8bcf4ddb01daf17724e4308138decd0;hb=8967d38bc578f1653c1dde01dce49a8f7b0c912e;hp=c03a5ccbd8b57044db6b28355863bac292c47a75;hpb=8f5f54a9e165dae424e5b0bb8e488c3d01849bf6;p=libs%2Fgl.git diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index c03a5ccb..162ed9c0 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -7,6 +7,7 @@ namespace Msp { namespace GL { namespace SL { +/** Determines the number of interface locations required by a variable. */ class LocationCounter: private NodeVisitor { private: @@ -24,6 +25,49 @@ private: virtual void visit(VariableDeclaration &); }; +/** Determines the size and alignment of a variable, in bytes. */ +class MemoryRequirementsCalculator: private NodeVisitor +{ +public: + struct Result + { + unsigned size; + unsigned alignment; + + Result(unsigned s, unsigned a): size(s), alignment(a) { } + }; +private: + unsigned r_size; + unsigned r_alignment; + int r_offset; + +public: + Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); } + +private: + virtual void visit(BasicTypeDeclaration &); + virtual void visit(StructDeclaration &); + virtual void visit(VariableDeclaration &); +}; + +/** Collects dependencies of a function. This includes global variables, +interface blocks, other functions and types. */ +class DependencyCollector: private TraversingVisitor +{ +private: + std::set dependencies; + std::set locals; + +public: + std::set apply(FunctionDeclaration &); + +private: + virtual void visit(VariableReference &); + virtual void visit(InterfaceBlockReference &); + virtual void visit(FunctionCall &); + virtual void visit(VariableDeclaration &); +}; + } // namespace SL } // namespace GL } // namespace Msp