Mesa (master): glsl: Fix incorrect optimization of instructions before discard statements.

Eric Anholt anholt at kemper.freedesktop.org
Fri Jun 10 20:22:29 UTC 2011


Module: Mesa
Branch: master
Commit: 20f087863d00fed9823791a447932e74d77cc546
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=20f087863d00fed9823791a447932e74d77cc546

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Jun  8 11:25:04 2011 -0700

glsl: Fix incorrect optimization of instructions before discard statements.

The function was named "find_unconditional_discard", but didn't
actually check that the discard statement found was unconditional.
Fixes piglit glsl-fs-discard-04.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/glsl/opt_discard_simplification.cpp |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/glsl/opt_discard_simplification.cpp b/src/glsl/opt_discard_simplification.cpp
index 7c2928d..a19947d 100644
--- a/src/glsl/opt_discard_simplification.cpp
+++ b/src/glsl/opt_discard_simplification.cpp
@@ -104,9 +104,23 @@ static ir_discard *
 find_unconditional_discard(exec_list &instructions)
 {
    foreach_list(n, &instructions) {
-      ir_discard *ir = ((ir_instruction *) n)->as_discard();
-      if (ir != NULL && ir->condition == NULL)
-	 return ir;
+      ir_instruction *ir = (ir_instruction *)n;
+
+      if (ir->ir_type == ir_type_return ||
+	  ir->ir_type == ir_type_loop_jump)
+	 return NULL;
+
+      /* So far, this code doesn't know how to look inside of flow
+       * control to see if a discard later on at this level is
+       * unconditional.
+       */
+      if (ir->ir_type == ir_type_if ||
+	  ir->ir_type == ir_type_loop)
+	 return NULL;
+
+      ir_discard *discard = ir->as_discard();
+      if (discard != NULL && discard->condition == NULL)
+	 return discard;
    }
    return NULL;
 }




More information about the mesa-commit mailing list