On 16.04.2011 18:50, Christoph Bumiller wrote:
> I hope the new version is correct, the commit message describes why I
> did the first change, and the second change is described in a comment.
>
> Note that the MAD for inversion uses Height - 1 instead of Height.
>
> With this, piglit glsl-arb-fragment-coord-conventions and
> fbo-depth-sample-compare pass on nvc0.
>
> I was assuming that integer pixel centers for size 100 range from 0 to
> 99 and half-integer pixel centers from 0.5 to 99.5.
>
Attached a better version of the patch, potentially saving an
instruction and avoiding precision issues with NEAREST filtering that
made piglit's blending-in-shader fail.

The only other location I found STATE_FB_WPOS_Y_TRANSFORM used was r600
classic, which should also work more correctly now since (at least
according to gallium caps) it uses half-integer pixel center, and for
H=100, 0.5 * -1 + 99 obviously isn't the desired 99.5.

Please review.

Christoph
>
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

>From 0214363d8bfc1084b93f4c2541c483313caafbc4 Mon Sep 17 00:00:00 2001
From: Christoph Bumiller <e0425...@student.tuwien.ac.at>
Date: Tue, 19 Apr 2011 11:54:41 +0200
Subject: [PATCH] mesa,st/mesa: fix WPOS adjustment

---
 src/mesa/program/prog_statevars.c        |    4 ++--
 src/mesa/program/prog_statevars.h        |    2 +-
 src/mesa/state_tracker/st_mesa_to_tgsi.c |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/program/prog_statevars.c 
b/src/mesa/program/prog_statevars.c
index 1fd26f4..d94d7fe 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -602,11 +602,11 @@ _mesa_fetch_state(struct gl_context *ctx, const 
gl_state_index state[],
             value[0] = 1.0F;
             value[1] = 0.0F;
             value[2] = -1.0F;
-            value[3] = (GLfloat) (ctx->DrawBuffer->Height - 1);
+            value[3] = (GLfloat) ctx->DrawBuffer->Height;
          } else {
             /* Flipping Y upside down (XY) followed by identity (ZW). */
             value[0] = -1.0F;
-            value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1);
+            value[1] = (GLfloat) ctx->DrawBuffer->Height;
             value[2] = 1.0F;
             value[3] = 0.0F;
          }
diff --git a/src/mesa/program/prog_statevars.h 
b/src/mesa/program/prog_statevars.h
index 9fe8d81..04af3f4 100644
--- a/src/mesa/program/prog_statevars.h
+++ b/src/mesa/program/prog_statevars.h
@@ -120,7 +120,7 @@ typedef enum gl_state_index_ {
    STATE_PT_BIAS,               /**< Pixel transfer RGBA bias */
    STATE_SHADOW_AMBIENT,        /**< ARB_shadow_ambient fail value; token[2] 
is texture unit index */
    STATE_FB_SIZE,               /**< (width-1, height-1, 0, 0) */
-   STATE_FB_WPOS_Y_TRANSFORM,   /**< (1, 0, -1, height-1) if a FBO is bound, 
(-1, height-1, 1, 0) otherwise */
+   STATE_FB_WPOS_Y_TRANSFORM,   /**< (1, 0, -1, height) if a FBO is bound, 
(-1, height, 1, 0) otherwise */
    STATE_ROT_MATRIX_0,          /**< ATI_envmap_bumpmap, rot matrix row 0 */
    STATE_ROT_MATRIX_1,          /**< ATI_envmap_bumpmap, rot matrix row 1 */
    STATE_INTERNAL_DRIVER       /* first available state index for drivers 
(must be last) */
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c 
b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index c07739f..21c5c82 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -883,7 +883,7 @@ emit_wpos(struct st_context *st,
          ureg_property_fs_coord_pixel_center(ureg, 
TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
       else if (pscreen->get_param(pscreen, 
PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER))
          /* the driver supports pixel center half integer, need to bias X,Y */
-         emit_adjusted_wpos(t, program, 0.5f, invert ? 0.5f : -0.5f);
+         emit_adjusted_wpos(t, program, -0.5f, -0.5f);
       else
          assert(0);
    }
@@ -895,7 +895,7 @@ emit_wpos(struct st_context *st,
       else if (pscreen->get_param(pscreen, 
PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          /* the driver supports pixel center integer, need to bias X,Y */
          ureg_property_fs_coord_pixel_center(ureg, 
TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
-         emit_adjusted_wpos(t, program, 0.5f, invert ? -0.5f : 0.5f);
+         emit_adjusted_wpos(t, program, 0.5f, 0.5f);
       }
       else
          assert(0);
-- 
1.7.3.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to