Mesa (glsl2): ir_to_mesa: Support user-defined varyings using the linker' s locations.

Eric Anholt anholt at kemper.freedesktop.org
Mon Jun 28 22:07:36 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jun 28 14:47:43 2010 -0700

ir_to_mesa: Support user-defined varyings using the linker's locations.

Fixes glsl-reload-source.

---

 src/mesa/shader/ir_to_mesa.cpp |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index d371e35..0f035b9 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -929,15 +929,29 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
 		!(var_in ^ in))
 	       break;
 	 }
-	 if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) {
-	    printf("Failed to find builtin for %s variable %s\n",
-		   var_in ? "in" : "out",
-		   ir->var->name);
-	    abort();
+	 if (i != ARRAY_SIZE(builtin_var_to_mesa_reg)) {
+	    entry = new(mem_ctx) temp_entry(ir->var,
+					    builtin_var_to_mesa_reg[i].file,
+					    builtin_var_to_mesa_reg[i].index);
+	    break;
 	 }
-	 entry = new(mem_ctx) temp_entry(ir->var,
-					 builtin_var_to_mesa_reg[i].file,
-					 builtin_var_to_mesa_reg[i].index);
+
+	 /* If no builtin, then it's a user-generated varying
+	  * (FINISHME: or a function argument!)
+	  */
+	 /* The linker-assigned location is VERT_RESULT_* or FRAG_ATTRIB*
+	  */
+	 assert(ir->var->location != -1);
+	 if (var_in) {
+	    entry = new(mem_ctx) temp_entry(ir->var,
+					    PROGRAM_INPUT,
+					    ir->var->location);
+	 } else {
+	    entry = new(mem_ctx) temp_entry(ir->var,
+					    PROGRAM_OUTPUT,
+					    ir->var->location);
+	 }
+
 	 break;
       case ir_var_auto:
 	 entry = new(mem_ctx) temp_entry(ir->var, PROGRAM_TEMPORARY,




More information about the mesa-commit mailing list