]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/optimize.h
Make function dependency collection its own visitor class
[libs/gl.git] / source / glsl / optimize.h
index e7592c00a29956e7ad4ab09384cf9798b3d1aacf..d434c68a85c1df63594dcda6294c9698573e969f 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. */
@@ -41,7 +57,6 @@ class InlineContentInjector: private TraversingVisitor
 private:
        enum Pass
        {
-               DEPENDS,
                REFERENCED,
                INLINE,
                RENAME
@@ -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<Assignment::Target, ExpressionInfo> expressions;