Changes:
- Now takes the fragment convention directly from the fragment shader

The pixel center condition of softpipe was previously, incorrectly,
INTEGER.

This patch supports the new properties and also fixes this bug.
---
 src/gallium/drivers/softpipe/sp_screen.c   |    3 +++
 src/gallium/drivers/softpipe/sp_setup.c    |   11 +++++++----
 src/gallium/drivers/softpipe/sp_state.h    |    3 +++
 src/gallium/drivers/softpipe/sp_state_fs.c |    8 ++++++++
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_screen.c 
b/src/gallium/drivers/softpipe/sp_screen.c
index bd3532d..6acf98e 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -91,6 +91,9 @@ softpipe_get_param(struct pipe_screen *screen, int param)
       return 1;
    case PIPE_CAP_BLEND_EQUATION_SEPARATE:
       return 1;
+   case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
+   case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
+      return 1;
    default:
       return 0;
    }
diff --git a/src/gallium/drivers/softpipe/sp_setup.c 
b/src/gallium/drivers/softpipe/sp_setup.c
index 3da7536..82d5fed 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -506,21 +506,24 @@ static void tri_persp_coeff( struct setup_context *setup,
 
 /**
  * Special coefficient setup for gl_FragCoord.
- * X and Y are trivial, though Y has to be inverted for OpenGL.
+ * X and Y are trivial, though Y may have to be inverted for OpenGL.
  * Z and W are copied from posCoef which should have already been computed.
  * We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
  */
 static void
 setup_fragcoord_coeff(struct setup_context *setup, uint slot)
 {
+   struct sp_fragment_shader* spfs = setup->softpipe->fs;
    /*X*/
-   setup->coef[slot].a0[0] = 0;
+   setup->coef[slot].a0[0] = spfs->pixel_center_integer ? 0.0 : 0.5;
    setup->coef[slot].dadx[0] = 1.0;
    setup->coef[slot].dady[0] = 0.0;
    /*Y*/
-   setup->coef[slot].a0[1] = 0.0;
+   setup->coef[slot].a0[1] =
+                  (spfs->origin_lower_left ? 
setup->softpipe->framebuffer.height : 0)
+                  + (spfs->pixel_center_integer ? 0.0 : 0.5);
    setup->coef[slot].dadx[1] = 0.0;
-   setup->coef[slot].dady[1] = 1.0;
+   setup->coef[slot].dady[1] = spfs->origin_lower_left ? -1.0 : 1.0;
    /*Z*/
    setup->coef[slot].a0[2] = setup->posCoef.a0[2];
    setup->coef[slot].dadx[2] = setup->posCoef.dadx[2];
diff --git a/src/gallium/drivers/softpipe/sp_state.h 
b/src/gallium/drivers/softpipe/sp_state.h
index 7f244c4..a83cae7 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -68,6 +68,9 @@ struct sp_fragment_shader {
 
    struct tgsi_shader_info info;
 
+   boolean origin_lower_left; /**< fragment shader uses lower left position 
origin? */
+   boolean pixel_center_integer; /**< fragment shader uses integer pixel 
center? */
+
    void (*prepare)( const struct sp_fragment_shader *shader,
                    struct tgsi_exec_machine *machine,
                    struct tgsi_sampler **samplers);
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c 
b/src/gallium/drivers/softpipe/sp_state_fs.c
index b7ed444..1171ec7 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -44,6 +44,7 @@ softpipe_create_fs_state(struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
    struct sp_fragment_shader *state;
+   unsigned i;
 
    /* debug */
    if (softpipe->dump_fs) 
@@ -60,6 +61,13 @@ softpipe_create_fs_state(struct pipe_context *pipe,
    /* get/save the summary info for this shader */
    tgsi_scan_shader(templ->tokens, &state->info);
 
+   for (i = 0; i < state->info.num_properties; ++i) {
+      if (state->info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN)
+         state->origin_lower_left = state->info.properties[i].data[0];
+      else if (state->info.properties[i].name == 
TGSI_PROPERTY_FS_COORD_PIXEL_CENTER)
+        state->pixel_center_integer = state->info.properties[i].data[0];
+   }
+
    return state;
 }
 
-- 
1.6.3.3


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to