X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.h;h=e7592c00a29956e7ad4ab09384cf9798b3d1aacf;hb=22d5405729048ee2677a1e45e309e6328de64a26;hp=bffc5a036197cc7f3a46e829018a38d98dac7495;hpb=6592dca643d9ac5b99d6a43cae30554ac1e4df62;p=libs%2Fgl.git diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index bffc5a03..e7592c00 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -10,8 +10,8 @@ namespace GL { namespace SL { /** Finds functions which are candidates for inlining. Currently this means -functions which have no parameters, contain no more than one return statement, -and are only called once. */ +functions which have no flow control statements, no more than one return +statement, and are only called once. */ class InlineableFunctionLocator: private TraversingVisitor { private: @@ -39,11 +39,17 @@ dependencies of the inlined statements to appear before the target function. */ class InlineContentInjector: private TraversingVisitor { private: + enum Pass + { + DEPENDS, + REFERENCED, + INLINE, + RENAME + }; + FunctionDeclaration *source_func; - Block *target_block; - std::map variable_map; - std::string remap_prefix; - unsigned remap_names; + Block staging_block; + Pass pass; RefPtr r_inlined_statement; std::set dependencies; std::set referenced_names; @@ -52,7 +58,7 @@ private: public: InlineContentInjector(); - const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionDeclaration &); + const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList::iterator &, FunctionCall &); private: virtual void visit(VariableReference &);