X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.h;h=6250130fb30a39bfd9b18c82cdc9acf654c347ad;hb=59347f76bc985e8c9c769d4a3eee672cba9c920b;hp=ea61b671d2e1ea2a68b10c4b4682e8cb6a560260;hpb=72a02f2f3f1c454aa670b256262d7bc0541222e3;p=libs%2Fgl.git diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index ea61b671..6250130f 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -116,22 +116,32 @@ Variables which are only referenced once are also inlined. */ class ExpressionInliner: private TraversingVisitor { private: + struct ExpressionUse + { + RefPtr *reference; + Block *ref_scope; + bool blocked; + + ExpressionUse(): reference(0), ref_scope(0), blocked(false) { } + }; + struct ExpressionInfo { - Expression *expression; + Assignment::Target target; + RefPtr expression; Block *assign_scope; - RefPtr *inline_point; + std::vector uses; bool trivial; - bool available; - ExpressionInfo(): expression(0), assign_scope(0), inline_point(0), trivial(false), available(true) { } + ExpressionInfo(): expression(0), assign_scope(0), trivial(false) { } }; - std::map expressions; + std::list expressions; + std::map assignments; ExpressionInfo *r_ref_info; - bool r_any_inlined; bool r_trivial; - bool mutating; + bool access_read; + bool access_write; bool iteration_init; Block *iteration_body; const Operator *r_oper; @@ -142,8 +152,6 @@ public: bool apply(Stage &); private: - void inline_expression(Expression &, RefPtr &); - virtual void visit(Block &); virtual void visit(RefPtr &); virtual void visit(VariableReference &); virtual void visit(MemberAccess &); @@ -175,13 +183,16 @@ public: bool apply(Stage &s) { s.content.visit(*this); return r_any_folded; } private: - static BasicTypeDeclaration::Kind get_value_kind(const Variant &); template static T evaluate_logical(char, T, T); template static bool evaluate_relation(const char *, T, T); template static T evaluate_arithmetic(char, T, T); + template + static T evaluate_int_special_op(char, T, T); + template + void convert_to_result(const Variant &); void set_result(const Variant &, bool = false); virtual void visit(RefPtr &); @@ -276,6 +287,7 @@ private: Node *node; Assignment::Target target; std::vector used_by; + unsigned in_loop; AssignmentInfo(): node(0) { } }; @@ -302,6 +314,8 @@ private: bool r_side_effects; bool in_struct; bool composite_reference; + unsigned in_loop; + std::vector loop_ext_refs; Assignment::Target r_reference; std::set unused_nodes;