X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_aalinetemp.h;h=e6ac69d186031e63651650adb70e1a41f3baac7d;hb=4102a3045cb64a7875c524a58f13766a48bbe164;hp=bcfd22f019f28fd8650e66bfe417f4e99fdf4016;hpb=6b1e4ea5a54ea852a904440cd9fa50251f63f64c;p=mesa.git diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index bcfd22f019f..e6ac69d1860 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -1,10 +1,8 @@ -/* $Id: s_aalinetemp.h,v 1.12 2001/05/21 18:13:43 brianp Exp $ */ - /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 6.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2004 Brian Paul 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"), @@ -34,107 +32,85 @@ * Function to render each fragment in the AA line. */ static void -NAME(plot)(GLcontext *ctx, const struct LineInfo *line, - struct pixel_buffer *pb, int ix, int iy) +NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy) { const GLfloat fx = (GLfloat) ix; const GLfloat fy = (GLfloat) iy; - const GLfloat coverage = compute_coveragef(line, ix, iy); - GLdepth z; - GLfloat fog; -#ifdef DO_RGBA - GLchan red, green, blue, alpha; +#ifdef DO_INDEX + const GLfloat coverage = compute_coveragei(line, ix, iy); #else - GLint index; + const GLfloat coverage = compute_coveragef(line, ix, iy); #endif - GLchan specRed, specGreen, specBlue; - GLfloat tex[MAX_TEXTURE_UNITS][4], lambda[MAX_TEXTURE_UNITS]; + const GLuint i = line->span.end; if (coverage == 0.0) return; + line->span.end++; + line->span.array->coverage[i] = coverage; + line->span.array->x[i] = ix; + line->span.array->y[i] = iy; + /* * Compute Z, color, texture coords, fog for the fragment by * solving the plane equations at (ix,iy). */ #ifdef DO_Z - z = (GLdepth) solve_plane(fx, fy, line->zPlane); -#else - z = 0.0; + line->span.array->z[i] = (GLdepth) IROUND(solve_plane(fx, fy, line->zPlane)); #endif #ifdef DO_FOG - fog = solve_plane(fx, fy, line->fPlane); -#else - fog = 0.0; + line->span.array->fog[i] = solve_plane(fx, fy, line->fPlane); #endif #ifdef DO_RGBA - red = solve_plane_chan(fx, fy, line->rPlane); - green = solve_plane_chan(fx, fy, line->gPlane); - blue = solve_plane_chan(fx, fy, line->bPlane); - alpha = solve_plane_chan(fx, fy, line->aPlane); + line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); + line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane); + line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane); + line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane); #endif #ifdef DO_INDEX - index = (GLint) solve_plane(fx, fy, line->iPlane); + line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane); #endif #ifdef DO_SPEC - specRed = solve_plane_chan(fx, fy, line->srPlane); - specGreen = solve_plane_chan(fx, fy, line->sgPlane); - specBlue = solve_plane_chan(fx, fy, line->sbPlane); -#else - (void) specRed; - (void) specGreen; - (void) specBlue; + line->span.array->spec[i][RCOMP] = solve_plane_chan(fx, fy, line->srPlane); + line->span.array->spec[i][GCOMP] = solve_plane_chan(fx, fy, line->sgPlane); + line->span.array->spec[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane); #endif #ifdef DO_TEX { - GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[0]); - tex[0][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ; - tex[0][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ; - tex[0][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ; - lambda[0] = compute_lambda(line->sPlane[0], line->tPlane[0], invQ, - line->texWidth[0], line->texHeight[0]); + const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[0]); + line->span.array->texcoords[0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ; + line->span.array->texcoords[0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ; + line->span.array->texcoords[0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ; + line->span.array->lambda[0][i] = compute_lambda(line->sPlane[0], line->tPlane[0], invQ, + line->texWidth[0], line->texHeight[0]); } #elif defined(DO_MULTITEX) { GLuint unit; for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { if (ctx->Texture.Unit[unit]._ReallyEnabled) { - GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[unit]); - tex[unit][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ; - tex[unit][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ; - tex[unit][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ; - lambda[unit] = compute_lambda(line->sPlane[unit], - line->tPlane[unit], invQ, - line->texWidth[unit], line->texHeight[unit]); + const GLfloat invQ = solve_plane_recip(fx, fy, line->vPlane[unit]); + line->span.array->texcoords[unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ; + line->span.array->texcoords[unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ; + line->span.array->texcoords[unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ; + line->span.array->lambda[unit][i] = compute_lambda(line->sPlane[unit], + line->tPlane[unit], invQ, + line->texWidth[unit], line->texHeight[unit]); } } } -#else - (void) tex[0][0]; - (void) lambda[0]; #endif - - PB_COVERAGE(pb, coverage); - -#if defined(DO_MULTITEX) -#if defined(DO_SPEC) - PB_WRITE_MULTITEX_SPEC_PIXEL(pb, ix, iy, z, fog, red, green, blue, alpha, - specRed, specGreen, specBlue, tex); -#else - PB_WRITE_MULTITEX_PIXEL(pb, ix, iy, z, fog, red, green, blue, alpha, tex); -#endif -#elif defined(DO_TEX) - PB_WRITE_TEX_PIXEL(pb, ix, iy, z, fog, red, green, blue, alpha, - tex[0][0], tex[0][1], tex[0][2]); + if (line->span.end == MAX_WIDTH) { +#if defined(DO_TEX) || defined(DO_MULTITEX) + _swrast_write_texture_span(ctx, &(line->span)); #elif defined(DO_RGBA) - PB_WRITE_RGBA_PIXEL(pb, ix, iy, z, fog, red, green, blue, alpha); -#elif defined(DO_INDEX) - PB_WRITE_CI_PIXEL(pb, ix, iy, z, fog, index); + _swrast_write_rgba_span(ctx, &(line->span)); +#else + _swrast_write_index_span(ctx, &(line->span)); #endif - - pb->haveCoverage = GL_TRUE; - PB_CHECK_FLUSH(ctx, pb); + line->span.end = 0; /* reset counter */ + } } @@ -146,7 +122,6 @@ static void NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - struct pixel_buffer *pb = SWRAST_CONTEXT(ctx)->PB; GLfloat tStart, tEnd; /* segment start, end along line length */ GLboolean inSegment; GLint iLen, i; @@ -159,24 +134,29 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) line.y1 = v1->win[1]; line.dx = line.x1 - line.x0; line.dy = line.y1 - line.y0; - line.len = sqrt(line.dx * line.dx + line.dy * line.dy); + line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); line.halfWidth = 0.5F * ctx->Line.Width; - if (line.len == 0.0) + if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; + INIT_SPAN(line.span, GL_LINE, 0, 0, SPAN_XY | SPAN_COVERAGE); + line.xAdj = line.dx / line.len * line.halfWidth; line.yAdj = line.dy / line.len * line.halfWidth; #ifdef DO_Z + line.span.arrayMask |= SPAN_Z; compute_plane(line.x0, line.y0, line.x1, line.y1, v0->win[2], v1->win[2], line.zPlane); #endif #ifdef DO_FOG + line.span.arrayMask |= SPAN_FOG; compute_plane(line.x0, line.y0, line.x1, line.y1, v0->fog, v1->fog, line.fPlane); #endif #ifdef DO_RGBA + line.span.arrayMask |= SPAN_RGBA; if (ctx->Light.ShadeModel == GL_SMOOTH) { compute_plane(line.x0, line.y0, line.x1, line.y1, v0->color[RCOMP], v1->color[RCOMP], line.rPlane); @@ -195,6 +175,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) } #endif #ifdef DO_SPEC + line.span.arrayMask |= SPAN_SPEC; if (ctx->Light.ShadeModel == GL_SMOOTH) { compute_plane(line.x0, line.y0, line.x1, line.y1, v0->specular[RCOMP], v1->specular[RCOMP], line.srPlane); @@ -210,6 +191,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) } #endif #ifdef DO_INDEX + line.span.arrayMask |= SPAN_INDEX; if (ctx->Light.ShadeModel == GL_SMOOTH) { compute_plane(line.x0, line.y0, line.x1, line.y1, v0->index, v1->index, line.iPlane); @@ -221,7 +203,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) #ifdef DO_TEX { const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current; - const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; + const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; const GLfloat s0 = v0->texcoord[0][0] * invW0; @@ -232,6 +214,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) const GLfloat r1 = v1->texcoord[0][2] * invW0; const GLfloat q0 = v0->texcoord[0][3] * invW0; const GLfloat q1 = v1->texcoord[0][3] * invW0; + line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[0]); compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[0]); compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[0]); @@ -242,10 +225,11 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) #elif defined(DO_MULTITEX) { GLuint u; + line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { if (ctx->Texture.Unit[u]._ReallyEnabled) { const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; - const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel]; + const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; const GLfloat invW0 = v0->win[3]; const GLfloat invW1 = v1->win[3]; const GLfloat s0 = v0->texcoord[u][0] * invW0; @@ -291,7 +275,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) /* stipple bit is off */ if (inSegment && (tEnd > tStart)) { /* draw the segment */ - segment(ctx, &line, NAME(plot), pb, tStart, tEnd); + segment(ctx, &line, NAME(plot), tStart, tEnd); inSegment = GL_FALSE; } else { @@ -303,13 +287,21 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) if (inSegment) { /* draw the final segment of the line */ - segment(ctx, &line, NAME(plot), pb, tStart, 1.0F); + segment(ctx, &line, NAME(plot), tStart, 1.0F); } } else { /* non-stippled */ - segment(ctx, &line, NAME(plot), pb, 0.0, 1.0); + segment(ctx, &line, NAME(plot), 0.0, 1.0); } + +#if defined(DO_TEX) || defined(DO_MULTITEX) + _swrast_write_texture_span(ctx, &(line.span)); +#elif defined(DO_RGBA) + _swrast_write_rgba_span(ctx, &(line.span)); +#else + _swrast_write_index_span(ctx, &(line.span)); +#endif }