X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.h;h=1504acb224e27dd5290947e9700fa657750ba433;hb=0ded10909240623e33712be80855827d440f3caf;hp=e7592c00a29956e7ad4ab09384cf9798b3d1aacf;hpb=22d5405729048ee2677a1e45e309e6328de64a26;p=libs%2Fgl.git diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index e7592c00..1504acb2 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -9,6 +9,22 @@ namespace Msp { namespace GL { namespace SL { +/** Assigns values to specialization constants, turning them into normal +constants. */ +class ConstantSpecializer: private TraversingVisitor +{ +private: + const std::map *values; + +public: + ConstantSpecializer(); + + void apply(Stage &, const std::map &); + +private: + virtual void visit(VariableDeclaration &); +}; + /** Finds functions which are candidates for inlining. Currently this means functions which have no flow control statements, no more than one return statement, and are only called once. */ @@ -23,7 +39,7 @@ private: public: InlineableFunctionLocator(); - const std::set &apply(Stage &s) { s.content.visit(*this); return inlineable; } + std::set apply(Stage &s) { s.content.visit(*this); return inlineable; } private: virtual void visit(FunctionCall &); @@ -41,7 +57,6 @@ class InlineContentInjector: private TraversingVisitor private: enum Pass { - DEPENDS, REFERENCED, INLINE, RENAME @@ -58,7 +73,7 @@ private: public: InlineContentInjector(); - const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionCall &); + std::string apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionCall &); private: virtual void visit(VariableReference &); @@ -109,7 +124,7 @@ private: bool trivial; bool available; - ExpressionInfo(); + ExpressionInfo(): expression(0), assign_scope(0), inline_point(0), trivial(false), available(true) { } }; std::map expressions; @@ -222,11 +237,7 @@ public: bool apply(Stage &); private: - virtual void visit(Literal &); - virtual void visit(UnaryExpression &); - virtual void visit(BinaryExpression &); - virtual void visit(TernaryExpression &); - virtual void visit(FunctionCall &); + virtual void visit(RefPtr &); virtual void visit(BasicTypeDeclaration &); virtual void visit(ImageTypeDeclaration &); virtual void visit(StructDeclaration &);