Mesa (glsl2): ir_to_mesa: Add support for structure constants.

Eric Anholt anholt at kemper.freedesktop.org
Tue Jul 27 02:43:53 UTC 2010


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

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Jul 26 19:08:44 2010 -0700

ir_to_mesa: Add support for structure constants.

Fixes:
TPPStreamCompiler::assignOperands

---

 src/mesa/program/ir_to_mesa.cpp |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1903b8f..20228e0 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1381,12 +1381,37 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
       assert(!"FINISHME: array constants");
    }
 
+   /* Unfortunately, 4 floats is all we can get into
+    * _mesa_add_unnamed_constant.  So, make a temp to store an
+    * aggregate constant and move each constant value into it.  If we
+    * get lucky, copy propagation will eliminate the extra moves.
+    */
+
+   if (ir->type->base_type == GLSL_TYPE_STRUCT) {
+      ir_to_mesa_src_reg temp_base = get_temp(ir->type);
+      ir_to_mesa_dst_reg temp = ir_to_mesa_dst_reg_from_src(temp_base);
+
+      foreach_iter(exec_list_iterator, iter, ir->components) {
+	 ir_constant *field_value = (ir_constant *)iter.get();
+	 int size = type_size(field_value->type);
+
+	 assert(size > 0);
+
+	 field_value->accept(this);
+	 src_reg = this->result;
+
+	 for (i = 0; i < (unsigned int)size; i++) {
+	    ir_to_mesa_emit_op1(ir, OPCODE_MOV, temp, src_reg);
+
+	    src_reg.index++;
+	    temp.index++;
+	 }
+      }
+      this->result = temp_base;
+      return;
+   }
+
    if (ir->type->is_matrix()) {
-      /* Unfortunately, 4 floats is all we can get into
-       * _mesa_add_unnamed_constant.  So, make a temp to store the
-       * matrix and move each constant value into it.  If we get
-       * lucky, copy propagation will eliminate the extra moves.
-       */
       ir_to_mesa_src_reg mat = get_temp(glsl_type::vec4_type);
       ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat);
 




More information about the mesa-commit mailing list