Overhaul/simplify SWvertex and SWspan attribute handling.

Instead of separate fog/specular/texcoord/varying code, just treat all of
them as generic attributes.  Simplifies the point/line/triangle functions.
This commit is contained in:
Brian 2007-05-20 12:27:39 -06:00
parent aa133a9dae
commit 9e8a961dd7
34 changed files with 1280 additions and 2138 deletions

View file

@ -138,10 +138,10 @@ static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
const GLfloat ty = m[13]; const GLfloat ty = m[13];
const GLfloat tz = m[14]; const GLfloat tz = m[14];
dst->win[0] = sx * src->x + tx; dst->attrib[FRAG_ATTRIB_WPOS][0] = sx * src->x + tx;
dst->win[1] = sy * src->y + ty; dst->attrib[FRAG_ATTRIB_WPOS][1] = sy * src->y + ty;
dst->win[2] = sz * src->z + tz; dst->attrib[FRAG_ATTRIB_WPOS][2] = sz * src->z + tz;
dst->win[3] = 1.0; dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red); dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green); dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);

View file

@ -44,7 +44,7 @@ void TAG(translate_vertex)(GLcontext *ctx,
UNVIEWPORT_VARS; UNVIEWPORT_VARS;
CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size; CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size;
dst->win[3] = 1.0; dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
switch ( format ) { switch ( format ) {
case TEX1_VERTEX_FORMAT: case TEX1_VERTEX_FORMAT:
@ -75,17 +75,17 @@ void TAG(translate_vertex)(GLcontext *ctx,
dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ ); dst->attrib[FRAG_ATTRIB_TEX0][1] = LE32_IN_FLOAT( p++ );
#endif #endif
dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0; dst->attrib[FRAG_ATTRIB_TEX0][3] = 1.0;
dst->win[3] = LE32_IN_FLOAT( p++ ); dst->attrib[FRAG_ATTRIB_WPOS][3] = LE32_IN_FLOAT( p++ );
case NOTEX_VERTEX_FORMAT: case NOTEX_VERTEX_FORMAT:
dst->specular[2] = ((GLubyte *)p)[0]; dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(((GLubyte *)p)[0]);
dst->specular[1] = ((GLubyte *)p)[1]; dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(((GLubyte *)p)[1]);
dst->specular[0] = ((GLubyte *)p)[2]; dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(((GLubyte *)p)[2]);
dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3]; dst->attrib[FRAG_ATTRIB_FOGC][0] = ((GLubyte *)p)[3]; /*XXX int->float?*/
p++; p++;
case TINY_VERTEX_FORMAT: case TINY_VERTEX_FORMAT:
dst->win[2] = UNVIEWPORT_Z( LE32_IN( p++ ) ); dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
dst->color[2] = ((GLubyte *)p)[0]; dst->color[2] = ((GLubyte *)p)[0];
dst->color[1] = ((GLubyte *)p)[1]; dst->color[1] = ((GLubyte *)p)[1];
@ -96,8 +96,8 @@ void TAG(translate_vertex)(GLcontext *ctx,
{ {
GLuint xy = LE32_IN( p ); GLuint xy = LE32_IN( p );
dst->win[0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) ); dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
dst->win[1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) ); dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
} }
} }

View file

@ -43,12 +43,12 @@
#define SORT_LINE_VERT() \ #define SORT_LINE_VERT() \
do { \ do { \
if(v[0].win[1] <= v[1].win[1]) { \ if(v[0].attrib[FRAG_ATTRIB_WPOS][1] <= v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
\ \
idx[0] = 0; \ idx[0] = 0; \
idx[1] = 1; \ idx[1] = 1; \
\ \
} else if (v[0].win[1] > v[1].win[1]) { \ } else if (v[0].attrib[FRAG_ATTRIB_WPOS][1] > v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \
\ \
idx[0] = 1; \ idx[0] = 1; \
idx[1] = 0; \ idx[1] = 0; \
@ -58,19 +58,19 @@ do { \
#define SET_LINE_VERT() \ #define SET_LINE_VERT() \
do { \ do { \
x[0] = (v[idx[0]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \ x[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
y[0] = fy[0] = dPriv->h - v[idx[0]].win[1]; \ y[0] = fy[0] = dPriv->h - v[idx[0]].attrib[FRAG_ATTRIB_WPOS][1]; \
z[0] = (v[idx[0]].win[2]) * 1024.0f * 32.0f; /* 0x8000; */ \ z[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000; */ \
\ \
x[1] = (v[idx[1]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \ x[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \
y[1] = dPriv->h - v[idx[1]].win[1]; \ y[1] = dPriv->h - v[idx[1]].attrib[FRAG_ATTRIB_WPOS][1]; \
z[1] = (v[idx[1]].win[2]) * 1024.0f * 32.0f; /* 0x8000 */ \ z[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000 */ \
} while(0) } while(0)
#define SET_LINE_XY() \ #define SET_LINE_XY() \
do { \ do { \
tmp = v[idx[0]].win[0]; \ tmp = v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0]; \
tmp2 = v[idx[1]].win[0]; \ tmp2 = v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0]; \
\ \
dx01 = x[0] - x[1]; \ dx01 = x[0] - x[1]; \
dy01 = y[0] - y[1]; \ dy01 = y[0] - y[1]; \
@ -265,7 +265,7 @@ do { \
#define SORT_VERT() \ #define SORT_VERT() \
do { \ do { \
for (i=0; i<3; i++) \ for (i=0; i<3; i++) \
fy[i] = v[i].win[1]; \ fy[i] = v[i].attrib[FRAG_ATTRIB_WPOS][1]; \
\ \
if (fy[1] > fy[0]) { /* (fy[1] > fy[0]) */ \ if (fy[1] > fy[0]) { /* (fy[1] > fy[0]) */ \
\ \
@ -305,9 +305,9 @@ do { \
do { \ do { \
for (i=0; i<3; i++) \ for (i=0; i<3; i++) \
{ \ { \
x[i] = ((v[idx[i]].win[0]) * /* 0x100000*/ 1024.0 * 1024.0); \ x[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][0]) * /* 0x100000*/ 1024.0 * 1024.0); \
y[i] = fy[i] = (dPriv->h - v[idx[i]].win[1]); \ y[i] = fy[i] = (dPriv->h - v[idx[i]].attrib[FRAG_ATTRIB_WPOS][1]); \
z[i] = ((v[idx[i]].win[2]) * /* 0x8000 */ 1024.0 * 32.0); \ z[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][2]) * /* 0x8000 */ 1024.0 * 32.0); \
} \ } \
\ \
ydiff = fy[0] - (float)y[0]; \ ydiff = fy[0] - (float)y[0]; \
@ -420,9 +420,9 @@ do { \
v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \ v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \
* (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \ * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
\ \
w0 = (v[idx[0]].win[3]); \ w0 = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][3]); \
w1 = (v[idx[1]].win[3]); \ w1 = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][3]); \
w2 = (v[idx[2]].win[3]); \ w2 = (v[idx[2]].attrib[FRAG_ATTRIB_WPOS][3]); \
} while (0) } while (0)
#define SET_BASEUV() \ #define SET_BASEUV() \
@ -732,8 +732,8 @@ DEBUG(("***\n"));
#if (IND & S3V_RAST_CULL_BIT) #if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign * cull = vmesa->backface_sign *
((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) + ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
(v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0])); (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < vmesa->cull_zero /* -0.02f */) return; if (cull < vmesa->cull_zero /* -0.02f */) return;
#endif #endif
@ -842,8 +842,8 @@ static void TAG(s3v_quad)( s3vContextPtr vmesa,
#if (IND & S3V_RAST_CULL_BIT) #if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign * cull = vmesa->backface_sign *
((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) + ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
(v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0])); (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */ if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */
#endif #endif
@ -897,8 +897,8 @@ second:
#if (IND & S3V_RAST_CULL_BIT) #if (IND & S3V_RAST_CULL_BIT)
cull = vmesa->backface_sign * cull = vmesa->backface_sign *
((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) + ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) +
(v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0])); (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]));
if (cull < /* -0.02f */ vmesa->cull_zero) return; if (cull < /* -0.02f */ vmesa->cull_zero) return;
#endif #endif

View file

@ -142,10 +142,10 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) { if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) {
dst->win[0] = src->x - fxMesa->x_offset; dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset;
dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
dst->win[2] = src->z; dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z;
dst->win[3] = 1.0; dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
dst->color[0] = src->color[2]; dst->color[0] = src->color[2];
dst->color[1] = src->color[1]; dst->color[1] = src->color[1];
@ -155,10 +155,10 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
else { else {
GLfloat w = 1.0 / src->rhw; GLfloat w = 1.0 / src->rhw;
dst->win[0] = src->x - fxMesa->x_offset; dst->attrib[FRAG_ATTRIB_WPOS][0] = src->x - fxMesa->x_offset;
dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset); dst->attrib[FRAG_ATTRIB_WPOS][1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
dst->win[2] = src->z; dst->attrib[FRAG_ATTRIB_WPOS][2] = src->z;
dst->win[3] = src->rhw; dst->attrib[FRAG_ATTRIB_WPOS][3] = src->rhw;
dst->color[0] = src->color[2]; dst->color[0] = src->color[2];
dst->color[1] = src->color[1]; dst->color[1] = src->color[1];

View file

@ -556,10 +556,10 @@ xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
vert1->color[0], vert1->color[1], vert1->color[0], vert1->color[1],
vert1->color[2], vert1->color[3], vert1->color[2], vert1->color[3],
xmesa->pixelformat); xmesa->pixelformat);
int x0 = (int) vert0->win[0]; int x0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][0];
int y0 = YFLIP(xrb, (GLint) vert0->win[1]); int y0 = YFLIP(xrb, (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1]);
int x1 = (int) vert1->win[0]; int x1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0];
int y1 = YFLIP(xrb, (GLint) vert1->win[1]); int y1 = YFLIP(xrb, (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][1]);
XMesaSetForeground(dpy, gc, pixel); XMesaSetForeground(dpy, gc, pixel);
XMesaSetFunction(dpy, gc, GXxor); XMesaSetFunction(dpy, gc, GXxor);
XSetLineAttributes(dpy, gc, (int) ctx->Line.Width, XSetLineAttributes(dpy, gc, (int) ctx->Line.Width,

View file

@ -59,19 +59,13 @@ struct LineInfo
/* DO_Z */ /* DO_Z */
GLfloat zPlane[4]; GLfloat zPlane[4];
/* DO_FOG */
GLfloat fPlane[4];
/* DO_RGBA */ /* DO_RGBA */
GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4];
/* DO_INDEX */ /* DO_INDEX */
GLfloat iPlane[4]; GLfloat iPlane[4];
/* DO_SPEC */
GLfloat srPlane[4], sgPlane[4], sbPlane[4];
/* DO_ATTRIBS */ /* DO_ATTRIBS */
GLfloat sPlane[FRAG_ATTRIB_MAX][4]; GLfloat wPlane[4];
GLfloat tPlane[FRAG_ATTRIB_MAX][4]; GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4];
GLfloat uPlane[FRAG_ATTRIB_MAX][4];
GLfloat vPlane[FRAG_ATTRIB_MAX][4];
GLfloat lambda[FRAG_ATTRIB_MAX]; GLfloat lambda[FRAG_ATTRIB_MAX];
GLfloat texWidth[FRAG_ATTRIB_MAX]; GLfloat texWidth[FRAG_ATTRIB_MAX];
GLfloat texHeight[FRAG_ATTRIB_MAX]; GLfloat texHeight[FRAG_ATTRIB_MAX];
@ -483,35 +477,24 @@ segment(GLcontext *ctx,
#define NAME(x) aa_ci_##x #define NAME(x) aa_ci_##x
#define DO_Z #define DO_Z
#define DO_FOG #define DO_ATTRIBS /* for fog */
#define DO_INDEX #define DO_INDEX
#include "s_aalinetemp.h" #include "s_aalinetemp.h"
#define NAME(x) aa_rgba_##x #define NAME(x) aa_rgba_##x
#define DO_Z #define DO_Z
#define DO_FOG
#define DO_RGBA #define DO_RGBA
#include "s_aalinetemp.h" #include "s_aalinetemp.h"
#define NAME(x) aa_tex_rgba_##x #define NAME(x) aa_general_rgba_##x
#define DO_Z #define DO_Z
#define DO_FOG
#define DO_RGBA #define DO_RGBA
#define DO_ATTRIBS #define DO_ATTRIBS
#include "s_aalinetemp.h" #include "s_aalinetemp.h"
#define NAME(x) aa_multitex_spec_##x
#define DO_Z
#define DO_FOG
#define DO_RGBA
#define DO_ATTRIBS
#define DO_SPEC
#include "s_aalinetemp.h"
void void
_swrast_choose_aa_line_function(GLcontext *ctx) _swrast_choose_aa_line_function(GLcontext *ctx)
@ -523,14 +506,12 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
if (ctx->Visual.rgbMode) { if (ctx->Visual.rgbMode) {
/* RGBA */ /* RGBA */
if (ctx->Texture._EnabledCoordUnits != 0 if (ctx->Texture._EnabledCoordUnits != 0
|| ctx->FragmentProgram._Current) { || ctx->FragmentProgram._Current
|| (ctx->Light.Enabled &&
if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR || ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
ctx->Fog.ColorSumEnabled) || ctx->Fog.ColorSumEnabled
swrast->Line = aa_multitex_spec_line; || swrast->_FogEnabled) {
else swrast->Line = aa_general_rgba_line;
swrast->Line = aa_tex_rgba_line;
} }
else { else {
swrast->Line = aa_rgba_line; swrast->Line = aa_rgba_line;

View file

@ -63,9 +63,6 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy)
#ifdef DO_Z #ifdef DO_Z
line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane); line->span.array->z[i] = (GLuint) solve_plane(fx, fy, line->zPlane);
#endif #endif
#ifdef DO_FOG
line->span.array->attribs[FRAG_ATTRIB_FOGC][i][0] = solve_plane(fx, fy, line->fPlane);
#endif
#ifdef DO_RGBA #ifdef DO_RGBA
line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane); 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][GCOMP] = solve_plane_chan(fx, fy, line->gPlane);
@ -75,30 +72,30 @@ NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy)
#ifdef DO_INDEX #ifdef DO_INDEX
line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane); line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane);
#endif #endif
#ifdef DO_SPEC
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
#if defined(DO_ATTRIBS) #if defined(DO_ATTRIBS)
ATTRIB_LOOP_BEGIN ATTRIB_LOOP_BEGIN
GLfloat (*attribArray)[4] = line->span.array->attribs[attr]; GLfloat (*attribArray)[4] = line->span.array->attribs[attr];
GLfloat invQ; if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0
if (ctx->FragmentProgram._Active) { && !ctx->FragmentProgram._Active) {
invQ = 1.0F; /* texcoord w/ divide by Q */
const GLuint unit = attr - FRAG_ATTRIB_TEX0;
const GLfloat invQ = solve_plane_recip(fx, fy, line->attrPlane[attr][3]);
GLuint c;
for (c = 0; c < 3; c++) {
attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invQ;
}
line->span.array->lambda[unit][i]
= compute_lambda(line->attrPlane[attr][0],
line->attrPlane[attr][1], invQ,
line->texWidth[attr], line->texHeight[attr]);
} }
else { else {
invQ = solve_plane_recip(fx, fy, line->vPlane[attr]); /* non-texture attrib */
} const GLfloat invW = solve_plane_recip(fx, fy, line->wPlane);
attribArray[i][0] = solve_plane(fx, fy, line->sPlane[attr]) * invQ; GLuint c;
attribArray[i][1] = solve_plane(fx, fy, line->tPlane[attr]) * invQ; for (c = 0; c < 4; c++) {
attribArray[i][2] = solve_plane(fx, fy, line->uPlane[attr]) * invQ; attribArray[i][c] = solve_plane(fx, fy, line->attrPlane[attr][c]) * invW;
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) { }
const GLuint unit = attr - FRAG_ATTRIB_TEX0;
line->span.array->lambda[unit][i]
= compute_lambda(line->sPlane[attr],
line->tPlane[attr], invQ,
line->texWidth[attr], line->texHeight[attr]);
} }
ATTRIB_LOOP_END ATTRIB_LOOP_END
#endif #endif
@ -128,10 +125,10 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
/* Init the LineInfo struct */ /* Init the LineInfo struct */
struct LineInfo line; struct LineInfo line;
line.x0 = v0->win[0]; line.x0 = v0->attrib[FRAG_ATTRIB_WPOS][0];
line.y0 = v0->win[1]; line.y0 = v0->attrib[FRAG_ATTRIB_WPOS][1];
line.x1 = v1->win[0]; line.x1 = v1->attrib[FRAG_ATTRIB_WPOS][0];
line.y1 = v1->win[1]; line.y1 = v1->attrib[FRAG_ATTRIB_WPOS][1];
line.dx = line.x1 - line.x0; line.dx = line.x1 - line.x0;
line.dy = line.y1 - line.y0; line.dy = line.y1 - line.y0;
line.len = SQRTF(line.dx * line.dx + line.dy * line.dy); line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
@ -148,14 +145,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
#ifdef DO_Z #ifdef DO_Z
line.span.arrayMask |= SPAN_Z; line.span.arrayMask |= SPAN_Z;
compute_plane(line.x0, line.y0, line.x1, line.y1, compute_plane(line.x0, line.y0, line.x1, line.y1,
v0->win[2], v1->win[2], line.zPlane); v0->attrib[FRAG_ATTRIB_WPOS][2], v1->attrib[FRAG_ATTRIB_WPOS][2], line.zPlane);
#endif
#ifdef DO_FOG
line.span.arrayMask |= SPAN_FOG;
compute_plane(line.x0, line.y0, line.x1, line.y1,
v0->attrib[FRAG_ATTRIB_FOGC][0],
v1->attrib[FRAG_ATTRIB_FOGC][0],
line.fPlane);
#endif #endif
#ifdef DO_RGBA #ifdef DO_RGBA
line.span.arrayMask |= SPAN_RGBA; line.span.arrayMask |= SPAN_RGBA;
@ -176,51 +166,32 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
constant_plane(v1->color[ACOMP], line.aPlane); constant_plane(v1->color[ACOMP], line.aPlane);
} }
#endif #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);
compute_plane(line.x0, line.y0, line.x1, line.y1,
v0->specular[GCOMP], v1->specular[GCOMP], line.sgPlane);
compute_plane(line.x0, line.y0, line.x1, line.y1,
v0->specular[BCOMP], v1->specular[BCOMP], line.sbPlane);
}
else {
constant_plane(v1->specular[RCOMP], line.srPlane);
constant_plane(v1->specular[GCOMP], line.sgPlane);
constant_plane(v1->specular[BCOMP], line.sbPlane);
}
#endif
#ifdef DO_INDEX #ifdef DO_INDEX
line.span.arrayMask |= SPAN_INDEX; line.span.arrayMask |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) { if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(line.x0, line.y0, line.x1, line.y1, compute_plane(line.x0, line.y0, line.x1, line.y1,
v0->index, v1->index, line.iPlane); v0->attrib[FRAG_ATTRIB_CI][0],
v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane);
} }
else { else {
constant_plane(v1->index, line.iPlane); constant_plane(v1->attrib[FRAG_ATTRIB_CI][0], line.iPlane);
} }
#endif #endif
#if defined(DO_ATTRIBS) #if defined(DO_ATTRIBS)
{ {
const GLfloat invW0 = v0->win[3]; const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3];
const GLfloat invW1 = v1->win[3]; const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3];
line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING); line.span.arrayMask |= SPAN_LAMBDA;
compute_plane(line.x0, line.y0, line.x1, line.y1, invW0, invW1, line.wPlane);
ATTRIB_LOOP_BEGIN ATTRIB_LOOP_BEGIN
const GLfloat s0 = v0->attrib[attr][0] * invW0; GLuint c;
const GLfloat s1 = v1->attrib[attr][0] * invW1; for (c = 0; c < 4; c++) {
const GLfloat t0 = v0->attrib[attr][1] * invW0; const GLfloat a0 = v0->attrib[attr][c] * invW0;
const GLfloat t1 = v1->attrib[attr][1] * invW1; const GLfloat a1 = v1->attrib[attr][c] * invW1;
const GLfloat r0 = v0->attrib[attr][2] * invW0; compute_plane(line.x0, line.y0, line.x1, line.y1, a0, a1, line.attrPlane[attr][c]);
const GLfloat r1 = v1->attrib[attr][2] * invW1; }
const GLfloat q0 = v0->attrib[attr][3] * invW0; line.span.arrayAttribs |= (1 << attr);
const GLfloat q1 = v1->attrib[attr][3] * invW1; if (attr >= FRAG_ATTRIB_TEX0 && attr < FRAG_ATTRIB_VAR0) {
compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[attr]);
compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[attr]);
compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[attr]);
compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[attr]);
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) {
const GLuint u = attr - FRAG_ATTRIB_TEX0; const GLuint u = attr - FRAG_ATTRIB_TEX0;
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current; const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel]; const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
@ -286,9 +257,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
#undef DO_Z #undef DO_Z
#undef DO_FOG
#undef DO_RGBA #undef DO_RGBA
#undef DO_INDEX #undef DO_INDEX
#undef DO_SPEC
#undef DO_ATTRIBS #undef DO_ATTRIBS
#undef NAME #undef NAME

