i965: Add support for gen6 reladdr VS constant loading.
authorEric Anholt <eric@anholt.net>
Thu, 9 Dec 2010 17:42:05 +0000 (09:42 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 10 Dec 2010 04:25:34 +0000 (20:25 -0800)
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_vs_emit.c

index 93ccdde44b5c755e490388c0a6beac2fa482dc11..9c764fe779d9fc46680ca4503e4090b40ef88fb8 100644 (file)
@@ -1771,7 +1771,7 @@ void brw_dp_READ_4_vs_relative(struct brw_compile *p,
    /* 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),
+   brw_ADD(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_D),
           addr_reg, brw_imm_d(offset));
    brw_pop_insn_state(p);
 
index eccc6b7584eb7d92805ba061cf7c559a53e7cab4..add5e394d4537e29cc8e1044b8dbc4acaf7f56b4 100644 (file)
@@ -1102,14 +1102,14 @@ 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_context *brw = p->brw;
+   struct intel_context *intel = &brw->intel;
    struct brw_reg const_reg = c->current_const[argIndex].reg;
-   struct brw_reg addrReg = c->regs[PROGRAM_ADDRESS][0];
-   struct brw_reg byte_addr_reg = retype(get_tmp(c), BRW_REGISTER_TYPE_D);
+   struct brw_reg addr_reg = c->regs[PROGRAM_ADDRESS][0];
+   uint32_t offset;
 
    assert(argIndex < 3);
 
-   assert(c->func.brw->intel.gen < 6); /* FINISHME */
-
    /* Can't reuse a reladdr constant load. */
    c->current_const[argIndex].index = -1;
 
@@ -1118,15 +1118,21 @@ get_reladdr_constant(struct brw_vs_compile *c,
          src->Index, argIndex, c->current_const[argIndex].reg.nr);
 #endif
 
-   brw_MUL(p, byte_addr_reg, addrReg, brw_imm_ud(16));
+   if (intel->gen >= 6) {
+      offset = src->Index;
+   } else {
+      struct brw_reg byte_addr_reg = retype(get_tmp(c), BRW_REGISTER_TYPE_D);
+      brw_MUL(p, byte_addr_reg, addr_reg, brw_imm_d(16));
+      addr_reg = byte_addr_reg;
+      offset = 16 * src->Index;
+   }
 
    /* fetch the first vec4 */
    brw_dp_READ_4_vs_relative(p,
-                            const_reg,                     /* writeback dest */
-                            byte_addr_reg,                 /* address register */
-                            16 * src->Index,               /* byte offset */
-                            SURF_INDEX_VERT_CONST_BUFFER   /* binding table index */
-                            );
+                            const_reg,
+                            addr_reg,
+                            offset,
+                            SURF_INDEX_VERT_CONST_BUFFER);
 
    return const_reg;
 }