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 f7374a8..3e0c61e 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 018f673..e0acf41 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 a873301..43cb6f3 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 a1addc4..8ef0fcb 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 5002ce8..4d18e80 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 eb67dd9..0bf7dbc 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 228e788..8ac4350 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 8a75c9c..56c33f3 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 d98dd3a..94388f1 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;