]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix function inlining in iteration init statement
authorMikko Rasa <tdb@tdb.fi>
Wed, 3 Mar 2021 23:56:26 +0000 (01:56 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 4 Mar 2021 11:46:15 +0000 (13:46 +0200)
Also reword the other related comment to be more accurate.

source/glsl/optimize.cpp

index a999a654db84ac8ac072ef7fb817d5107643a584..0af24e3e8f88df55e0d449e0044f6007fafe0275 100644 (file)
@@ -289,11 +289,15 @@ void FunctionInliner::visit(Conditional &cond)
 
 void FunctionInliner::visit(Iteration &iter)
 {
-       SetForScope<Block *> set_block(current_block, &iter.body);
+       /* Visit the initialization statement before entering the loop body so the
+       inlined statements get inserted outside. */
        if(iter.init_statement)
                iter.init_statement->visit(*this);
-       /* Skip the condition and loop expression parts because they're executed on
-       every iteration of the loop */
+
+       SetForScope<Block *> set_block(current_block, &iter.body);
+       /* Skip the condition and loop expression parts because they're not properly
+       inside the body block.  Inlining anything into them will require a more
+       comprehensive transformation. */
        iter.body.visit(*this);
 }