i965: Support relative addressed VS constant reads using the appropriate msg.
authorEric Anholt <eric@anholt.net>
Thu, 22 Jul 2010 01:29:06 +0000 (18:29 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 22 Jul 2010 03:17:24 +0000 (20:17 -0700)
The previous support was overly complicated by trying to use the same
1-OWORD message for both offsets.

src/mesa/drivers/dri/i965/brw_eu.h
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_vs_emit.c

index 3a0100024cf750135e26556d6abe43f7e106e0db..a2acf8c967b98331c1fe6d794af077b97d57f817 100644 (file)
@@ -897,6 +897,12 @@ void brw_dp_READ_4_vs( struct brw_compile *p,
                        GLuint location,
                        GLuint bind_table_index );
 
+void brw_dp_READ_4_vs_relative(struct brw_compile *p,
+                              struct brw_reg dest,
+                              struct brw_reg addrReg,
+                              GLuint offset,
+                              GLuint bind_table_index);
+
 void brw_dp_WRITE_16( struct brw_compile *p,
                      struct brw_reg src,
                      GLuint scratch_offset );
index 7cda28a4674d6fd240e16ca2c0c8a507c1655108..b390f825c0587cdedff0806f2c5fe2570ac2014e 100644 (file)
@@ -1290,6 +1290,60 @@ void brw_dp_READ_4_vs(struct brw_compile *p,
    }
 }
 
+/**
+ * Read a float[4] constant per vertex from VS constant buffer, with
+ * relative addressing.
+ */
+void brw_dp_READ_4_vs_relative(struct brw_compile *p,
+                              struct brw_reg dest,
+                              struct brw_reg addr_reg,
+                              GLuint offset,
+                              GLuint bind_table_index)
+{
+   struct intel_context *intel = &p->brw->intel;
+   int msg_type;
+
+   /* Setup MRF[1] with offset into const buffer */
+   brw_push_insn_state(p);
+   brw_set_compression_control(p, BRW_COMPRESSION_NONE);
+   brw_set_mask_control(p, BRW_MASK_DISABLE);
+   brw_set_predicate_control(p, BRW_PREDICATE_NONE);
+
+   /* M1.0 is block offset 0, M1.4 is block offset 1, all other
+    * fields ignored.
+    */
+   brw_ADD(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD),
+          addr_reg, brw_imm_d(offset));
+   brw_pop_insn_state(p);
+
+   struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
+
+   insn->header.predicate_control = BRW_PREDICATE_NONE;
+   insn->header.compression_control = BRW_COMPRESSION_NONE;
+   insn->header.destreg__conditionalmod = 0;
+   insn->header.mask_control = BRW_MASK_DISABLE;
+
+   brw_set_dest(insn, dest);
+   brw_set_src0(insn, brw_vec8_grf(0, 0));
+
+   if (intel->gen == 6)
+      msg_type = GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ;
+   else if (intel->gen == 5 || intel->is_g4x)
+      msg_type = G45_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ;
+   else
+      msg_type = BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ;
+
+   brw_set_dp_read_message(p->brw,
+                          insn,
+                          bind_table_index,
+                          BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD,
+                          msg_type,
+                          0, /* source cache = data cache */
+                          2, /* msg_length */
+                          1, /* response_length */
+                          0); /* eot */
+}
+
 
 
 void brw_fb_WRITE(struct brw_compile *p,
index 4616e507f5d533110f846fb3748d9f7505c390f3..190fa8901de05063a4a149e740bbb7f3083a747d 100644 (file)
@@ -901,7 +901,6 @@ get_reladdr_constant(struct brw_vs_compile *c,
    const struct prog_src_register *src = &inst->SrcReg[argIndex];
    struct brw_compile *p = &c->func;
    struct brw_reg const_reg = c->current_const[argIndex].reg;
-   struct brw_reg const2_reg;
    struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0];
 
    assert(argIndex < 3);
@@ -915,36 +914,12 @@ get_reladdr_constant(struct brw_vs_compile *c,
 #endif
 
    /* fetch the first vec4 */
-   brw_dp_READ_4_vs(p,
-                   const_reg,                     /* writeback dest */
-                   0,                             /* oword */
-                   1,                             /* relative indexing? */
-                   addrReg,                       /* address register */
-                   16 * src->Index,               /* byte offset */
-                   SURF_INDEX_VERT_CONST_BUFFER   /* binding table index */
-                   );
-   /* second vec4 */
-   const2_reg = get_tmp(c);
-
-   /* use upper half of address reg for second read */
-   addrReg = stride(addrReg, 0, 4, 0);
-   addrReg.subnr = 16;
-
-   brw_dp_READ_4_vs(p,
-                   const2_reg,              /* writeback dest */
-                   1,                       /* oword */
-                   1,                       /* relative indexing? */
-                   addrReg,                 /* address register */
-                   16 * src->Index,         /* byte offset */
-                   SURF_INDEX_VERT_CONST_BUFFER
-                   );
-
-   /* merge the two Owords into the constant register */
-   /* const_reg[7..4] = const2_reg[7..4] */
-   brw_MOV(p,
-          suboffset(stride(const_reg, 0, 4, 1), 4),
-          suboffset(stride(const2_reg, 0, 4, 1), 4));
-   release_tmp(c, const2_reg);
+   brw_dp_READ_4_vs_relative(p,
+                            const_reg,                     /* writeback dest */
+                            addrReg,                       /* address register */
+                            16 * src->Index,               /* byte offset */
+                            SURF_INDEX_VERT_CONST_BUFFER   /* binding table index */
+                            );
 
    return const_reg;
 }