iface_target_block->body.insert(iface_insert_point, iface_var);
iface_target_block->variables.insert(make_pair(name, iface_var));
+ if(iface_target_block==&stage->content && iface=="in")
+ declared_inputs.push_back(iface_var);
return iface_var;
}
}
}
}
- else if(var.interface=="in")
+ else if(var.interface=="in" && current_block==&stage->content)
{
+ declared_inputs.push_back(&var);
+
/* Try to link input variables in global scope with output variables from
previous stage. */
- if(current_block==&stage->content && !var.linked_declaration && stage->previous)
+ if(!var.linked_declaration && stage->previous)
{
const map<string, VariableDeclaration *> &prev_vars = stage->previous->content.variables;
map<string, VariableDeclaration *>::const_iterator i = prev_vars.find(var.name);
void InterfaceGenerator::visit(Passthrough &pass)
{
- vector<VariableDeclaration *> pass_vars;
-
- // Pass through all input variables of this stage.
- for(map<string, VariableDeclaration *>::const_iterator i=stage->content.variables.begin(); i!=stage->content.variables.end(); ++i)
- if(i->second->interface=="in")
- pass_vars.push_back(i->second);
+ // Pass through all input variables declared so far.
+ vector<VariableDeclaration *> pass_vars = declared_inputs;
if(stage->previous)
{
std::string out_prefix;
bool function_scope;
bool copy_block;
+ std::vector<VariableDeclaration *> declared_inputs;
Block *iface_target_block;
NodeList<Statement>::iterator iface_insert_point;
NodeList<Statement>::iterator assignment_insert_point;
--- /dev/null
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void process();
+void main()
+{
+ gl_Position = position;
+ passthrough;
+ process();
+}
+layout(location=1) in vec4 color;
+void process()
+{
+ passthrough;
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+ frag_color = color;
+}
+
+/* Expected output: vertex
+layout(location=0) in vec4 position;
+layout(location=1) in vec4 color;
+out vec4 _vs_out_color;
+void main()
+{
+ gl_Position = position;
+ _vs_out_color = color;
+}
+*/
+
+/* Expected output: fragment
+layout(location=0) out vec4 frag_color;
+in vec4 _vs_out_color;
+void main()
+{
+ frag_color = _vs_out_color;
+}
+*/