View file

@ -144,6 +144,19 @@ solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
} }
static INLINE GLfloat
plane_dx(const GLfloat plane[4])
{
return -plane[0] / plane[2];
}
static INLINE GLfloat
plane_dy(const GLfloat plane[4])
{
return -plane[1] / plane[2];
}
/* /*
* Compute how much (area) of the given pixel is inside the triangle. * Compute how much (area) of the given pixel is inside the triangle.
@ -337,7 +350,6 @@ compute_coveragei(const GLfloat v0[3], const GLfloat v1[3],
} }
static void static void
rgba_aa_tri(GLcontext *ctx, rgba_aa_tri(GLcontext *ctx,
const SWvertex *v0, const SWvertex *v0,
@ -345,7 +357,6 @@ rgba_aa_tri(GLcontext *ctx,
const SWvertex *v2) const SWvertex *v2)
{ {
#define DO_Z #define DO_Z
#define DO_FOG
#define DO_RGBA #define DO_RGBA
#include "s_aatritemp.h" #include "s_aatritemp.h"
} }
@ -358,76 +369,25 @@ index_aa_tri(GLcontext *ctx,
const SWvertex *v2) const SWvertex *v2)
{ {
#define DO_Z #define DO_Z
#define DO_FOG #define DO_ATTRIBS
#define DO_INDEX #define DO_INDEX
#include "s_aatritemp.h" #include "s_aatritemp.h"
} }
/*
* Compute mipmap level of detail.
* XXX we should really include the R coordinate in this computation
* in order to do 3-D texture mipmapping.
*/
static INLINE GLfloat
compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
const GLfloat qPlane[4], GLfloat cx, GLfloat cy,
GLfloat invQ, GLfloat texWidth, GLfloat texHeight)
{
const GLfloat s = solve_plane(cx, cy, sPlane);
const GLfloat t = solve_plane(cx, cy, tPlane);
const GLfloat invQ_x1 = solve_plane_recip(cx+1.0F, cy, qPlane);
const GLfloat invQ_y1 = solve_plane_recip(cx, cy+1.0F, qPlane);
const GLfloat s_x1 = s - sPlane[0] / sPlane[2];
const GLfloat s_y1 = s - sPlane[1] / sPlane[2];
const GLfloat t_x1 = t - tPlane[0] / tPlane[2];
const GLfloat t_y1 = t - tPlane[1] / tPlane[2];
GLfloat dsdx = s_x1 * invQ_x1 - s * invQ;
GLfloat dsdy = s_y1 * invQ_y1 - s * invQ;
GLfloat dtdx = t_x1 * invQ_x1 - t * invQ;
GLfloat dtdy = t_y1 * invQ_y1 - t * invQ;
GLfloat maxU, maxV, rho, lambda;
dsdx = FABSF(dsdx);
dsdy = FABSF(dsdy);
dtdx = FABSF(dtdx);
dtdy = FABSF(dtdy);
maxU = MAX2(dsdx, dsdy) * texWidth;
maxV = MAX2(dtdx, dtdy) * texHeight;
rho = MAX2(maxU, maxV);
lambda = LOG2(rho);
return lambda;
}
static void static void
tex_aa_tri(GLcontext *ctx, general_aa_tri(GLcontext *ctx,
const SWvertex *v0, const SWvertex *v0,
const SWvertex *v1, const SWvertex *v1,
const SWvertex *v2) const SWvertex *v2)
{ {
#define DO_Z #define DO_Z
#define DO_FOG
#define DO_RGBA #define DO_RGBA
#define DO_ATTRIBS #define DO_ATTRIBS
#include "s_aatritemp.h" #include "s_aatritemp.h"
} }
static void
spec_tex_aa_tri(GLcontext *ctx,
const SWvertex *v0,
const SWvertex *v1,
const SWvertex *v2)
{
#define DO_Z
#define DO_FOG
#define DO_RGBA
#define DO_ATTRIBS
#define DO_SPEC
#include "s_aatritemp.h"
}
/* /*
* Examine GL state and set swrast->Triangle to an * Examine GL state and set swrast->Triangle to an
@ -436,16 +396,15 @@ spec_tex_aa_tri(GLcontext *ctx,
void void
_swrast_set_aa_triangle_function(GLcontext *ctx) _swrast_set_aa_triangle_function(GLcontext *ctx)
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
ASSERT(ctx->Polygon.SmoothFlag); ASSERT(ctx->Polygon.SmoothFlag);
if (ctx->Texture._EnabledCoordUnits != 0 if (ctx->Texture._EnabledCoordUnits != 0
|| ctx->FragmentProgram._Current) { || ctx->FragmentProgram._Current
if (NEED_SECONDARY_COLOR(ctx)) { || swrast->_FogEnabled
SWRAST_CONTEXT(ctx)->Triangle = spec_tex_aa_tri; || NEED_SECONDARY_COLOR(ctx)) {
} SWRAST_CONTEXT(ctx)->Triangle = general_aa_tri;
else {
SWRAST_CONTEXT(ctx)->Triangle = tex_aa_tri;
}
} }
else if (ctx->Visual.rgbMode) { else if (ctx->Visual.rgbMode) {
SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;

View file

@ -35,16 +35,15 @@
* DO_Z - if defined, compute Z values * DO_Z - if defined, compute Z values
* DO_RGBA - if defined, compute RGBA values * DO_RGBA - if defined, compute RGBA values
* DO_INDEX - if defined, compute color index values * DO_INDEX - if defined, compute color index values
* DO_SPEC - if defined, compute specular RGB values
* DO_ATTRIBS - if defined, compute texcoords, varying, etc. * DO_ATTRIBS - if defined, compute texcoords, varying, etc.
*/ */
/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/ /*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
{ {
const SWcontext *swrast = SWRAST_CONTEXT(ctx); const SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLfloat *p0 = v0->win; const GLfloat *p0 = v0->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *p1 = v1->win; const GLfloat *p1 = v1->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *p2 = v2->win; const GLfloat *p2 = v2->attrib[FRAG_ATTRIB_WPOS];
const SWvertex *vMin, *vMid, *vMax; const SWvertex *vMin, *vMid, *vMax;
GLint iyMin, iyMax; GLint iyMin, iyMax;
GLfloat yMin, yMax; GLfloat yMin, yMax;
@ -56,27 +55,15 @@
#ifdef DO_Z #ifdef DO_Z
GLfloat zPlane[4]; GLfloat zPlane[4];
#endif #endif
#ifdef DO_FOG
GLfloat fogPlane[4];
#else
GLfloat *fog = NULL;
#endif
#ifdef DO_RGBA #ifdef DO_RGBA
GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4];
#endif #endif
#ifdef DO_INDEX #ifdef DO_INDEX
GLfloat iPlane[4]; GLfloat iPlane[4];
#endif #endif
#ifdef DO_SPEC
GLfloat srPlane[4], sgPlane[4], sbPlane[4];
#endif
#if defined(DO_ATTRIBS) #if defined(DO_ATTRIBS)
GLfloat sPlane[FRAG_ATTRIB_MAX][4]; /* texture S */ GLfloat attrPlane[FRAG_ATTRIB_MAX][4][4];
GLfloat tPlane[FRAG_ATTRIB_MAX][4]; /* texture T */ GLfloat wPlane[4]; /* win[3] */
GLfloat uPlane[FRAG_ATTRIB_MAX][4]; /* texture R */
GLfloat vPlane[FRAG_ATTRIB_MAX][4]; /* texture Q */
GLfloat texWidth[FRAG_ATTRIB_MAX];
GLfloat texHeight[FRAG_ATTRIB_MAX];
#endif #endif
GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign; GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
@ -86,9 +73,9 @@
/* determine bottom to top order of vertices */ /* determine bottom to top order of vertices */
{ {
GLfloat y0 = v0->win[1]; GLfloat y0 = v0->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat y1 = v1->win[1]; GLfloat y1 = v1->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat y2 = v2->win[1]; GLfloat y2 = v2->attrib[FRAG_ATTRIB_WPOS][1];
if (y0 <= y1) { if (y0 <= y1) {
if (y1 <= y2) { if (y1 <= y2) {
vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */ vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */
@ -113,12 +100,12 @@
} }
} }
majDx = vMax->win[0] - vMin->win[0]; majDx = vMax->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0];
majDy = vMax->win[1] - vMin->win[1]; majDy = vMax->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1];
{ {
const GLfloat botDx = vMid->win[0] - vMin->win[0]; const GLfloat botDx = vMid->attrib[FRAG_ATTRIB_WPOS][0] - vMin->attrib[FRAG_ATTRIB_WPOS][0];
const GLfloat botDy = vMid->win[1] - vMin->win[1]; const GLfloat botDy = vMid->attrib[FRAG_ATTRIB_WPOS][1] - vMin->attrib[FRAG_ATTRIB_WPOS][1];
const GLfloat area = majDx * botDy - botDx * majDy; const GLfloat area = majDx * botDy - botDx * majDy;
/* Do backface culling */ /* Do backface culling */
if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area))
@ -135,14 +122,6 @@
compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
span.arrayMask |= SPAN_Z; span.arrayMask |= SPAN_Z;
#endif #endif
#ifdef DO_FOG
compute_plane(p0, p1, p2,
v0->attrib[FRAG_ATTRIB_FOGC][0],
v1->attrib[FRAG_ATTRIB_FOGC][0],
v2->attrib[FRAG_ATTRIB_FOGC][0],
fogPlane);
span.arrayMask |= SPAN_FOG;
#endif
#ifdef DO_RGBA #ifdef DO_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) { if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane); compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane);
@ -160,62 +139,43 @@
#endif #endif
#ifdef DO_INDEX #ifdef DO_INDEX
if (ctx->Light.ShadeModel == GL_SMOOTH) { if (ctx->Light.ShadeModel == GL_SMOOTH) {
compute_plane(p0, p1, p2, (GLfloat) v0->index, compute_plane(p0, p1, p2, (GLfloat) v0->attrib[FRAG_ATTRIB_CI][0],
v1->index, v2->index, iPlane); v1->attrib[FRAG_ATTRIB_CI][0], v2->attrib[FRAG_ATTRIB_CI][0], iPlane);
} }
else { else {
constant_plane(v2->index, iPlane); constant_plane(v2->attrib[FRAG_ATTRIB_CI][0], iPlane);
} }
span.arrayMask |= SPAN_INDEX; span.arrayMask |= SPAN_INDEX;
#endif #endif
#ifdef DO_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
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);
constant_plane(v2->specular[GCOMP], sgPlane);
constant_plane(v2->specular[BCOMP], sbPlane);
}
span.arrayMask |= SPAN_SPEC;
#endif
#if defined(DO_ATTRIBS) #if defined(DO_ATTRIBS)
{ {
const GLfloat invW0 = v0->win[3]; const GLfloat invW0 = v0->attrib[FRAG_ATTRIB_WPOS][3];
const GLfloat invW1 = v1->win[3]; const GLfloat invW1 = v1->attrib[FRAG_ATTRIB_WPOS][3];
const GLfloat invW2 = v2->win[3]; const GLfloat invW2 = v2->attrib[FRAG_ATTRIB_WPOS][3];
compute_plane(p0, p1, p2, invW0, invW1, invW2, wPlane);
span.attrStepX[FRAG_ATTRIB_WPOS][3] = plane_dx(wPlane);
span.attrStepY[FRAG_ATTRIB_WPOS][3] = plane_dy(wPlane);
ATTRIB_LOOP_BEGIN ATTRIB_LOOP_BEGIN
const GLfloat s0 = v0->attrib[attr][0] * invW0; GLuint c;
const GLfloat s1 = v1->attrib[attr][0] * invW1; if (swrast->_InterpMode[attr] == GL_FLAT) {
const GLfloat s2 = v2->attrib[attr][0] * invW2; for (c = 0; c < 4; c++) {
const GLfloat t0 = v0->attrib[attr][1] * invW0; constant_plane(v2->attrib[attr][c] * invW2, attrPlane[attr][c]);
const GLfloat t1 = v1->attrib[attr][1] * invW1; }
const GLfloat t2 = v2->attrib[attr][1] * invW2;
const GLfloat r0 = v0->attrib[attr][2] * invW0;
const GLfloat r1 = v1->attrib[attr][2] * invW1;
const GLfloat r2 = v2->attrib[attr][2] * invW2;
const GLfloat q0 = v0->attrib[attr][3] * invW0;
const GLfloat q1 = v1->attrib[attr][3] * invW1;
const GLfloat q2 = v2->attrib[attr][3] * invW2;
compute_plane(p0, p1, p2, s0, s1, s2, sPlane[attr]);
compute_plane(p0, p1, p2, t0, t1, t2, tPlane[attr]);
compute_plane(p0, p1, p2, r0, r1, r2, uPlane[attr]);
compute_plane(p0, p1, p2, q0, q1, q2, vPlane[attr]);
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) {
const GLuint u = attr - FRAG_ATTRIB_TEX0;
const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
texWidth[attr] = (GLfloat) texImage->Width;
texHeight[attr] = (GLfloat) texImage->Height;
} }
else { else {
texWidth[attr] = texHeight[attr] = 1.0; for (c = 0; c < 4; c++) {
const GLfloat a0 = v0->attrib[attr][c] * invW0;
const GLfloat a1 = v1->attrib[attr][c] * invW1;
const GLfloat a2 = v2->attrib[attr][c] * invW2;
compute_plane(p0, p1, p2, a0, a1, a2, attrPlane[attr][c]);
}
}
for (c = 0; c < 4; c++) {
span.attrStepX[attr][c] = plane_dx(attrPlane[attr][c]);
span.attrStepY[attr][c] = plane_dy(attrPlane[attr][c]);
} }
ATTRIB_LOOP_END ATTRIB_LOOP_END
} }
span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING);
#endif #endif
/* Begin bottom-to-top scan over the triangle. /* Begin bottom-to-top scan over the triangle.
@ -224,16 +184,16 @@
* edges, stopping when we find that coverage = 0. If the long edge * edges, stopping when we find that coverage = 0. If the long edge
* is on the left we scan left-to-right. Else, we scan right-to-left. * is on the left we scan left-to-right. Else, we scan right-to-left.
*/ */
yMin = vMin->win[1]; yMin = vMin->attrib[FRAG_ATTRIB_WPOS][1];
yMax = vMax->win[1]; yMax = vMax->attrib[FRAG_ATTRIB_WPOS][1];
iyMin = (GLint) yMin; iyMin = (GLint) yMin;
iyMax = (GLint) yMax + 1; iyMax = (GLint) yMax + 1;
if (ltor) { if (ltor) {
/* scan left to right */ /* scan left to right */
const GLfloat *pMin = vMin->win; const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *pMid = vMid->win; const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *pMax = vMax->win; const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS];
const GLfloat dxdy = majDx / majDy; const GLfloat dxdy = majDx / majDy;
const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F; const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
@ -253,6 +213,18 @@
/* enter interior of triangle */ /* enter interior of triangle */
ix = startX; ix = startX;
#if defined(DO_ATTRIBS)
/* compute attributes at left-most fragment */
span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 0.5, iy + 0.5, wPlane);
ATTRIB_LOOP_BEGIN
GLuint c;
for (c = 0; c < 4; c++) {
span.attrStart[attr][c] = solve_plane(ix + 0.5, iy + 0.5, attrPlane[attr][c]);
}
ATTRIB_LOOP_END
#endif
count = 0; count = 0;
while (coverage > 0.0F) { while (coverage > 0.0F) {
/* (cx,cy) = center of fragment */ /* (cx,cy) = center of fragment */
@ -266,9 +238,6 @@
#ifdef DO_Z #ifdef DO_Z
array->z[count] = (GLuint) solve_plane(cx, cy, zPlane); array->z[count] = (GLuint) solve_plane(cx, cy, zPlane);
#endif #endif
#ifdef DO_FOG
array->attribs[FRAG_ATTRIB_FOGC][count][0] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA #ifdef DO_RGBA
array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane); array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane); array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane);
@ -277,25 +246,6 @@
#endif #endif
#ifdef DO_INDEX #ifdef DO_INDEX
array->index[count] = (GLint) solve_plane(cx, cy, iPlane); array->index[count] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
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
#if defined(DO_ATTRIBS)
ATTRIB_LOOP_BEGIN
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]);
array->attribs[attr][count][0] = solve_plane(cx, cy, sPlane[attr]) * invQ;
array->attribs[attr][count][1] = solve_plane(cx, cy, tPlane[attr]) * invQ;
array->attribs[attr][count][2] = solve_plane(cx, cy, uPlane[attr]) * invQ;
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) {
const GLuint unit = attr - FRAG_ATTRIB_TEX0;
array->lambda[unit][count] = compute_lambda(sPlane[attr], tPlane[attr],
vPlane[attr], cx, cy, invQ,
texWidth[attr], texHeight[attr]);
}
ATTRIB_LOOP_END
#endif #endif
ix++; ix++;
count++; count++;
@ -308,7 +258,6 @@
span.x = startX; span.x = startX;
span.y = iy; span.y = iy;
span.end = (GLuint) ix - (GLuint) startX; span.end = (GLuint) ix - (GLuint) startX;
ASSERT(span.interpMask == 0);
#if defined(DO_RGBA) #if defined(DO_RGBA)
_swrast_write_rgba_span(ctx, &span); _swrast_write_rgba_span(ctx, &span);
#else #else
@ -318,9 +267,9 @@
} }
else { else {
/* scan right to left */ /* scan right to left */
const GLfloat *pMin = vMin->win; const GLfloat *pMin = vMin->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *pMid = vMid->win; const GLfloat *pMid = vMid->attrib[FRAG_ATTRIB_WPOS];
const GLfloat *pMax = vMax->win; const GLfloat *pMax = vMax->attrib[FRAG_ATTRIB_WPOS];
const GLfloat dxdy = majDx / majDy; const GLfloat dxdy = majDx / majDy;
const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F; const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F;
GLfloat x = pMin[0] - (yMin - iyMin) * dxdy; GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
@ -358,9 +307,6 @@
#ifdef DO_Z #ifdef DO_Z
array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane);
#endif #endif
#ifdef DO_FOG
array->attribs[FRAG_ATTRIB_FOGC][ix][0] = solve_plane(cx, cy, fogPlane);
#endif
#ifdef DO_RGBA #ifdef DO_RGBA
array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane); array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane); array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane);
@ -369,34 +315,23 @@
#endif #endif
#ifdef DO_INDEX #ifdef DO_INDEX
array->index[ix] = (GLint) solve_plane(cx, cy, iPlane); array->index[ix] = (GLint) solve_plane(cx, cy, iPlane);
#endif
#ifdef DO_SPEC
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
#if defined(DO_ATTRIBS)
ATTRIB_LOOP_BEGIN
GLfloat invQ = solve_plane_recip(cx, cy, vPlane[attr]);
array->attribs[attr][ix][0] = solve_plane(cx, cy, sPlane[attr]) * invQ;
array->attribs[attr][ix][1] = solve_plane(cx, cy, tPlane[attr]) * invQ;
array->attribs[attr][ix][2] = solve_plane(cx, cy, uPlane[attr]) * invQ;
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) {
const GLuint unit = attr - FRAG_ATTRIB_TEX0;
array->lambda[unit][ix] = compute_lambda(sPlane[attr],
tPlane[attr],
vPlane[attr],
cx, cy, invQ,
texWidth[attr],
texHeight[attr]);
}
ATTRIB_LOOP_END
#endif #endif
ix--; ix--;
count++; count++;
coverage = compute_coveragef(pMin, pMax, pMid, ix, iy); coverage = compute_coveragef(pMin, pMax, pMid, ix, iy);
} }
#if defined(DO_ATTRIBS)
/* compute attributes at left-most fragment */
span.attrStart[FRAG_ATTRIB_WPOS][3] = solve_plane(ix + 1.5, iy + 0.5, wPlane);
ATTRIB_LOOP_BEGIN
GLuint c;
for (c = 0; c < 4; c++) {
span.attrStart[attr][c] = solve_plane(ix + 1.5, iy + 0.5, attrPlane[attr][c]);
}
ATTRIB_LOOP_END
#endif
if (startX <= ix) if (startX <= ix)
continue; continue;
@ -410,48 +345,22 @@
SWspanarrays *array = span.array; SWspanarrays *array = span.array;
GLint j; GLint j;
for (j = 0; j < (GLint) n; j++) { for (j = 0; j < (GLint) n; j++) {
array->coverage[j] = array->coverage[j + left];
#ifdef DO_RGBA #ifdef DO_RGBA
COPY_CHAN4(array->rgba[j], array->rgba[j + left]); COPY_CHAN4(array->rgba[j], array->rgba[j + left]);
#endif #endif
#ifdef DO_SPEC
COPY_CHAN4(array->spec[j], array->spec[j + left]);
#endif
#ifdef DO_INDEX #ifdef DO_INDEX
array->index[j] = array->index[j + left]; array->index[j] = array->index[j + left];
#endif #endif
#ifdef DO_Z #ifdef DO_Z
array->z[j] = array->z[j + left]; array->z[j] = array->z[j + left];
#endif #endif
#ifdef DO_FOG
array->attribs[FRAG_ATTRIB_FOGC][j][0]
= array->attribs[FRAG_ATTRIB_FOGC][j + left][0];
#endif
#if defined(DO_ATTRIBS)
array->lambda[0][j] = array->lambda[0][j + left];
#endif
array->coverage[j] = array->coverage[j + left];
} }
} }
#ifdef DO_ATTRIBS
/* shift texcoords, varying */
{
SWspanarrays *array = span.array;
ATTRIB_LOOP_BEGIN
GLint j;
for (j = 0; j < (GLint) n; j++) {
array->attribs[attr][j][0] = array->attribs[attr][j + left][0];
array->attribs[attr][j][1] = array->attribs[attr][j + left][1];
array->attribs[attr][j][2] = array->attribs[attr][j + left][2];
/*array->lambda[unit][j] = array->lambda[unit][j + left];*/
}
ATTRIB_LOOP_END
}
#endif
span.x = left; span.x = left;
span.y = iy; span.y = iy;
span.end = n; span.end = n;
ASSERT(span.interpMask == 0);
#if defined(DO_RGBA) #if defined(DO_RGBA)
_swrast_write_rgba_span(ctx, &span); _swrast_write_rgba_span(ctx, &span);
#else #else
@ -462,30 +371,8 @@
} }
#ifdef DO_Z
#undef DO_Z #undef DO_Z
#endif
#ifdef DO_FOG
#undef DO_FOG
#endif
#ifdef DO_RGBA
#undef DO_RGBA #undef DO_RGBA
#endif
#ifdef DO_INDEX
#undef DO_INDEX #undef DO_INDEX
#endif
#ifdef DO_SPEC
#undef DO_SPEC
#endif
#ifdef DO_ATTRIBS
#undef DO_ATTRIBS #undef DO_ATTRIBS
#endif
#ifdef DO_OCCLUSION_TEST
#undef DO_OCCLUSION_TEST #undef DO_OCCLUSION_TEST
#endif

