diff options
author | Keith Whitwell <[email protected]> | 2000-11-05 18:24:40 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2000-11-05 18:24:40 +0000 |
commit | cd03ed4f54444d96e4e47cdb118a3dfd94d92bb0 (patch) | |
tree | 57d9620635286b4ee4b8adf950014113d5961017 /src/mesa/swrast/s_points.c | |
parent | 7c20642b1091df1aab7d9076a3fe2fb11c6f011c (diff) |
Reorganized software rasterizer as a module which manages its own state,
with tighter interfaces with the rest of the world.
Proper documentation to come.
Diffstat (limited to 'src/mesa/swrast/s_points.c')
-rw-r--r-- | src/mesa/swrast/s_points.c | 1546 |
1 files changed, 654 insertions, 892 deletions
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index b24fc642ac1..a4a889e2ddf 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.1 2000/10/31 18:00:04 keithw Exp $ */ +/* $Id: s_points.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -27,13 +27,15 @@ #include "glheader.h" #include "context.h" -#include "feedback.h" #include "macros.h" #include "mmath.h" #include "texstate.h" #include "vb.h" +#include "s_context.h" +#include "s_feedback.h" #include "s_pb.h" +#include "s_points.h" #include "s_span.h" @@ -48,9 +50,6 @@ * 2. size1: size=1 and any rasterization functions * 3. general: any size and rasterization functions (slowest) * - * All point rendering functions take the same two arguments: first and - * last which specify that the points specified by VB[first] through - * VB[last] are to be rendered. */ @@ -61,33 +60,22 @@ * CI points with size == 1.0 */ static void -size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +size1_ci_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLfloat *win, *fog; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; GLint *pbx = PB->x, *pby = PB->y; GLdepth *pbz = PB->z; GLfixed *pbfog = PB->fog; GLuint *pbi = PB->index; GLuint pbcount = PB->count; - GLuint i; - - win = &VB->Win.data[first][0]; - fog = &VB->FogCoordPtr->data[first]; - - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - pbx[pbcount] = (GLint) win[0]; - pby[pbcount] = (GLint) win[1]; - pbz[pbcount] = (GLint) (win[2] + ctx->PointZoffset); - pbfog[pbcount] = FloatToFixed(fog[i]); - pbi[pbcount] = VB->IndexPtr->data[i]; - pbcount++; - } - win += 3; - } - PB->count = pbcount; + + pbx[pbcount] = (GLint) vert->win[0]; + pby[pbcount] = (GLint) vert->win[1]; + pbz[pbcount] = (GLint) vert->win[2]; + pbfog[pbcount] = FloatToFixed(vert->fog); + pbi[pbcount] = vert->index; + + PB->count++; PB_CHECK_FLUSH(ctx, PB); } @@ -97,32 +85,20 @@ size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) * RGBA points with size == 1.0 */ static void -size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +size1_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLuint i; - - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLint x, y, z; - GLint fog; - GLint red, green, blue, alpha; - - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - - fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - red = VB->ColorPtr->data[i][0]; - green = VB->ColorPtr->data[i][1]; - blue = VB->ColorPtr->data[i][2]; - alpha = VB->ColorPtr->data[i][3]; - - PB_WRITE_RGBA_PIXEL( PB, x, y, z, fog, red, green, blue, alpha ); - } - } + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; + + GLint x = (GLint) vert->win[0]; + GLint y = (GLint) vert->win[1]; + GLint z = (GLint) (vert->win[2]); + GLfixed fog = FloatToFixed( vert->fog ); + GLubyte red = vert->color[0]; + GLubyte green = vert->color[1]; + GLubyte blue = vert->color[2]; + GLubyte alpha = vert->color[3]; + + PB_WRITE_RGBA_PIXEL( PB, x, y, z, fog, red, green, blue, alpha ); PB_CHECK_FLUSH(ctx, PB); } @@ -132,50 +108,44 @@ size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) * General CI points. */ static void -general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +general_ci_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLint isize = (GLint) (ctx->Point.Size + 0.5F); GLint radius = isize >> 1; - GLuint i; - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLint x0, x1, y0, y1; - GLint ix, iy; + GLint x0, x1, y0, y1; + GLint ix, iy; - GLint x = (GLint) VB->Win.data[i][0]; - GLint y = (GLint) VB->Win.data[i][1]; - GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) vert->win[0]; + GLint y = (GLint) vert->win[1]; + GLint z = (GLint) (vert->win[2]); - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); + GLfixed fog = FloatToFixed( vert->fog ); - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } - PB_SET_INDEX( PB, VB->IndexPtr->data[i] ); + PB_SET_INDEX( PB, vert->index ); - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - PB_WRITE_PIXEL( PB, ix, iy, z, fog ); - } - } - PB_CHECK_FLUSH(ctx,PB); + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z, fog ); } } + PB_CHECK_FLUSH(ctx,PB); } @@ -183,54 +153,48 @@ general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) * General RGBA points. */ static void -general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +general_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; GLint isize = (GLint) (ctx->Point.Size + 0.5F); GLint radius = isize >> 1; - GLuint i; - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLint x0, x1, y0, y1; - GLint ix, iy; + GLint x0, x1, y0, y1; + GLint ix, iy; - GLint x = (GLint) VB->Win.data[i][0]; - GLint y = (GLint) VB->Win.data[i][1]; - GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) vert->win[0]; + GLint y = (GLint) vert->win[1]; + GLint z = (GLint) (vert->win[2]); - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); + GLfixed fog = FloatToFixed( vert->fog ); - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } - PB_SET_COLOR( PB, - VB->ColorPtr->data[i][0], - VB->ColorPtr->data[i][1], - VB->ColorPtr->data[i][2], - VB->ColorPtr->data[i][3] ); + PB_SET_COLOR( PB, + vert->color[0], + vert->color[1], + vert->color[2], + vert->color[3] ); - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - PB_WRITE_PIXEL( PB, ix, iy, z, fog ); - } - } - PB_CHECK_FLUSH(ctx,PB); + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z, fog ); } } + PB_CHECK_FLUSH(ctx,PB); } @@ -240,185 +204,142 @@ general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) * Textured RGBA points. */ static void -textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +textured_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLuint i; - - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLint x0, x1, y0, y1; - GLint ix, iy, radius; - GLint red, green, blue, alpha; - GLfloat s, t, u; - - GLint x = (GLint) VB->Win.data[i][0]; - GLint y = (GLint) VB->Win.data[i][1]; - GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - GLint isize = (GLint) (ctx->Point.Size + 0.5F); - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - if (isize < 1) { - isize = 1; - } - radius = isize >> 1; - - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; - red = VB->ColorPtr->data[i][0]; - green = VB->ColorPtr->data[i][1]; - blue = VB->ColorPtr->data[i][2]; - alpha = VB->ColorPtr->data[i][3]; - - switch (VB->TexCoordPtr[0]->size) { - case 4: - s = VB->TexCoordPtr[0]->data[i][0]/VB->TexCoordPtr[0]->data[i][3]; - t = VB->TexCoordPtr[0]->data[i][1]/VB->TexCoordPtr[0]->data[i][3]; - u = VB->TexCoordPtr[0]->data[i][2]/VB->TexCoordPtr[0]->data[i][3]; - break; - case 3: - s = VB->TexCoordPtr[0]->data[i][0]; - t = VB->TexCoordPtr[0]->data[i][1]; - u = VB->TexCoordPtr[0]->data[i][2]; - break; - case 2: - s = VB->TexCoordPtr[0]->data[i][0]; - t = VB->TexCoordPtr[0]->data[i][1]; - u = 0.0; - break; - case 1: - s = VB->TexCoordPtr[0]->data[i][0]; - t = 0.0; - u = 0.0; - break; - default: - /* should never get here */ - s = t = u = 0.0; - gl_problem(ctx, "unexpected texcoord size in textured_rgba_points()"); - } + GLint x0, x1, y0, y1; + GLint ix, iy, radius; + GLint red, green, blue, alpha; + GLfloat s, t, u; - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - PB_WRITE_TEX_PIXEL( PB, ix, iy, z, fog, red, green, blue, alpha, - s, t, u ); - } - } + GLint x = (GLint) vert->win[0]; + GLint y = (GLint) vert->win[1]; + GLint z = (GLint) (vert->win[2]); + GLint isize = (GLint) (ctx->Point.Size + 0.5F); + + GLfixed fog = FloatToFixed( vert->fog ); - PB_CHECK_FLUSH(ctx, PB); + if (isize < 1) { + isize = 1; + } + radius = isize >> 1; + + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } + + red = vert->color[0]; + green = vert->color[1]; + blue = vert->color[2]; + alpha = vert->color[3]; + + if (vert->texcoord[0][3] != 1.0) { + s = vert->texcoord[0][0]/vert->texcoord[0][3]; + t = vert->texcoord[0][1]/vert->texcoord[0][3]; + u = vert->texcoord[0][2]/vert->texcoord[0][3]; + } else { + s = vert->texcoord[0][0]; + t = vert->texcoord[0][1]; + u = vert->texcoord[0][2]; + } + + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + PB_WRITE_TEX_PIXEL( PB, ix, iy, z, fog, red, green, blue, alpha, + s, t, u ); } } + + PB_CHECK_FLUSH(ctx, PB); } + /* * Multitextured RGBA points. */ static void -multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +multitextured_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLuint i; - - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - const GLint red = VB->ColorPtr->data[i][0]; - const GLint green = VB->ColorPtr->data[i][1]; - const GLint blue = VB->ColorPtr->data[i][2]; - const GLint alpha = VB->ColorPtr->data[i][3]; - const GLint sRed = VB->SecondaryColorPtr->data ? VB->SecondaryColorPtr->data[i][0] : 0; - const GLint sGreen = VB->SecondaryColorPtr->data ? VB->SecondaryColorPtr->data[i][1] : 0; - const GLint sBlue = VB->SecondaryColorPtr->data ? VB->SecondaryColorPtr->data[i][2] : 0; - const GLint x = (GLint) VB->Win.data[i][0]; - const GLint y = (GLint) VB->Win.data[i][1]; - const GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - GLint x0, x1, y0, y1; - GLint ix, iy; - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; - GLint radius, u; - GLint isize = (GLint) (ctx->Point.Size + 0.5F); - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - if (isize < 1) { - isize = 1; - } - radius = isize >> 1; - - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; + + const GLint red = vert->color[0]; + const GLint green = vert->color[1]; + const GLint blue = vert->color[2]; + const GLint alpha = vert->color[3]; + const GLint sRed = vert->specular[0]; + const GLint sGreen = vert->specular[1]; + const GLint sBlue = vert->specular[2]; + const GLint x = (GLint) vert->win[0]; + const GLint y = (GLint) vert->win[1]; + const GLint z = (GLint) (vert->win[2]); + GLint x0, x1, y0, y1; + GLint ix, iy; + GLfloat texcoord[MAX_TEXTURE_UNITS][4]; + GLint radius, u; + GLint isize = (GLint) (ctx->Point.Size + 0.5F); - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].ReallyEnabled) { - switch (VB->TexCoordPtr[0]->size) { - case 4: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2] / - VB->TexCoordPtr[u]->data[i][3]; - break; - case 3: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2]; - break; - case 2: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = 0.0; - break; - case 1: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = 0.0; - texcoord[u][2] = 0.0; - break; - default: - /* should never get here */ - gl_problem(ctx, "unexpected texcoord size"); - } - } - } + GLfixed fog = FloatToFixed( vert->fog ); - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - PB_WRITE_MULTITEX_SPEC_PIXEL( PB, ix, iy, z, fog, - red, green, blue, alpha, - sRed, sGreen, sBlue, - texcoord ); - } - } - PB_CHECK_FLUSH(ctx, PB); + if (isize < 1) { + isize = 1; + } + radius = isize >> 1; + + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } + + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + if (vert->texcoord[u][3] != 1.0) { + texcoord[u][0] = vert->texcoord[u][0] / + vert->texcoord[u][3]; + texcoord[u][1] = vert->texcoord[u][1] / + vert->texcoord[u][3]; + texcoord[u][2] = vert->texcoord[u][2] / + vert->texcoord[u][3]; + } + else { + texcoord[u][0] = vert->texcoord[u][0]; + texcoord[u][1] = vert->texcoord[u][1]; + texcoord[u][2] = vert->texcoord[u][2]; + } } } + + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + PB_WRITE_MULTITEX_SPEC_PIXEL( PB, ix, iy, z, fog, + red, green, blue, alpha, + sRed, sGreen, sBlue, + texcoord ); + } + } + PB_CHECK_FLUSH(ctx, PB); } @@ -439,214 +360,140 @@ multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) * Antialiased points with or without texture mapping. */ static void -antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +antialiased_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLfloat radius = ctx->Point.Size * 0.5F; const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ const GLfloat rmax = radius + 0.7071F; const GLfloat rmin2 = MAX2(0.0, rmin * rmin); const GLfloat rmax2 = rmax * rmax; const GLfloat cscale = 256.0F / (rmax2 - rmin2); - GLuint i; - - if (ctx->Texture.ReallyEnabled) { - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLint x, y; - GLfloat vx = VB->Win.data[i][0]; - GLfloat vy = VB->Win.data[i][1]; - const GLint xmin = (GLint) (vx - radius); - const GLint xmax = (GLint) (vx + radius); - const GLint ymin = (GLint) (vy - radius); - const GLint ymax = (GLint) (vy + radius); - const GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - const GLint red = VB->ColorPtr->data[i][0]; - const GLint green = VB->ColorPtr->data[i][1]; - const GLint blue = VB->ColorPtr->data[i][2]; - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; - GLint u, alpha; - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].ReallyEnabled) { - switch (VB->TexCoordPtr[0]->size) { - case 4: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2] / - VB->TexCoordPtr[u]->data[i][3]; - break; - case 3: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2]; - break; - case 2: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = 0.0; - break; - case 1: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = 0.0; - texcoord[u][2] = 0.0; - break; - default: - /* should never get here */ - gl_problem(ctx, "unexpected texcoord size in antialiased_rgba_points()"); - } - } - } - /* translate by a half pixel to simplify math below */ - vx -= 0.5F; - vx -= 0.5F; - - for (y = ymin; y <= ymax; y++) { - for (x = xmin; x <= xmax; x++) { - const GLfloat dx = x - vx; - const GLfloat dy = y - vy; - const GLfloat dist2 = dx*dx + dy*dy; - if (dist2 < rmax2) { - alpha = VB->ColorPtr->data[i][3]; - if (dist2 >= rmin2) { - GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); - /* coverage is in [0,256] */ - alpha = (alpha * coverage) >> 8; - } - if (ctx->Texture.MultiTextureEnabled) { - PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, fog, - red, green, blue, - alpha, texcoord ); - } - else { - PB_WRITE_TEX_PIXEL( PB, x,y,z, fog, - red, green, blue, alpha, - texcoord[0][0], - texcoord[0][1], - texcoord[0][2] ); - } - } - } - } + if (ctx->Texture._ReallyEnabled) { + GLint x, y; + GLfloat vx = vert->win[0]; + GLfloat vy = vert->win[1]; + const GLint xmin = (GLint) (vx - radius); + const GLint xmax = (GLint) (vx + radius); + const GLint ymin = (GLint) (vy - radius); + const GLint ymax = (GLint) (vy + radius); + const GLint z = (GLint) (vert->win[2]); + const GLint red = vert->color[0]; + const GLint green = vert->color[1]; + const GLint blue = vert->color[2]; + GLfloat texcoord[MAX_TEXTURE_UNITS][4]; + GLint u, alpha; + + GLfixed fog = FloatToFixed( vert->fog ); + + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + if (texcoord[u][3] != 1.0) { + texcoord[u][0] = (vert->texcoord[u][0] / + vert->texcoord[u][3]); + texcoord[u][1] = (vert->texcoord[u][1] / + vert->texcoord[u][3]); + texcoord[u][2] = (vert->texcoord[u][2] / + vert->texcoord[u][3]); + } + else { + texcoord[u][0] = vert->texcoord[u][0]; + texcoord[u][1] = vert->texcoord[u][1]; + texcoord[u][2] = vert->texcoord[u][2]; + } + } + } - PB_CHECK_FLUSH(ctx,PB); - } + /* translate by a half pixel to simplify math below */ + vx -= 0.5F; + vx -= 0.5F; + + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { + const GLfloat dx = x - vx; + const GLfloat dy = y - vy; + const GLfloat dist2 = dx*dx + dy*dy; + if (dist2 < rmax2) { + alpha = vert->color[3]; + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + if (ctx->Texture._MultiTextureEnabled) { + PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, fog, + red, green, blue, + alpha, texcoord ); + } + else { + PB_WRITE_TEX_PIXEL( PB, x,y,z, fog, + red, green, blue, alpha, + texcoord[0][0], + texcoord[0][1], + texcoord[0][2] ); + } + } + } } + + PB_CHECK_FLUSH(ctx,PB); } else { /* Not texture mapped */ - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - const GLint xmin = (GLint) (VB->Win.data[i][0] - 0.0 - radius); - const GLint xmax = (GLint) (VB->Win.data[i][0] - 0.0 + radius); - const GLint ymin = (GLint) (VB->Win.data[i][1] - 0.0 - radius); - const GLint ymax = (GLint) (VB->Win.data[i][1] - 0.0 + radius); - const GLint red = VB->ColorPtr->data[i][0]; - const GLint green = VB->ColorPtr->data[i][1]; - const GLint blue = VB->ColorPtr->data[i][2]; - const GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - GLint x, y; - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - /* - printf("point %g, %g\n", VB->Win.data[i][0], VB->Win.data[i][1]); - printf("%d..%d X %d..%d\n", xmin, xmax, ymin, ymax); - */ - for (y = ymin; y <= ymax; y++) { - for (x = xmin; x <= xmax; x++) { - const GLfloat dx = x + 0.5F - VB->Win.data[i][0]; - const GLfloat dy = y + 0.5F - VB->Win.data[i][1]; - const GLfloat dist2 = dx*dx + dy*dy; - if (dist2 < rmax2) { - GLint alpha = VB->ColorPtr->data[i][3]; - if (dist2 >= rmin2) { - GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); - /* coverage is in [0,256] */ - alpha = (alpha * coverage) >> 8; - } - PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog, - red, green, blue, alpha); - } - } - } - PB_CHECK_FLUSH(ctx,PB); + const GLint xmin = (GLint) (vert->win[0] - 0.0 - radius); + const GLint xmax = (GLint) (vert->win[0] - 0.0 + radius); + const GLint ymin = (GLint) (vert->win[1] - 0.0 - radius); + const GLint ymax = (GLint) (vert->win[1] - 0.0 + radius); + const GLint red = vert->color[0]; + const GLint green = vert->color[1]; + const GLint blue = vert->color[2]; + const GLint z = (GLint) (vert->win[2]); + GLint x, y; + + GLfixed fog = FloatToFixed( vert->fog ); + + /* + printf("point %g, %g\n", vert->win[0], vert->win[1]); + printf("%d..%d X %d..%d\n", xmin, xmax, ymin, ymax); + */ + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { + const GLfloat dx = x + 0.5F - vert->win[0]; + const GLfloat dy = y + 0.5F - vert->win[1]; + const GLfloat dist2 = dx*dx + dy*dy; + if (dist2 < rmax2) { + GLint alpha = vert->color[3]; + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog, + red, green, blue, alpha); + } } } + PB_CHECK_FLUSH(ctx,PB); } } -/* - * Null rasterizer for measuring transformation speed. - */ -static void -null_points( GLcontext *ctx, GLuint first, GLuint last ) -{ - (void) ctx; - (void) first; - (void) last; -} - - - /* Definition of the functions for GL_EXT_point_parameters */ /* Calculates the distance attenuation formula of a vector of points in * eye space coordinates */ -static void -dist3(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, const GLvector4f *v) -{ - GLuint stride = v->stride; - const GLfloat *p = VEC_ELT(v, GLfloat, first); - GLuint i; - - for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) { - GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]); - out[i] = 1.0F / (ctx->Point.Params[0] + - dist * (ctx->Point.Params[1] + - dist * ctx->Point.Params[2])); - } -} - - -static void -dist2(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, const GLvector4f *v) +static GLfloat attenuation_distance(const GLcontext *ctx, const GLfloat *pos) { - GLuint stride = v->stride; - const GLfloat *p = VEC_ELT(v, GLfloat, first); - GLuint i; - - for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) { - GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]); - out[i] = 1.0F / (ctx->Point.Params[0] + - dist * (ctx->Point.Params[1] + - dist * ctx->Point.Params[2])); - } + GLfloat dist = GL_SQRT(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2]); + return 1.0F / (ctx->Point.Params[0] + + dist * (ctx->Point.Params[1] + + dist * ctx->Point.Params[2])); } -typedef void (*dist_func)(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, const GLvector4f *v); - - -static dist_func eye_dist_tab[5] = { - 0, - 0, - dist2, - dist3, - dist3 -}; @@ -654,465 +501,389 @@ static dist_func eye_dist_tab[5] = { * Distance Attenuated General CI points. */ static void -dist_atten_general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +dist_atten_general_ci_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLfloat dist[VB_SIZE]; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLfloat psize = ctx->Point.Size; - GLuint i; - - ASSERT(ctx->NeedEyeCoords); - (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); - - - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x0, x1, y0, y1; - GLint ix, iy; - GLint isize, radius; - GLint x = (GLint) VB->Win.data[i][0]; - GLint y = (GLint) VB->Win.data[i][1]; - GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - GLfloat dsize = psize * dist[i]; - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); - } - else { - isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); - } - radius = isize >> 1; - - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + 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); + } + else { + isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); + } + radius = isize >> 1; + + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } - PB_SET_INDEX( PB, VB->IndexPtr->data[i] ); + PB_SET_INDEX( PB, vert->index ); - for (iy=y0;iy<=y1;iy++) { - for (ix=x0;ix<=x1;ix++) { - PB_WRITE_PIXEL( PB, ix, iy, z, fog ); - } - } - PB_CHECK_FLUSH(ctx,PB); + for (iy=y0;iy<=y1;iy++) { + for (ix=x0;ix<=x1;ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z, fog ); } } + PB_CHECK_FLUSH(ctx,PB); } /* * Distance Attenuated General RGBA points. */ static void -dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +dist_atten_general_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLfloat dist[VB_SIZE]; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLfloat psize = ctx->Point.Size; - GLuint i; - - ASSERT (ctx->NeedEyeCoords); - (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); - - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x0, x1, y0, y1; - GLint ix, iy; - GLint isize, radius; - GLint x = (GLint) VB->Win.data[i][0]; - GLint y = (GLint) VB->Win.data[i][1]; - GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - GLfloat dsize=psize*dist[i]; - GLchan alpha; - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F); - alpha = VB->ColorPtr->data[i][3]; - } - else { - isize = (GLint) (MAX2(ctx->Point.Threshold,ctx->Point.MinSize)+0.5F); - dsize /= ctx->Point.Threshold; - alpha = (GLint) (VB->ColorPtr->data[i][3]* (dsize*dsize)); - } - radius = isize >> 1; - - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + 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); + 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)); + } + radius = isize >> 1; + + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } - PB_SET_COLOR( PB, - VB->ColorPtr->data[i][0], - VB->ColorPtr->data[i][1], - VB->ColorPtr->data[i][2], - alpha ); + PB_SET_COLOR( PB, + vert->color[0], + vert->color[1], + vert->color[2], + alpha ); - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - PB_WRITE_PIXEL( PB, ix, iy, z, fog ); - } - } - PB_CHECK_FLUSH(ctx,PB); + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + PB_WRITE_PIXEL( PB, ix, iy, z, fog ); } } + PB_CHECK_FLUSH(ctx,PB); } /* * Distance Attenuated Textured RGBA points. */ static void -dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +dist_atten_textured_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLfloat dist[VB_SIZE]; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLfloat psize = ctx->Point.Size; - GLuint i; - - ASSERT(ctx->NeedEyeCoords); - (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); - - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - const GLint x = (GLint) VB->Win.data[i][0]; - const GLint y = (GLint) VB->Win.data[i][1]; - const GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - const GLint red = VB->ColorPtr->data[i][0]; - const GLint green = VB->ColorPtr->data[i][1]; - const GLint blue = VB->ColorPtr->data[i][2]; - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; - GLint x0, x1, y0, y1; - GLint ix, iy, alpha, u; - GLint isize, radius; - GLfloat dsize = psize*dist[i]; - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - /* compute point size and alpha */ - if (dsize >= ctx->Point.Threshold) { - isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); - alpha = VB->ColorPtr->data[i][3]; - } - else { - isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); - dsize /= ctx->Point.Threshold; - alpha = (GLint) (VB->ColorPtr->data[i][3] * (dsize * dsize)); - } - if (isize < 1) { - isize = 1; - } - radius = isize >> 1; - - if (isize & 1) { - /* odd size */ - x0 = x - radius; - x1 = x + radius; - y0 = y - radius; - y1 = y + radius; - } - else { - /* even size */ - x0 = (GLint) (x + 1.5F) - radius; - x1 = x0 + isize - 1; - y0 = (GLint) (y + 1.5F) - radius; - y1 = y0 + isize - 1; - } + 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]); + const GLint red = vert->color[0]; + const GLint green = vert->color[1]; + const GLint blue = vert->color[2]; + GLfloat texcoord[MAX_TEXTURE_UNITS][4]; + 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); + 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)); + } + if (isize < 1) { + isize = 1; + } + radius = isize >> 1; + + if (isize & 1) { + /* odd size */ + x0 = x - radius; + x1 = x + radius; + y0 = y - radius; + y1 = y + radius; + } + else { + /* even size */ + x0 = (GLint) (x + 1.5F) - radius; + x1 = x0 + isize - 1; + y0 = (GLint) (y + 1.5F) - radius; + y1 = y0 + isize - 1; + } - /* get texture coordinates */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].ReallyEnabled) { - switch (VB->TexCoordPtr[0]->size) { - case 4: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2] / - VB->TexCoordPtr[u]->data[i][3]; - break; - case 3: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2]; - break; - case 2: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = 0.0; - break; - case 1: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = 0.0; - texcoord[u][2] = 0.0; - break; - default: - /* should never get here */ - gl_problem(ctx, "unexpected texcoord size"); - } - } - } + /* get texture coordinates */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + if (texcoord[u][3] != 1.0) { + texcoord[u][0] = vert->texcoord[u][0] / + vert->texcoord[u][3]; + texcoord[u][1] = vert->texcoord[u][1] / + vert->texcoord[u][3]; + texcoord[u][2] = vert->texcoord[u][2] / + vert->texcoord[u][3]; + } + else { + texcoord[u][0] = vert->texcoord[u][0]; + texcoord[u][1] = vert->texcoord[u][1]; + texcoord[u][2] = vert->texcoord[u][2]; + } + } + } - for (iy = y0; iy <= y1; iy++) { - for (ix = x0; ix <= x1; ix++) { - if (ctx->Texture.MultiTextureEnabled) { - PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, fog, - red, green, blue, alpha, - texcoord ); - } - else { - PB_WRITE_TEX_PIXEL( PB, ix, iy, z, fog, - red, green, blue, alpha, - texcoord[0][0], - texcoord[0][1], - texcoord[0][2] ); - } - } - } - PB_CHECK_FLUSH(ctx,PB); + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { + if (ctx->Texture._MultiTextureEnabled) { + PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, fog, + red, green, blue, alpha, + texcoord ); + } + else { + PB_WRITE_TEX_PIXEL( PB, ix, iy, z, fog, + red, green, blue, alpha, + texcoord[0][0], + texcoord[0][1], + texcoord[0][2] ); + } } } + PB_CHECK_FLUSH(ctx,PB); } /* * Distance Attenuated Antialiased points with or without texture mapping. */ static void -dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +dist_atten_antialiased_rgba_point( GLcontext *ctx, SWvertex *vert ) { - struct vertex_buffer *VB = ctx->VB; - struct pixel_buffer *PB = ctx->PB; - GLfloat dist[VB_SIZE]; + struct pixel_buffer *PB = SWRAST_CONTEXT(ctx)->PB; const GLfloat psize = ctx->Point.Size; - GLuint i; - - ASSERT(ctx->NeedEyeCoords); - (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); - - if (ctx->Texture.ReallyEnabled) { - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; - GLint xmin, ymin, xmax, ymax; - GLint x, y, z; - GLint red, green, blue, alpha; - GLfloat texcoord[MAX_TEXTURE_UNITS][4]; - GLfloat dsize = psize * dist[i]; - GLint u; - - GLfixed fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - if (dsize >= ctx->Point.Threshold) { - radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; - alphaf = 1.0F; - } - else { - radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); - dsize /= ctx->Point.Threshold; - alphaf = (dsize*dsize); - } - rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - rmax = radius + 0.7071F; - rmin2 = MAX2(0.0, rmin * rmin); - rmax2 = rmax * rmax; - cscale = 256.0F / (rmax2 - rmin2); - - xmin = (GLint) (VB->Win.data[i][0] - radius); - xmax = (GLint) (VB->Win.data[i][0] + radius); - ymin = (GLint) (VB->Win.data[i][1] - radius); - ymax = (GLint) (VB->Win.data[i][1] + radius); - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - - red = VB->ColorPtr->data[i][0]; - green = VB->ColorPtr->data[i][1]; - blue = VB->ColorPtr->data[i][2]; + GLfloat dist = attenuation_distance( ctx, vert->eye ); + + if (ctx->Texture._ReallyEnabled) { + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; + 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; + } + else { + radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); + dsize /= ctx->Point.Threshold; + alphaf = (dsize*dsize); + } + rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + rmax = radius + 0.7071F; + rmin2 = MAX2(0.0, rmin * rmin); + rmax2 = rmax * rmax; + cscale = 256.0F / (rmax2 - rmin2); + + xmin = (GLint) (vert->win[0] - radius); + xmax = (GLint) (vert->win[0] + radius); + ymin = (GLint) (vert->win[1] - radius); + ymax = (GLint) (vert->win[1] + radius); + z = (GLint) (vert->win[2]); + + red = vert->color[0]; + green = vert->color[1]; + blue = vert->color[2]; - /* get texture coordinates */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].ReallyEnabled) { - switch (VB->TexCoordPtr[0]->size) { - case 4: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1] / - VB->TexCoordPtr[u]->data[i][3]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2] / - VB->TexCoordPtr[u]->data[i][3]; - break; - case 3: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = VB->TexCoordPtr[u]->data[i][2]; - break; - case 2: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = VB->TexCoordPtr[u]->data[i][1]; - texcoord[u][2] = 0.0; - break; - case 1: - texcoord[u][0] = VB->TexCoordPtr[u]->data[i][0]; - texcoord[u][1] = 0.0; - texcoord[u][2] = 0.0; - break; - default: - /* should never get here */ - gl_problem(ctx, "unexpected texcoord size"); - } - } - } + /* get texture coordinates */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u]._ReallyEnabled) { + if (vert->texcoord[u][3] != 1.0 && vert->texcoord[u][3] != 0.0) { + texcoord[u][0] = vert->texcoord[u][0] / vert->texcoord[u][3]; + texcoord[u][1] = vert->texcoord[u][1] / vert->texcoord[u][3]; + texcoord[u][2] = vert->texcoord[u][2] / vert->texcoord[u][3]; + } + else { + texcoord[u][0] = vert->texcoord[u][0]; + texcoord[u][1] = vert->texcoord[u][1]; + texcoord[u][2] = vert->texcoord[u][2]; + } + } + } - for (y = ymin; y <= ymax; y++) { - for (x = xmin; x <= xmax; x++) { - const GLfloat dx = x + 0.5F - VB->Win.data[i][0]; - const GLfloat dy = y + 0.5F - VB->Win.data[i][1]; - const GLfloat dist2 = dx*dx + dy*dy; - if (dist2 < rmax2) { - alpha = VB->ColorPtr->data[i][3]; - if (dist2 >= rmin2) { - GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); - /* coverage is in [0,256] */ - alpha = (alpha * coverage) >> 8; - } - alpha = (GLint) (alpha * alphaf); - if (ctx->Texture.MultiTextureEnabled) { - PB_WRITE_MULTITEX_PIXEL( PB, x, y, z, fog, - red, green, blue, alpha, - texcoord ); - } - else { - PB_WRITE_TEX_PIXEL( PB, x,y,z, fog, - red, green, blue, alpha, - texcoord[0][0], - texcoord[0][1], - texcoord[0][2] ); - } - } - } - } - PB_CHECK_FLUSH(ctx,PB); - } + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { + const GLfloat dx = x + 0.5F - vert->win[0]; + const GLfloat dy = y + 0.5F - vert->win[1]; + const GLfloat dist2 = dx*dx + dy*dy; + if (dist2 < rmax2) { + alpha = vert->color[3]; + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + alpha = (GLint) (alpha * alphaf); + if (ctx->Texture._MultiTextureEnabled) { + PB_WRITE_MULTITEX_PIXEL( PB, x, y, z, fog, + red, green, blue, alpha, + texcoord ); + } + else { + PB_WRITE_TEX_PIXEL( PB, x,y,z, fog, + red, green, blue, alpha, + texcoord[0][0], + texcoord[0][1], + texcoord[0][2] ); + } + } + } } + PB_CHECK_FLUSH(ctx,PB); } else { /* Not texture mapped */ - for (i = first; i <= last; i++) { - if (VB->ClipMask[i] == 0) { - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; - GLint xmin, ymin, xmax, ymax; - GLint x, y, z; - GLfixed fog; - GLint red, green, blue, alpha; - GLfloat dsize = psize * dist[i]; - - if (dsize >= ctx->Point.Threshold) { - radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; - alphaf = 1.0F; - } - else { - radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); - dsize /= ctx->Point.Threshold; - alphaf = dsize * dsize; - } - rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - rmax = radius + 0.7071F; - rmin2 = MAX2(0.0, rmin * rmin); - rmax2 = rmax * rmax; - cscale = 256.0F / (rmax2 - rmin2); - - xmin = (GLint) (VB->Win.data[i][0] - radius); - xmax = (GLint) (VB->Win.data[i][0] + radius); - ymin = (GLint) (VB->Win.data[i][1] - radius); - ymax = (GLint) (VB->Win.data[i][1] + radius); - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - - fog = FloatToFixed( VB->FogCoordPtr->data[i] ); - - red = VB->ColorPtr->data[i][0]; - green = VB->ColorPtr->data[i][1]; - blue = VB->ColorPtr->data[i][2]; - - for (y = ymin; y <= ymax; y++) { - for (x = xmin; x <= xmax; x++) { - const GLfloat dx = x + 0.5F - VB->Win.data[i][0]; - const GLfloat dy = y + 0.5F - VB->Win.data[i][1]; - const GLfloat dist2 = dx * dx + dy * dy; - if (dist2 < rmax2) { - alpha = VB->ColorPtr->data[i][3]; - if (dist2 >= rmin2) { - GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); - /* coverage is in [0,256] */ - alpha = (alpha * coverage) >> 8; - } - alpha = (GLint) (alpha * alphaf); - PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog, - red, green, blue, alpha); - } - } - } - PB_CHECK_FLUSH(ctx,PB); + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; + 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; + } + else { + radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); + dsize /= ctx->Point.Threshold; + alphaf = dsize * dsize; + } + rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + rmax = radius + 0.7071F; + rmin2 = MAX2(0.0, rmin * rmin); + rmax2 = rmax * rmax; + cscale = 256.0F / (rmax2 - rmin2); + + xmin = (GLint) (vert->win[0] - radius); + xmax = (GLint) (vert->win[0] + radius); + ymin = (GLint) (vert->win[1] - radius); + ymax = (GLint) (vert->win[1] + radius); + z = (GLint) (vert->win[2]); + + fog = FloatToFixed( vert->fog ); + + red = vert->color[0]; + green = vert->color[1]; + blue = vert->color[2]; + + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { + const GLfloat dx = x + 0.5F - vert->win[0]; + const GLfloat dy = y + 0.5F - vert->win[1]; + const GLfloat dist2 = dx * dx + dy * dy; + if (dist2 < rmax2) { + alpha = vert->color[3]; + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); + /* coverage is in [0,256] */ + alpha = (alpha * coverage) >> 8; + } + alpha = (GLint) (alpha * alphaf); + PB_WRITE_RGBA_PIXEL(PB, x, y, z, fog, + red, green, blue, alpha); + } } } + PB_CHECK_FLUSH(ctx,PB); } } #ifdef DEBUG void -_mesa_print_points_function(GLcontext *ctx) +_mesa_print_point_function(GLcontext *ctx) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); + printf("Point Func == "); - if (ctx->Driver.PointsFunc == size1_ci_points) - printf("size1_ci_points\n"); - else if (ctx->Driver.PointsFunc == size1_rgba_points) - printf("size1_rgba_points\n"); - else if (ctx->Driver.PointsFunc == general_ci_points) - printf("general_ci_points\n"); - else if (ctx->Driver.PointsFunc == general_rgba_points) - printf("general_rgba_points\n"); - else if (ctx->Driver.PointsFunc == textured_rgba_points) - printf("textured_rgba_points\n"); - else if (ctx->Driver.PointsFunc == multitextured_rgba_points) - printf("multitextured_rgba_points\n"); - else if (ctx->Driver.PointsFunc == antialiased_rgba_points) - printf("antialiased_rgba_points\n"); - else if (ctx->Driver.PointsFunc == null_points) - printf("null_points\n"); - else if (ctx->Driver.PointsFunc == dist_atten_general_ci_points) - printf("dist_atten_general_ci_points\n"); - else if (ctx->Driver.PointsFunc == dist_atten_general_rgba_points) - printf("dist_atten_general_rgba_points\n"); - else if (ctx->Driver.PointsFunc == dist_atten_textured_rgba_points) - printf("dist_atten_textured_rgba_points\n"); - else if (ctx->Driver.PointsFunc == dist_atten_antialiased_rgba_points) - printf("dist_atten_antialiased_rgba_points\n"); - else if (!ctx->Driver.PointsFunc) + if (swrast->Point == size1_ci_point) + printf("size1_ci_point\n"); + else if (swrast->Point == size1_rgba_point) + printf("size1_rgba_point\n"); + else if (swrast->Point == general_ci_point) + printf("general_ci_point\n"); + else if (swrast->Point == general_rgba_point) + printf("general_rgba_point\n"); + else if (swrast->Point == textured_rgba_point) + printf("textured_rgba_point\n"); + else if (swrast->Point == multitextured_rgba_point) + printf("multitextured_rgba_point\n"); + else if (swrast->Point == antialiased_rgba_point) + printf("antialiased_rgba_point\n"); + else if (swrast->Point == dist_atten_general_ci_point) + printf("dist_atten_general_ci_point\n"); + else if (swrast->Point == dist_atten_general_rgba_point) + printf("dist_atten_general_rgba_point\n"); + else if (swrast->Point == dist_atten_textured_rgba_point) + printf("dist_atten_textured_rgba_point\n"); + else if (swrast->Point == dist_atten_antialiased_rgba_point) + printf("dist_atten_antialiased_rgba_point\n"); + else if (!swrast->Point) printf("NULL\n"); else - printf("Driver func %p\n", ctx->Driver.PointsFunc); + printf("Driver func %p\n", swrast->Point); } #endif @@ -1122,70 +893,61 @@ _mesa_print_points_function(GLcontext *ctx) * should be used. */ void -_swrast_set_point_function( GLcontext *ctx ) +_swrast_choose_point( GLcontext *ctx ) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); GLboolean rgbmode = ctx->Visual.RGBAflag; if (ctx->RenderMode==GL_RENDER) { - if (ctx->NoRaster) { - ctx->Driver.PointsFunc = null_points; - return; - } - if (ctx->Driver.PointsFunc) { - /* Device driver will draw points. */ - ctx->IndirectTriangles &= ~DD_POINT_SW_RASTERIZE; - return; - } - - if (!ctx->Point.Attenuated) { + if (!ctx->Point._Attenuated) { if (ctx->Point.SmoothFlag && rgbmode) { - ctx->Driver.PointsFunc = antialiased_rgba_points; + swrast->Point = antialiased_rgba_point; } - else if (ctx->Texture.ReallyEnabled) { - if (ctx->Texture.MultiTextureEnabled || + else if (ctx->Texture._ReallyEnabled) { + if (ctx->Texture._MultiTextureEnabled || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR || ctx->Fog.ColorSumEnabled) { - ctx->Driver.PointsFunc = multitextured_rgba_points; + swrast->Point = multitextured_rgba_point; } else { - ctx->Driver.PointsFunc = textured_rgba_points; + swrast->Point = textured_rgba_point; } } else if (ctx->Point.Size==1.0) { /* size=1, any raster ops */ if (rgbmode) - ctx->Driver.PointsFunc = size1_rgba_points; + swrast->Point = size1_rgba_point; else - ctx->Driver.PointsFunc = size1_ci_points; + swrast->Point = size1_ci_point; } else { /* every other kind of point rendering */ if (rgbmode) - ctx->Driver.PointsFunc = general_rgba_points; + swrast->Point = general_rgba_point; else - ctx->Driver.PointsFunc = general_ci_points; + swrast->Point = general_ci_point; } } else if(ctx->Point.SmoothFlag && rgbmode) { - ctx->Driver.PointsFunc = dist_atten_antialiased_rgba_points; + swrast->Point = dist_atten_antialiased_rgba_point; } - else if (ctx->Texture.ReallyEnabled) { - ctx->Driver.PointsFunc = dist_atten_textured_rgba_points; + else if (ctx->Texture._ReallyEnabled) { + swrast->Point = dist_atten_textured_rgba_point; } else { /* every other kind of point rendering */ if (rgbmode) - ctx->Driver.PointsFunc = dist_atten_general_rgba_points; + swrast->Point = dist_atten_general_rgba_point; else - ctx->Driver.PointsFunc = dist_atten_general_ci_points; + swrast->Point = dist_atten_general_ci_point; } } else if (ctx->RenderMode==GL_FEEDBACK) { - ctx->Driver.PointsFunc = gl_feedback_points; + swrast->Point = gl_feedback_point; } else { /* GL_SELECT mode */ - ctx->Driver.PointsFunc = gl_select_points; + swrast->Point = gl_select_point; } /*_mesa_print_points_function(ctx);*/ |