]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/optimize.h
Don't return references from apply functions
[libs/gl.git] / source / glsl / optimize.h
index 6d4b1bcb5d2c2e5d883d7ab640390481c8c7e84e..4113f21465a990e85a4fa701351b8277cec09cfe 100644 (file)
@@ -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<std::string, int> *values;
+
+public:
+       ConstantSpecializer();
+
+       void apply(Stage &, const std::map<std::string, int> &);
+
+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<FunctionDeclaration *> &apply(Stage &s) { s.content.visit(*this); return inlineable; }
+       std::set<FunctionDeclaration *> 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
@@ -49,7 +64,6 @@ private:
 
        FunctionDeclaration *source_func;
        Block staging_block;
-       std::string remap_prefix;
        Pass pass;
        RefPtr<Statement> r_inlined_statement;
        std::set<Node *> dependencies;
@@ -59,7 +73,7 @@ private:
 public:
        InlineContentInjector();
 
-       const std::string &apply(Stage &, FunctionDeclaration &, Block &, const NodeList<Statement>::iterator &, FunctionCall &);
+       std::string apply(Stage &, FunctionDeclaration &, Block &, const NodeList<Statement>::iterator &, FunctionCall &);
 
 private:
        virtual void visit(VariableReference &);
@@ -110,7 +124,7 @@ private:
                bool trivial;
                bool available;
 
-               ExpressionInfo();
+               ExpressionInfo(): expression(0), assign_scope(0), inline_point(0), trivial(false), available(true) { }
        };
 
        std::map<Assignment::Target, ExpressionInfo> expressions;