View file

@ -111,13 +111,13 @@ _swrast_alpha_test(const GLcontext *ctx, SWspan *span)
if (span->arrayMask & SPAN_RGBA) { if (span->arrayMask & SPAN_RGBA) {
/* Use array's alpha values */ /* Use array's alpha values */
if (span->array->ChanType == GL_UNSIGNED_BYTE) { if (span->array->ChanType == GL_UNSIGNED_BYTE) {
GLubyte (*rgba)[4] = span->array->color.sz1.rgba; GLubyte (*rgba)[4] = span->array->rgba8;
GLubyte ref; GLubyte ref;
CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef); CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef);
ALPHA_TEST(rgba[i][ACOMP], ;); ALPHA_TEST(rgba[i][ACOMP], ;);
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) { else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba; GLushort (*rgba)[4] = span->array->rgba16;
GLushort ref; GLushort ref;
CLAMPED_FLOAT_TO_USHORT(ref, ctx->Color.AlphaRef); CLAMPED_FLOAT_TO_USHORT(ref, ctx->Color.AlphaRef);
ALPHA_TEST(rgba[i][ACOMP], ;); ALPHA_TEST(rgba[i][ACOMP], ;);

View file

@ -83,15 +83,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
_swrast_validate_derived( ctx ); _swrast_validate_derived( ctx );
INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_XY); INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_XY);
_swrast_span_default_attribs(ctx, &span);
_swrast_span_default_color(ctx, &span);
_swrast_span_default_secondary_color(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
for (row = 0; row < height; row++) { for (row = 0; row < height; row++) {
const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
@ -189,20 +181,13 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
_swrast_validate_derived( ctx ); _swrast_validate_derived( ctx );
INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_MASK); INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_MASK);
_swrast_span_default_attribs(ctx, &span);
/*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */ /*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */
span.x = px; span.x = px;
span.y = py; span.y = py;
/*span.end = width;*/ /*span.end = width;*/
_swrast_span_default_color(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
for (row=0; row<height; row++, span.y++) { for (row=0; row<height; row++, span.y++) {
const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack, const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0); bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);

View file

@ -188,6 +188,37 @@ _swrast_update_texture_env( GLcontext *ctx )
} }
/**
* Determine if we can defer texturing/shading until after Z/stencil
* testing. This potentially allows us to skip texturing/shading for
* lots of fragments.
*/
static void
_swrast_update_deferred_texture(GLcontext *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
if (ctx->Color.AlphaEnabled) {
/* alpha test depends on post-texture/shader colors */
swrast->_DeferredTexture = GL_FALSE;
}
else {
const struct gl_fragment_program *fprog
= ctx->FragmentProgram._Current;
if (fprog && (fprog->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR))) {
/* Z comes from fragment program/shader */
swrast->_DeferredTexture = GL_FALSE;
}
else if (ctx->Query.CurrentOcclusionObject) {
/* occlusion query depends on shader discard/kill results */
swrast->_DeferredTexture = GL_FALSE;
}
else {
swrast->_DeferredTexture = GL_TRUE;
}
}
}
/** /**
* Update swrast->_FogColor and swrast->_FogEnable values. * Update swrast->_FogColor and swrast->_FogEnable values.
*/ */
@ -324,7 +355,6 @@ _swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
swrast->Line = _swrast_add_spec_terms_line; swrast->Line = _swrast_add_spec_terms_line;
} }
swrast->Line( ctx, v0, v1 ); swrast->Line( ctx, v0, v1 );
} }
@ -505,7 +535,7 @@ _swrast_update_texture_samplers(GLcontext *ctx)
/** /**
* Update swrast->_ActiveAttribs and swrast->_NumActiveAttribs * Update swrast->_ActiveAttribs, swrast->_NumActiveAttribs, swrast->_ActiveAtttribMask.
*/ */
static void static void
_swrast_update_fragment_attribs(GLcontext *ctx) _swrast_update_fragment_attribs(GLcontext *ctx)
@ -513,42 +543,50 @@ _swrast_update_fragment_attribs(GLcontext *ctx)
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint attribsMask; GLuint attribsMask;
/*
* Compute _ActiveAttribsMask = which fragment attributes are needed.
*/
if (ctx->FragmentProgram._Current) { if (ctx->FragmentProgram._Current) {
/* fragment program/shader */
attribsMask = ctx->FragmentProgram._Current->Base.InputsRead; attribsMask = ctx->FragmentProgram._Current->Base.InputsRead;
} }
else if (ctx->ATIFragmentShader._Enabled) {
attribsMask = ~0; /* XXX fix me */
}
else { else {
GLuint u; /* fixed function */
attribsMask = 0x0; attribsMask = 0x0;
#if 0 /* not yet */ #if CHAN_TYPE == GL_FLOAT
if (ctx->Depth.Test) attribsMask |= FRAG_BIT_COL0;
attribsMask |= FRAG_BIT_WPOS;
if (NEED_SECONDARY_COLOR(ctx))
attribsMask |= FRAG_BIT_COL1;
#endif #endif
if (ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
attribsMask |= FRAG_BIT_COL1;
}
if (swrast->_FogEnabled) if (swrast->_FogEnabled)
attribsMask |= FRAG_BIT_FOGC; attribsMask |= FRAG_BIT_FOGC;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { attribsMask |= (ctx->Texture._EnabledUnits << FRAG_ATTRIB_TEX0);
if (ctx->Texture.Unit[u]._ReallyEnabled) {
attribsMask |= FRAG_BIT_TEX(u);
}
}
} }
/* don't want to interpolate these generic attribs just yet */ swrast->_ActiveAttribMask = attribsMask;
/* XXX temporary */
attribsMask &= ~(FRAG_BIT_WPOS |
FRAG_BIT_COL0 |
FRAG_BIT_COL1 |
FRAG_BIT_FOGC);
/* Update _ActiveAttribs[] list */ /* Update _ActiveAttribs[] list */
{ {
GLuint i, num = 0; GLuint i, num = 0;
for (i = 0; i < FRAG_ATTRIB_MAX; i++) { for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
if (attribsMask & (1 << i)) if (attribsMask & (1 << i)) {
swrast->_ActiveAttribs[num++] = i; swrast->_ActiveAttribs[num++] = i;
/* how should this attribute be interpolated? */
if (i == FRAG_ATTRIB_COL0 || i == FRAG_ATTRIB_COL1)
swrast->_InterpMode[i] = ctx->Light.ShadeModel;
else
swrast->_InterpMode[i] = GL_SMOOTH;
}
} }
swrast->_NumActiveAttribs = num; swrast->_NumActiveAttribs = num;
} }
@ -627,14 +665,19 @@ _swrast_validate_derived( GLcontext *ctx )
if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM))
_swrast_update_texture_samplers( ctx ); _swrast_update_texture_samplers( ctx );
if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) {
_swrast_validate_texture_images( ctx ); _swrast_validate_texture_images(ctx);
if (swrast->NewState & (_NEW_COLOR)) {
_swrast_update_deferred_texture(ctx);
}
}
if (swrast->NewState & _SWRAST_NEW_RASTERMASK) if (swrast->NewState & _SWRAST_NEW_RASTERMASK)
_swrast_update_rasterflags( ctx ); _swrast_update_rasterflags( ctx );
if (swrast->NewState & (_NEW_DEPTH | if (swrast->NewState & (_NEW_DEPTH |
_NEW_FOG | _NEW_FOG |
_NEW_LIGHT |
_NEW_PROGRAM | _NEW_PROGRAM |
_NEW_TEXTURE)) _NEW_TEXTURE))
_swrast_update_fragment_attribs(ctx); _swrast_update_fragment_attribs(ctx);
@ -787,14 +830,11 @@ _swrast_CreateContext( GLcontext *ctx )
} }
swrast->SpanArrays->ChanType = CHAN_TYPE; swrast->SpanArrays->ChanType = CHAN_TYPE;
#if CHAN_TYPE == GL_UNSIGNED_BYTE #if CHAN_TYPE == GL_UNSIGNED_BYTE
swrast->SpanArrays->rgba = swrast->SpanArrays->color.sz1.rgba; swrast->SpanArrays->rgba = swrast->SpanArrays->rgba8;
swrast->SpanArrays->spec = swrast->SpanArrays->color.sz1.spec;
#elif CHAN_TYPE == GL_UNSIGNED_SHORT #elif CHAN_TYPE == GL_UNSIGNED_SHORT
swrast->SpanArrays->rgba = swrast->SpanArrays->color.sz2.rgba; swrast->SpanArrays->rgba = swrast->SpanArrays->rgba16;
swrast->SpanArrays->spec = swrast->SpanArrays->color.sz2.spec;
#else #else
swrast->SpanArrays->rgba = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0]; swrast->SpanArrays->rgba = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
swrast->SpanArrays->spec = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL1];
#endif #endif
/* init point span buffer */ /* init point span buffer */
@ -896,7 +936,10 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
if (SWRAST_DEBUG_VERTICES) { if (SWRAST_DEBUG_VERTICES) {
_mesa_debug(ctx, "win %f %f %f %f\n", _mesa_debug(ctx, "win %f %f %f %f\n",
v->win[0], v->win[1], v->win[2], v->win[3]); v->attrib[FRAG_ATTRIB_WPOS][0],
v->attrib[FRAG_ATTRIB_WPOS][1],
v->attrib[FRAG_ATTRIB_WPOS][2],
v->attrib[FRAG_ATTRIB_WPOS][3]);
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
if (ctx->Texture.Unit[i]._ReallyEnabled) if (ctx->Texture.Unit[i]._ReallyEnabled)
@ -909,18 +952,17 @@ _swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
#if CHAN_TYPE == GL_FLOAT #if CHAN_TYPE == GL_FLOAT
_mesa_debug(ctx, "color %f %f %f %f\n", _mesa_debug(ctx, "color %f %f %f %f\n",
v->color[0], v->color[1], v->color[2], v->color[3]); v->color[0], v->color[1], v->color[2], v->color[3]);
_mesa_debug(ctx, "spec %f %f %f %f\n",
v->specular[0], v->specular[1],
v->specular[2], v->specular[3]);
#else #else
_mesa_debug(ctx, "color %d %d %d %d\n", _mesa_debug(ctx, "color %d %d %d %d\n",
v->color[0], v->color[1], v->color[2], v->color[3]); v->color[0], v->color[1], v->color[2], v->color[3]);
_mesa_debug(ctx, "spec %d %d %d %d\n",
v->specular[0], v->specular[1],
v->specular[2], v->specular[3]);
#endif #endif
_mesa_debug(ctx, "spec %g %g %g %g\n",
v->attrib[FRAG_ATTRIB_COL1][0],
v->attrib[FRAG_ATTRIB_COL1][1],
v->attrib[FRAG_ATTRIB_COL1][2],
v->attrib[FRAG_ATTRIB_COL1][3]);
_mesa_debug(ctx, "fog %f\n", v->attrib[FRAG_ATTRIB_FOGC][0]); _mesa_debug(ctx, "fog %f\n", v->attrib[FRAG_ATTRIB_FOGC][0]);
_mesa_debug(ctx, "index %d\n", v->index); _mesa_debug(ctx, "index %d\n", v->attrib[FRAG_ATTRIB_CI][0]);
_mesa_debug(ctx, "pointsize %f\n", v->pointSize); _mesa_debug(ctx, "pointsize %f\n", v->pointSize);
_mesa_debug(ctx, "\n"); _mesa_debug(ctx, "\n");
} }

View file

@ -132,6 +132,7 @@ typedef struct
GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */ GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */
GLboolean _AnyTextureCombine; GLboolean _AnyTextureCombine;
GLboolean _FogEnabled; GLboolean _FogEnabled;
GLboolean _DeferredTexture;
GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */ GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */
/** Multiple render targets */ /** Multiple render targets */
@ -140,8 +141,12 @@ typedef struct
/** List/array of the fragment attributes to interpolate */ /** List/array of the fragment attributes to interpolate */
GLuint _ActiveAttribs[FRAG_ATTRIB_MAX]; GLuint _ActiveAttribs[FRAG_ATTRIB_MAX];
/** Same info, but as a bitmask */
GLbitfield _ActiveAttribMask;
/** Number of fragment attributes to interpolate */ /** Number of fragment attributes to interpolate */
GLuint _NumActiveAttribs; GLuint _NumActiveAttribs;
/** Indicates how each attrib is to be interpolated (lines/tris) */
GLenum _InterpMode[FRAG_ATTRIB_MAX]; /* GL_FLAT or GL_SMOOTH (for now) */
/* Accum buffer temporaries. /* Accum buffer temporaries.
*/ */

View file

@ -94,7 +94,6 @@ static void
copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty) GLint width, GLint height, GLint destx, GLint desty)
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLint row; GLint row;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
const GLbitfield transferOps = ctx->_ImageTransferState; const GLbitfield transferOps = ctx->_ImageTransferState;
@ -104,12 +103,7 @@ copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
SWspan span; SWspan span;
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
_swrast_span_default_attribs(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
_swrast_span_default_secondary_color(ctx, &span);
/* allocate space for GLfloat image */ /* allocate space for GLfloat image */
tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
@ -194,7 +188,6 @@ static void
copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy, copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint destx, GLint desty) GLint width, GLint height, GLint destx, GLint desty)
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLfloat *tmpImage, *p; GLfloat *tmpImage, *p;
GLint sy, dy, stepy, row; GLint sy, dy, stepy, row;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
@ -240,11 +233,7 @@ copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
} }
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
if (ctx->Depth.Test) _swrast_span_default_attribs(ctx, &span);
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
_swrast_span_default_secondary_color(ctx, &span);
if (overlapping) { if (overlapping) {
tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4); tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat) * 4);
@ -313,7 +302,6 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint width, GLint height,
GLint destx, GLint desty ) GLint destx, GLint desty )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLuint *tmpImage,*p; GLuint *tmpImage,*p;
GLint sy, dy, stepy; GLint sy, dy, stepy;
GLint j; GLint j;
@ -327,6 +315,7 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
} }
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
_swrast_span_default_attribs(ctx, &span);
if (ctx->DrawBuffer == ctx->ReadBuffer) { if (ctx->DrawBuffer == ctx->ReadBuffer) {
overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
@ -350,11 +339,6 @@ copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
stepy = 1; stepy = 1;
} }
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (overlapping) { if (overlapping) {
GLint ssy = sy; GLint ssy = sy;
tmpImage = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); tmpImage = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint));
@ -450,7 +434,6 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
GLint width, GLint height, GLint width, GLint height,
GLint destx, GLint desty ) GLint destx, GLint desty )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
struct gl_framebuffer *fb = ctx->ReadBuffer; struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *readRb = fb->_DepthBuffer; struct gl_renderbuffer *readRb = fb->_DepthBuffer;
GLfloat *p, *tmpImage; GLfloat *p, *tmpImage;
@ -466,6 +449,7 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
} }
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
_swrast_span_default_attribs(ctx, &span);
if (ctx->DrawBuffer == ctx->ReadBuffer) { if (ctx->DrawBuffer == ctx->ReadBuffer) {
overlapping = regions_overlap(srcx, srcy, destx, desty, width, height, overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
@ -489,11 +473,6 @@ copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
stepy = 1; stepy = 1;
} }
_swrast_span_default_color(ctx, &span);
_swrast_span_default_secondary_color(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (overlapping) { if (overlapping) {
GLint ssy = sy; GLint ssy = sy;
tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat)); tmpImage = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat));

