X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=6c00bca8de3d7f5f8dc3372dfd45cc8937b0568f;hb=3f245515062d10e4d527827e5126fe412de06ce0;hp=c2d7aa0483bd36e4411a55c2d5325158dfae1b92;hpb=c72c4ebe384a0d5a48c268d09449707bd86090a8;p=libs%2Fgl.git diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index c2d7aa04..6c00bca8 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -7,6 +7,11 @@ namespace Msp { namespace GL { namespace SL { +bool is_scalar(const BasicTypeDeclaration &); +bool is_vector_or_matrix(const BasicTypeDeclaration &); +BasicTypeDeclaration *get_element_type(BasicTypeDeclaration &); +bool can_convert(const BasicTypeDeclaration &, const BasicTypeDeclaration &); + /** Compares two types for equality. Struct types are compared recursively. */ class TypeComparer: private NodeVisitor { @@ -29,6 +34,9 @@ private: T *multi_visit(T &); virtual void visit(Literal &); virtual void visit(VariableReference &); + virtual void visit(UnaryExpression &); + virtual void visit(BinaryExpression &); + virtual void visit(TernaryExpression &); virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); virtual void visit(StructDeclaration &); @@ -53,7 +61,7 @@ private: virtual void visit(VariableDeclaration &); }; -/** Determines the size and alignment of a variable, in bytes. */ +/** Determines the size and alignment of a variable or a type, in bytes. */ class MemoryRequirementsCalculator: private NodeVisitor { public: @@ -61,8 +69,9 @@ public: { unsigned size; unsigned alignment; + unsigned stride; - Result(unsigned s, unsigned a): size(s), alignment(a) { } + Result(unsigned s, unsigned a): size(s), alignment(a), stride(s+a-1-(s+a-1)%a) { } }; private: unsigned r_size; @@ -71,6 +80,7 @@ private: public: Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); } + Result apply(TypeDeclaration &t) { t.visit(*this); return Result(r_size, r_alignment); } private: virtual void visit(BasicTypeDeclaration &);