summaryrefslogtreecommitdiff
path: root/src/mesa/swrast/s_aatritemp.h
diff options
context:
space:
mode:
authorBrian <brian@nostromo.localnet.net>2007-02-05 10:10:01 -0700
committerBrian <brian@nostromo.localnet.net>2007-02-05 10:10:01 -0700
commitdd34fe8679fa200e55cfaf8e80bbecdecea084e3 (patch)
tree329b7c0280a198b8dabd02a5afb97dcaa5f3f4bd /src/mesa/swrast/s_aatritemp.h
parent93b975a1d9fcc4a10987676f7368809522f27d71 (diff)
Merge SWvertex texcoord and varying fields into attrib[] array field.
Fragment texcoords and varying code is now unified in the point/line/triangle rasterization code. In the future, merge color, fog, etc. attribs.
Diffstat (limited to 'src/mesa/swrast/s_aatritemp.h')
-rw-r--r--src/mesa/swrast/s_aatritemp.h217
1 files changed, 87 insertions, 130 deletions
diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h
index 3359a919e5..bbf9cc611d 100644
--- a/src/mesa/swrast/s_aatritemp.h
+++ b/src/mesa/swrast/s_aatritemp.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 6.5.3
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -36,12 +36,12 @@
* DO_RGBA - if defined, compute RGBA values
* DO_INDEX - if defined, compute color index values
* DO_SPEC - if defined, compute specular RGB values
- * DO_TEX - if defined, compute unit 0 STRQ texcoords
- * DO_MULTITEX - if defined, compute all unit's STRQ texcoords
+ * DO_TEXVAR - if defined, compute texcoords, varying
*/
/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
{
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLfloat *p0 = v0->win;
const GLfloat *p1 = v1->win;
const GLfloat *p2 = v2->win;
@@ -70,20 +70,18 @@
#ifdef DO_SPEC
GLfloat srPlane[4], sgPlane[4], sbPlane[4];
#endif
-#ifdef DO_TEX
- GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4];
- GLfloat texWidth, texHeight;
-#elif defined(DO_MULTITEX)
- GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */
- GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */
- GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */
- GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */
- GLfloat texWidth[MAX_TEXTURE_COORD_UNITS];
- GLfloat texHeight[MAX_TEXTURE_COORD_UNITS];
+#if defined(DO_TEXVAR)
+ GLfloat sPlane[FRAG_ATTRIB_MAX][4]; /* texture S */
+ GLfloat tPlane[FRAG_ATTRIB_MAX][4]; /* texture T */
+ 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
GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
-
+ (void) swrast;
+
INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE);
/* determine bottom to top order of vertices */
@@ -179,65 +177,44 @@
}
span.arrayMask |= SPAN_SPEC;
#endif
-#ifdef DO_TEX
+#if defined(DO_TEXVAR)
{
- const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
- const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ GLuint attr;
const GLfloat invW0 = v0->win[3];
const GLfloat invW1 = v1->win[3];
const GLfloat invW2 = v2->win[3];
- const GLfloat s0 = v0->texcoord[0][0] * invW0;
- const GLfloat s1 = v1->texcoord[0][0] * invW1;
- const GLfloat s2 = v2->texcoord[0][0] * invW2;
- const GLfloat t0 = v0->texcoord[0][1] * invW0;
- const GLfloat t1 = v1->texcoord[0][1] * invW1;
- const GLfloat t2 = v2->texcoord[0][1] * invW2;
- const GLfloat r0 = v0->texcoord[0][2] * invW0;
- const GLfloat r1 = v1->texcoord[0][2] * invW1;
- const GLfloat r2 = v2->texcoord[0][2] * invW2;
- const GLfloat q0 = v0->texcoord[0][3] * invW0;
- const GLfloat q1 = v1->texcoord[0][3] * invW1;
- const GLfloat q2 = v2->texcoord[0][3] * invW2;
- compute_plane(p0, p1, p2, s0, s1, s2, sPlane);
- compute_plane(p0, p1, p2, t0, t1, t2, tPlane);
- compute_plane(p0, p1, p2, r0, r1, r2, uPlane);
- compute_plane(p0, p1, p2, q0, q1, q2, vPlane);
- texWidth = (GLfloat) texImage->Width;
- texHeight = (GLfloat) texImage->Height;
- }
- span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
-#elif defined(DO_MULTITEX)
- {
- GLuint u;
- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
- const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
- const GLfloat invW0 = v0->win[3];
- const GLfloat invW1 = v1->win[3];
- const GLfloat invW2 = v2->win[3];
- const GLfloat s0 = v0->texcoord[u][0] * invW0;
- const GLfloat s1 = v1->texcoord[u][0] * invW1;
- const GLfloat s2 = v2->texcoord[u][0] * invW2;
- const GLfloat t0 = v0->texcoord[u][1] * invW0;
- const GLfloat t1 = v1->texcoord[u][1] * invW1;
- const GLfloat t2 = v2->texcoord[u][1] * invW2;
- const GLfloat r0 = v0->texcoord[u][2] * invW0;
- const GLfloat r1 = v1->texcoord[u][2] * invW1;
- const GLfloat r2 = v2->texcoord[u][2] * invW2;
- const GLfloat q0 = v0->texcoord[u][3] * invW0;
- const GLfloat q1 = v1->texcoord[u][3] * invW1;
- const GLfloat q2 = v2->texcoord[u][3] * invW2;
- compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]);
- compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]);
- compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]);
- compute_plane(p0, p1, p2, q0, q1, q2, vPlane[u]);
- texWidth[u] = (GLfloat) texImage->Width;
- texHeight[u] = (GLfloat) texImage->Height;
+ for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) {
+ if (swrast->_FragmentAttribs & (1 << attr)) {
+ const GLfloat s0 = v0->attrib[attr][0] * invW0;
+ const GLfloat s1 = v1->attrib[attr][0] * invW1;
+ const GLfloat s2 = v2->attrib[attr][0] * invW2;
+ const GLfloat t0 = v0->attrib[attr][1] * invW0;
+ 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) {
+ 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 {
+ texWidth[attr] = texHeight[attr] = 1.0;
+ }
}
}
}
- span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
+ span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA | SPAN_VARYING);
#endif
/* Begin bottom-to-top scan over the triangle.
@@ -305,28 +282,21 @@
array->spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
-#ifdef DO_TEX
+#if defined(DO_TEXVAR)
{
- const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- array->attribs[FRAG_ATTRIB_TEX0 + 0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + 0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + 0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
- array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane,
- cx, cy, invQ,
- texWidth, texHeight);
- }
-#elif defined(DO_MULTITEX)
- {
- GLuint unit;
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- array->attribs[FRAG_ATTRIB_TEX0 + unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
- array->lambda[unit][count] = compute_lambda(sPlane[unit],
- tPlane[unit], vPlane[unit], cx, cy, invQ,
- texWidth[unit], texHeight[unit]);
+ GLuint attr;
+ for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) {
+ if (swrast->_FragmentAttribs & (1 << attr)) {
+ 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) {
+ 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]);
+ }
}
}
}
@@ -409,30 +379,24 @@
array->spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
#endif
-#ifdef DO_TEX
- {
- const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
- array->attribs[FRAG_ATTRIB_TEX0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
- array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane,
- cx, cy, invQ, texWidth, texHeight);
- }
-#elif defined(DO_MULTITEX)
+#if defined(DO_TEXVAR)
{
- GLuint unit;
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
- GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
- array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
- array->attribs[FRAG_ATTRIB_TEX0 + unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
- array->lambda[unit][ix] = compute_lambda(sPlane[unit],
- tPlane[unit],
- vPlane[unit],
- cx, cy, invQ,
- texWidth[unit],
- texHeight[unit]);
+ GLuint attr;
+ for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) {
+ if (swrast->_FragmentAttribs & (1 << attr)) {
+ 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) {
+ 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]);
+ }
}
}
}
@@ -471,28 +435,25 @@
array->attribs[FRAG_ATTRIB_FOGC][j][0]
= array->attribs[FRAG_ATTRIB_FOGC][j + left][0];
#endif
-#ifdef DO_TEX
- COPY_4V(array->attribs[FRAG_ATTRIB_TEX0 + 0][j], array->attribs[FRAG_ATTRIB_TEX0 + 0][j + left]);
-#endif
-#if defined(DO_MULTITEX) || defined(DO_TEX)
+#if defined(DO_TEXVAR)
array->lambda[0][j] = array->lambda[0][j + left];
#endif
array->coverage[j] = array->coverage[j + left];
}
}
-#ifdef DO_MULTITEX
- /* shift texcoords */
+#ifdef DO_TEXVAR
+ /* shift texcoords, varying */
{
SWspanarrays *array = span.array;
- GLuint unit;
- for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
- if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ GLuint attr;
+ for (attr = swrast->_MinFragmentAttrib; attr < swrast->_MaxFragmentAttrib; attr++) {
+ if (swrast->_FragmentAttribs & (1 << attr)) {
GLint j;
for (j = 0; j < (GLint) n; j++) {
- array->attribs[FRAG_ATTRIB_TEX0 + unit][j][0] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][0];
- array->attribs[FRAG_ATTRIB_TEX0 + unit][j][1] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][1];
- array->attribs[FRAG_ATTRIB_TEX0 + unit][j][2] = array->attribs[FRAG_ATTRIB_TEX0 + unit][j + left][2];
- array->lambda[unit][j] = array->lambda[unit][j + left];
+ 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];*/
}
}
}
@@ -533,12 +494,8 @@
#undef DO_SPEC
#endif
-#ifdef DO_TEX
-#undef DO_TEX
-#endif
-
-#ifdef DO_MULTITEX
-#undef DO_MULTITEX
+#ifdef DO_TEXVAR
+#undef DO_TEXVAR
#endif
#ifdef DO_OCCLUSION_TEST