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 * );
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;
#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 {
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;
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.
/* 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 );
+ }
}
}
}
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 * );
--- /dev/null
+/**************************************************************************
+ *
+ * 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;
+}
+
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 \
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 \
&st_update_framebuffer,
&st_update_clip,
&st_update_fs,
+ &st_update_point,
&st_update_setup,
&st_update_viewport,
&st_update_scissor,
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;
--- /dev/null
+/**************************************************************************
+ *
+ * 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
+};
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;