X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Freflect.h;h=d48fbec156506f31fda79fd86aa676b8257a128d;hp=8de915729ce50e8748c9e8011419d5bd4f7cf6b8;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=cc5483cc709fdf7b6966a3e69dabfcafebaaffa0 diff --git a/source/glsl/reflect.h b/source/glsl/reflect.h index 8de91572..d48fbec1 100644 --- a/source/glsl/reflect.h +++ b/source/glsl/reflect.h @@ -7,20 +7,23 @@ 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 { private: - Node *first; - Node *second; - unsigned first_tag; - bool r_result; + Node *first = 0; + Node *second = 0; + unsigned first_tag = 0; + bool r_result = false; static unsigned next_tag; public: - TypeComparer(); - bool apply(TypeDeclaration &t1, TypeDeclaration &t2) { compare(t1, t2); return r_result; } private: @@ -29,6 +32,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 &); @@ -39,11 +45,9 @@ private: class LocationCounter: private NodeVisitor { private: - unsigned r_count; + unsigned r_count = 0; public: - LocationCounter(); - unsigned apply(VariableDeclaration &v) { v.visit(*this); return r_count; } private: @@ -66,9 +70,9 @@ public: Result(unsigned s, unsigned a): size(s), alignment(a), stride(s+a-1-(s+a-1)%a) { } }; private: - unsigned r_size; - unsigned r_alignment; - int r_offset; + unsigned r_size = 0; + unsigned r_alignment = 1; + int r_offset = -1; public: Result apply(VariableDeclaration &v) { v.visit(*this); return Result(r_size, r_alignment); }