View file

@ -71,13 +71,7 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
} }
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
_swrast_span_default_secondary_color(ctx, &span); _swrast_span_default_attribs(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
/* copy input params since clipping may change them */ /* copy input params since clipping may change them */
unpack = *userUnpack; unpack = *userUnpack;
@ -274,9 +268,9 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
for (row = 0; row < drawHeight; row++) { for (row = 0; row < drawHeight; row++) {
ASSERT(drawWidth <= MAX_WIDTH); ASSERT(drawWidth <= MAX_WIDTH);
_mesa_map_ci8_to_rgba8(ctx, drawWidth, src, _mesa_map_ci8_to_rgba8(ctx, drawWidth, src,
span.array->color.sz1.rgba); span.array->rgba8);
rb->PutRow(ctx, rb, drawWidth, destX, destY, rb->PutRow(ctx, rb, drawWidth, destX, destY,
span.array->color.sz1.rgba, NULL); span.array->rgba8, NULL);
src += unpack.RowLength; src += unpack.RowLength;
destY += yStep; destY += yStep;
} }
@ -287,12 +281,12 @@ fast_draw_rgba_pixels(GLcontext *ctx, GLint x, GLint y,
for (row = 0; row < drawHeight; row++) { for (row = 0; row < drawHeight; row++) {
ASSERT(drawWidth <= MAX_WIDTH); ASSERT(drawWidth <= MAX_WIDTH);
_mesa_map_ci8_to_rgba8(ctx, drawWidth, src, _mesa_map_ci8_to_rgba8(ctx, drawWidth, src,
span.array->color.sz1.rgba); span.array->rgba8);
span.x = destX; span.x = destX;
span.y = destY; span.y = destY;
span.end = drawWidth; span.end = drawWidth;
_swrast_write_zoomed_rgba_span(ctx, imgX, imgY, &span, _swrast_write_zoomed_rgba_span(ctx, imgX, imgY, &span,
span.array->color.sz1.rgba); span.array->rgba8);
src += unpack.RowLength; src += unpack.RowLength;
destY++; destY++;
} }
@ -333,18 +327,13 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
const struct gl_pixelstore_attrib *unpack, const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels ) const GLvoid *pixels )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint imgX = x, imgY = y; const GLint imgX = x, imgY = y;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
GLint row, skipPixels; GLint row, skipPixels;
SWspan span; SWspan span;
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
_swrast_span_default_attribs(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
/* /*
* General solution * General solution
@ -433,20 +422,13 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
const struct gl_pixelstore_attrib *unpack, const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels ) const GLvoid *pixels )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLboolean scaleOrBias const GLboolean scaleOrBias
= ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0; = ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
SWspan span; SWspan span;
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z); INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
_swrast_span_default_attribs(ctx, &span);
_swrast_span_default_color(ctx, &span);
_swrast_span_default_secondary_color(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
if (type == GL_UNSIGNED_SHORT if (type == GL_UNSIGNED_SHORT
&& ctx->DrawBuffer->Visual.depthBits == 16 && ctx->DrawBuffer->Visual.depthBits == 16
@ -550,7 +532,6 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
const struct gl_pixelstore_attrib *unpack, const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels ) const GLvoid *pixels )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLint imgX = x, imgY = y; const GLint imgX = x, imgY = y;
const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
GLfloat *convImage = NULL; GLfloat *convImage = NULL;
@ -562,14 +543,8 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
unpack, pixels)) unpack, pixels))
return; return;
INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA); INIT_SPAN(span, GL_BITMAP, 0, 0x0, SPAN_RGBA);
_swrast_span_default_secondary_color(ctx, &span); _swrast_span_default_attribs(ctx, &span);
if (ctx->Depth.Test)
_swrast_span_default_z(ctx, &span);
if (swrast->_FogEnabled)
_swrast_span_default_fog(ctx, &span);
if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) { if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
/* Convolution has to be handled specially. We'll create an /* Convolution has to be handled specially. We'll create an

View file

@ -42,17 +42,17 @@ feedback_vertex(GLcontext * ctx, const SWvertex * v, const SWvertex * pv)
GLfloat color[4]; GLfloat color[4];
const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0]; const GLfloat *vtc = v->attrib[FRAG_ATTRIB_TEX0];
win[0] = v->win[0]; win[0] = v->attrib[FRAG_ATTRIB_WPOS][0];
win[1] = v->win[1]; win[1] = v->attrib[FRAG_ATTRIB_WPOS][1];
win[2] = v->win[2] / ctx->DrawBuffer->_DepthMaxF; win[2] = v->attrib[FRAG_ATTRIB_WPOS][2] / ctx->DrawBuffer->_DepthMaxF;
win[3] = 1.0F / v->win[3]; win[3] = 1.0F / v->attrib[FRAG_ATTRIB_WPOS][3];
color[0] = CHAN_TO_FLOAT(pv->color[0]); color[0] = CHAN_TO_FLOAT(pv->color[0]);
color[1] = CHAN_TO_FLOAT(pv->color[1]); color[1] = CHAN_TO_FLOAT(pv->color[1]);
color[2] = CHAN_TO_FLOAT(pv->color[2]); color[2] = CHAN_TO_FLOAT(pv->color[2]);
color[3] = CHAN_TO_FLOAT(pv->color[3]); color[3] = CHAN_TO_FLOAT(pv->color[3]);
_mesa_feedback_vertex(ctx, win, color, (GLfloat) v->index, vtc); _mesa_feedback_vertex(ctx, win, color, v->attrib[FRAG_ATTRIB_CI][0], vtc);
} }
@ -120,9 +120,10 @@ _swrast_select_triangle(GLcontext *ctx, const SWvertex *v0,
{ {
if (_swrast_culltriangle(ctx, v0, v1, v2)) { if (_swrast_culltriangle(ctx, v0, v1, v2)) {
const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag(ctx, v0->win[2] * zs);
_mesa_update_hitflag(ctx, v1->win[2] * zs); _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs );
_mesa_update_hitflag(ctx, v2->win[2] * zs); _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs );
_mesa_update_hitflag( ctx, v2->attrib[FRAG_ATTRIB_WPOS][2] * zs );
} }
} }
@ -131,8 +132,8 @@ void
_swrast_select_line(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) _swrast_select_line(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
{ {
const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag(ctx, v0->win[2] * zs); _mesa_update_hitflag( ctx, v0->attrib[FRAG_ATTRIB_WPOS][2] * zs );
_mesa_update_hitflag(ctx, v1->win[2] * zs); _mesa_update_hitflag( ctx, v1->attrib[FRAG_ATTRIB_WPOS][2] * zs );
} }
@ -140,5 +141,5 @@ void
_swrast_select_point(GLcontext *ctx, const SWvertex *v) _swrast_select_point(GLcontext *ctx, const SWvertex *v)
{ {
const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF; const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
_mesa_update_hitflag(ctx, v->win[2] * zs); _mesa_update_hitflag( ctx, v->attrib[FRAG_ATTRIB_WPOS][2] * zs );
} }

View file

@ -65,30 +65,92 @@ _swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
} }
#define LINEAR_FOG(f, coord) f = (fogEnd - coord) * fogScale
#define EXP_FOG(f, coord) f = EXPF(density * coord)
#define EXP2_FOG(f, coord) \
do { \
GLfloat tmp = negDensitySquared * coord * coord; \
if (tmp < FLT_MIN_10_EXP) \
tmp = FLT_MIN_10_EXP; \
f = EXPF(tmp); \
} while(0)
#define BLEND_FOG(f, coord) f = coord
/** /**
* Template code for computing fog blend factor and applying it to colors. * Template code for computing fog blend factor and applying it to colors.
* \param TYPE either GLubyte, GLushort or GLfloat. * \param TYPE either GLubyte, GLushort or GLfloat.
* \param COMPUTE_F code to compute the fog blend factor, f. * \param COMPUTE_F code to compute the fog blend factor, f.
*/ */
#define FOG_LOOP(TYPE, COMPUTE_F) \ #define FOG_LOOP(TYPE, FOG_FUNC) \
do { \ if (span->arrayAttribs & FRAG_BIT_FOGC) { \
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \ GLuint i; \
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \ for (i = 0; i < span->end; i++) { \
const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;\ const GLfloat fogCoord = span->array->attribs[FRAG_ATTRIB_FOGC][i][0]; \
GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F; \ const GLfloat c = FABSF(fogCoord); \
GLuint i; \ GLfloat f, oneMinusF; \
for (i = 0; i < span->end; i++) { \ FOG_FUNC(f, c); \
GLfloat f, oneMinusF; \ f = CLAMP(f, 0.0F, 1.0F); \
COMPUTE_F; \ oneMinusF = 1.0F - f; \
f = CLAMP(f, 0.0F, 1.0F); \ rgba[i][RCOMP] = (TYPE) (f * rgba[i][RCOMP] + oneMinusF * rFog); \
oneMinusF = 1.0F - f; \ rgba[i][GCOMP] = (TYPE) (f * rgba[i][GCOMP] + oneMinusF * gFog); \
rgba[i][RCOMP] = (TYPE) (f * rgba[i][RCOMP] + oneMinusF * rFog); \ rgba[i][BCOMP] = (TYPE) (f * rgba[i][BCOMP] + oneMinusF * bFog); \
rgba[i][GCOMP] = (TYPE) (f * rgba[i][GCOMP] + oneMinusF * gFog); \ } \
rgba[i][BCOMP] = (TYPE) (f * rgba[i][BCOMP] + oneMinusF * bFog); \ } \
fogCoord += fogStep; \ else { \
w += wStep; \ const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \
} \ GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \
} while (0) const GLfloat wStep = span->attrStepX[FRAG_ATTRIB_WPOS][3]; \
GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; \
GLuint i; \
for (i = 0; i < span->end; i++) { \
const GLfloat c = FABSF(fogCoord) / w; \
GLfloat f, oneMinusF; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
oneMinusF = 1.0F - f; \
rgba[i][RCOMP] = (TYPE) (f * rgba[i][RCOMP] + oneMinusF * rFog); \
rgba[i][GCOMP] = (TYPE) (f * rgba[i][GCOMP] + oneMinusF * gFog); \
rgba[i][BCOMP] = (TYPE) (f * rgba[i][BCOMP] + oneMinusF * bFog); \
fogCoord += fogStep; \
w += wStep; \
} \
}
/* As above, but CI mode (XXX try to merge someday) */
#define FOG_LOOP_CI(FOG_FUNC) \
if (span->arrayAttribs & FRAG_BIT_FOGC) { \
GLuint i; \
for (i = 0; i < span->end; i++) { \
const GLfloat fogCoord = span->array->attribs[FRAG_ATTRIB_FOGC][i][0]; \
const GLfloat c = FABSF(fogCoord); \
GLfloat f; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); \
} \
} \
else { \
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; \
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0]; \
const GLfloat wStep = span->attrStepX[FRAG_ATTRIB_WPOS][3]; \
GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; \
GLuint i; \
for (i = 0; i < span->end; i++) { \
const GLfloat c = FABSF(fogCoord) / w; \
GLfloat f; \
FOG_FUNC(f, c); \
f = CLAMP(f, 0.0F, 1.0F); \
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex); \
fogCoord += fogStep; \
w += wStep; \
} \
}
@ -104,12 +166,12 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span )
{ {
const SWcontext *swrast = SWRAST_CONTEXT(ctx); const SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLfloat rFog, gFog, bFog; GLfloat rFog, gFog, bFog;
const GLuint haveW = (span->interpMask & SPAN_W);
ASSERT(swrast->_FogEnabled); ASSERT(swrast->_FogEnabled);
ASSERT((span->interpMask | span->arrayMask) & SPAN_FOG); ASSERT(swrast->_ActiveAttribMask & FRAG_BIT_FOGC);
ASSERT(span->arrayMask & SPAN_RGBA); ASSERT(span->arrayMask & SPAN_RGBA);
/* compute (scaled) fog color */
if (span->array->ChanType == GL_UNSIGNED_BYTE) { if (span->array->ChanType == GL_UNSIGNED_BYTE) {
rFog = ctx->Fog.Color[RCOMP] * 255.0; rFog = ctx->Fog.Color[RCOMP] * 255.0;
gFog = ctx->Fog.Color[GCOMP] * 255.0; gFog = ctx->Fog.Color[GCOMP] * 255.0;
@ -126,79 +188,68 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span )
bFog = ctx->Fog.Color[BCOMP]; bFog = ctx->Fog.Color[BCOMP];
} }
/* NOTE: if haveW is true, that means the fog start/step values are
* perspective-corrected and we have to divide each fog coord by W.
*/
/* we need to compute fog blend factors */
if (swrast->_PreferPixelFog) { if (swrast->_PreferPixelFog) {
/* The span's fog values are fog coordinates, now compute blend factors /* The span's fog values are fog coordinates, now compute blend factors
* and blend the fragment colors with the fog color. * and blend the fragment colors with the fog color.
*/ */
const GLfloat fogEnd = ctx->Fog.End;
const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End)
? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
const GLfloat density = -ctx->Fog.Density;
const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
switch (swrast->_FogMode) { switch (swrast->_FogMode) {
case GL_LINEAR: case GL_LINEAR:
#define COMPUTE_F f = (fogEnd - FABSF(fogCoord) / w) * fogScale; {
if (span->array->ChanType == GL_UNSIGNED_BYTE) { const GLfloat fogEnd = ctx->Fog.End;
GLubyte (*rgba)[4] = span->array->color.sz1.rgba; const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End)
FOG_LOOP(GLubyte, COMPUTE_F); ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
GLubyte (*rgba)[4] = span->array->rgba8;
FOG_LOOP(GLubyte, LINEAR_FOG);
}
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->rgba16;
FOG_LOOP(GLushort, LINEAR_FOG);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, LINEAR_FOG);
}
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba;
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
#undef COMPUTE_F
break; break;
case GL_EXP: case GL_EXP:
#define COMPUTE_F f = EXPF(density * FABSF(fogCoord) / w); {
if (span->array->ChanType == GL_UNSIGNED_BYTE) { const GLfloat density = -ctx->Fog.Density;
GLubyte (*rgba)[4] = span->array->color.sz1.rgba; if (span->array->ChanType == GL_UNSIGNED_BYTE) {
FOG_LOOP(GLubyte, COMPUTE_F); GLubyte (*rgba)[4] = span->array->rgba8;
FOG_LOOP(GLubyte, EXP_FOG);
}
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->rgba16;
FOG_LOOP(GLushort, EXP_FOG);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, EXP_FOG);
}
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba;
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
#undef COMPUTE_F
break; break;
case GL_EXP2: case GL_EXP2:
#define COMPUTE_F const GLfloat coord = fogCoord / w; \ {
GLfloat tmp = negDensitySquared * coord * coord; \ const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
if (tmp < FLT_MIN_10_EXP) \ if (span->array->ChanType == GL_UNSIGNED_BYTE) {
tmp = FLT_MIN_10_EXP; \ GLubyte (*rgba)[4] = span->array->rgba8;
f = EXPF(tmp); FOG_LOOP(GLubyte, EXP2_FOG);
if (span->array->ChanType == GL_UNSIGNED_BYTE) { }
GLubyte (*rgba)[4] = span->array->color.sz1.rgba; else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
FOG_LOOP(GLubyte, COMPUTE_F); GLushort (*rgba)[4] = span->array->rgba16;
FOG_LOOP(GLushort, EXP2_FOG);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, EXP2_FOG);
}
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba;
FOG_LOOP(GLushort, COMPUTE_F);
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F);
}
#undef COMPUTE_F
break; break;
default: default:
@ -206,63 +257,23 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span )
return; return;
} }
} }
else if (span->arrayMask & SPAN_FOG) {
/* The span's fog array values are blend factors.
* They were previously computed per-vertex.
*/
GLuint i;
if (span->array->ChanType == GL_UNSIGNED_BYTE) {
GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
for (i = 0; i < span->end; i++) {
const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLubyte) (f * rgba[i][RCOMP] + oneMinusF * rFog);
rgba[i][GCOMP] = (GLubyte) (f * rgba[i][GCOMP] + oneMinusF * gFog);
rgba[i][BCOMP] = (GLubyte) (f * rgba[i][BCOMP] + oneMinusF * bFog);
}
}
else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba;
for (i = 0; i < span->end; i++) {
const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = (GLushort) (f * rgba[i][RCOMP] + oneMinusF * rFog);
rgba[i][GCOMP] = (GLushort) (f * rgba[i][GCOMP] + oneMinusF * gFog);
rgba[i][BCOMP] = (GLushort) (f * rgba[i][BCOMP] + oneMinusF * bFog);
}
}
else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT);
for (i = 0; i < span->end; i++) {
const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
const GLfloat oneMinusF = 1.0F - f;
rgba[i][RCOMP] = f * rgba[i][RCOMP] + oneMinusF * rFog;
rgba[i][GCOMP] = f * rgba[i][GCOMP] + oneMinusF * gFog;
rgba[i][BCOMP] = f * rgba[i][BCOMP] + oneMinusF * bFog;
}
}
}
else { else {
/* The span's fog start/step values are blend factors. /* The span's fog start/step/array values are blend factors in [0,1].
* They were previously computed per-vertex. * They were previously computed per-vertex.
*/ */
#define COMPUTE_F f = fogCoord / w;
if (span->array->ChanType == GL_UNSIGNED_BYTE) { if (span->array->ChanType == GL_UNSIGNED_BYTE) {
GLubyte (*rgba)[4] = span->array->color.sz1.rgba; GLubyte (*rgba)[4] = span->array->rgba8;
FOG_LOOP(GLubyte, COMPUTE_F); FOG_LOOP(GLubyte, BLEND_FOG);
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) { else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
GLushort (*rgba)[4] = span->array->color.sz2.rgba; GLushort (*rgba)[4] = span->array->rgba16;
FOG_LOOP(GLushort, COMPUTE_F); FOG_LOOP(GLushort, BLEND_FOG);
} }
else { else {
GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0]; GLfloat (*rgba)[4] = span->array->attribs[FRAG_ATTRIB_COL0];
ASSERT(span->array->ChanType == GL_FLOAT); ASSERT(span->array->ChanType == GL_FLOAT);
FOG_LOOP(GLfloat, COMPUTE_F); FOG_LOOP(GLfloat, BLEND_FOG);
} }
#undef COMPUTE_F
} }
} }
@ -274,13 +285,11 @@ void
_swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
{ {
const SWcontext *swrast = SWRAST_CONTEXT(ctx); const SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint haveW = (span->interpMask & SPAN_W);
const GLuint fogIndex = (GLuint) ctx->Fog.Index; const GLuint fogIndex = (GLuint) ctx->Fog.Index;
GLuint *index = span->array->index; GLuint *index = span->array->index;
ASSERT(swrast->_FogEnabled); ASSERT(swrast->_FogEnabled);
ASSERT(span->arrayMask & SPAN_INDEX); ASSERT(span->arrayMask & SPAN_INDEX);
ASSERT((span->interpMask | span->arrayMask) & SPAN_FOG);
/* we need to compute fog blend factors */ /* we need to compute fog blend factors */
if (swrast->_PreferPixelFog) { if (swrast->_PreferPixelFog) {
@ -293,60 +302,19 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
const GLfloat fogEnd = ctx->Fog.End; const GLfloat fogEnd = ctx->Fog.End;
const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End) const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End)
? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start); ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; FOG_LOOP_CI(LINEAR_FOG);
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = (fogEnd - fogCoord / w) * fogScale;
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
w += wStep;
}
} }
break; break;
case GL_EXP: case GL_EXP:
{ {
const GLfloat density = -ctx->Fog.Density; const GLfloat density = -ctx->Fog.Density;
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; FOG_LOOP_CI(EXP_FOG);
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
GLfloat f = EXPF(density * fogCoord / w);
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
w += wStep;
}
} }
break; break;
case GL_EXP2: case GL_EXP2:
{ {
const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density; const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; FOG_LOOP_CI(EXP2_FOG);
GLfloat fogCoord = span->attrStart[FRAG_ATTRIB_FOGC][0];
const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
for (i = 0; i < span->end; i++) {
const GLfloat coord = fogCoord / w;
GLfloat tmp = negDensitySquared * coord * coord;
GLfloat f;
#if defined(__alpha__) || defined(__alpha)
/* XXX this underflow check may be needed for other systems*/
if (tmp < FLT_MIN_10_EXP)
tmp = FLT_MIN_10_EXP;
#endif
f = EXPF(tmp);
f = CLAMP(f, 0.0F, 1.0F);
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fogCoord += fogStep;
w += wStep;
}
} }
break; break;
default: default:
@ -354,31 +322,10 @@ _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span )
return; return;
} }
} }
else if (span->arrayMask & SPAN_FOG) {
/* The span's fog array values are blend factors.
* They were previously computed per-vertex.
*/
GLuint i;
for (i = 0; i < span->end; i++) {
const GLfloat f = span->array->attribs[FRAG_ATTRIB_FOGC][i][0];
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
}
}
else { else {
/* The span's fog start/step values are blend factors. /* The span's fog start/step/array values are blend factors in [0,1].
* They were previously computed per-vertex. * They were previously computed per-vertex.
*/ */
const GLfloat fogStep = span->attrStepX[FRAG_ATTRIB_FOGC][0]; FOG_LOOP_CI(BLEND_FOG);
GLfloat fog = span->attrStart[FRAG_ATTRIB_FOGC][0];
const GLfloat wStep = haveW ? span->attrStepX[FRAG_ATTRIB_WPOS][3] : 0.0F;
GLfloat w = haveW ? span->attrStart[FRAG_ATTRIB_WPOS][3] : 1.0F;
GLuint i;
ASSERT(span->interpMask & SPAN_FOG);
for (i = 0; i < span->end; i++) {
const GLfloat f = fog / w;
index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
fog += fogStep;
w += wStep;
}
} }
} }

