diff options
author | Brian <[email protected]> | 2007-06-19 19:52:25 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-06-19 19:52:25 -0600 |
commit | 6cb2d0cb71d2019bd2c941a8c042e56275b22c1c (patch) | |
tree | 549ac563454270eaef2abbb05203e462ea6b9289 /src/mesa/pipe | |
parent | af9b5ca0359b5712509d7815a7fbc81a3255f4af (diff) |
hook up point state
Diffstat (limited to 'src/mesa/pipe')
-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 |
6 files changed, 129 insertions, 59 deletions
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index f7374a8380a..3e0c61eda20 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 018f67302dd..e0acf4177b8 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 a8733013684..43cb6f3f0bc 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 a1addc4ee17..8ef0fcbf9c5 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 5002ce88fcc..4d18e80b388 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 00000000000..566b33e6969 --- /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 <[email protected]> + */ +#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; +} + |