hook up point state
authorBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 01:52:25 +0000 (19:52 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 20 Jun 2007 01:52:25 +0000 (19:52 -0600)
src/mesa/pipe/p_context.h
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_prim_setup.c
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_point.c [new file with mode: 0644]
src/mesa/sources
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_atom.h
src/mesa/state_tracker/st_atom_point.c [new file with mode: 0644]
src/mesa/state_tracker/st_context.h

index f7374a8380af374bb0f33c6b5d88df41f19dcdce..3e0c61eda201da77c18f0314e5b737e9a8134cde 100644 (file)
@@ -71,6 +71,9 @@ struct pipe_context {
    void (*set_depth_state)( struct pipe_context *,
                               const struct pipe_depth_state * );
 
+   void (*set_point_state)( struct pipe_context *,
+                            const struct pipe_point_state * );
+
    void (*set_framebuffer_state)( struct pipe_context *,
                                   const struct pipe_framebuffer_state * );
 
index 018f67302ddaede0d56d2b197e6d0494fd78f9d1..e0acf4177b81d84fbc4f5261b8cb1b48f6ec6556 100644 (file)
@@ -68,6 +68,7 @@ struct pipe_context *softpipe_create( void )
    softpipe->pipe.destroy = softpipe_destroy;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
+   softpipe->pipe.set_point_state = softpipe_set_point_state;
    softpipe->pipe.set_viewport = softpipe_set_viewport;
    softpipe->pipe.set_setup_state = softpipe_set_setup_state;
    softpipe->pipe.set_scissor_rect = softpipe_set_scissor_rect;
index a87330136846bccc0e490047cc8843ff1f1a34eb..43cb6f3f0bc765cc0e4c76d0d9d5e63c377ce9a0 100644 (file)
@@ -54,11 +54,13 @@ enum interp_mode {
 #define G_NEW_SETUP     0x2
 #define G_NEW_FS        0x4
 #define G_NEW_BLEND     0x8
+#define G_NEW_POINT     0x10
 #define G_NEW_CLIP      0x20
 #define G_NEW_SCISSOR   0x40
 #define G_NEW_STIPPLE   0x80
 #define G_NEW_FRAMEBUFFER 0x100
 #define G_NEW_ALPHA_TEST  0x200
+#define G_NEW_DEPTH_TEST  0x400
 
 
 struct softpipe_context {     
@@ -74,6 +76,7 @@ struct softpipe_context {
    struct pipe_blend_state  blend;
    struct pipe_alpha_test_state alpha_test;
    struct pipe_clip_state   clip;
+   struct pipe_point_state  point;
    struct pipe_scissor_rect scissor;
    struct pipe_poly_stipple poly_stipple;
    GLuint dirty;
index a1addc4ee178e3ba496e524e0926e1aaa994eb60..8ef0fcbf9c5e3da367372c04d60ba5b296b8f38e 100644 (file)
@@ -769,17 +769,12 @@ static void
 setup_point(struct prim_stage *stage, struct prim_header *prim)
 {
    struct setup_stage *setup = setup_stage( stage );
-   GLfloat halfSize = 7.3; /*XXX this is a vertex attrib */
-   GLfloat halfSizeSquared = halfSize * halfSize;
+   /*XXX this should be a vertex attrib! */
+   GLfloat halfSize = 0.5 * setup->stage.softpipe->point.size;
+   GLboolean round = setup->stage.softpipe->point.smooth;
    const struct vertex_header *v0 = prim->v[0];
    const GLfloat x = v0->data[FRAG_ATTRIB_WPOS][0];
    const GLfloat y = v0->data[FRAG_ATTRIB_WPOS][1];
-   const GLint ixmin = block((GLint) (x - halfSize));
-   const GLint ixmax = block((GLint) (x + halfSize));
-   const GLint iymin = block((GLint) (y - halfSize));
-   const GLint iymax = block((GLint) (y + halfSize));
-   GLboolean round = GL_TRUE;
-   GLint ix, iy;
    GLuint slot, j;
 
    /* For points, all interpolants are constant-valued.
@@ -808,57 +803,75 @@ setup_point(struct prim_stage *stage, struct prim_header *prim)
 
    /* XXX need to clip against scissor bounds too */
 
-   for (iy = iymin; iy <= iymax; iy += 2) {
-      for (ix = ixmin; ix <= ixmax; ix += 2) {
-
-         if (round) {
-            /* rounded points */
-            /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */
-            GLfloat dx, dy;
-
-            setup->quad.mask = 0x0;
-
-            dx = (ix + 0.5) - x;
-            dy = (iy + 0.5) - y;
-            if (dx * dx + dy * dy <= halfSizeSquared)
-               setup->quad.mask |= MASK_BOTTOM_LEFT;
-
-            dx = (ix + 1.5) - x;
-            dy = (iy + 0.5) - y;
-            if (dx * dx + dy * dy <= halfSizeSquared)
-               setup->quad.mask |= MASK_BOTTOM_RIGHT;
-
-            dx = (ix + 0.5) - x;
-            dy = (iy + 1.5) - y;
-            if (dx * dx + dy * dy <= halfSizeSquared)
-               setup->quad.mask |= MASK_TOP_LEFT;
-
-            dx = (ix + 1.5) - x;
-            dy = (iy + 1.5) - y;
-            if (dx * dx + dy * dy <= halfSizeSquared)
-               setup->quad.mask |= MASK_TOP_RIGHT;
-         }
-         else {
-            /* square points */
-            setup->quad.mask = 0xf;
-
-            if (ix + 0.5 < x - halfSize)
-               setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
-
-            if (ix + 1.5 > x + halfSize)
-               setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
-
-            if (iy + 0.5 < y - halfSize)
-               setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
-
-            if (iy + 1.5 > y + halfSize)
-               setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
-         }
-
-         if (setup->quad.mask) {
-            setup->quad.x0 = ix;
-            setup->quad.y0 = iy;
-            quad_shade( setup->stage.softpipe, &setup->quad );
+   if (halfSize <= 0.5 && !round) {
+      /* special case for 1-pixel points */
+      const GLint ix = ((GLint) x) & 1;
+      const GLint iy = ((GLint) y) & 1;
+      setup->quad.x0 = x - ix;
+      setup->quad.y0 = y - iy;
+      setup->quad.mask = (1 << ix) << (2 * iy);
+      quad_shade(setup->stage.softpipe, &setup->quad);
+   }
+   else {
+      const GLint ixmin = block((GLint) (x - halfSize));
+      const GLint ixmax = block((GLint) (x + halfSize));
+      const GLint iymin = block((GLint) (y - halfSize));
+      const GLint iymax = block((GLint) (y + halfSize));
+      GLfloat halfSizeSquared = halfSize * halfSize;
+      GLint ix, iy;
+
+      for (iy = iymin; iy <= iymax; iy += 2) {
+         for (ix = ixmin; ix <= ixmax; ix += 2) {
+
+            if (round) {
+               /* rounded points */
+               /* XXX for GL_SMOOTH, need to compute per-fragment coverage too */
+               GLfloat dx, dy;
+
+               setup->quad.mask = 0x0;
+
+               dx = (ix + 0.5) - x;
+               dy = (iy + 0.5) - y;
+               if (dx * dx + dy * dy <= halfSizeSquared)
+                  setup->quad.mask |= MASK_BOTTOM_LEFT;
+
+               dx = (ix + 1.5) - x;
+               dy = (iy + 0.5) - y;
+               if (dx * dx + dy * dy <= halfSizeSquared)
+                  setup->quad.mask |= MASK_BOTTOM_RIGHT;
+
+               dx = (ix + 0.5) - x;
+               dy = (iy + 1.5) - y;
+               if (dx * dx + dy * dy <= halfSizeSquared)
+                  setup->quad.mask |= MASK_TOP_LEFT;
+
+               dx = (ix + 1.5) - x;
+               dy = (iy + 1.5) - y;
+               if (dx * dx + dy * dy <= halfSizeSquared)
+                  setup->quad.mask |= MASK_TOP_RIGHT;
+            }
+            else {
+               /* square points */
+               setup->quad.mask = 0xf;
+
+               if (ix + 0.5 < x - halfSize)
+                  setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
+
+               if (ix + 1.5 > x + halfSize)
+                  setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
+
+               if (iy + 0.5 < y - halfSize)
+                  setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
+
+               if (iy + 1.5 > y + halfSize)
+                  setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
+            }
+
+            if (setup->quad.mask) {
+               setup->quad.x0 = ix;
+               setup->quad.y0 = iy;
+               quad_shade( setup->stage.softpipe, &setup->quad );
+            }
          }
       }
    }
index 5002ce88fcc2a50e2ffe42151ff9d4aa30de08f3..4d18e80b3889411edc85f409654e45b949eebac7 100644 (file)
@@ -53,6 +53,9 @@ void softpipe_set_scissor_rect( struct pipe_context *,
 void softpipe_set_fs_state( struct pipe_context *,
                           const struct pipe_fs_state * );
 
+void softpipe_set_point_state( struct pipe_context *,
+                               const struct pipe_point_state * );
+
 void softpipe_set_polygon_stipple( struct pipe_context *,
                                  const struct pipe_poly_stipple * );
 
diff --git a/src/mesa/pipe/softpipe/sp_state_point.c b/src/mesa/pipe/softpipe/sp_state_point.c
new file mode 100644 (file)
index 0000000..566b33e
--- /dev/null
@@ -0,0 +1,47 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+/* Authors:  Keith Whitwell <keith@tungstengraphics.com>
+ */
+#include "imports.h"
+
+#include "sp_context.h"
+#include "sp_state.h"
+#include "sp_draw.h"
+
+
+
+void softpipe_set_point_state( struct pipe_context *pipe,
+                            const struct pipe_point_state *point )
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+
+   softpipe->point = *point;
+
+   softpipe->dirty |= G_NEW_POINT;
+}
+
index eb67dd9f7b9ce5ff69de0e5b891d761abe080dc5..0bf7dbceb3eb1cb9d849b97483e94f08e0dc035f 100644 (file)
@@ -167,6 +167,7 @@ SOFTPIPE_SOURCES = \
        pipe/softpipe/sp_state_clip.c \
        pipe/softpipe/sp_state_derived.c \
        pipe/softpipe/sp_state_fs.c \
+       pipe/softpipe/sp_state_point.c \
        pipe/softpipe/sp_state_setup.c \
        pipe/softpipe/sp_state_surface.c \
        pipe/softpipe/sp_tile_fs.c \
@@ -180,6 +181,7 @@ STATETRACKER_SOURCES = \
        state_tracker/st_atom_depth.c \
        state_tracker/st_atom_fs.c \
        state_tracker/st_atom_framebuffer.c \
+       state_tracker/st_atom_point.c \
        state_tracker/st_atom_scissor.c \
        state_tracker/st_atom_stencil.c \
        state_tracker/st_atom_setup.c \
index 228e7889b78d74b364b34fee461abab3ec2cf163..8ac435041d019e16dea47b974f0b82e2a2137f17 100644 (file)
@@ -45,6 +45,7 @@ static const struct st_tracked_state *atoms[] =
    &st_update_framebuffer,
    &st_update_clip,
    &st_update_fs,
+   &st_update_point,
    &st_update_setup,
    &st_update_viewport,
    &st_update_scissor,
index 8a75c9c6d5a2e1e37e2fcee663cc87b9df51ef69..56c33f3076ed46330976dab98a6bb041abe9826e 100644 (file)
@@ -48,6 +48,7 @@ const struct st_tracked_state st_update_framebuffer;
 const struct st_tracked_state st_update_clip;
 const struct st_tracked_state st_update_depth;
 const struct st_tracked_state st_update_fs;
+const struct st_tracked_state st_update_point;
 const struct st_tracked_state st_update_setup;
 const struct st_tracked_state st_update_viewport;
 const struct st_tracked_state st_update_constants;
diff --git a/src/mesa/state_tracker/st_atom_point.c b/src/mesa/state_tracker/st_atom_point.c
new file mode 100644 (file)
index 0000000..7299142
--- /dev/null
@@ -0,0 +1,70 @@
+/**************************************************************************
+ * 
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+ /*
+  * Authors:
+  *   Keith Whitwell <keith@tungstengraphics.com>
+  *   Brian Paul
+  */
+
+#include "st_context.h"
+#include "st_atom.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+
+
+static void 
+update_point( struct st_context *st )
+{
+   struct pipe_point_state point;
+
+   memset(&point, 0, sizeof(point));
+
+   point.smooth = st->ctx->Point.SmoothFlag;
+   point.size = st->ctx->Point.Size;
+   point.min_size = st->ctx->Point.MinSize;
+   point.max_size = st->ctx->Point.MaxSize;
+   point.attenuation[0] = st->ctx->Point.Params[0];
+   point.attenuation[1] = st->ctx->Point.Params[1];
+   point.attenuation[2] = st->ctx->Point.Params[2];
+
+   if (memcmp(&point, &st->state.point, sizeof(point)) != 0) {
+      /* state has changed */
+      st->state.point = point;  /* struct copy */
+      st->pipe->set_point_state(st->pipe, &point); /* set new state */
+   }
+}
+
+
+const struct st_tracked_state st_update_point = {
+   .dirty = {
+      .mesa = (_NEW_POINT),
+      .st  = 0,
+   },
+   .update = update_point
+};
index d98dd3aadae1c0f45b29d4e0e6602b200982e750..94388f1aee62cd8104ef6d39c642dd3ddceae561 100644 (file)
@@ -71,9 +71,9 @@ struct st_context
       struct pipe_fs_state     fs;
       struct pipe_alpha_test_state  alpha_test;
       struct pipe_blend_state  blend;
-      struct pipe_surface      cbuf;
       struct pipe_clip_state   clip;
       struct pipe_depth_state  depth;
+      struct pipe_point_state  point;
       struct pipe_scissor_rect scissor;
       struct pipe_poly_stipple poly_stipple;
       struct pipe_stencil_state stencil;