View file

@ -121,29 +121,29 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
/**********************************************************************/ /**********************************************************************/
/* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/ /* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/
#define NAME simple_ci_line #define NAME simple_no_z_ci_line
#define INTERP_INDEX #define INTERP_INDEX
#define RENDER_SPAN(span) _swrast_write_index_span(ctx, &span) #define RENDER_SPAN(span) _swrast_write_index_span(ctx, &span)
#include "s_linetemp.h" #include "s_linetemp.h"
/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/ /* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
#define NAME simple_rgba_line #define NAME simple_no_z_rgba_line
#define INTERP_RGBA #define INTERP_RGBA
#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span); #define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span);
#include "s_linetemp.h" #include "s_linetemp.h"
/* Z, fog, wide, stipple color index line */ /* Z, fog, wide, stipple color index line */
#define NAME general_ci_line #define NAME ci_line
#define INTERP_INDEX #define INTERP_INDEX
#define INTERP_Z #define INTERP_Z
#define INTERP_FOG #define INTERP_ATTRIBS /* for fog */
#define RENDER_SPAN(span) \ #define RENDER_SPAN(span) \
if (ctx->Line.StippleFlag) { \ if (ctx->Line.StippleFlag) { \
span.arrayMask |= SPAN_MASK; \ span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \ compute_stipple_mask(ctx, span.end, span.array->mask); \
} \ } \
if (ctx->Line._Width > 1.0) { \ if (ctx->Line._Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \ } \
else { \ else { \
@ -153,16 +153,15 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
/* Z, fog, wide, stipple RGBA line */ /* Z, fog, wide, stipple RGBA line */
#define NAME general_rgba_line #define NAME rgba_line
#define INTERP_RGBA #define INTERP_RGBA
#define INTERP_Z #define INTERP_Z
#define INTERP_FOG
#define RENDER_SPAN(span) \ #define RENDER_SPAN(span) \
if (ctx->Line.StippleFlag) { \ if (ctx->Line.StippleFlag) { \
span.arrayMask |= SPAN_MASK; \ span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \ compute_stipple_mask(ctx, span.end, span.array->mask); \
} \ } \
if (ctx->Line._Width > 1.0) { \ if (ctx->Line._Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \ } \
else { \ else { \
@ -171,19 +170,17 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
#include "s_linetemp.h" #include "s_linetemp.h"
/* General-purpose textured line (any/all features). */ /* General-purpose line (any/all features). */
#define NAME textured_line #define NAME general_line
#define INTERP_RGBA #define INTERP_RGBA
#define INTERP_SPEC
#define INTERP_Z #define INTERP_Z
#define INTERP_FOG
#define INTERP_ATTRIBS #define INTERP_ATTRIBS
#define RENDER_SPAN(span) \ #define RENDER_SPAN(span) \
if (ctx->Line.StippleFlag) { \ if (ctx->Line.StippleFlag) { \
span.arrayMask |= SPAN_MASK; \ span.arrayMask |= SPAN_MASK; \
compute_stipple_mask(ctx, span.end, span.array->mask); \ compute_stipple_mask(ctx, span.end, span.array->mask); \
} \ } \
if (ctx->Line._Width > 1.0) { \ if (ctx->Line._Width > 1.0) { \
draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
} \ } \
else { \ else { \
@ -194,48 +191,39 @@ draw_wide_line( GLcontext *ctx, SWspan *span, GLboolean xMajor )
void void
_swrast_add_spec_terms_line( GLcontext *ctx, _swrast_add_spec_terms_line(GLcontext *ctx,
const SWvertex *v0, const SWvertex *v0, const SWvertex *v1)
const SWvertex *v1 )
{ {
SWvertex *ncv0 = (SWvertex *)v0; SWvertex *ncv0 = (SWvertex *)v0;
SWvertex *ncv1 = (SWvertex *)v1; SWvertex *ncv1 = (SWvertex *)v1;
GLchan c[2][4]; GLfloat rSum, gSum, bSum;
COPY_CHAN4( c[0], ncv0->color ); GLchan cSave[2][4];
COPY_CHAN4( c[1], ncv1->color );
ACC_3V( ncv0->color, ncv0->specular ); /* save original colors */
ACC_3V( ncv1->color, ncv1->specular ); COPY_CHAN4(cSave[0], ncv0->color);
COPY_CHAN4(cSave[1], ncv1->color);
/* sum v0 */
rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
/* sum v1 */
rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
/* draw */
SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 ); SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
COPY_CHAN4( ncv0->color, c[0] ); /* restore original colors */
COPY_CHAN4( ncv1->color, c[1] ); COPY_CHAN4( ncv0->attrib[FRAG_ATTRIB_COL0], cSave[0] );
COPY_CHAN4( ncv1->attrib[FRAG_ATTRIB_COL0], cSave[1] );
} }
#ifdef DEBUG
extern void
_mesa_print_line_function(GLcontext *ctx); /* silence compiler warning */
void
_mesa_print_line_function(GLcontext *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
_mesa_printf("Line Func == ");
if (swrast->Line == simple_ci_line)
_mesa_printf("simple_ci_line\n");
else if (swrast->Line == simple_rgba_line)
_mesa_printf("simple_rgba_line\n");
else if (swrast->Line == general_ci_line)
_mesa_printf("general_ci_line\n");
else if (swrast->Line == general_rgba_line)
_mesa_printf("general_rgba_line\n");
else if (swrast->Line == textured_line)
_mesa_printf("textured_line\n");
else
_mesa_printf("Driver func %p\n", (void *(*)()) swrast->Line);
}
#endif
#ifdef DEBUG #ifdef DEBUG
@ -257,7 +245,7 @@ do { \
/* /**
* Determine which line drawing function to use given the current * Determine which line drawing function to use given the current
* rendering context. * rendering context.
* *
@ -269,6 +257,9 @@ _swrast_choose_line( GLcontext *ctx )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLboolean rgbmode = ctx->Visual.rgbMode; const GLboolean rgbmode = ctx->Visual.rgbMode;
GLboolean specular = (ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
if (ctx->RenderMode == GL_RENDER) { if (ctx->RenderMode == GL_RENDER) {
if (ctx->Line.SmoothFlag) { if (ctx->Line.SmoothFlag) {
@ -277,24 +268,27 @@ _swrast_choose_line( GLcontext *ctx )
ASSERT(swrast->Line); ASSERT(swrast->Line);
} }
else if (ctx->Texture._EnabledCoordUnits else if (ctx->Texture._EnabledCoordUnits
|| ctx->FragmentProgram._Current) { || ctx->FragmentProgram._Current
/* textured lines */ || swrast->_FogEnabled
USE(textured_line); || specular) {
USE(general_line);
} }
else if (ctx->Depth.Test || swrast->_FogEnabled || ctx->Line._Width != 1.0 else if (ctx->Depth.Test
|| ctx->Line._Width != 1.0
|| ctx->Line.StippleFlag) { || ctx->Line.StippleFlag) {
/* no texture, but Z, fog, width>1, stipple, etc. */ /* no texture, but Z, fog, width>1, stipple, etc. */
if (rgbmode) if (rgbmode)
USE(general_rgba_line); USE(rgba_line);
else else
USE(general_ci_line); USE(ci_line);
} }
else { else {
/* simplest lines */ ASSERT(!ctx->Depth.Test);
/* simple lines */
if (rgbmode) if (rgbmode)
USE(simple_rgba_line); USE(simple_no_z_rgba_line);
else else
USE(simple_ci_line); USE(simple_no_z_ci_line);
} }
} }
else if (ctx->RenderMode == GL_FEEDBACK) { else if (ctx->RenderMode == GL_FEEDBACK) {
@ -304,6 +298,4 @@ _swrast_choose_line( GLcontext *ctx )
ASSERT(ctx->RenderMode == GL_SELECT); ASSERT(ctx->RenderMode == GL_SELECT);
USE(_swrast_select_line); USE(_swrast_select_line);
} }
/*_mesa_print_line_function(ctx);*/
} }

View file

@ -1,6 +1,6 @@
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 6.5.3 * Version: 7.0
* *
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
* *
@ -31,9 +31,7 @@
* The following macros may be defined to indicate what auxillary information * The following macros may be defined to indicate what auxillary information
* must be interplated along the line: * must be interplated along the line:
* INTERP_Z - if defined, interpolate Z values * INTERP_Z - if defined, interpolate Z values
* INTERP_FOG - if defined, interpolate FOG values
* INTERP_RGBA - if defined, interpolate RGBA values * INTERP_RGBA - if defined, interpolate RGBA values
* INTERP_SPEC - if defined, interpolate specular RGB values
* INTERP_INDEX - if defined, interpolate color index values * INTERP_INDEX - if defined, interpolate color index values
* INTERP_ATTRIBS - if defined, interpolate attribs (texcoords, varying, etc) * INTERP_ATTRIBS - if defined, interpolate attribs (texcoords, varying, etc)
* *
@ -72,10 +70,10 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
const SWcontext *swrast = SWRAST_CONTEXT(ctx); const SWcontext *swrast = SWRAST_CONTEXT(ctx);
SWspan span; SWspan span;
GLuint interpFlags = 0; GLuint interpFlags = 0;
GLint x0 = (GLint) vert0->win[0]; GLint x0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][0];
GLint x1 = (GLint) vert1->win[0]; GLint x1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][0];
GLint y0 = (GLint) vert0->win[1]; GLint y0 = (GLint) vert0->attrib[FRAG_ATTRIB_WPOS][1];
GLint y1 = (GLint) vert1->win[1]; GLint y1 = (GLint) vert1->attrib[FRAG_ATTRIB_WPOS][1];
GLint dx, dy; GLint dx, dy;
GLint numPixels; GLint numPixels;
GLint xstep, ystep; GLint xstep, ystep;
@ -104,8 +102,8 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
/* Cull primitives with malformed coordinates. /* Cull primitives with malformed coordinates.
*/ */
{ {
GLfloat tmp = vert0->win[0] + vert0->win[1] GLfloat tmp = vert0->attrib[FRAG_ATTRIB_WPOS][0] + vert0->attrib[FRAG_ATTRIB_WPOS][1]
+ vert1->win[0] + vert1->win[1]; + vert1->attrib[FRAG_ATTRIB_WPOS][0] + vert1->attrib[FRAG_ATTRIB_WPOS][1];
if (IS_INF_OR_NAN(tmp)) if (IS_INF_OR_NAN(tmp))
return; return;
} }
@ -113,8 +111,12 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
/* /*
printf("%s():\n", __FUNCTION__); printf("%s():\n", __FUNCTION__);
printf(" (%f, %f, %f) -> (%f, %f, %f)\n", printf(" (%f, %f, %f) -> (%f, %f, %f)\n",
vert0->win[0], vert0->win[1], vert0->win[2], vert0->attrib[FRAG_ATTRIB_WPOS][0],
vert1->win[0], vert1->win[1], vert1->win[2]); vert0->attrib[FRAG_ATTRIB_WPOS][1],
vert0->attrib[FRAG_ATTRIB_WPOS][2],
vert1->attrib[FRAG_ATTRIB_WPOS][0],
vert1->attrib[FRAG_ATTRIB_WPOS][1],
vert1->attrib[FRAG_ATTRIB_WPOS][2]);
printf(" (%d, %d, %d) -> (%d, %d, %d)\n", printf(" (%d, %d, %d) -> (%d, %d, %d)\n",
vert0->color[0], vert0->color[1], vert0->color[2], vert0->color[0], vert0->color[1], vert0->color[2],
vert1->color[0], vert1->color[1], vert1->color[2]); vert1->color[0], vert1->color[1], vert1->color[2]);
@ -154,6 +156,18 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
if (dx == 0 && dy == 0) if (dx == 0 && dy == 0)
return; return;
/*
printf("%s %d,%d %g %g %g %g %g %g %g %g\n", __FUNCTION__, dx, dy,
vert0->attrib[FRAG_ATTRIB_COL1][0],
vert0->attrib[FRAG_ATTRIB_COL1][1],
vert0->attrib[FRAG_ATTRIB_COL1][2],
vert0->attrib[FRAG_ATTRIB_COL1][3],
vert1->attrib[FRAG_ATTRIB_COL1][0],
vert1->attrib[FRAG_ATTRIB_COL1][1],
vert1->attrib[FRAG_ATTRIB_COL1][2],
vert1->attrib[FRAG_ATTRIB_COL1][3]);
*/
#ifdef DEPTH_TYPE #ifdef DEPTH_TYPE
zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0); zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0);
#endif #endif
@ -232,33 +246,15 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
span.alphaStep = 0; span.alphaStep = 0;
} }
#endif #endif
#ifdef INTERP_SPEC
interpFlags |= SPAN_SPEC;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
span.specRed = ChanToFixed(vert0->specular[0]);
span.specGreen = ChanToFixed(vert0->specular[1]);
span.specBlue = ChanToFixed(vert0->specular[2]);
span.specRedStep = (ChanToFixed(vert1->specular[0]) - span.specRed) / numPixels;
span.specGreenStep = (ChanToFixed(vert1->specular[1]) - span.specBlue) / numPixels;
span.specBlueStep = (ChanToFixed(vert1->specular[2]) - span.specGreen) / numPixels;
}
else {
span.specRed = ChanToFixed(vert1->specular[0]);
span.specGreen = ChanToFixed(vert1->specular[1]);
span.specBlue = ChanToFixed(vert1->specular[2]);
span.specRedStep = 0;
span.specGreenStep = 0;
span.specBlueStep = 0;
}
#endif
#ifdef INTERP_INDEX #ifdef INTERP_INDEX
interpFlags |= SPAN_INDEX; interpFlags |= SPAN_INDEX;
if (ctx->Light.ShadeModel == GL_SMOOTH) { if (ctx->Light.ShadeModel == GL_SMOOTH) {
span.index = FloatToFixed(vert0->index); span.index = FloatToFixed(vert0->attrib[FRAG_ATTRIB_CI][0]);
span.indexStep = FloatToFixed(vert1->index - vert0->index) / numPixels; span.indexStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_CI][0]
- vert0->attrib[FRAG_ATTRIB_CI][0]) / numPixels;
} }
else { else {
span.index = FloatToFixed(vert1->index); span.index = FloatToFixed(vert1->attrib[FRAG_ATTRIB_CI][0]);
span.indexStep = 0; span.indexStep = 0;
} }
#endif #endif
@ -266,57 +262,49 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
interpFlags |= SPAN_Z; interpFlags |= SPAN_Z;
{ {
if (depthBits <= 16) { if (depthBits <= 16) {
span.z = FloatToFixed(vert0->win[2]) + FIXED_HALF; span.z = FloatToFixed(vert0->attrib[FRAG_ATTRIB_WPOS][2]) + FIXED_HALF;
span.zStep = FloatToFixed(vert1->win[2] - vert0->win[2]) / numPixels; span.zStep = FloatToFixed( vert1->attrib[FRAG_ATTRIB_WPOS][2]
- vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels;
} }
else { else {
/* don't use fixed point */ /* don't use fixed point */
span.z = (GLuint) vert0->win[2]; span.z = (GLuint) vert0->attrib[FRAG_ATTRIB_WPOS][2];
span.zStep = (GLint) ((vert1->win[2] - vert0->win[2]) / numPixels); span.zStep = (GLint) (( vert1->attrib[FRAG_ATTRIB_WPOS][2]
- vert0->attrib[FRAG_ATTRIB_WPOS][2]) / numPixels);
} }
} }
#endif #endif
#ifdef INTERP_FOG
interpFlags |= SPAN_FOG;
span.attrStart[FRAG_ATTRIB_FOGC][0] = vert0->attrib[FRAG_ATTRIB_FOGC][0];
span.attrStepX[FRAG_ATTRIB_FOGC][0] = (vert1->attrib[FRAG_ATTRIB_FOGC][0]
- vert0->attrib[FRAG_ATTRIB_FOGC][0]) / numPixels;
#endif
#if defined(INTERP_ATTRIBS) #if defined(INTERP_ATTRIBS)
interpFlags |= (SPAN_TEXTURE | SPAN_VARYING);
{ {
const GLfloat invLen = 1.0F / numPixels; const GLfloat invLen = 1.0F / numPixels;
const GLfloat invw0 = vert0->win[3]; const GLfloat invw0 = vert0->attrib[FRAG_ATTRIB_WPOS][3];
const GLfloat invw1 = vert1->win[3]; const GLfloat invw1 = vert1->attrib[FRAG_ATTRIB_WPOS][3];
span.attrStart[FRAG_ATTRIB_WPOS][3] = invw0;
span.attrStepX[FRAG_ATTRIB_WPOS][3] = (invw1 - invw0) * invLen;
span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0;
ATTRIB_LOOP_BEGIN ATTRIB_LOOP_BEGIN
GLfloat ds, dt, dr, dq; if (swrast->_InterpMode[attr] == GL_FLAT) {
span.attrStart[attr][0] = invw0 * vert0->attrib[attr][0]; COPY_4V(span.attrStart[attr], vert1->attrib[attr]);
span.attrStart[attr][1] = invw0 * vert0->attrib[attr][1]; ASSIGN_4V(span.attrStepX[attr], 0.0, 0.0, 0.0, 0.0);
span.attrStart[attr][2] = invw0 * vert0->attrib[attr][2]; }
span.attrStart[attr][3] = invw0 * vert0->attrib[attr][3]; else {
ds = (invw1 * vert1->attrib[attr][0]) - span.attrStart[attr][0]; GLuint c;
dt = (invw1 * vert1->attrib[attr][1]) - span.attrStart[attr][1]; for (c = 0; c < 4; c++) {
dr = (invw1 * vert1->attrib[attr][2]) - span.attrStart[attr][2]; float da;
dq = (invw1 * vert1->attrib[attr][3]) - span.attrStart[attr][3]; span.attrStart[attr][c] = invw0 * vert0->attrib[attr][c];
span.attrStepX[attr][0] = ds * invLen; da = (invw1 * vert1->attrib[attr][c]) - span.attrStart[attr][c];
span.attrStepX[attr][1] = dt * invLen; span.attrStepX[attr][c] = da * invLen;
span.attrStepX[attr][2] = dr * invLen; }
span.attrStepX[attr][3] = dq * invLen; }
span.attrStepY[attr][0] = 0.0F; ASSIGN_4V(span.attrStepY[attr], 0.0, 0.0, 0.0, 0.0);
span.attrStepY[attr][1] = 0.0F;
span.attrStepY[attr][2] = 0.0F;
span.attrStepY[attr][3] = 0.0F;
ATTRIB_LOOP_END ATTRIB_LOOP_END
} }
#endif #endif
INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY); INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
/* Need these for fragment prog texcoord interpolation */
span.attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F;
span.attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
span.attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
/* /*
* Draw * Draw
*/ */
@ -346,7 +334,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#ifdef PIXEL_ADDRESS #ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep); pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
#endif #endif
if (error<0) { if (error < 0) {
error += errorInc; error += errorInc;
} }
else { else {
@ -413,9 +401,7 @@ NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
#undef NAME #undef NAME
#undef INTERP_Z #undef INTERP_Z
#undef INTERP_FOG
#undef INTERP_RGBA #undef INTERP_RGBA
#undef INTERP_SPEC
#undef INTERP_ATTRIBS #undef INTERP_ATTRIBS
#undef INTERP_INDEX #undef INTERP_INDEX
#undef PIXEL_ADDRESS #undef PIXEL_ADDRESS

View file

@ -229,13 +229,13 @@ _swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
if (span->array->ChanType == GL_UNSIGNED_BYTE) { if (span->array->ChanType == GL_UNSIGNED_BYTE) {
/* treat 4*GLubyte as GLuint */ /* treat 4*GLubyte as GLuint */
logicop_uint1(ctx, span->end, logicop_uint1(ctx, span->end,
(GLuint *) span->array->color.sz1.rgba, (GLuint *) span->array->rgba8,
(const GLuint *) rbPixels, span->array->mask); (const GLuint *) rbPixels, span->array->mask);
} }
else if (span->array->ChanType == GL_UNSIGNED_SHORT) { else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
/* treat 2*GLushort as GLuint */ /* treat 2*GLushort as GLuint */
logicop_uint2(ctx, 2 * span->end, logicop_uint2(ctx, 2 * span->end,
(GLuint *) span->array->color.sz2.rgba, (GLuint *) span->array->rgba16,
(const GLuint *) rbPixels, span->array->mask); (const GLuint *) rbPixels, span->array->mask);
} }
else { else {

View file

@ -61,7 +61,7 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask); const GLuint srcMask = *((GLuint *) ctx->Color.ColorMask);
const GLuint dstMask = ~srcMask; const GLuint dstMask = ~srcMask;
const GLuint *dst = (const GLuint *) rbPixels; const GLuint *dst = (const GLuint *) rbPixels;
GLuint *src = (GLuint *) span->array->color.sz1.rgba; GLuint *src = (GLuint *) span->array->rgba8;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
src[i] = (src[i] & srcMask) | (dst[i] & dstMask); src[i] = (src[i] & srcMask) | (dst[i] & dstMask);
@ -75,7 +75,7 @@ _swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0; const GLushort bMask = ctx->Color.ColorMask[BCOMP] ? 0xffff : 0x0;
const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0; const GLushort aMask = ctx->Color.ColorMask[ACOMP] ? 0xffff : 0x0;
const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels; const GLushort (*dst)[4] = (const GLushort (*)[4]) rbPixels;
GLushort (*src)[4] = span->array->color.sz2.rgba; GLushort (*src)[4] = span->array->rgba16;
GLuint i; GLuint i;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask); src[i][RCOMP] = (src[i][RCOMP] & rMask) | (dst[i][RCOMP] & ~rMask);

View file

@ -34,7 +34,6 @@
#include "s_span.h" #include "s_span.h"
#define RGBA 0x1 #define RGBA 0x1
#define INDEX 0x2 #define INDEX 0x2
#define SMOOTH 0x4 #define SMOOTH 0x4
@ -154,16 +153,26 @@
#include "s_pointtemp.h" #include "s_pointtemp.h"
void
void _swrast_add_spec_terms_point( GLcontext *ctx, _swrast_add_spec_terms_point(GLcontext *ctx, const SWvertex *v0)
const SWvertex *v0 )
{ {
SWvertex *ncv0 = (SWvertex *)v0; SWvertex *ncv0 = (SWvertex *) v0;
GLchan c[1][4]; GLfloat rSum, gSum, bSum;
COPY_CHAN4( c[0], ncv0->color ); GLchan cSave[4];
ACC_3V( ncv0->color, ncv0->specular );
SWRAST_CONTEXT(ctx)->SpecPoint( ctx, ncv0 ); /* save */
COPY_CHAN4( ncv0->color, c[0] ); COPY_CHAN4( cSave, ncv0->color );
/* sum */
rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
/* draw */
SWRAST_CONTEXT(ctx)->SpecPoint(ctx, ncv0);
/* restore */
COPY_CHAN4(ncv0->color, cSave);
} }
@ -196,6 +205,9 @@ _swrast_choose_point( GLcontext *ctx )
{ {
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLboolean rgbMode = ctx->Visual.rgbMode; GLboolean rgbMode = ctx->Visual.rgbMode;
GLboolean specular = (ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
if (ctx->RenderMode==GL_RENDER) { if (ctx->RenderMode==GL_RENDER) {
if (ctx->Point.PointSprite) { if (ctx->Point.PointSprite) {
@ -242,8 +254,10 @@ _swrast_choose_point( GLcontext *ctx )
USE(atten_general_ci_point); USE(atten_general_ci_point);
} }
} }
else if (ctx->Texture._EnabledCoordUnits && rgbMode) { else if ((ctx->Texture._EnabledCoordUnits
/* textured */ || specular
|| swrast->_FogEnabled) && rgbMode) {
/* textured, fogged */
USE(textured_rgba_point); USE(textured_rgba_point);
} }
else if (ctx->Point._Size != 1.0) { else if (ctx->Point._Size != 1.0) {
@ -258,6 +272,7 @@ _swrast_choose_point( GLcontext *ctx )
else { else {
/* single pixel points */ /* single pixel points */
if (rgbMode) { if (rgbMode) {
assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0);
USE(size1_rgba_point); USE(size1_rgba_point);
} }
else { else {

View file

@ -40,7 +40,6 @@
* RGBA = do rgba instead of color index * RGBA = do rgba instead of color index
* SMOOTH = do antialiasing * SMOOTH = do antialiasing
* ATTRIBS = general attributes (texcoords, etc) * ATTRIBS = general attributes (texcoords, etc)
* SPECULAR = do separate specular color
* LARGE = do points with diameter > 1 pixel * LARGE = do points with diameter > 1 pixel
* ATTENUATE = compute point size attenuation * ATTENUATE = compute point size attenuation
* SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite * SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite
@ -78,13 +77,8 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
const GLchan blue = vert->color[2]; const GLchan blue = vert->color[2];
const GLchan alpha = vert->color[3]; const GLchan alpha = vert->color[3];
#endif #endif
#if FLAGS & SPECULAR
const GLchan specRed = vert->specular[0];
const GLchan specGreen = vert->specular[1];
const GLchan specBlue = vert->specular[2];
#endif
#if FLAGS & INDEX #if FLAGS & INDEX
const GLuint colorIndex = (GLuint) vert->index; /* XXX round? */ const GLuint colorIndex = (GLuint) vert->attrib[FRAG_ATTRIB_CI][0]; /* XXX round? */
#endif #endif
#if FLAGS & ATTRIBS #if FLAGS & ATTRIBS
GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */ GLfloat attrib[FRAG_ATTRIB_MAX][4]; /* texture & varying */
@ -92,10 +86,22 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
SWcontext *swrast = SWRAST_CONTEXT(ctx); SWcontext *swrast = SWRAST_CONTEXT(ctx);
SWspan *span = &(swrast->PointSpan); SWspan *span = &(swrast->PointSpan);
/*
printf("%s %g %g %g %g\n", __FUNCTION__,
vert->attrib[FRAG_ATTRIB_COL1][0],
vert->attrib[FRAG_ATTRIB_COL1][1],
vert->attrib[FRAG_ATTRIB_COL1][2],
vert->attrib[FRAG_ATTRIB_COL1][3]);
if ( vert->attrib[FRAG_ATTRIB_COL1][0] == 0.0 &&
vert->attrib[FRAG_ATTRIB_COL1][1] == 1.0 &&
vert->attrib[FRAG_ATTRIB_COL1][2] == 0.0)
foo();
*/
/* Cull primitives with malformed coordinates. /* Cull primitives with malformed coordinates.
*/ */
{ {
float tmp = vert->win[0] + vert->win[1]; float tmp = vert->attrib[FRAG_ATTRIB_WPOS][0] + vert->attrib[FRAG_ATTRIB_WPOS][1];
if (IS_INF_OR_NAN(tmp)) if (IS_INF_OR_NAN(tmp))
return; return;
} }
@ -103,49 +109,37 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
/* /*
* Span init * Span init
*/ */
span->interpMask = SPAN_FOG; span->interpMask = 0;
span->arrayMask = SPAN_XY | SPAN_Z; span->arrayMask = SPAN_XY | SPAN_Z;
span->attrStart[FRAG_ATTRIB_FOGC][0] = vert->attrib[FRAG_ATTRIB_FOGC][0];
span->attrStepX[FRAG_ATTRIB_FOGC][0] = 0.0;
span->attrStepY[FRAG_ATTRIB_FOGC][0] = 0.0;
#if FLAGS & RGBA #if FLAGS & RGBA
span->arrayMask |= SPAN_RGBA; span->arrayMask |= SPAN_RGBA;
#endif #endif
#if FLAGS & SPECULAR
span->arrayMask |= SPAN_SPEC;
#endif
#if FLAGS & INDEX #if FLAGS & INDEX
span->arrayMask |= SPAN_INDEX; span->arrayMask |= SPAN_INDEX;
#endif #endif
#if FLAGS & ATTRIBS #if FLAGS & ATTRIBS
span->arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); span->arrayMask |= SPAN_LAMBDA;
if (ctx->FragmentProgram._Active) {
/* Don't divide texture s,t,r by q (use TXP to do that) */ /* we're filling in the attrib arrays: */
ATTRIB_LOOP_BEGIN span->arrayAttribs = swrast->_ActiveAttribMask;
COPY_4V(attrib[attr], vert->attrib[attr]);
ATTRIB_LOOP_END ATTRIB_LOOP_BEGIN
} COPY_4V(attrib[attr], vert->attrib[attr]);
else { ATTRIB_LOOP_END
/* Divide texture s,t,r by q here */
ATTRIB_LOOP_BEGIN
const GLfloat q = vert->attrib[attr][3];
const GLfloat invQ = (q == 0.0F || q == 1.0F) ? 1.0F : (1.0F / q);
attrib[attr][0] = vert->attrib[attr][0] * invQ;
attrib[attr][1] = vert->attrib[attr][1] * invQ;
attrib[attr][2] = vert->attrib[attr][2] * invQ;
attrib[attr][3] = q;
ATTRIB_LOOP_END
}
/* need these for fragment programs */ /* need these for fragment programs */
span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F; span->attrStart[FRAG_ATTRIB_WPOS][3] = 1.0F;
span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F; span->attrStepX[FRAG_ATTRIB_WPOS][3] = 0.0F;
span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F; span->attrStepY[FRAG_ATTRIB_WPOS][3] = 0.0F;
#else
assert((swrast->_ActiveAttribMask & FRAG_BIT_COL1) == 0);
#endif #endif
#if FLAGS & SMOOTH #if FLAGS & SMOOTH
span->arrayMask |= SPAN_COVERAGE; span->arrayMask |= SPAN_COVERAGE;
#endif #endif
#if FLAGS & SPRITE #if FLAGS & SPRITE
span->arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA); span->arrayMask |= SPAN_LAMBDA;
#endif #endif
/* Compute point size if not known to be one */ /* Compute point size if not known to be one */
@ -189,7 +183,7 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
{{ {{
GLint x, y; GLint x, y;
const GLfloat radius = 0.5F * size; const GLfloat radius = 0.5F * size;
const GLuint z = (GLuint) (vert->win[2] + 0.5F); const GLuint z = (GLuint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
GLuint count; GLuint count;
#if FLAGS & SMOOTH #if FLAGS & SMOOTH
const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
@ -197,10 +191,10 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
const GLfloat rmin2 = MAX2(0.0F, rmin * rmin); const GLfloat rmin2 = MAX2(0.0F, rmin * rmin);
const GLfloat rmax2 = rmax * rmax; const GLfloat rmax2 = rmax * rmax;
const GLfloat cscale = 1.0F / (rmax2 - rmin2); const GLfloat cscale = 1.0F / (rmax2 - rmin2);
const GLint xmin = (GLint) (vert->win[0] - radius); const GLint xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - radius);
const GLint xmax = (GLint) (vert->win[0] + radius); const GLint xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + radius);
const GLint ymin = (GLint) (vert->win[1] - radius); const GLint ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - radius);
const GLint ymax = (GLint) (vert->win[1] + radius); const GLint ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + radius);
#else #else
/* non-smooth */ /* non-smooth */
GLint xmin, xmax, ymin, ymax; GLint xmin, xmax, ymin, ymax;
@ -210,16 +204,16 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
iRadius = iSize / 2; iRadius = iSize / 2;
if (iSize & 1) { if (iSize & 1) {
/* odd size */ /* odd size */
xmin = (GLint) (vert->win[0] - iRadius); xmin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius);
xmax = (GLint) (vert->win[0] + iRadius); xmax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][0] + iRadius);
ymin = (GLint) (vert->win[1] - iRadius); ymin = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius);
ymax = (GLint) (vert->win[1] + iRadius); ymax = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][1] + iRadius);
} }
else { else {
/* even size */ /* even size */
xmin = (GLint) vert->win[0] - iRadius + 1; xmin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0] - iRadius + 1;
xmax = xmin + iSize - 1; xmax = xmin + iSize - 1;
ymin = (GLint) vert->win[1] - iRadius + 1; ymin = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1] - iRadius + 1;
ymax = ymin + iSize - 1; ymax = ymin + iSize - 1;
} }
#endif /*SMOOTH*/ #endif /*SMOOTH*/
@ -264,29 +258,26 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
span->array->rgba[count][BCOMP] = blue; span->array->rgba[count][BCOMP] = blue;
span->array->rgba[count][ACOMP] = alpha; span->array->rgba[count][ACOMP] = alpha;
#endif #endif
#if FLAGS & SPECULAR
span->array->spec[count][RCOMP] = specRed;
span->array->spec[count][GCOMP] = specGreen;
span->array->spec[count][BCOMP] = specBlue;
#endif
#if FLAGS & INDEX #if FLAGS & INDEX
span->array->index[count] = colorIndex; span->array->index[count] = colorIndex;
#endif #endif
#if FLAGS & ATTRIBS #if FLAGS & ATTRIBS
ATTRIB_LOOP_BEGIN ATTRIB_LOOP_BEGIN
COPY_4V(span->array->attribs[attr][count], attrib[attr]); COPY_4V(span->array->attribs[attr][count], attrib[attr]);
if (attr < FRAG_ATTRIB_VAR0 && attr >= FRAG_ATTRIB_TEX0) { /**
if (attr < FRAG_ATTRIB_VAR0) {
const GLuint u = attr - FRAG_ATTRIB_TEX0; const GLuint u = attr - FRAG_ATTRIB_TEX0;
span->array->lambda[u][count] = 0.0; span->array->lambda[u][count] = 0.0;
} }
**/
ATTRIB_LOOP_END ATTRIB_LOOP_END
#endif #endif
#if FLAGS & SMOOTH #if FLAGS & SMOOTH
/* compute coverage */ /* compute coverage */
{ {
const GLfloat dx = x - vert->win[0] + 0.5F; const GLfloat dx = x - vert->attrib[FRAG_ATTRIB_WPOS][0] + 0.5F;
const GLfloat dy = y - vert->win[1] + 0.5F; const GLfloat dy = y - vert->attrib[FRAG_ATTRIB_WPOS][1] + 0.5F;
const GLfloat dist2 = dx * dx + dy * dy; const GLfloat dist2 = dx * dx + dy * dy;
if (dist2 < rmax2) { if (dist2 < rmax2) {
if (dist2 >= rmin2) { if (dist2 >= rmin2) {
@ -327,12 +318,12 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
GLuint attr = FRAG_ATTRIB_TEX0 + u; GLuint attr = FRAG_ATTRIB_TEX0 + u;
if (ctx->Texture.Unit[u]._ReallyEnabled) { if (ctx->Texture.Unit[u]._ReallyEnabled) {
if (ctx->Point.CoordReplace[u]) { if (ctx->Point.CoordReplace[u]) {
GLfloat s = 0.5F + (x + 0.5F - vert->win[0]) / size; GLfloat s = 0.5F + (x + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][0]) / size;
GLfloat t, r; GLfloat t, r;
if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT) if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
t = 0.5F + (y + 0.5F - vert->win[1]) / size; t = 0.5F + (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size;
else /* GL_UPPER_LEFT */ else /* GL_UPPER_LEFT */
t = 0.5F - (y + 0.5F - vert->win[1]) / size; t = 0.5F - (y + 0.5F - vert->attrib[FRAG_ATTRIB_WPOS][1]) / size;
if (ctx->Point.SpriteRMode == GL_ZERO) if (ctx->Point.SpriteRMode == GL_ZERO)
r = 0.0F; r = 0.0F;
else if (ctx->Point.SpriteRMode == GL_S) else if (ctx->Point.SpriteRMode == GL_S)
@ -389,11 +380,6 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
span->array->rgba[count][BCOMP] = blue; span->array->rgba[count][BCOMP] = blue;
span->array->rgba[count][ACOMP] = alpha; span->array->rgba[count][ACOMP] = alpha;
#endif #endif
#if FLAGS & SPECULAR
span->array->spec[count][RCOMP] = specRed;
span->array->spec[count][GCOMP] = specGreen;
span->array->spec[count][BCOMP] = specBlue;
#endif
#if FLAGS & INDEX #if FLAGS & INDEX
span->array->index[count] = colorIndex; span->array->index[count] = colorIndex;
#endif #endif
@ -403,9 +389,10 @@ NAME ( GLcontext *ctx, const SWvertex *vert )
ATTRIB_LOOP_END ATTRIB_LOOP_END
#endif #endif
span->array->x[count] = (GLint) vert->win[0]; span->array->x[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][0];
span->array->y[count] = (GLint) vert->win[1]; span->array->y[count] = (GLint) vert->attrib[FRAG_ATTRIB_WPOS][1];
span->array->z[count] = (GLint) (vert->win[2] + 0.5F); span->array->z[count] = (GLint) (vert->attrib[FRAG_ATTRIB_WPOS][2] + 0.5F);
span->end = count + 1; span->end = count + 1;
}} }}

File diff suppressed because it is too large Load diff

View file

@ -33,45 +33,24 @@
/** /**
* \defgroup SpanFlags * \defgroup SpanFlags
* Bitflags used for interpMask and arrayMask fields below to indicate * Special bitflags to describe span data.
* which interpolant values and fragment arrays are in use, respectively.
* *
* XXX We should replace these flags with the FRAG_BIT_ values someday... * In general, the point/line/triangle functions interpolate/emit the
* attributes specified by swrast->_ActiveAttribs (i.e. FRAT_BIT_* values).
* Some things don't fit into that, though, so we have these flags.
*/ */
/*@{*/ /*@{*/
#define SPAN_RGBA 0x001 #define SPAN_RGBA 0x01 /**< interpMask and arrayMask */
#define SPAN_SPEC 0x002 #define SPAN_INDEX 0x02 /**< interpMask and arrayMask */
#define SPAN_INDEX 0x004 #define SPAN_Z 0x04 /**< interpMask and arrayMask */
#define SPAN_Z 0x008 #define SPAN_FLAT 0x08 /**< interpMask: flat shading? */
#define SPAN_W 0x010 #define SPAN_XY 0x10 /**< array.x[], y[] valid? */
#define SPAN_FOG 0x020 #define SPAN_MASK 0x20 /**< was array.mask[] filled in by caller? */
#define SPAN_TEXTURE 0x040 #define SPAN_LAMBDA 0x40 /**< array.lambda[] valid? */
#define SPAN_INT_TEXTURE 0x080 #define SPAN_COVERAGE 0x80 /**< array.coverage[] valid? */
#define SPAN_LAMBDA 0x100
#define SPAN_COVERAGE 0x200
#define SPAN_FLAT 0x400 /**< flat shading? */
#define SPAN_XY 0x800
#define SPAN_MASK 0x1000
#define SPAN_VARYING 0x2000
/*@}*/ /*@}*/
#if 0
/* alternate arrangement for code below */
struct arrays2 {
union {
GLubyte sz1[MAX_WIDTH][4]; /* primary color */
GLushort sz2[MAX_WIDTH][4];
} rgba;
union {
GLubyte sz1[MAX_WIDTH][4]; /* specular color and temp storage */
GLushort sz2[MAX_WIDTH][4];
} spec;
};
#endif
/** /**
* \sw_span_arrays * \sw_span_arrays
* \brief Arrays of fragment values. * \brief Arrays of fragment values.
@ -92,26 +71,19 @@ typedef struct sw_span_arrays
GLubyte mask[MAX_WIDTH]; GLubyte mask[MAX_WIDTH];
GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */ GLenum ChanType; /**< Color channel type, GL_UNSIGNED_BYTE, GL_FLOAT */
union {
struct {
GLubyte rgba[MAX_WIDTH][4]; /**< primary color */
GLubyte spec[MAX_WIDTH][4]; /**< specular color and temp storage */
} sz1;
struct {
GLushort rgba[MAX_WIDTH][4];
GLushort spec[MAX_WIDTH][4];
} sz2;
} color;
/** XXX these are temporary fields, pointing into above color arrays */
GLchan (*rgba)[4];
GLchan (*spec)[4];
/** Attribute arrays that don't fit into attribs[] array above */
/*@{*/
GLubyte rgba8[MAX_WIDTH][4];
GLushort rgba16[MAX_WIDTH][4];
GLchan (*rgba)[4]; /** either == rgba8 or rgba16 */
GLint x[MAX_WIDTH]; /**< fragment X coords */ GLint x[MAX_WIDTH]; /**< fragment X coords */
GLint y[MAX_WIDTH]; /**< fragment Y coords */ GLint y[MAX_WIDTH]; /**< fragment Y coords */
GLuint z[MAX_WIDTH]; /**< fragment Z coords */ GLuint z[MAX_WIDTH]; /**< fragment Z coords */
GLuint index[MAX_WIDTH]; /**< Color indexes */ GLuint index[MAX_WIDTH]; /**< Color indexes */
GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */ GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH]; /**< Texture LOD */
GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */ GLfloat coverage[MAX_WIDTH]; /**< Fragment coverage for AA/smoothing */
/*@}*/
} SWspanarrays; } SWspanarrays;
@ -160,26 +132,13 @@ typedef struct sw_span
/* For horizontal spans, step is the partial derivative wrt X. /* For horizontal spans, step is the partial derivative wrt X.
* For lines, step is the delta from one fragment to the next. * For lines, step is the delta from one fragment to the next.
*/ */
#if CHAN_TYPE == GL_FLOAT
GLfloat red, redStep;
GLfloat green, greenStep;
GLfloat blue, blueStep;
GLfloat alpha, alphaStep;
GLfloat specRed, specRedStep;
GLfloat specGreen, specGreenStep;
GLfloat specBlue, specBlueStep;
#else /* CHAN_TYPE == GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT */
GLfixed red, redStep; GLfixed red, redStep;
GLfixed green, greenStep; GLfixed green, greenStep;
GLfixed blue, blueStep; GLfixed blue, blueStep;
GLfixed alpha, alphaStep; GLfixed alpha, alphaStep;
GLfixed specRed, specRedStep;
GLfixed specGreen, specGreenStep;
GLfixed specBlue, specBlueStep;
#endif
GLfixed index, indexStep; GLfixed index, indexStep;
GLfixed z, zStep; /* XXX z should probably be GLuint */ GLfixed z, zStep; /**< XXX z should probably be GLuint */
GLfixed intTex[2], intTexStep[2]; /* s, t only */ GLfixed intTex[2], intTexStep[2]; /**< (s,t) for unit[0] only */
/** /**
* This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
@ -187,6 +146,8 @@ typedef struct sw_span
*/ */
GLbitfield arrayMask; GLbitfield arrayMask;
GLbitfield arrayAttribs;
/** /**
* We store the arrays of fragment values in a separate struct so * We store the arrays of fragment values in a separate struct so
* that we can allocate sw_span structs on the stack without using * that we can allocate sw_span structs on the stack without using
@ -203,6 +164,7 @@ do { \
(S).primitive = (PRIMITIVE); \ (S).primitive = (PRIMITIVE); \
(S).interpMask = (INTERP_MASK); \ (S).interpMask = (INTERP_MASK); \
(S).arrayMask = (ARRAY_MASK); \ (S).arrayMask = (ARRAY_MASK); \
(S).arrayAttribs = 0x0; \
(S).end = (END); \ (S).end = (END); \
(S).facing = 0; \ (S).facing = 0; \
(S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \ (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \
@ -211,23 +173,11 @@ do { \
extern void extern void
_swrast_span_default_z( GLcontext *ctx, SWspan *span ); _swrast_span_default_attribs(GLcontext *ctx, SWspan *span);
extern void extern void
_swrast_span_interpolate_z( const GLcontext *ctx, SWspan *span ); _swrast_span_interpolate_z( const GLcontext *ctx, SWspan *span );
extern void
_swrast_span_default_fog( GLcontext *ctx, SWspan *span );
extern void
_swrast_span_default_color( GLcontext *ctx, SWspan *span );
extern void
_swrast_span_default_secondary_color(GLcontext *ctx, SWspan *span);
extern void
_swrast_span_default_texcoords( GLcontext *ctx, SWspan *span );
extern GLfloat extern GLfloat
_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH, GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,

View file

@ -1080,7 +1080,6 @@ _swrast_texture_span( GLcontext *ctx, SWspan *span )
GLuint unit; GLuint unit;
ASSERT(span->end < MAX_WIDTH); ASSERT(span->end < MAX_WIDTH);
ASSERT(span->arrayMask & SPAN_TEXTURE);
/* /*
* Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR) * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR)

View file

@ -52,10 +52,10 @@ _swrast_culltriangle( GLcontext *ctx,
const SWvertex *v1, const SWvertex *v1,
const SWvertex *v2 ) const SWvertex *v2 )
{ {
GLfloat ex = v1->win[0] - v0->win[0]; GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat ey = v1->win[1] - v0->win[1]; GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat fx = v2->win[0] - v0->win[0]; GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat fy = v2->win[1] - v0->win[1]; GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat c = ex*fy-ey*fx; GLfloat c = ex*fy-ey*fx;
if (c * SWRAST_CONTEXT(ctx)->_BackfaceSign > 0) if (c * SWRAST_CONTEXT(ctx)->_BackfaceSign > 0)
@ -71,7 +71,7 @@ _swrast_culltriangle( GLcontext *ctx,
*/ */
#define NAME ci_triangle #define NAME ci_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_FOG 1 #define INTERP_ATTRIBS 1 /* just for fog */
#define INTERP_INDEX 1 #define INTERP_INDEX 1
#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span); #define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span);
#include "s_tritemp.h" #include "s_tritemp.h"
@ -83,7 +83,6 @@ _swrast_culltriangle( GLcontext *ctx,
*/ */
#define NAME flat_rgba_triangle #define NAME flat_rgba_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_FOG 1
#define SETUP_CODE \ #define SETUP_CODE \
ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
@ -106,7 +105,6 @@ _swrast_culltriangle( GLcontext *ctx,
*/ */
#define NAME smooth_rgba_triangle #define NAME smooth_rgba_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_FOG 1
#define INTERP_RGB 1 #define INTERP_RGB 1
#define INTERP_ALPHA 1 #define INTERP_ALPHA 1
#define SETUP_CODE \ #define SETUP_CODE \
@ -228,7 +226,6 @@ _swrast_culltriangle( GLcontext *ctx,
#include "s_tritemp.h" #include "s_tritemp.h"
#if CHAN_TYPE != GL_FLOAT #if CHAN_TYPE != GL_FLOAT
struct affine_info struct affine_info
@ -511,7 +508,6 @@ affine_span(GLcontext *ctx, SWspan *span,
*/ */
#define NAME affine_textured_triangle #define NAME affine_textured_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_FOG 1
#define INTERP_RGB 1 #define INTERP_RGB 1
#define INTERP_ALPHA 1 #define INTERP_ALPHA 1
#define INTERP_INT_TEX 1 #define INTERP_INT_TEX 1
@ -784,8 +780,6 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
*/ */
#define NAME persp_textured_triangle #define NAME persp_textured_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_W 1
#define INTERP_FOG 1
#define INTERP_RGB 1 #define INTERP_RGB 1
#define INTERP_ALPHA 1 #define INTERP_ALPHA 1
#define INTERP_ATTRIBS 1 #define INTERP_ATTRIBS 1
@ -843,9 +837,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
#include "s_tritemp.h" #include "s_tritemp.h"
#endif /*CHAN_TYPE != GL_FLOAT*/
#endif /* CHAN_BITS != GL_FLOAT */
@ -854,10 +846,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span,
*/ */
#define NAME general_triangle #define NAME general_triangle
#define INTERP_Z 1 #define INTERP_Z 1
#define INTERP_W 1
#define INTERP_FOG 1
#define INTERP_RGB 1 #define INTERP_RGB 1
#define INTERP_SPEC 1
#define INTERP_ALPHA 1 #define INTERP_ALPHA 1
#define INTERP_ATTRIBS 1 #define INTERP_ATTRIBS 1
#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); #define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
@ -924,51 +913,47 @@ nodraw_triangle( GLcontext *ctx,
* draw the triangle, then restore the original primary color. * draw the triangle, then restore the original primary color.
* Inefficient, but seldom needed. * Inefficient, but seldom needed.
*/ */
void _swrast_add_spec_terms_triangle( GLcontext *ctx, void
const SWvertex *v0, _swrast_add_spec_terms_triangle(GLcontext *ctx, const SWvertex *v0,
const SWvertex *v1, const SWvertex *v1, const SWvertex *v2)
const SWvertex *v2 )
{ {
SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */ SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */
SWvertex *ncv1 = (SWvertex *)v1; SWvertex *ncv1 = (SWvertex *)v1;
SWvertex *ncv2 = (SWvertex *)v2; SWvertex *ncv2 = (SWvertex *)v2;
#if CHAN_TYPE == GL_FLOAT
GLfloat rSum, gSum, bSum; GLfloat rSum, gSum, bSum;
#else GLchan cSave[3][4];
GLint rSum, gSum, bSum;
#endif
GLchan c[3][4];
/* save original colors */ /* save original colors */
COPY_CHAN4( c[0], ncv0->color ); COPY_CHAN4( cSave[0], ncv0->color );
COPY_CHAN4( c[1], ncv1->color ); COPY_CHAN4( cSave[1], ncv1->color );
COPY_CHAN4( c[2], ncv2->color ); COPY_CHAN4( cSave[2], ncv2->color );
/* sum v0 */ /* sum v0 */
rSum = ncv0->color[0] + ncv0->specular[0]; rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
gSum = ncv0->color[1] + ncv0->specular[1]; gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
bSum = ncv0->color[2] + ncv0->specular[2]; bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
ncv0->color[0] = MIN2(rSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
ncv0->color[1] = MIN2(gSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
ncv0->color[2] = MIN2(bSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
/* sum v1 */ /* sum v1 */
rSum = ncv1->color[0] + ncv1->specular[0]; rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
gSum = ncv1->color[1] + ncv1->specular[1]; gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
bSum = ncv1->color[2] + ncv1->specular[2]; bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
ncv1->color[0] = MIN2(rSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
ncv1->color[1] = MIN2(gSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
ncv1->color[2] = MIN2(bSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
/* sum v2 */ /* sum v2 */
rSum = ncv2->color[0] + ncv2->specular[0]; rSum = CHAN_TO_FLOAT(ncv2->color[0]) + ncv2->attrib[FRAG_ATTRIB_COL1][0];
gSum = ncv2->color[1] + ncv2->specular[1]; gSum = CHAN_TO_FLOAT(ncv2->color[1]) + ncv2->attrib[FRAG_ATTRIB_COL1][1];
bSum = ncv2->color[2] + ncv2->specular[2]; bSum = CHAN_TO_FLOAT(ncv2->color[2]) + ncv2->attrib[FRAG_ATTRIB_COL1][2];
ncv2->color[0] = MIN2(rSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[0], rSum);
ncv2->color[1] = MIN2(gSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[1], gSum);
ncv2->color[2] = MIN2(bSum, CHAN_MAX); UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[2], bSum);
/* draw */ /* draw */
SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 ); SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 );
/* restore original colors */ /* restore original colors */
COPY_CHAN4( ncv0->color, c[0] ); COPY_CHAN4( ncv0->color, cSave[0] );
COPY_CHAN4( ncv1->color, c[1] ); COPY_CHAN4( ncv1->color, cSave[1] );
COPY_CHAN4( ncv2->color, c[2] ); COPY_CHAN4( ncv2->color, cSave[2] );
} }
@ -1044,9 +1029,15 @@ _swrast_choose_triangle( GLcontext *ctx )
return; return;
} }
/*
* XXX should examine swrast->_ActiveAttribMask to determine what
* needs to be interpolated.
*/
if (ctx->Texture._EnabledCoordUnits || if (ctx->Texture._EnabledCoordUnits ||
ctx->FragmentProgram._Current || ctx->FragmentProgram._Current ||
ctx->ATIFragmentShader._Enabled) { ctx->ATIFragmentShader._Enabled ||
NEED_SECONDARY_COLOR(ctx) ||
swrast->_FogEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */ /* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D; const struct gl_texture_object *texObj2D;
const struct gl_texture_image *texImg; const struct gl_texture_image *texImg;
@ -1072,6 +1063,7 @@ _swrast_choose_triangle( GLcontext *ctx )
&& (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA) && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA)
&& minFilter == magFilter && minFilter == magFilter
&& ctx->Light.Model.ColorControl == GL_SINGLE_COLOR && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
&& !swrast->_FogEnabled
&& ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) { && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) {
if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
if (minFilter == GL_NEAREST if (minFilter == GL_NEAREST
@ -1091,7 +1083,7 @@ _swrast_choose_triangle( GLcontext *ctx )
} }
} }
else { else {
#if (CHAN_BITS == 16 || CHAN_BITS == 32) #if CHAN_BITS != 8
USE(general_triangle); USE(general_triangle);
#else #else
USE(affine_textured_triangle); USE(affine_textured_triangle);
@ -1099,7 +1091,7 @@ _swrast_choose_triangle( GLcontext *ctx )
} }
} }
else { else {
#if (CHAN_BITS == 16 || CHAN_BITS == 32) #if CHAN_BITS != 8
USE(general_triangle); USE(general_triangle);
#else #else
USE(persp_textured_triangle); USE(persp_textured_triangle);
@ -1112,14 +1104,23 @@ _swrast_choose_triangle( GLcontext *ctx )
} }
} }
else { else {
ASSERT(!ctx->Texture._EnabledCoordUnits); ASSERT(!swrast->_FogEnabled);
ASSERT(!NEED_SECONDARY_COLOR(ctx));
if (ctx->Light.ShadeModel==GL_SMOOTH) { if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */ /* smooth shaded, no texturing, stippled or some raster ops */
USE(smooth_rgba_triangle); #if CHAN_BITS != 8
USE(general_triangle);
#else
USE(smooth_rgba_triangle);
#endif
} }
else { else {
/* flat shaded, no texturing, stippled or some raster ops */ /* flat shaded, no texturing, stippled or some raster ops */
#if CHAN_BITS != 8
USE(general_triangle);
#else
USE(flat_rgba_triangle); USE(flat_rgba_triangle);
#endif
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -155,14 +155,11 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
zoomed_arrays.ChanType = span->array->ChanType; zoomed_arrays.ChanType = span->array->ChanType;
/* XXX temporary */ /* XXX temporary */
#if CHAN_TYPE == GL_UNSIGNED_BYTE #if CHAN_TYPE == GL_UNSIGNED_BYTE
zoomed_arrays.rgba = zoomed_arrays.color.sz1.rgba; zoomed_arrays.rgba = zoomed_arrays.rgba8;
zoomed_arrays.spec = zoomed_arrays.color.sz1.spec;
#elif CHAN_TYPE == GL_UNSIGNED_SHORT #elif CHAN_TYPE == GL_UNSIGNED_SHORT
zoomed_arrays.rgba = zoomed_arrays.color.sz2.rgba; zoomed_arrays.rgba = zoomed_arrays.rgba16;
zoomed_arrays.spec = zoomed_arrays.color.sz2.spec;
#else #else
zoomed_arrays.rgba = zoomed_arrays.attribs[FRAG_ATTRIB_COL0]; zoomed_arrays.rgba = zoomed_arrays.attribs[FRAG_ATTRIB_COL0];
zoomed_arrays.spec = zoomed_arrays.attribs[FRAG_ATTRIB_COL1];
#endif #endif
@ -219,7 +216,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0); ASSERT(j >= 0);
ASSERT(j < (GLint) span->end); ASSERT(j < (GLint) span->end);
COPY_4UBV(zoomed.array->color.sz1.rgba[i], rgba[j]); COPY_4UBV(zoomed.array->rgba8[i], rgba[j]);
} }
} }
else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) { else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) {
@ -229,7 +226,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0); ASSERT(j >= 0);
ASSERT(j < (GLint) span->end); ASSERT(j < (GLint) span->end);
COPY_4V(zoomed.array->color.sz2.rgba[i], rgba[j]); COPY_4V(zoomed.array->rgba16[i], rgba[j]);
} }
} }
else { else {
@ -251,10 +248,10 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0); ASSERT(j >= 0);
ASSERT(j < (GLint) span->end); ASSERT(j < (GLint) span->end);
zoomed.array->color.sz1.rgba[i][0] = rgb[j][0]; zoomed.array->rgba8[i][0] = rgb[j][0];
zoomed.array->color.sz1.rgba[i][1] = rgb[j][1]; zoomed.array->rgba8[i][1] = rgb[j][1];
zoomed.array->color.sz1.rgba[i][2] = rgb[j][2]; zoomed.array->rgba8[i][2] = rgb[j][2];
zoomed.array->color.sz1.rgba[i][3] = 0xff; zoomed.array->rgba8[i][3] = 0xff;
} }
} }
else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) { else if (zoomed.array->ChanType == GL_UNSIGNED_SHORT) {
@ -264,10 +261,10 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x;
ASSERT(j >= 0); ASSERT(j >= 0);
ASSERT(j < (GLint) span->end); ASSERT(j < (GLint) span->end);
zoomed.array->color.sz2.rgba[i][0] = rgb[j][0]; zoomed.array->rgba16[i][0] = rgb[j][0];
zoomed.array->color.sz2.rgba[i][1] = rgb[j][1]; zoomed.array->rgba16[i][1] = rgb[j][1];
zoomed.array->color.sz2.rgba[i][2] = rgb[j][2]; zoomed.array->rgba16[i][2] = rgb[j][2];
zoomed.array->color.sz2.rgba[i][3] = 0xffff; zoomed.array->rgba16[i][3] = 0xffff;
} }
} }
else { else {
@ -314,8 +311,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
* Also, clipping may change the span end value, so store it as well. * Also, clipping may change the span end value, so store it as well.
*/ */
const GLint end = zoomed.end; /* save */ const GLint end = zoomed.end; /* save */
/* use specular color array for temp storage */ GLuint rgbaSave[MAX_WIDTH][4];
void *rgbaSave = zoomed.array->spec;
const GLint pixelSize = const GLint pixelSize =
(zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) : (zoomed.array->ChanType == GL_UNSIGNED_BYTE) ? 4 * sizeof(GLubyte) :
((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort) ((zoomed.array->ChanType == GL_UNSIGNED_SHORT) ? 4 * sizeof(GLushort)
@ -334,7 +330,7 @@ zoom_span( GLcontext *ctx, GLint imgX, GLint imgY, const SWspan *span,
} }
else if (format == GL_COLOR_INDEX) { else if (format == GL_COLOR_INDEX) {
/* use specular color array for temp storage */ /* use specular color array for temp storage */
GLuint *indexSave = (GLuint *) zoomed.array->spec; GLuint *indexSave = (GLuint *) zoomed.array->attribs[FRAG_ATTRIB_FOGC];
const GLint end = zoomed.end; /* save */ const GLint end = zoomed.end; /* save */
if (y1 - y0 > 1) { if (y1 - y0 > 1) {
MEMCPY(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint)); MEMCPY(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint));

View file

@ -45,6 +45,14 @@
* improve its usefulness as a fallback mechanism for hardware * improve its usefulness as a fallback mechanism for hardware
* drivers. * drivers.
* *
* wpos = attr[FRAG_ATTRIB_WPOS] and MUST BE THE FIRST values in the
* vertex because of the tnl clipping code.
* wpos[0] and [1] are the screen-coords of SWvertex.
* wpos[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]).
* wpos[3] is 1/w where w is the clip-space W coord. This is the value
* that clip{XYZ} were multiplied by to get ndc{XYZ}.
*
* Full software drivers: * Full software drivers:
* - Register the rastersetup and triangle functions from * - Register the rastersetup and triangle functions from
* utils/software_helper. * utils/software_helper.
@ -61,20 +69,15 @@
* primitives unaccelerated), hook in swrast_setup instead. * primitives unaccelerated), hook in swrast_setup instead.
*/ */
typedef struct { typedef struct {
/** win[0], win[1] are the screen-coords of SWvertex. GLfloat attrib[FRAG_ATTRIB_MAX][4];
* win[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]). GLchan color[4]; /** integer color */
* win[3] is 1/w where w is the clip-space W coord. This is the value
* that clip{XYZ} were multiplied by to get ndc{XYZ}.
*/
GLfloat win[4];
GLchan color[4];
GLchan specular[4];
GLfloat index;
GLfloat pointSize; GLfloat pointSize;
GLfloat attrib[FRAG_ATTRIB_MAX][4]; /**< texcoords & varying, more to come */
} SWvertex; } SWvertex;
#define FRAG_ATTRIB_CI FRAG_ATTRIB_COL0
struct swrast_device_driver; struct swrast_device_driver;

View file

@ -120,16 +120,25 @@ setup_vertex_format(GLcontext *ctx)
RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset ); RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, win ); EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] );
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) {
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); if (ctx->FragmentProgram._Current
|| ctx->ATIFragmentShader._Enabled
|| CHAN_TYPE == GL_FLOAT)
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, attrib[FRAG_ATTRIB_COL0]);
else
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
}
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4CHAN_4F_RGBA, specular); EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
}
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) {
EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F, index ); EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F,
attrib[FRAG_ATTRIB_CI][0] );
}
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) { if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F; const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F;
@ -184,6 +193,10 @@ _swsetup_RenderStart( GLcontext *ctx )
_swsetup_choose_trifuncs(ctx); _swsetup_choose_trifuncs(ctx);
} }
if (swsetup->NewState & _NEW_PROGRAM) {
RENDERINPUTS_ZERO( swsetup->last_index_bitset );
}
swsetup->NewState = 0; swsetup->NewState = 0;
_swrast_render_start(ctx); _swrast_render_start(ctx);
@ -258,10 +271,10 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp );
dest->win[0] = m[0] * tmp[0] + m[12]; dest->attrib[FRAG_ATTRIB_WPOS][0] = m[0] * tmp[0] + m[12];
dest->win[1] = m[5] * tmp[1] + m[13]; dest->attrib[FRAG_ATTRIB_WPOS][1] = m[5] * tmp[1] + m[13];
dest->win[2] = m[10] * tmp[2] + m[14]; dest->attrib[FRAG_ATTRIB_WPOS][2] = m[10] * tmp[2] + m[14];
dest->win[3] = tmp[3]; dest->attrib[FRAG_ATTRIB_WPOS][3] = tmp[3];
/** XXX try to limit these loops someday */ /** XXX try to limit these loops someday */
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
@ -276,13 +289,16 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp ); UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp );
COPY_4V(dest->attrib[FRAG_ATTRIB_COL1], tmp);
/*
UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, tmp ); UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, tmp );
*/
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0]; dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
dest->index = tmp[0]; dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
/* XXX See _tnl_get_attr about pointsize ... */ /* XXX See _tnl_get_attr about pointsize ... */
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp ); _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp );

