/* Treat function calls as having side effects so expression statements
consisting of nothing but a function call won't be optimized away. */
r_side_effects = true;
+
+ if(stage->type==Stage::GEOMETRY && call.name=="EmitVertex")
+ {
+ for(map<Statement *, VariableInfo>::const_iterator i=variables.begin(); i!=variables.end(); ++i)
+ if(i->second.output)
+ referenced(i->first, call);
+ }
}
void UnusedVariableRemover::record_assignment(const Assignment::Target &target, Node &node)
--- /dev/null
+uniform bool flag;
+uniform sampler2D tex;
+
+#pragma MSP stage(vertex)
+layout(location=0) in vec4 position;
+void main()
+{
+ out vec2 texcoord = position.xy*0.5+0.5;
+ gl_Position = position;
+}
+
+#pragma MSP stage(geometry)
+layout(triangles) in;
+layout(triangles, max_vertices=3) out;
+void main()
+{
+ passthrough[0];
+ if(flag)
+ EmitVertex();
+ passthrough[1];
+ if(flag)
+ EmitVertex();
+ passthrough[2];
+ if(flag)
+ EmitVertex();
+}
+
+#pragma MSP stage(fragment)
+layout(location=0) out vec4 frag_color;
+void main()
+{
+ frag_color = texture(tex, texcoord);
+}
+
+/* Expected output: vertex
+layout(location=0) in vec4 position;
+out vec2 texcoord;
+void main()
+{
+ texcoord = position.xy*0.5+0.5;
+ gl_Position = position;
+}
+*/
+
+/* Expected output: geometry
+uniform bool flag;
+layout(triangles) in;
+layout(triangles, max_vertices=3) out;
+in vec2 texcoord[];
+out vec2 _gs_out_texcoord;
+void main()
+{
+ gl_Position = gl_in[0].gl_Position;
+ _gs_out_texcoord = texcoord[0];
+ if(flag)
+ EmitVertex();
+ gl_Position = gl_in[1].gl_Position;
+ _gs_out_texcoord = texcoord[1];
+ if(flag)
+ EmitVertex();
+ gl_Position = gl_in[2].gl_Position;
+ _gs_out_texcoord = texcoord[2];
+ if(flag)
+ EmitVertex();
+}
+*/
+
+/* Expected output: fragment
+uniform sampler2D tex;
+layout(location=0) out vec4 frag_color;
+in vec2 _gs_out_texcoord;
+void main()
+{
+ frag_color = texture(tex, _gs_out_texcoord);
+}
+*/