X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Foptimize.cpp;h=c1431f2b6e9d9e33ed522cd853bcd326bbb3414a;hp=f938314814ea9cd4211279d5e94ff817c2a92fcc;hb=041ba4b1acd55337239c5ce24cc310118c621206;hpb=cd01b904990d306eadd120f306b1d0ceb4d8f5c8 diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index f9383148..c1431f2b 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -668,6 +668,11 @@ void UnusedTypeRemover::visit(VariableDeclaration &var) unused_nodes.erase(var.type_declaration); } +void UnusedTypeRemover::visit(InterfaceBlock &iface) +{ + unused_nodes.erase(iface.type_declaration); +} + void UnusedTypeRemover::visit(FunctionDeclaration &func) { unused_nodes.erase(func.return_type_declaration); @@ -690,9 +695,19 @@ bool UnusedVariableRemover::apply(Stage &stage) BlockVariableMap &global_variables = variables.back(); for(BlockVariableMap::iterator i=global_variables.begin(); i!=global_variables.end(); ++i) { + string interface = i->first->interface; + bool linked = i->first->linked_declaration; + map::iterator j = aggregates.find(i->first); + if(j!=aggregates.end()) + if(InterfaceBlock *iface = dynamic_cast(j->second)) + { + interface = iface->interface; + linked = iface->linked_block; + } + /* Don't remove output variables which are used by the next stage or the graphics API. */ - if(i->first->interface=="out" && (stage.type==Stage::FRAGMENT || i->first->linked_declaration || !i->first->name.compare(0, 3, "gl_"))) + if(interface=="out" && (stage.type==Stage::FRAGMENT || linked || !i->first->name.compare(0, 3, "gl_"))) continue; // Mark other unreferenced global variables as unused. @@ -833,7 +848,7 @@ void UnusedVariableRemover::visit(InterfaceBlock &iface) { SetForScope set(aggregate, &iface); unused_nodes.insert(&iface); - TraversingVisitor::visit(iface); + iface.struct_declaration->members.visit(*this); } void UnusedVariableRemover::visit(FunctionDeclaration &func)