View file

@ -57,7 +57,7 @@ static void _swsetup_render_line_tri( GLcontext *ctx,
SWvertex *v1 = &verts[e1]; SWvertex *v1 = &verts[e1];
SWvertex *v2 = &verts[e2]; SWvertex *v2 = &verts[e2];
GLchan c[2][4]; GLchan c[2][4];
GLchan s[2][4]; GLfloat s[2][4];
GLfloat i[2]; GLfloat i[2];
/* cull testing */ /* cull testing */
@ -71,17 +71,17 @@ static void _swsetup_render_line_tri( GLcontext *ctx,
if (ctx->Light.ShadeModel == GL_FLAT) { if (ctx->Light.ShadeModel == GL_FLAT) {
COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color); COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular); COPY_4V(s[0], v0->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(s[1], v1->specular); COPY_4V(s[1], v1->attrib[FRAG_ATTRIB_COL1]);
i[0] = v0->index; i[0] = v0->attrib[FRAG_ATTRIB_CI][0];
i[1] = v1->index; i[1] = v1->attrib[FRAG_ATTRIB_CI][0];
COPY_CHAN4(v0->color, v2->color); COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color); COPY_CHAN4(v1->color, v2->color);
COPY_CHAN4(v0->specular, v2->specular); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(v1->specular, v2->specular); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
v0->index = v2->index; v0->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
v1->index = v2->index; v1->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
} }
if (swsetup->render_prim == GL_POLYGON) { if (swsetup->render_prim == GL_POLYGON) {
@ -97,10 +97,10 @@ static void _swsetup_render_line_tri( GLcontext *ctx,
if (ctx->Light.ShadeModel == GL_FLAT) { if (ctx->Light.ShadeModel == GL_FLAT) {
COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]); COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], s[0]);
COPY_CHAN4(v1->specular, s[1]); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], s[1]);
v0->index = i[0]; v0->attrib[FRAG_ATTRIB_CI][0] = i[0];
v1->index = i[1]; v1->attrib[FRAG_ATTRIB_CI][0] = i[1];
} }
} }
@ -116,7 +116,7 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
SWvertex *v1 = &verts[e1]; SWvertex *v1 = &verts[e1];
SWvertex *v2 = &verts[e2]; SWvertex *v2 = &verts[e2];
GLchan c[2][4]; GLchan c[2][4];
GLchan s[2][4]; GLfloat s[2][4];
GLfloat i[2]; GLfloat i[2];
/* cull testing */ /* cull testing */
@ -131,18 +131,18 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
/* save colors/indexes for v0, v1 vertices */ /* save colors/indexes for v0, v1 vertices */
COPY_CHAN4(c[0], v0->color); COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color); COPY_CHAN4(c[1], v1->color);
COPY_CHAN4(s[0], v0->specular); COPY_4V(s[0], v0->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(s[1], v1->specular); COPY_4V(s[1], v1->attrib[FRAG_ATTRIB_COL1]);
i[0] = v0->index; i[0] = v0->attrib[FRAG_ATTRIB_CI][0];
i[1] = v1->index; i[1] = v1->attrib[FRAG_ATTRIB_CI][0];
/* copy v2 color/indexes to v0, v1 indexes */ /* copy v2 color/indexes to v0, v1 indexes */
COPY_CHAN4(v0->color, v2->color); COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color); COPY_CHAN4(v1->color, v2->color);
COPY_CHAN4(v0->specular, v2->specular); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(v1->specular, v2->specular); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
v0->index = v2->index; v0->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
v1->index = v2->index; v1->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
} }
if (ef[e0]) _swrast_Point( ctx, v0 ); if (ef[e0]) _swrast_Point( ctx, v0 );
@ -153,10 +153,10 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
/* restore v0, v1 colores/indexes */ /* restore v0, v1 colores/indexes */
COPY_CHAN4(v0->color, c[0]); COPY_CHAN4(v0->color, c[0]);
COPY_CHAN4(v1->color, c[1]); COPY_CHAN4(v1->color, c[1]);
COPY_CHAN4(v0->specular, s[0]); COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], s[0]);
COPY_CHAN4(v1->specular, s[1]); COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], s[1]);
v0->index = i[0]; v0->attrib[FRAG_ATTRIB_CI][0] = i[0];
v1->index = i[1]; v1->attrib[FRAG_ATTRIB_CI][0] = i[1];
} }
_swrast_flush(ctx); _swrast_flush(ctx);
} }

