]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/optimize.h
Remove conditional and iteration statements with no effect from GLSL
[libs/gl.git] / source / glsl / optimize.h
index 6250130fb30a39bfd9b18c82cdc9acf654c347ad..92353a77ee1748c651d8d6f35ab266d6a429593c 100644 (file)
@@ -210,7 +210,8 @@ private:
 };
 
 /** Removes conditional statements and loops where the condition can be
-determined as constant at compile time. */
+determined as constant at compile time.  Also removes such statements where
+the body is empty and the condition has no side effects. */
 class ConstantConditionEliminator: private TraversingVisitor
 {
 private:
@@ -224,6 +225,7 @@ private:
        NodeList<Statement>::iterator insert_point;
        std::set<Node *> nodes_to_remove;
        RefPtr<Expression> r_ternary_result;
+       bool r_external_side_effects;
 
 public:
        void apply(Stage &);
@@ -233,7 +235,10 @@ private:
 
        virtual void visit(Block &);
        virtual void visit(RefPtr<Expression> &);
+       virtual void visit(UnaryExpression &);
+       virtual void visit(Assignment &);
        virtual void visit(TernaryExpression &);
+       virtual void visit(FunctionCall &);
        virtual void visit(Conditional &);
        virtual void visit(Iteration &);
 };