i965: Fix fp fragment.position handling and enable HW part of ARB_fcc.
authorEric Anholt <eric@anholt.net>
Tue, 26 Jan 2010 21:08:42 +0000 (13:08 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 26 Jan 2010 21:30:26 +0000 (13:30 -0800)
As with swrast, this fixes the default pixel center behavior which was
broken, and implements the previous behavior for integer.  Fixes
piglit fp-arb-fragment-coord-conventions-none.  The extension won't be
exposed until we get the GLSL part implemented.

The DRI1 origin_x/y parts are dropped since they're no longer relevant.

src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/brw_wm.h
src/mesa/drivers/dri/i965/brw_wm_emit.c

index 8afd1f4aef3887a6a453bcee0d133d74c1e7d64b..9191c81755de25f646c3acd18a57af7b1d3d73f8 100644 (file)
@@ -336,11 +336,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
     * drawable height in order to invert the Y axis.
     */
    if (fp->program.Base.InputsRead & FRAG_BIT_WPOS) {
-      if (brw->intel.driDrawable != NULL) {
-         key->origin_x = brw->intel.driDrawable->x;
-         key->origin_y = brw->intel.driDrawable->y;
-         key->drawable_height = brw->intel.driDrawable->h;
-      }
+      key->drawable_height = ctx->DrawBuffer->Height;
    }
 
    key->nr_color_regions = brw->state.nr_color_regions;
index b9b987ea70a987f47da8bc061d832bd59348b7be..88d84ee82febb549e08064f3b7f53ad11bfbd874 100644 (file)
@@ -76,7 +76,6 @@ struct brw_wm_prog_key {
 
    GLushort tex_swizzles[BRW_MAX_TEX_UNIT];
 
-   GLushort origin_x, origin_y;
    GLushort drawable_height;
    GLbitfield64 vp_outputs_written;
    GLuint program_string_id:32;
index f316e0cda49b205a36318057d16d3d7a0619cc43..fa0898c5862d5e237ae0485ceee7b22bb232e1ca 100644 (file)
@@ -138,19 +138,43 @@ void emit_wpos_xy(struct brw_wm_compile *c,
     * X and Y channels.
     */
    if (mask & WRITEMASK_X) {
-      /* X' = X - origin */
-      brw_ADD(p,
-             dst[0],
-             retype(arg0[0], BRW_REGISTER_TYPE_W),
-             brw_imm_d(0 - c->key.origin_x));
+      if (c->fp->program.PixelCenterInteger) {
+        /* X' = X */
+        brw_MOV(p,
+                dst[0],
+                retype(arg0[0], BRW_REGISTER_TYPE_W));
+      } else {
+        /* X' = X + 0.5 */
+        brw_ADD(p,
+                dst[0],
+                retype(arg0[0], BRW_REGISTER_TYPE_W),
+                brw_imm_f(0.5));
+      }
    }
 
    if (mask & WRITEMASK_Y) {
-      /* Y' = height - (Y - origin_y) = height + origin_y - Y */
-      brw_ADD(p,
-             dst[1],
-             negate(retype(arg0[1], BRW_REGISTER_TYPE_W)),
-             brw_imm_d(c->key.origin_y + c->key.drawable_height - 1));
+      if (c->fp->program.OriginUpperLeft) {
+        if (c->fp->program.PixelCenterInteger) {
+           /* Y' = Y */
+           brw_MOV(p,
+                   dst[1],
+                   retype(arg0[1], BRW_REGISTER_TYPE_W));
+        } else {
+           /* Y' = Y + 0.5 */
+           brw_ADD(p,
+                   dst[1],
+                   retype(arg0[1], BRW_REGISTER_TYPE_W),
+                   brw_imm_f(0.5));
+        }
+      } else {
+        float center_offset = c->fp->program.PixelCenterInteger ? 0.0 : 0.5;
+
+        /* Y' = (height - 1) - Y + center */
+        brw_ADD(p,
+                dst[1],
+                negate(retype(arg0[1], BRW_REGISTER_TYPE_W)),
+                brw_imm_f(c->key.drawable_height - 1 + center_offset));
+      }
    }
 }