X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.cpp;h=87a57eb7f82496c797c6afdcf7ddbb257049655c;hb=05d8360ceef28e0b36e96127e04a82dd77a5c433;hp=be6cf7b6e456257bb8b46c6fc27f3781189eb1b2;hpb=2a9f8f3803e1b57e0e5325454266d4e701b38cc5;p=libs%2Fgl.git diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index be6cf7b6..87a57eb7 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -523,15 +523,14 @@ void ConstantConditionEliminator::visit(Block &block) void ConstantConditionEliminator::visit(Conditional &cond) { - ExpressionEvaluator eval; - cond.condition->visit(eval); - if(eval.is_result_valid()) - { - Block &block = (eval.get_result() ? cond.body : cond.else_body); - current_block->body.splice(insert_point, block.body); - nodes_to_remove.insert(&cond); - return; - } + if(Literal *literal = dynamic_cast(cond.condition.get())) + if(literal->value.check_type()) + { + Block &block = (literal->value.value() ? cond.body : cond.else_body); + current_block->body.splice(insert_point, block.body); + nodes_to_remove.insert(&cond); + return; + } TraversingVisitor::visit(cond); } @@ -558,15 +557,6 @@ void ConstantConditionEliminator::visit(Iteration &iter) } -UnusedVariableRemover::VariableInfo::VariableInfo(): - local(false), - output(false), - conditionally_assigned(false), - referenced(false), - interface_block(0) -{ } - - bool UnusedTypeRemover::apply(Stage &stage) { stage.content.visit(*this); @@ -634,6 +624,15 @@ void UnusedTypeRemover::visit(FunctionDeclaration &func) } +UnusedVariableRemover::VariableInfo::VariableInfo(): + local(false), + output(false), + conditionally_assigned(false), + referenced(false), + interface_block(0) +{ } + + UnusedVariableRemover::UnusedVariableRemover(): stage(0), interface_block(0), @@ -661,7 +660,7 @@ bool UnusedVariableRemover::apply(Stage &s) } if(output) { - if(!i->second.assignments.empty() && i->second.interface_block) + if((i->second.referenced || !i->second.assignments.empty()) && i->second.interface_block) used_interface_blocks.insert(i->second.interface_block); continue; }