Mesa (7.9): st/mesa: fix incorrect fragcoord.x translation

Brian Paul brianp at kemper.freedesktop.org
Tue Feb 22 01:20:22 UTC 2011


Module: Mesa
Branch: 7.9
Commit: 0a218b00e7deeea0c217c5854eda0b667d98384a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a218b00e7deeea0c217c5854eda0b667d98384a

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Jan 25 11:54:05 2011 -0700

st/mesa: fix incorrect fragcoord.x translation

emit_adjusted_wpos() needs separate x,y translation values.  If we
invert Y, we don't want to effect X.

Part of the fix for http://bugs.freedesktop.org/show_bug.cgi?id=26795

NOTE: This is a candidate for the 7.9 and 7.10 branches.
(cherry picked from commit bb56631f0cb6b3fc552a72e0165816909bf6fdc9)

---

 src/mesa/state_tracker/st_mesa_to_tgsi.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 2712717..81980f7 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -739,10 +739,12 @@ compile_instruction(
 
 /**
  * Emit the TGSI instructions to adjust the WPOS pixel center convention
+ * Basically, add (adjX, adjY) to the fragment position.
  */
 static void
 emit_adjusted_wpos( struct st_translate *t,
-                    const struct gl_program *program, GLfloat value)
+                    const struct gl_program *program,
+                    GLfloat adjX, GLfloat adjY)
 {
    struct ureg_program *ureg = t->ureg;
    struct ureg_dst wpos_temp = ureg_DECL_temporary(ureg);
@@ -752,7 +754,7 @@ emit_adjusted_wpos( struct st_translate *t,
     * The shader might also use gl_FragCoord.w and .z.
     */
    ureg_ADD(ureg, wpos_temp, wpos_input,
-            ureg_imm4f(ureg, value, value, 0.0f, 0.0f));
+            ureg_imm4f(ureg, adjX, adjY, 0.0f, 0.0f));
 
    t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]] = ureg_src(wpos_temp);
 }
@@ -858,7 +860,7 @@ emit_wpos(struct st_context *st,
       if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER))
          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))
-         emit_adjusted_wpos(t, program, invert ? 0.5f : -0.5f);
+         emit_adjusted_wpos(t, program, 0.5f, invert ? 0.5f : -0.5f);
       else
          assert(0);
    }
@@ -867,7 +869,7 @@ emit_wpos(struct st_context *st,
       }
       else if (pscreen->get_param(pscreen, PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER)) {
          ureg_property_fs_coord_pixel_center(ureg, TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
-         emit_adjusted_wpos(t, program, invert ? -0.5f : 0.5f);
+         emit_adjusted_wpos(t, program, 0.5f, invert ? -0.5f : 0.5f);
       }
       else
          assert(0);




More information about the mesa-commit mailing list