View file

@ -36,7 +36,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
GLenum mode = GL_FILL; GLenum mode = GL_FILL;
GLuint facing = 0; GLuint facing = 0;
GLchan saved_color[3][4]; GLchan saved_color[3][4];
GLchan saved_spec[3][4]; GLfloat saved_spec[3][4];
GLfloat saved_index[3]; GLfloat saved_index[3];
v[0] = &verts[e0]; v[0] = &verts[e0];
@ -46,10 +46,10 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT)) if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
{ {
GLfloat ex = v[0]->win[0] - v[2]->win[0]; GLfloat ex = v[0]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat ey = v[0]->win[1] - v[2]->win[1]; GLfloat ey = v[0]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat fx = v[1]->win[0] - v[2]->win[0]; GLfloat fx = v[1]->attrib[FRAG_ATTRIB_WPOS][0] - v[2]->attrib[FRAG_ATTRIB_WPOS][0];
GLfloat fy = v[1]->win[1] - v[2]->win[1]; GLfloat fy = v[1]->attrib[FRAG_ATTRIB_WPOS][1] - v[2]->attrib[FRAG_ATTRIB_WPOS][1];
GLfloat cc = ex*fy - ey*fx; GLfloat cc = ex*fy - ey*fx;
if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT)) if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
@ -85,30 +85,30 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (VB->SecondaryColorPtr[1]) { if (VB->SecondaryColorPtr[1]) {
GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
COPY_CHAN4(saved_spec[0], v[0]->specular); COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(saved_spec[1], v[1]->specular); COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]);
COPY_CHAN4(saved_spec[2], v[2]->specular); COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]);
if (VB->SecondaryColorPtr[1]->stride) { if (VB->SecondaryColorPtr[1]->stride) {
SS_SPEC(v[0]->specular, vbspec[e0]); SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]);
SS_SPEC(v[1]->specular, vbspec[e1]); SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]);
SS_SPEC(v[2]->specular, vbspec[e2]); SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]);
} }
else { else {
SS_SPEC(v[0]->specular, vbspec[0]); SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
SS_SPEC(v[1]->specular, vbspec[0]); SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
SS_SPEC(v[2]->specular, vbspec[0]); SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
} }
} }
} else { } else {
GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data; GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
saved_index[0] = v[0]->index; saved_index[0] = v[0]->attrib[FRAG_ATTRIB_CI][0];
saved_index[1] = v[1]->index; saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0];
saved_index[2] = v[2]->index; saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0];
SS_IND(v[0]->index, (GLuint) vbindex[e0]); SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e0]);
SS_IND(v[1]->index, (GLuint) vbindex[e1]); SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e1]);
SS_IND(v[2]->index, (GLuint) vbindex[e2]); SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e2]);
} }
} }
} }
@ -117,9 +117,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (IND & SS_OFFSET_BIT) if (IND & SS_OFFSET_BIT)
{ {
offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD; offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
z[0] = v[0]->win[2]; z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2];
z[1] = v[1]->win[2]; z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2];
z[2] = v[2]->win[2]; z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2];
if (cc * cc > 1e-16) { if (cc * cc > 1e-16) {
const GLfloat ez = z[0] - z[2]; const GLfloat ez = z[0] - z[2];
const GLfloat fz = z[1] - z[2]; const GLfloat fz = z[1] - z[2];
@ -130,40 +130,40 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
/* Unfortunately, we need to clamp to prevent negative Zs below. /* Unfortunately, we need to clamp to prevent negative Zs below.
* Technically, we should do the clamping per-fragment. * Technically, we should do the clamping per-fragment.
*/ */
offset = MAX2(offset, -v[0]->win[2]); offset = MAX2(offset, -v[0]->attrib[FRAG_ATTRIB_WPOS][2]);
offset = MAX2(offset, -v[1]->win[2]); offset = MAX2(offset, -v[1]->attrib[FRAG_ATTRIB_WPOS][2]);
offset = MAX2(offset, -v[2]->win[2]); offset = MAX2(offset, -v[2]->attrib[FRAG_ATTRIB_WPOS][2]);
} }
} }
} }
if (mode == GL_POINT) { if (mode == GL_POINT) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
v[0]->win[2] += offset; v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[1]->win[2] += offset; v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[2]->win[2] += offset; v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
} }
_swsetup_render_point_tri( ctx, e0, e1, e2, facing ); _swsetup_render_point_tri( ctx, e0, e1, e2, facing );
} else if (mode == GL_LINE) { } else if (mode == GL_LINE) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
v[0]->win[2] += offset; v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[1]->win[2] += offset; v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[2]->win[2] += offset; v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
} }
_swsetup_render_line_tri( ctx, e0, e1, e2, facing ); _swsetup_render_line_tri( ctx, e0, e1, e2, facing );
} else { } else {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) { if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
v[0]->win[2] += offset; v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[1]->win[2] += offset; v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
v[2]->win[2] += offset; v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
} }
_swrast_Triangle( ctx, v[0], v[1], v[2] ); _swrast_Triangle( ctx, v[0], v[1], v[2] );
} }
if (IND & SS_OFFSET_BIT) { if (IND & SS_OFFSET_BIT) {
v[0]->win[2] = z[0]; v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0];
v[1]->win[2] = z[1]; v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1];
v[2]->win[2] = z[2]; v[2]->attrib[FRAG_ATTRIB_WPOS][2] = z[2];
} }
if (IND & SS_TWOSIDE_BIT) { if (IND & SS_TWOSIDE_BIT) {
@ -176,14 +176,14 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
} }
if (VB->SecondaryColorPtr[1]) { if (VB->SecondaryColorPtr[1]) {
COPY_CHAN4(v[0]->specular, saved_spec[0]); COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]);
COPY_CHAN4(v[1]->specular, saved_spec[1]); COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]);
COPY_CHAN4(v[2]->specular, saved_spec[2]); COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]);
} }
} else { } else {
v[0]->index = saved_index[0]; v[0]->attrib[FRAG_ATTRIB_CI][0] = saved_index[0];
v[1]->index = saved_index[1]; v[1]->attrib[FRAG_ATTRIB_CI][0] = saved_index[1];
v[2]->index = saved_index[2]; v[2]->attrib[FRAG_ATTRIB_CI][0] = saved_index[2];
} }
} }
} }

View file

@ -89,15 +89,15 @@ void TAG(translate_vertex)(GLcontext *ctx,
if (format == TINY_VERTEX_FORMAT) { if (format == TINY_VERTEX_FORMAT) {
if (HAVE_HW_VIEWPORT) { if (HAVE_HW_VIEWPORT) {
dst->win[0] = s[0] * src->v.x + s[12]; dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0] * src->v.x + s[12];
dst->win[1] = s[5] * src->v.y + s[13]; dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5] * src->v.y + s[13];
dst->win[2] = s[10] * src->v.z + s[14]; dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
dst->win[3] = 1.0; dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
} else { } else {
dst->win[0] = UNVIEWPORT_X( src->v.x ); dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
dst->win[1] = UNVIEWPORT_Y( src->v.y ); dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
dst->win[2] = UNVIEWPORT_Z( src->v.z ); dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
dst->win[3] = 1.0; dst->attrib[FRAG_ATTRIB_WPOS][3] = 1.0;
} }
dst->color[0] = src->tv.color.red; dst->color[0] = src->tv.color.red;
@ -109,21 +109,21 @@ void TAG(translate_vertex)(GLcontext *ctx,
if (HAVE_HW_VIEWPORT) { if (HAVE_HW_VIEWPORT) {
if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
GLfloat oow = 1.0 / src->v.w; GLfloat oow = 1.0 / src->v.w;
dst->win[0] = s[0] * src->v.x * oow + s[12]; dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0] * src->v.x * oow + s[12];
dst->win[1] = s[5] * src->v.y * oow + s[13]; dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5] * src->v.y * oow + s[13];
dst->win[2] = s[10] * src->v.z * oow + s[14]; dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z * oow + s[14];
dst->win[3] = oow; dst->attrib[FRAG_ATTRIB_WPOS][3] = oow;
} else { } else {
dst->win[0] = s[0] * src->v.x + s[12]; dst->attrib[FRAG_ATTRIB_WPOS][0] = s[0] * src->v.x + s[12];
dst->win[1] = s[5] * src->v.y + s[13]; dst->attrib[FRAG_ATTRIB_WPOS][1] = s[5] * src->v.y + s[13];
dst->win[2] = s[10] * src->v.z + s[14]; dst->attrib[FRAG_ATTRIB_WPOS][2] = s[10] * src->v.z + s[14];
dst->win[3] = src->v.w; dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
} }
} else { } else {
dst->win[0] = UNVIEWPORT_X( src->v.x ); dst->attrib[FRAG_ATTRIB_WPOS][0] = UNVIEWPORT_X( src->v.x );
dst->win[1] = UNVIEWPORT_Y( src->v.y ); dst->attrib[FRAG_ATTRIB_WPOS][1] = UNVIEWPORT_Y( src->v.y );
dst->win[2] = UNVIEWPORT_Z( src->v.z ); dst->attrib[FRAG_ATTRIB_WPOS][2] = UNVIEWPORT_Z( src->v.z );
dst->win[3] = src->v.w; dst->attrib[FRAG_ATTRIB_WPOS][3] = src->v.w;
} }
dst->color[0] = src->v.color.red; dst->color[0] = src->v.color.red;
@ -131,11 +131,11 @@ void TAG(translate_vertex)(GLcontext *ctx,
dst->color[2] = src->v.color.blue; dst->color[2] = src->v.color.blue;
dst->color[3] = src->v.color.alpha; dst->color[3] = src->v.color.alpha;
dst->specular[0] = src->v.specular.red; dst->attrib[FRAG_ATTRIB_COL1][0] = UBYTE_TO_FLOAT(src->v.specular.red);
dst->specular[1] = src->v.specular.green; dst->attrib[FRAG_ATTRIB_COL1][1] = UBYTE_TO_FLOAT(src->v.specular.green);
dst->specular[2] = src->v.specular.blue; dst->attrib[FRAG_ATTRIB_COL1][2] = UBYTE_TO_FLOAT(src->v.specular.blue);
dst->attrib[FRAG_ATTRIB_FOGC][0] = src->v.specular.alpha/255.0; dst->attrib[FRAG_ATTRIB_FOGC][0] = UBYTE_TO_FLOAT(src->v.specular.alpha);
if (HAVE_PTEX_VERTICES && if (HAVE_PTEX_VERTICES &&
((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) || ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) ||