diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-06-19 19:52:25 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-06-19 19:52:25 -0600 |
commit | 6cb2d0cb71d2019bd2c941a8c042e56275b22c1c (patch) | |
tree | 549ac563454270eaef2abbb05203e462ea6b9289 /src | |
parent | af9b5ca0359b5712509d7815a7fbc81a3255f4af (diff) |
hook up point state
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/pipe/p_context.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 1 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_prim_setup.c | 131 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state.h | 3 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_state_point.c | 47 | ||||
-rw-r--r-- | src/mesa/sources | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.h | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_point.c | 70 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 2 |
11 files changed, 204 insertions, 60 deletions
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index f7374a8380..3e0c61eda2 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -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 * ); diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 018f67302d..e0acf4177b 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -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; diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index a873301368..43cb6f3f0b 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -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; diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c index a1addc4ee1..8ef0fcbf9c 100644 --- a/src/mesa/pipe/softpipe/sp_prim_setup.c +++ b/src/mesa/pipe/softpipe/sp_prim_setup.c @@ -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 ); + } } } } diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 5002ce88fc..4d18e80b38 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -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 index 0000000000..566b33e696 --- /dev/null +++ b/src/mesa/pipe/softpipe/sp_state_point.c @@ -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; +} + diff --git a/src/mesa/sources b/src/mesa/sources index eb67dd9f7b..0bf7dbceb3 100644 --- a/src/mesa/sources +++ b/src/mesa/sources @@ -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 \ diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 228e7889b7..8ac435041d 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -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, diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h index 8a75c9c6d5..56c33f3076 100644 --- a/src/mesa/state_tracker/st_atom.h +++ b/src/mesa/state_tracker/st_atom.h @@ -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 index 0000000000..7299142932 --- /dev/null +++ b/src/mesa/state_tracker/st_atom_point.c @@ -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 +}; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index d98dd3aada..94388f1aee 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -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; |