[Mesa-dev] [PATCH 10/10] i965/vs: Fix GL_FIXED setup when a writemask is present.

Eric Anholt eric at anholt.net
Tue Aug 23 18:25:57 PDT 2011


By emitting code before generate_code(), we ended up in align1 mode
where writemasks don't exist, so we rescaled gl_Vertex.w and things
went badly.  By moving GL_FIXED support to the visitor, we end up with
normal codegen, and as a bonus the GL_FIXED setup ends up getting
printed appropriately in debug output.

Fixes gtf/GL2Tests/fixed_data_type
---
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp    |   25 +++++++++++------------
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   12 +++++++++++
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index cae678e..04de8d4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -42,24 +42,23 @@ vec4_visitor::setup_attributes(int payload_reg)
       if (prog_data->inputs_read & BITFIELD64_BIT(i)) {
 	 attribute_map[i] = payload_reg + nr_attributes;
 	 nr_attributes++;
-
-	 /* Do GL_FIXED rescaling for GLES2.0.  Our GL_FIXED
-	  * attributes come in as floating point conversions of the
-	  * integer values.
-	  */
-	 if (c->key.gl_fixed_input_size[i] != 0) {
-	    struct brw_reg reg = brw_vec8_grf(attribute_map[i], 0);
-
-	    brw_MUL(p,
-		    brw_writemask(reg, (1 << c->key.gl_fixed_input_size[i]) - 1),
-		    reg, brw_imm_f(1.0 / 65536.0));
-	 }
       }
    }
 
    foreach_list(node, &this->instructions) {
       vec4_instruction *inst = (vec4_instruction *)node;
 
+      /* We have to support ATTR as a destination for GL_FIXED fixup. */
+      if (inst->dst.file == ATTR) {
+	 int grf = attribute_map[inst->dst.reg + inst->dst.reg_offset];
+
+	 struct brw_reg reg = brw_vec8_grf(grf, 0);
+	 reg.dw1.bits.writemask = inst->dst.writemask;
+
+	 inst->dst.file = HW_REG;
+	 inst->dst.fixed_hw_reg = reg;
+      }
+
       for (int i = 0; i < 3; i++) {
 	 if (inst->src[i].file != ATTR)
 	    continue;
@@ -630,7 +629,7 @@ vec4_visitor::run()
 void
 vec4_visitor::generate_code()
 {
-   int last_native_inst = p->nr_insn;
+   int last_native_inst = 0;
    const char *last_annotation_string = NULL;
    ir_instruction *last_annotation_ir = NULL;
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 58a573b..b1b6eaa 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -657,6 +657,18 @@ vec4_visitor::visit(ir_variable *ir)
    switch (ir->mode) {
    case ir_var_in:
       reg = new(mem_ctx) dst_reg(ATTR, ir->location);
+
+      /* Do GL_FIXED rescaling for GLES2.0.  Our GL_FIXED attributes
+       * come in as floating point conversions of the integer values.
+       */
+      for (int i = ir->location; i < ir->location + type_size(ir->type); i++) {
+	 if (!c->key.gl_fixed_input_size[i])
+	    continue;
+
+	 dst_reg dst = *reg;
+	 dst.writemask = (1 << c->key.gl_fixed_input_size[i]) - 1;
+	 emit(BRW_OPCODE_MUL, dst, src_reg(dst), src_reg(1.0f / 65536.0f));
+      }
       break;
 
    case ir_var_out:
-- 
1.7.5.4



More information about the mesa-dev mailing list