X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=162ed9c0b8bcf4ddb01daf17724e4308138decd0;hp=72a50c3eb6368b303ba5bd6e2fad8f7095e0189b;hb=8967d38bc578f1653c1dde01dce49a8f7b0c912e;hpb=42903b905cd3924ecc45d3cb08222bc3548cab91 diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 72a50c3e..162ed9c0 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -25,6 +25,31 @@ 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