[Mesa-dev] [PATCH] glsl: Don't forget to do packed outputs at return-from-main, too.
Eric Anholt
eric at anholt.net
Mon Jan 5 15:59:51 PST 2015
Fixes piglit vs-*-main-return.
---
src/glsl/lower_packed_varyings.cpp | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
index 5e844c7..b8c3228 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -646,6 +646,33 @@ lower_packed_varyings_gs_splicer::visit_leave(ir_emit_vertex *ev)
return visit_continue;
}
+namespace {
+
+class ir_insert_before_return_visitor : public ir_hierarchical_visitor
+{
+public:
+ ir_insert_before_return_visitor(void *mem_ctx, exec_list *instructions)
+ : mem_ctx(mem_ctx), instructions(instructions)
+ {
+ }
+
+ ir_visitor_status visit_enter(ir_return *ir) {
+ exec_list cloned;
+ clone_ir_list(mem_ctx, &cloned, instructions);
+ ir->insert_before(&cloned);
+ return visit_continue_with_parent;
+ }
+
+ ir_visitor_status visit_enter(ir_assignment *ir) {
+ /* No need to descend expression trees. */
+ return visit_continue_with_parent;
+ }
+
+ void *mem_ctx;
+ exec_list *instructions;
+};
+
+} /* anonymous namespace */
void
lower_packed_varyings(void *mem_ctx, unsigned locations_used,
@@ -670,8 +697,11 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
splicer.run(instructions);
} else {
/* For other shader types, outputs need to be lowered at the end of
- * main()
+ * main(), and at each early return from main.
*/
+ ir_insert_before_return_visitor v(mem_ctx, &new_instructions);
+ v.run(&main_func_sig->body);
+
main_func_sig->body.append_list(&new_instructions);
}
} else {
--
2.1.3
More information about the mesa-dev
mailing list