[PATCH] st/mesa: fix WPOS adjustment
Christoph Bumiller
e0425955 at student.tuwien.ac.at
Sat Apr 16 09:38:16 PDT 2011
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
--------------060109020702020200070908--
More information about the mesa-dev
mailing list