X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.cpp;h=137bd94343190f275eebbaa877dfa554b4785a50;hb=dda547f94e4aff590592908b38ca1e78c2c24b08;hp=a999a654db84ac8ac072ef7fb817d5107643a584;hpb=1cd0ea7f79b2b0dedd8a2a6622e5d2e8b2ea2512;p=libs%2Fgl.git diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index a999a654..137bd943 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -289,11 +289,15 @@ void FunctionInliner::visit(Conditional &cond) void FunctionInliner::visit(Iteration &iter) { - SetForScope 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 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); } @@ -674,7 +678,8 @@ void UnusedVariableRemover::visit(InterfaceBlockReference &iface) void UnusedVariableRemover::visit(MemberAccess &memacc) { - r_assign_to_subfield = true; + if(assignment_target) + r_assign_to_subfield = true; TraversingVisitor::visit(memacc); unused_nodes.erase(memacc.declaration); }