fix a couple of cases where a message reg is used as an instruction source.
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 1 Sep 2006 14:18:06 +0000 (14:18 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 1 Sep 2006 14:18:06 +0000 (14:18 +0000)
src/mesa/drivers/dri/i965/brw_eu_emit.c
src/mesa/drivers/dri/i965/brw_vs_emit.c

index 791eaab0cc7bd64cfc61ef8e015898f34799d84c..6425c91450cb268742a85c5b9fa56db6a259c9e3 100644 (file)
@@ -94,6 +94,8 @@ static void brw_set_dest( struct brw_instruction *insn,
 static void brw_set_src0( struct brw_instruction *insn,
                      struct brw_reg reg )
 {
+   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
+
    insn->bits1.da1.src0_reg_file = reg.file;
    insn->bits1.da1.src0_reg_type = reg.type;
    insn->bits2.da1.src0_abs = reg.abs;
@@ -165,6 +167,8 @@ static void brw_set_src0( struct brw_instruction *insn,
 static void brw_set_src1( struct brw_instruction *insn,
                          struct brw_reg reg )
 {
+   assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
+
    insn->bits1.da1.src1_reg_file = reg.file;
    insn->bits1.da1.src1_reg_type = reg.type;
    insn->bits3.da1.src1_abs = reg.abs;
index 96f9f5bd81b98707b75617be026ada914bb9ae82..cfade7c992a6d2232994e43430db393e4c906a27 100644 (file)
@@ -529,6 +529,11 @@ static void emit_lit_noalias( struct brw_vs_compile *c,
 {
    struct brw_compile *p = &c->func;
    struct brw_instruction *if_insn;
+   struct brw_reg tmp = dst;
+   GLboolean need_tmp = (dst.file != BRW_GENERAL_REGISTER_FILE);
+
+   if (need_tmp) 
+      tmp = get_tmp(c);
    
    brw_MOV(p, brw_writemask(dst, WRITEMASK_YZ), brw_imm_f(0)); 
    brw_MOV(p, brw_writemask(dst, WRITEMASK_XW), brw_imm_f(1)); 
@@ -544,13 +549,13 @@ static void emit_lit_noalias( struct brw_vs_compile *c,
       brw_MOV(p, brw_writemask(dst, WRITEMASK_Y), brw_swizzle1(arg0,0));
 
       brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, brw_swizzle1(arg0,1), brw_imm_f(0));
-      brw_MOV(p, brw_writemask(dst, WRITEMASK_Z),  brw_swizzle1(arg0,1));
+      brw_MOV(p, brw_writemask(tmp, WRITEMASK_Z),  brw_swizzle1(arg0,1));
       brw_set_predicate_control(p, BRW_PREDICATE_NONE);
 
       emit_math2(c, 
                 BRW_MATH_FUNCTION_POW, 
                 brw_writemask(dst, WRITEMASK_Z),
-                brw_swizzle1(dst, 2),
+                brw_swizzle1(tmp, 2),
                 brw_swizzle1(arg0, 3),
                 BRW_MATH_PRECISION_PARTIAL);      
    }
@@ -691,8 +696,14 @@ static void emit_swz( struct brw_vs_compile *c,
    GLuint ones_mask = 0;
    GLuint src_mask = 0;
    GLubyte src_swz[4];
+   GLboolean need_tmp = (src.NegateBase &&
+                        dst.file != BRW_GENERAL_REGISTER_FILE);
+   struct brw_reg tmp = dst;
    GLuint i;
 
+   if (need_tmp)
+      tmp = get_tmp(c);
+
    for (i = 0; i < 4; i++) {
       if (dst.dw1.bits.writemask & (1<<i)) {
         GLubyte s = GET_SWZ(src.Swizzle, i);
@@ -728,17 +739,22 @@ static void emit_swz( struct brw_vs_compile *c,
                         src_swz[0], src_swz[1], 
                         src_swz[2], src_swz[3]);
 
-      brw_MOV(p, brw_writemask(dst, src_mask), arg0);
+      brw_MOV(p, brw_writemask(tmp, src_mask), arg0);
    } 
    
    if (zeros_mask) 
-      brw_MOV(p, brw_writemask(dst, zeros_mask), brw_imm_f(0));
+      brw_MOV(p, brw_writemask(tmp, zeros_mask), brw_imm_f(0));
 
    if (ones_mask) 
-      brw_MOV(p, brw_writemask(dst, ones_mask), brw_imm_f(1));
+      brw_MOV(p, brw_writemask(tmp, ones_mask), brw_imm_f(1));
 
    if (src.NegateBase)
-      brw_MOV(p, brw_writemask(dst, src.NegateBase), negate(dst));
+      brw_MOV(p, brw_writemask(tmp, src.NegateBase), negate(tmp));
+   
+   if (need_tmp) {
+      brw_MOV(p, dst, tmp);
+      release_tmp(c, tmp);
+   }
 }