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.
>From f150c14f8d33f5898b47d5ef01aef5aa051aa841 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller <e0425...@student.tuwien.ac.at> Date: Sat, 16 Apr 2011 18:38:16 +0200 Subject: [PATCH] st/mesa: fix WPOS adjustment For the first change, where we want to convert from half integer to integer coordinates, consider the upper left position: u,h -> l,i / 0.5 -> 99.0 : ( 0.5 - 0.5) * -1 + 99 u,h -> u,i / 0.5 -> 0.0 : ( 0.5 - 0.5) l,h -> u,i / 99.5 -> 0.0 : (99.5 - 0.5) * -1 + 99 l,h -> l,i / 99.5 -> 99.0 : (99.5 - 0.5) --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index c07739f..6a63a39 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); } @@ -891,6 +891,10 @@ emit_wpos(struct st_context *st, /* Fragment shader wants pixel center half integer */ if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER)) { /* the driver supports pixel center half integer */ + if (invert) { + /* for h = 100: (0.5 -> 99.5) by ((0.5 - 1.0) * -1 + 99.0) */ + emit_adjusted_wpos(t, program, 0.0f, -1.0f); + } } 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 */ -- 1.7.3.4
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev