Skip to content
Browse files

glsl: make lower_output_reads work for geometry shaders

Also fix an optimization pass bug in glsl_to_tgsi that was revealed by
enabling lower_output_reads, and re-enable the lower_output_reads pass
unconditionally for all shaders.
  • Loading branch information...
1 parent 1311ff0 commit ad3ec5693bc7244b702f188ba1064f0482384adf @Plombo committed Aug 24, 2012
Showing with 14 additions and 6 deletions.
  1. +12 −1 src/glsl/lower_output_reads.cpp
  2. +2 −5 src/mesa/state_tracker/st_glsl_to_tgsi.cpp
View
13 src/glsl/lower_output_reads.cpp
@@ -50,6 +50,7 @@ class output_read_remover : public ir_hierarchical_visitor {
output_read_remover();
~output_read_remover();
virtual ir_visitor_status visit(class ir_dereference_variable *);
+ virtual ir_visitor_status visit(class ir_emitvertex *);
virtual ir_visitor_status visit_leave(class ir_return *);
virtual ir_visitor_status visit_leave(class ir_function_signature *);
};
@@ -116,7 +117,9 @@ copy(void *ctx, ir_variable *output, ir_variable *temp)
return new(ctx) ir_assignment(lhs, rhs);
}
-/** Insert a copy-back assignment before a "return" statement */
+/** Insert a copy-back assignment before a "return" statement or a call to
+ * EmitVertex().
+ */
static void
emit_return_copy(const void *key, void *data, void *closure)
{
@@ -140,6 +143,14 @@ output_read_remover::visit_leave(ir_return *ir)
}
ir_visitor_status
+output_read_remover::visit(ir_emitvertex *ir)
+{
+ hash_table_call_foreach(replacements, emit_return_copy, ir);
+ hash_table_clear(replacements);
+ return visit_continue;
+}
+
+ir_visitor_status
output_read_remover::visit_leave(ir_function_signature *sig)
{
if (strcmp(sig->function_name(), "main") != 0)
View
7 src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3444,6 +3444,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
!inst->dst.reladdr &&
!inst->saturate &&
!inst->src[0].reladdr &&
+ !inst->src[0].reladdr2 &&
!inst->src[0].negate) {
for (int i = 0; i < 4; i++) {
if (inst->dst.writemask & (1 << i)) {
@@ -4916,11 +4917,7 @@ get_mesa_program(struct gl_context *ctx,
prog->Parameters);
/* Remove reads from output registers. */
- if (shader->Type != GL_GEOMETRY_SHADER) {
- /* FINISHME: Make lower_output_reads compatible with geometry shaders
- * and enable it unconditionally. */
- lower_output_reads(shader->ir);
- }
+ lower_output_reads(shader->ir);
/* Emit intermediate IR for main(). */
visit_exec_list(shader->ir, v);

0 comments on commit ad3ec56

Please sign in to comment.
Something went wrong with that request. Please try again.