-/* $Id: s_aatritemp.h,v 1.25 2002/01/28 00:07:33 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4];
GLfloat texWidth, texHeight;
#elif defined(DO_MULTITEX)
- GLfloat sPlane[MAX_TEXTURE_UNITS][4];
- GLfloat tPlane[MAX_TEXTURE_UNITS][4];
- GLfloat uPlane[MAX_TEXTURE_UNITS][4];
- GLfloat vPlane[MAX_TEXTURE_UNITS][4];
- GLfloat texWidth[MAX_TEXTURE_UNITS], texHeight[MAX_TEXTURE_UNITS];
-#endif
- GLfloat bf = SWRAST_CONTEXT(ctx)->_backface_sign;
+ GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */
+ GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */
+ GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */
+ GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */
+ GLfloat texWidth[MAX_TEXTURE_COORD_UNITS];
+ GLfloat texHeight[MAX_TEXTURE_COORD_UNITS];
+#endif
+ GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
- INIT_SPAN(span);
- span.arrayMask |= SPAN_COVERAGE;
+ INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE);
/* determine bottom to top order of vertices */
{
const GLfloat botDx = vMid->win[0] - vMin->win[0];
const GLfloat botDy = vMid->win[1] - vMin->win[1];
const GLfloat area = majDx * botDy - botDx * majDy;
- ltor = (GLboolean) (area < 0.0F);
/* Do backface culling */
if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area))
return;
+ ltor = (GLboolean) (area < 0.0F);
}
#ifndef DO_OCCLUSION_TEST
#endif
#ifdef DO_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- compute_plane(p0, p1, p2, v0->color[0], v1->color[0], v2->color[0], rPlane);
- compute_plane(p0, p1, p2, v0->color[1], v1->color[1], v2->color[1], gPlane);
- compute_plane(p0, p1, p2, v0->color[2], v1->color[2], v2->color[2], bPlane);
- compute_plane(p0, p1, p2, v0->color[3], v1->color[3], v2->color[3], aPlane);
+ compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane);
+ compute_plane(p0, p1, p2, v0->color[GCOMP], v1->color[GCOMP], v2->color[GCOMP], gPlane);
+ compute_plane(p0, p1, p2, v0->color[BCOMP], v1->color[BCOMP], v2->color[BCOMP], bPlane);
+ compute_plane(p0, p1, p2, v0->color[ACOMP], v1->color[ACOMP], v2->color[ACOMP], aPlane);
}
else {
constant_plane(v2->color[RCOMP], rPlane);
#endif
#ifdef DO_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- compute_plane(p0, p1, p2, v0->specular[0], v1->specular[0], v2->specular[0],srPlane);
- compute_plane(p0, p1, p2, v0->specular[1], v1->specular[1], v2->specular[1],sgPlane);
- compute_plane(p0, p1, p2, v0->specular[2], v1->specular[2], v2->specular[2],sbPlane);
+ compute_plane(p0, p1, p2, v0->specular[RCOMP], v1->specular[RCOMP], v2->specular[RCOMP], srPlane);
+ compute_plane(p0, p1, p2, v0->specular[GCOMP], v1->specular[GCOMP], v2->specular[GCOMP], sgPlane);
+ compute_plane(p0, p1, p2, v0->specular[BCOMP], v1->specular[BCOMP], v2->specular[BCOMP], sbPlane);
}
else {
constant_plane(v2->specular[RCOMP], srPlane);
#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 invW2 = v2->win[3];
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 invW2 = v2->win[3];
GLint ix, startX = (GLint) (x - xAdj);
GLuint count;
GLfloat coverage = 0.0F;
- SW_SPAN_RESET(span);
/* skip over fragments with zero coverage */
while (startX < MAX_WIDTH) {
while (coverage > 0.0F) {
/* (cx,cy) = center of fragment */
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+ struct span_arrays *array = span.array;
#ifdef DO_INDEX
- span.coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy);
+ array->coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy);
#else
- span.coverage[count] = coverage;
+ array->coverage[count] = coverage;
#endif
#ifdef DO_Z
- span.zArray[count] = (GLdepth) solve_plane(cx, cy, zPlane);
+ array->z[count] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane));
#endif
#ifdef DO_FOG
- span.fogArray[count] = solve_plane(cx, cy, fogPlane);
+ array->fog[count] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
- span.color.rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
- span.color.rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane);
- span.color.rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane);
- span.color.rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane);
+ array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
+ array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane);
+ array->rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane);
+ array->rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane);
#endif
#ifdef DO_INDEX
- span.color.index[count] = (GLint) solve_plane(cx, cy, iPlane);
+ array->index[count] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
- span.specArray[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
- span.specArray[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
- span.specArray[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+ array->spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ array->spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
#ifdef DO_TEX
{
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- span.texcoords[0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
- span.texcoords[0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
- span.texcoords[0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
- span.lambda[0][count] = compute_lambda(sPlane, tPlane, invQ,
+ array->texcoords[0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->texcoords[0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->texcoords[0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane,
+ cx, cy, invQ,
texWidth, texHeight);
}
#elif defined(DO_MULTITEX)
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- span.texcoords[unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- span.texcoords[unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- span.texcoords[unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
- span.lambda[unit][count] = compute_lambda(sPlane[unit],
- tPlane[unit], invQ, texWidth[unit], texHeight[unit]);
+ array->texcoords[unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->texcoords[unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->texcoords[unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->lambda[unit][count] = compute_lambda(sPlane[unit],
+ tPlane[unit], vPlane[unit], cx, cy, invQ,
+ texWidth[unit], texHeight[unit]);
}
}
}
span.end = (GLuint) ix - (GLuint) startX;
ASSERT(span.interpMask == 0);
#if defined(DO_MULTITEX) || defined(DO_TEX)
- _mesa_write_texture_span(ctx, &span, GL_POLYGON);
+ _swrast_write_texture_span(ctx, &span);
#elif defined(DO_RGBA)
- _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
+ _swrast_write_rgba_span(ctx, &span);
#elif defined(DO_INDEX)
- _mesa_write_index_span(ctx, &span, GL_POLYGON);
+ _swrast_write_index_span(ctx, &span);
#endif
}
}
while (coverage > 0.0F) {
/* (cx,cy) = center of fragment */
const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+ struct span_arrays *array = span.array;
#ifdef DO_INDEX
- span.coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy);
+ array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy);
#else
- span.coverage[ix] = coverage;
+ array->coverage[ix] = coverage;
#endif
#ifdef DO_Z
- span.zArray[ix] = (GLdepth) solve_plane(cx, cy, zPlane);
+ array->z[ix] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane));
#endif
#ifdef DO_FOG
- span.fogArray[ix] = solve_plane(cx, cy, fogPlane);
+ array->fog[ix] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA
- span.color.rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
- span.color.rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane);
- span.color.rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane);
- span.color.rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane);
+ array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
+ array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane);
+ array->rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane);
+ array->rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane);
#endif
#ifdef DO_INDEX
- span.color.index[ix] = (GLint) solve_plane(cx, cy, iPlane);
+ array->index[ix] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
- span.specArray[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
- span.specArray[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
- span.specArray[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+ array->spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ array->spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
#ifdef DO_TEX
{
const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- span.texcoords[0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
- span.texcoords[0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
- span.texcoords[0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
- span.lambda[0][ix] = compute_lambda(sPlane, tPlane, invQ,
- texWidth, texHeight);
+ array->texcoords[0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->texcoords[0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->texcoords[0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane,
+ cx, cy, invQ, texWidth, texHeight);
}
#elif defined(DO_MULTITEX)
{
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- span.texcoords[unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- span.texcoords[unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- span.texcoords[unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
- span.lambda[unit][ix] = compute_lambda(sPlane[unit],
+ array->texcoords[unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->texcoords[unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->texcoords[unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->lambda[unit][ix] = compute_lambda(sPlane[unit],
tPlane[unit],
- invQ,
+ vPlane[unit],
+ cx, cy, invQ,
texWidth[unit],
texHeight[unit]);
}
/* shift all values to the left */
/* XXX this is temporary */
{
+ struct span_arrays *array = span.array;
GLint j;
for (j = 0; j < (GLint) n; j++) {
#ifdef DO_RGBA
- COPY_4V(span.color.rgba[j], span.color.rgba[j + left]);
+ COPY_CHAN4(array->rgba[j], array->rgba[j + left]);
#endif
#ifdef DO_SPEC
- COPY_4V(span.specArray[j], span.specArray[j + left]);
+ COPY_CHAN4(array->spec[j], array->spec[j + left]);
#endif
#ifdef DO_INDEX
- span.color.index[j] = span.color.index[j + left];
+ array->index[j] = array->index[j + left];
#endif
#ifdef DO_Z
- span.zArray[j] = span.zArray[j + left];
+ array->z[j] = array->z[j + left];
#endif
#ifdef DO_FOG
- span.fogArray[j] = span.fogArray[j + left];
+ array->fog[j] = array->fog[j + left];
#endif
#ifdef DO_TEX
- COPY_4V(span.texcoords[0][j], span.texcoords[0][j + left]);
+ COPY_4V(array->texcoords[0][j], array->texcoords[0][j + left]);
#endif
#if defined(DO_MULTITEX) || defined(DO_TEX)
- span.lambda[0][j] = span.lambda[0][j + left];
+ array->lambda[0][j] = array->lambda[0][j + left];
#endif
- span.coverage[j] = span.coverage[j + left];
+ array->coverage[j] = array->coverage[j + left];
}
}
#ifdef DO_MULTITEX
/* shift texcoords */
{
+ struct span_arrays *array = span.array;
GLuint unit;
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
if (ctx->Texture.Unit[unit]._ReallyEnabled) {
GLint j;
for (j = 0; j < (GLint) n; j++) {
- span.texcoords[unit][j][0] = span.texcoords[unit][j + left][0];
- span.texcoords[unit][j][1] = span.texcoords[unit][j + left][1];
- span.texcoords[unit][j][2] = span.texcoords[unit][j + left][2];
- span.lambda[unit][j] = span.lambda[unit][j + left];
+ array->texcoords[unit][j][0] = array->texcoords[unit][j + left][0];
+ array->texcoords[unit][j][1] = array->texcoords[unit][j + left][1];
+ array->texcoords[unit][j][2] = array->texcoords[unit][j + left][2];
+ array->lambda[unit][j] = array->lambda[unit][j + left];
}
}
}
span.end = n;
ASSERT(span.interpMask == 0);
#if defined(DO_MULTITEX) || defined(DO_TEX)
- _mesa_write_texture_span(ctx, &span, GL_POLYGON);
+ _swrast_write_texture_span(ctx, &span);
#elif defined(DO_RGBA)
- _mesa_write_rgba_span(ctx, &span, GL_POLYGON);
+ _swrast_write_rgba_span(ctx, &span);
#elif defined(DO_INDEX)
- _mesa_write_index_span(ctx, &span, GL_POLYGON);
+ _swrast_write_index_span(ctx, &span);
#endif
}
}