Keith, I don't know if you've started on the origin_lower_left
removal, but here's a patch that fixes things up for the polygon
stipple paths and softpipe.

If I get around to inverting gl_FragCoord in fragment shaders this
week, I'll commit all the changes then.

-Brian
diff --git a/src/gallium/drivers/softpipe/sp_quad_stipple.c b/src/gallium/drivers/softpipe/sp_quad_stipple.c
index 05e862f..07162db 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stipple.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stipple.c
@@ -22,21 +22,11 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
    if (quad->input.prim == QUAD_PRIM_TRI) {
       struct softpipe_context *softpipe = qs->softpipe;
       /* need to invert Y to index into OpenGL's stipple pattern */
-      int y0, y1;
-      uint stipple0, stipple1;
       const int col0 = quad->input.x0 % 32;
-
-      if (softpipe->rasterizer->origin_lower_left) {
-         y0 = softpipe->framebuffer.height - 1 - quad->input.y0;
-         y1 = y0 - 1;
-      }
-      else {
-         y0 = quad->input.y0;
-         y1 = y0 + 1;
-      }
-
-      stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
-      stipple1 = softpipe->poly_stipple.stipple[y1 % 32];
+      const int y0 = quad->input.y0;
+      const int y1 = y0 + 1;
+      const uint stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
+      const uint stipple1 = softpipe->poly_stipple.stipple[y1 % 32];
 
       /* turn off quad mask bits that fail the stipple test */
       if ((stipple0 & (bit31 >> col0)) == 0)
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index 0925653..96cb09b 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -732,18 +732,9 @@ setup_fragcoord_coeff(struct setup_context *setup, uint slot)
    setup->coef[slot].dadx[0] = 1.0;
    setup->coef[slot].dady[0] = 0.0;
    /*Y*/
-   if (setup->softpipe->rasterizer->origin_lower_left) {
-      /* y=0=bottom */
-      const int winHeight = setup->softpipe->framebuffer.height;
-      setup->coef[slot].a0[1] = (float) (winHeight - 1);
-      setup->coef[slot].dady[1] = -1.0;
-   }
-   else {
-      /* y=0=top */
-      setup->coef[slot].a0[1] = 0.0;
-      setup->coef[slot].dady[1] = 1.0;
-   }
+   setup->coef[slot].a0[1] = 0.0;
    setup->coef[slot].dadx[1] = 0.0;
+   setup->coef[slot].dady[1] = 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/mesa/state_tracker/st_atom_stipple.c b/src/mesa/state_tracker/st_atom_stipple.c
index f395930..54af147 100644
--- a/src/mesa/state_tracker/st_atom_stipple.c
+++ b/src/mesa/state_tracker/st_atom_stipple.c
@@ -39,24 +39,43 @@
 #include "pipe/p_defines.h"
 
 
+/**
+ * OpenGL's polygon stipple is indexed with window coordinates in which
+ * the origin (0,0) is the lower-left corner of the window.
+ * With Gallium, the origin is the upper-left corner of the window.
+ * To convert GL's polygon stipple to what gallium expects we need to
+ * invert the pattern vertically and rotate the stipple rows according
+ * to the window height.
+ */
+static void
+invert_stipple(GLuint dest[32], const GLuint src[32], GLuint winHeight)
+{
+   GLuint i;
+
+   for (i = 0; i < 32; i++) {
+      dest[i] = src[(winHeight - 1 - i) & 0x1f];
+   }
+}
+
+
+
 static void 
 update_stipple( struct st_context *st )
 {
-   const GLuint sz = sizeof(st->state.poly_stipple.stipple);
-   assert(sz == sizeof(st->ctx->PolygonStipple));
-
-   if (memcmp(&st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz)) {
-      /* state has changed */
-      memcpy(st->state.poly_stipple.stipple, st->ctx->PolygonStipple, sz);
+   if (st->ctx->Polygon.StippleFlag) {
+      invert_stipple(st->state.poly_stipple.stipple, st->ctx->PolygonStipple,
+                     st->ctx->DrawBuffer->Height);
       st->pipe->set_polygon_stipple(st->pipe, &st->state.poly_stipple);
    }
 }
 
 
+/** Update the stipple when the pattern or window height changes */
 const struct st_tracked_state st_update_polygon_stipple = {
    "st_update_polygon_stipple",				/* name */
    {							/* dirty */
-      (_NEW_POLYGONSTIPPLE),				/* mesa */
+      (_NEW_POLYGONSTIPPLE |
+       _NEW_BUFFERS),					/* mesa */
       0,						/* st */
    },
    update_stipple					/* update */
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to