From fb7899bfec447e5840c2c1ea96619084093be424 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 8 Dec 2000 00:18:39 +0000 Subject: [PATCH] Compute attenuated point size in a new pipeline stage. Store computed point size in the SWvertex struct. --- src/mesa/swrast/s_points.c | 72 +++++++++++++------------------- src/mesa/swrast/swrast.h | 2 +- src/mesa/swrast_setup/ss_vb.c | 18 ++++---- src/mesa/swrast_setup/ss_vbtmp.h | 8 +++- src/mesa/tnl/t_context.h | 6 ++- 5 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index 7a7d66daca0..6e7e7010b2b 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -1,4 +1,4 @@ -/* $Id: s_points.c,v 1.7 2000/11/19 23:10:26 brianp Exp $ */ +/* $Id: s_points.c,v 1.8 2000/12/08 00:18:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -482,6 +482,7 @@ antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) /* Definition of the functions for GL_EXT_point_parameters */ +#if 000 /* Calculates the distance attenuation formula of a vector of points in * eye space coordinates */ @@ -492,9 +493,7 @@ static GLfloat attenuation_distance(const GLcontext *ctx, const GLfloat *pos) dist * (ctx->Point.Params[1] + dist * ctx->Point.Params[2])); } - - - +#endif /* @@ -504,20 +503,17 @@ static void dist_atten_general_ci_point( GLcontext *ctx, const SWvertex *vert ) { struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; - const GLfloat psize = ctx->Point._Size; - GLfloat dist = attenuation_distance( ctx, vert->eye ); GLint x0, x1, y0, y1; GLint ix, iy; GLint isize, radius; GLint x = (GLint) vert->win[0]; GLint y = (GLint) vert->win[1]; GLint z = (GLint) (vert->win[2]); - GLfloat dsize = psize * dist; GLfixed fog = FloatToFixed( vert->fog ); - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); + if (vert->pointSize >= ctx->Point.Threshold) { + isize = (GLint) (MIN2(vert->pointSize, ctx->Point.MaxSize) + 0.5F); } else { isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); @@ -556,26 +552,23 @@ static void dist_atten_general_rgba_point( GLcontext *ctx, const SWvertex *vert ) { struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; - const GLfloat psize = ctx->Point._Size; - GLfloat dist = attenuation_distance( ctx, vert->eye ); GLint x0, x1, y0, y1; GLint ix, iy; GLint isize, radius; GLint x = (GLint) vert->win[0]; GLint y = (GLint) vert->win[1]; GLint z = (GLint) (vert->win[2]); - GLfloat dsize=psize*dist; GLchan alpha; GLfixed fog = FloatToFixed( vert->fog ); - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F); + if (vert->pointSize >= ctx->Point.Threshold) { + isize = (GLint) (MIN2(vert->pointSize, ctx->Point.MaxSize) + 0.5F); alpha = vert->color[3]; } else { - isize = (GLint) (MAX2(ctx->Point.Threshold,ctx->Point.MinSize)+0.5F); - dsize /= ctx->Point.Threshold; - alpha = (GLint) (vert->color[3]* (dsize*dsize)); + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; + isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); + alpha = (GLint) (vert->color[3] * (dsize * dsize)); } radius = isize >> 1; @@ -616,9 +609,6 @@ dist_atten_textured_rgba_point( GLcontext *ctx, const SWvertex *vert ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); struct pixel_buffer *PB = swrast->PB; - const GLfloat psize = ctx->Point._Size; - GLfloat dist = attenuation_distance( ctx, vert->eye ); - const GLint x = (GLint) vert->win[0]; const GLint y = (GLint) vert->win[1]; const GLint z = (GLint) (vert->win[2]); @@ -629,18 +619,17 @@ dist_atten_textured_rgba_point( GLcontext *ctx, const SWvertex *vert ) GLint x0, x1, y0, y1; GLint ix, iy, alpha, u; GLint isize, radius; - GLfloat dsize = psize*dist; GLfixed fog = FloatToFixed( vert->fog ); /* compute point size and alpha */ - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); + if (vert->pointSize >= ctx->Point.Threshold) { + isize = (GLint) (MIN2(vert->pointSize, ctx->Point.MaxSize) + 0.5F); alpha = vert->color[3]; } else { + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); - dsize /= ctx->Point.Threshold; alpha = (GLint) (vert->color[3] * (dsize * dsize)); } if (isize < 1) { @@ -709,28 +698,25 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); struct pixel_buffer *PB = swrast->PB; - const GLfloat psize = ctx->Point._Size; - GLfloat dist = attenuation_distance( ctx, vert->eye ); if (ctx->Texture._ReallyEnabled) { - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaAtten; GLint xmin, ymin, xmax, ymax; GLint x, y, z; GLint red, green, blue, alpha; GLfloat texcoord[MAX_TEXTURE_UNITS][4]; - GLfloat dsize = psize * dist; GLint u; GLfixed fog = FloatToFixed( vert->fog ); - if (dsize >= ctx->Point.Threshold) { - radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; - alphaf = 1.0F; + if (vert->pointSize >= ctx->Point.Threshold) { + radius = MIN2(vert->pointSize, ctx->Point.MaxSize) * 0.5F; + alphaAtten = 1.0F; } else { + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); - dsize /= ctx->Point.Threshold; - alphaf = (dsize*dsize); + alphaAtten = dsize * dsize; } rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ rmax = radius + 0.7071F; @@ -776,7 +762,7 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) /* coverage is in [0,256] */ alpha = (alpha * coverage) >> 8; } - alpha = (GLint) (alpha * alphaf); + alpha = (GLint) (alpha * alphaAtten); if (swrast->_MultiTextureEnabled) { PB_WRITE_MULTITEX_PIXEL( PB, x, y, z, fog, red, green, blue, alpha, @@ -796,21 +782,20 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) } else { /* Not texture mapped */ - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaAtten; GLint xmin, ymin, xmax, ymax; GLint x, y, z; GLfixed fog; GLint red, green, blue, alpha; - GLfloat dsize = psize * dist; - if (dsize >= ctx->Point.Threshold) { - radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; - alphaf = 1.0F; + if (vert->pointSize >= ctx->Point.Threshold) { + radius = MIN2(vert->pointSize, ctx->Point.MaxSize) * 0.5F; + alphaAtten = 1.0F; } else { + GLfloat dsize = vert->pointSize / ctx->Point.Threshold; radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); - dsize /= ctx->Point.Threshold; - alphaf = dsize * dsize; + alphaAtten = dsize * dsize; } rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ rmax = radius + 0.7071F; @@ -842,7 +827,7 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) /* coverage is in [0,256] */ alpha = (alpha * coverage) >> 8; } - alpha = (GLint) (alpha * alphaf); + alpha = (GLint) (alpha * alphaAtten); PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog, red, green, blue, alpha); } @@ -853,6 +838,7 @@ dist_atten_antialiased_rgba_point( GLcontext *ctx, const SWvertex *vert ) } + #ifdef DEBUG extern void _mesa_print_point_function(GLcontext *ctx); /* silence compiler warning */ @@ -932,7 +918,7 @@ _swrast_choose_point( GLcontext *ctx ) swrast->Point = general_ci_point; } } - else if(ctx->Point.SmoothFlag && rgbmode) { + else if (ctx->Point.SmoothFlag && rgbmode) { swrast->Point = dist_atten_antialiased_rgba_point; } else if (ctx->Texture._ReallyEnabled) { diff --git a/src/mesa/swrast/swrast.h b/src/mesa/swrast/swrast.h index d2eefbebd9f..f3820a68b88 100644 --- a/src/mesa/swrast/swrast.h +++ b/src/mesa/swrast/swrast.h @@ -56,12 +56,12 @@ */ typedef struct { GLfloat win[4]; - GLfloat eye[4]; /* for GL_EXT_point_param only */ GLfloat texcoord[MAX_TEXTURE_UNITS][4]; GLchan color[4]; GLchan specular[4]; GLfloat fog; GLuint index; + GLfloat pointSize; } SWvertex; diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c index ff1916174b7..25f2299f473 100644 --- a/src/mesa/swrast_setup/ss_vb.c +++ b/src/mesa/swrast_setup/ss_vb.c @@ -53,7 +53,7 @@ typedef void (*SetupFunc)( struct vertex_buffer *VB, #define MULTITEX 0x8 #define SPEC 0x10 #define FOG 0x20 -#define EYE 0x40 +#define POINT 0x40 #define MAX_SETUPFUNC 0x80 static SetupFunc setup_func[MAX_SETUPFUNC]; @@ -87,12 +87,12 @@ static SetupFunc setup_func[MAX_SETUPFUNC]; #define TAG(x) x##_multitex_color_spec_fog #include "ss_vbtmp.h" -#define IND (TEX0|COLOR|EYE) -#define TAG(x) x##_tex0_color_eye +#define IND (TEX0|COLOR|POINT) +#define TAG(x) x##_tex0_color_point #include "ss_vbtmp.h" -#define IND (MULTITEX|COLOR|SPEC|INDEX|EYE|FOG) -#define TAG(x) x##_multitex_color_spec_index_eye_fog +#define IND (MULTITEX|COLOR|SPEC|INDEX|POINT|FOG) +#define TAG(x) x##_multitex_color_spec_index_point_fog #include "ss_vbtmp.h" #define IND (COLOR|INDEX|TEX0) @@ -108,7 +108,7 @@ _swsetup_vb_init( GLcontext *ctx ) (void) ctx; for (i = 0 ; i < Elements(setup_func) ; i++) - setup_func[i] = rs_multitex_color_spec_index_eye_fog; + setup_func[i] = rs_multitex_color_spec_index_point_fog; /* Some specialized cases: */ @@ -143,8 +143,8 @@ _swsetup_vb_init( GLcontext *ctx ) setup_func[MULTITEX|SPEC|FOG] = rs_multitex_color_spec_fog; setup_func[MULTITEX|COLOR|SPEC|FOG] = rs_multitex_color_spec_fog; - setup_func[TEX0|EYE] = rs_tex0_color_eye; - setup_func[TEX0|COLOR|EYE] = rs_tex0_color_eye; + setup_func[TEX0|POINT] = rs_tex0_color_point; + setup_func[TEX0|COLOR|POINT] = rs_tex0_color_point; setup_func[COLOR|INDEX|TEX0] = rs_selection_feedback; } @@ -174,7 +174,7 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) } if (ctx->Point._Attenuated) - funcindex |= EYE; + funcindex |= POINT; if (ctx->Fog.Enabled) funcindex |= FOG; diff --git a/src/mesa/swrast_setup/ss_vbtmp.h b/src/mesa/swrast_setup/ss_vbtmp.h index 1303883f4f4..7ed4d514416 100644 --- a/src/mesa/swrast_setup/ss_vbtmp.h +++ b/src/mesa/swrast_setup/ss_vbtmp.h @@ -38,6 +38,7 @@ static void TAG(rs)(struct vertex_buffer *VB, GLuint start, GLuint end) GLubyte (*spec)[4]; GLuint *index; GLfloat *fog; + GLfloat *pointSize; GLuint sz[MAX_TEXTURE_UNITS]; GLuint szeye; int i; @@ -79,6 +80,7 @@ static void TAG(rs)(struct vertex_buffer *VB, GLuint start, GLuint end) color = VB->Color[0]->data; spec = VB->SecondaryColor[0]->data; index = VB->Index[0]->data; + pointSize = VB->PointSize.data; v = &(SWSETUP_VB(VB)->verts[start]); @@ -86,9 +88,10 @@ static void TAG(rs)(struct vertex_buffer *VB, GLuint start, GLuint end) if (VB->ClipMask[i] == 0) { COPY_4FV( v->win, win[i] ); +#if 0 if (IND & EYE) COPY_4FV( v->eye, eye[i] ); - +#endif if (IND & TEX0) COPY_CLEAN_4V( v->texcoord[0], sz[0], tc[0][i] ); @@ -110,6 +113,9 @@ static void TAG(rs)(struct vertex_buffer *VB, GLuint start, GLuint end) if (IND & INDEX) v->index = index[i]; + + if (IND & POINT) + v->pointSize = pointSize[i]; } } } diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 720db4b7f9d..fb036b9f3d9 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,5 +1,5 @@ -/* $Id: t_context.h,v 1.5 2000/11/24 15:22:00 keithw Exp $ */ +/* $Id: t_context.h,v 1.6 2000/12/08 00:18:39 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -109,6 +109,7 @@ #define VERT_EVAL_P2 0x8000000 /* */ #define VERT_SPEC_RGB 0x10000000 #define VERT_FOG_COORD 0x20000000 +#define VERT_POINT_SIZE 0x40000000 #define VERT_EYE VERT_BEGIN /* reuse */ #define VERT_WIN VERT_END /* reuse */ @@ -353,6 +354,7 @@ typedef struct vertex_buffer GLvector4f Eye; GLvector4f Clip; GLvector4f Win; + GLvector1f PointSize; GLvector4ub BColor; /* not used in cva vb's */ GLvector1ui BIndex; /* not used in cva vb's */ GLvector4ub BSecondary; /* not used in cva vb's */ @@ -446,7 +448,7 @@ typedef GLuint (*clip_poly_func)( struct vertex_buffer *VB, #define PIPE_OP_RAST_SETUP_1 0x200 #define PIPE_OP_RENDER 0x400 #define PIPE_OP_CVA_PREPARE 0x800 - +#define PIPE_OP_POINT_SIZE 0x1000 struct gl_pipeline_stage { -- 2.30.2