for(const auto &kvp: variables)
{
- if(kvp.second.output)
+ if(!kvp.second.referenced)
+ unused_nodes.insert(kvp.first);
+ else if(kvp.second.output)
{
/* The last visible assignments of output variables are used by the
next stage or the API. */
for(AssignmentInfo *a: kvp.second.assignments)
unused_nodes.erase(a->node);
}
- else if(!kvp.second.referenced)
- unused_nodes.insert(kvp.first);
}
NodeRemover().apply(s, unused_nodes);
graphics API. */
var_info.output = (var.interface=="out" && (stage->type==Stage::FRAGMENT || var.linked_declaration || !var.name.compare(0, 3, "gl_")));
+ // Linked outputs are automatically referenced.
+ if(var_info.output && var.linked_declaration)
+ var_info.referenced = true;
+
if(var.init_expression)
{
var_info.initialized = true;