Mesa (glsl2): ir_to_mesa: Don' t emit a duplicate return at the end of a function.

Eric Anholt anholt at kemper.freedesktop.org
Thu Jul 29 23:18:10 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 806cb9f9528e3c55c157d7e8bbb751b769b6fcb7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=806cb9f9528e3c55c157d7e8bbb751b769b6fcb7

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jul 29 15:17:23 2010 -0700

ir_to_mesa: Don't emit a duplicate return at the end of a function.

It was harmless, but ugly.

---

 src/mesa/program/ir_to_mesa.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 3a28c56..b6dfde3 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2350,8 +2350,12 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
 
 	    visit_exec_list(&entry->sig->body, &v);
 
-	    entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_RET);
-	    entry->bgn_inst = v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB);
+	    ir_to_mesa_instruction *last;
+	    last = (ir_to_mesa_instruction *)v.instructions.get_tail();
+	    if (last->op != OPCODE_RET)
+	       v.ir_to_mesa_emit_op0(NULL, OPCODE_RET);
+
+	    v.ir_to_mesa_emit_op0(NULL, OPCODE_ENDSUB);
 	    progress = GL_TRUE;
 	 }
       }




More information about the mesa-commit mailing list