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);
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<VariableDeclaration *, Node *>::iterator j = aggregates.find(i->first);
+ if(j!=aggregates.end())
+ if(InterfaceBlock *iface = dynamic_cast<InterfaceBlock *>(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.
{
SetForScope<Node *> set(aggregate, &iface);
unused_nodes.insert(&iface);
- TraversingVisitor::visit(iface);
+ iface.struct_declaration->members.visit(*this);
}
void UnusedVariableRemover::visit(FunctionDeclaration &func)