965: always perform SF parameter setup for position
authorKeith Whitwell <keith@tungstengraphics.com>
Thu, 3 Jan 2008 17:21:22 +0000 (17:21 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 4 Jan 2008 01:20:41 +0000 (01:20 +0000)
Match behaviour of DRI driver.  Fix fragment shader to find the other
parameters one slot further on.  Will need more work to cope with FP's
that actually reference position.

src/mesa/pipe/i965simple/brw_sf.c
src/mesa/pipe/i965simple/brw_wm_decl.c

index c04234e..362196a 100644 (file)
@@ -58,7 +58,7 @@ static void compile_sf_prog( struct brw_context *brw,
    c.nr_attrs = c.key.vp_output_count;
    c.nr_attr_regs = (c.nr_attrs+1)/2;
 
-   c.nr_setup_attrs = c.key.fp_input_count;
+   c.nr_setup_attrs = c.key.fp_input_count + 1; /* +1 for position */
    c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
 
    c.prog_data.urb_read_length = c.nr_attr_regs;
@@ -205,6 +205,14 @@ static void upload_sf_prog( struct brw_context *brw )
       }
    }
 
+   /* Hack: Adjust for position.  Optimize away when not required (ie
+    * for perspective interpolation).
+    */
+   key.persp_mask <<= 1;
+   key.linear_mask <<= 1; 
+   key.linear_mask |= 1;
+   key.const_mask <<= 1;
+
    _mesa_printf("key.persp_mask: %x\n", key.persp_mask);
    _mesa_printf("key.linear_mask: %x\n", key.linear_mask);
    _mesa_printf("key.const_mask: %x\n", key.const_mask);
index 5b1abb9..b45a333 100644 (file)
@@ -273,6 +273,12 @@ static void prealloc_reg(struct brw_wm_compile *c)
       c->reg_index += nr_curbe_regs;
    }
 
+   /* Adjust for parameter coefficients for position, which are
+    * currently always provided.
+    */
+//   c->position_coef[i] = brw_vec8_grf(c->reg_index, 0);
+   c->reg_index += 2;
+
    /* Next we receive the plane coefficients for parameter
     * interpolation:
     */
@@ -282,7 +288,7 @@ static void prealloc_reg(struct brw_wm_compile *c)
    }
 
    c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
-   c->prog_data.urb_read_length = c->fp->program.num_inputs * 2;
+   c->prog_data.urb_read_length = (c->fp->program.num_inputs + 1) * 2;
    c->prog_data.curb_read_length = nr_curbe_regs;
 
    /* That's the end of the payload, now we can start allocating registers.