summaryrefslogtreecommitdiff
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-04-08 02:27:16 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-04-08 02:27:16 +0000
commit36a0a3252e1e20df69b53f70ba93bc74c4a4bf0e (patch)
tree6c680de320af7a288fe70e5a95696bcf0f5faa56 /src/mesa/swrast
parent0cebd5822a39ad3b3d7621f8e59efab329bfb5b9 (diff)
Added ctx->Texture._EnabledCoordUnits bitfield.
Fixed some vertex array / vertex program glitches with glDrawElements. Fixed some fragment program runtime bugs. Non-trivial Cg programs are running now.
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aaline.c8
-rw-r--r--src/mesa/swrast/s_aatriangle.c8
-rw-r--r--src/mesa/swrast/s_bitmap.c10
-rw-r--r--src/mesa/swrast/s_context.c4
-rw-r--r--src/mesa/swrast/s_copypix.c2
-rw-r--r--src/mesa/swrast/s_drawpix.c10
-rw-r--r--src/mesa/swrast/s_lines.c7
-rw-r--r--src/mesa/swrast/s_nvfragprog.c78
-rw-r--r--src/mesa/swrast/s_points.c12
-rw-r--r--src/mesa/swrast/s_span.c58
-rw-r--r--src/mesa/swrast/s_triangle.c16
-rw-r--r--src/mesa/swrast/s_tritemp.h4
12 files changed, 132 insertions, 85 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index 58cc145618..bbdc92b92a 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,8 +1,6 @@
-/* $Id: s_aaline.c,v 1.21 2003/03/14 15:38:04 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 5.0.1
+ * Version: 5.0.3
*
* Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
@@ -519,8 +517,8 @@ _swrast_choose_aa_line_function(GLcontext *ctx)
if (ctx->Visual.rgbMode) {
/* RGBA */
- if (ctx->Texture._EnabledUnits != 0) {
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits != 0) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
/* Multitextured! */
if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR ||
ctx->Fog.ColorSumEnabled)
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index b717ee7774..21b8c0437e 100644
--- a/src/mesa/swrast/s_aatriangle.c
+++ b/src/mesa/swrast/s_aatriangle.c
@@ -1,5 +1,3 @@
-/* $Id: s_aatriangle.c,v 1.31 2003/03/25 02:23:44 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -465,9 +463,9 @@ _swrast_set_aa_triangle_function(GLcontext *ctx)
{
ASSERT(ctx->Polygon.SmoothFlag);
- if (ctx->Texture._EnabledUnits != 0) {
+ if (ctx->Texture._EnabledCoordUnits != 0) {
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
}
else {
@@ -475,7 +473,7 @@ _swrast_set_aa_triangle_function(GLcontext *ctx)
}
}
else {
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c
index f8fc071099..0e20a20d7f 100644
--- a/src/mesa/swrast/s_bitmap.c
+++ b/src/mesa/swrast/s_bitmap.c
@@ -1,10 +1,8 @@
-/* $Id: s_bitmap.c,v 1.22 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 5.0
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -82,7 +80,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
_swrast_span_default_z(ctx, &span);
if (ctx->Fog.Enabled)
_swrast_span_default_fog(ctx, &span);
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
for (row = 0; row < height; row++, span.y++) {
@@ -198,7 +196,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
_swrast_span_default_z(ctx, &span);
if (ctx->Fog.Enabled)
_swrast_span_default_fog(ctx, &span);
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
for (row=0; row<height; row++, span.y++) {
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index e36da39030..79ee5b440f 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,5 +1,3 @@
-/* $Id: s_context.c,v 1.48 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -600,7 +598,7 @@ _swrast_flush( GLcontext *ctx )
/* flush any pending fragments from rendering points */
if (swrast->PointSpan.end > 0) {
if (ctx->Visual.rgbMode) {
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_write_texture_span(ctx, &(swrast->PointSpan));
else
_swrast_write_rgba_span(ctx, &(swrast->PointSpan));
diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c
index b66cad2dad..15cedb4c1d 100644
--- a/src/mesa/swrast/s_copypix.c
+++ b/src/mesa/swrast/s_copypix.c
@@ -1,5 +1,3 @@
-/* $Id: s_copypix.c,v 1.44 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c
index bc791b9078..008b60dcff 100644
--- a/src/mesa/swrast/s_drawpix.c
+++ b/src/mesa/swrast/s_drawpix.c
@@ -1,5 +1,3 @@
-/* $Id: s_drawpix.c,v 1.47 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -111,11 +109,11 @@ fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
_swrast_span_default_z(ctx, &span);
if (ctx->Fog.Enabled)
_swrast_span_default_fog(ctx, &span);
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
if ((SWRAST_CONTEXT(ctx)->_RasterMask & ~CLIP_BIT) == 0
- && ctx->Texture._EnabledUnits == 0
+ && ctx->Texture._EnabledCoordUnits == 0
&& unpack->Alignment == 1
&& !unpack->SwapBytes
&& !unpack->LsbFirst) {
@@ -650,7 +648,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
if (ctx->Fog.Enabled)
_swrast_span_default_fog(ctx, &span);
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
if (type == GL_UNSIGNED_SHORT && ctx->Visual.depthBits == 16
@@ -777,7 +775,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
_swrast_span_default_z(ctx, &span);
if (ctx->Fog.Enabled)
_swrast_span_default_fog(ctx, &span);
- if (ctx->Texture._EnabledUnits)
+ if (ctx->Texture._EnabledCoordUnits)
_swrast_span_default_texcoords(ctx, &span);
if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0
diff --git a/src/mesa/swrast/s_lines.c b/src/mesa/swrast/s_lines.c
index c3c5c582f1..a9284d5029 100644
--- a/src/mesa/swrast/s_lines.c
+++ b/src/mesa/swrast/s_lines.c
@@ -1,5 +1,3 @@
-/* $Id: s_lines.c,v 1.36 2003/03/25 02:23:46 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -305,9 +303,10 @@ _swrast_choose_line( GLcontext *ctx )
_swrast_choose_aa_line_function(ctx);
ASSERT(swrast->Line);
}
- else if (ctx->Texture._EnabledUnits) {
+ else if (ctx->Texture._EnabledCoordUnits) {
/* textured lines */
- if (ctx->Texture._EnabledUnits > 0x1 || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
+ if (ctx->Texture._EnabledCoordUnits > 0x1
+ || (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)) {
/* multi-texture and/or separate specular color */
USE(multitextured_line);
}
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index b34703b857..8ab65b8e32 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1,4 +1,4 @@
-/* $Id: s_nvfragprog.c,v 1.13 2003/04/05 00:38:10 brianp Exp $ */
+/* $Id: s_nvfragprog.c,v 1.14 2003/04/08 02:27:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -25,7 +25,6 @@
*/
-
#include "glheader.h"
#include "colormac.h"
#include "context.h"
@@ -37,20 +36,23 @@
#include "s_texture.h"
+/* if 1, print some debugging info */
+#define DEBUG_FRAG 0
+
+
/**
* Fetch a texel.
*/
static void
-fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLuint unit,
- GLfloat color[4] )
+fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
+ GLuint unit, GLfloat color[4] )
{
- const GLfloat *lambda = NULL;
GLchan rgba[4];
SWcontext *swrast = SWRAST_CONTEXT(ctx);
swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
1, (const GLfloat (*)[4]) texcoord,
- lambda, &rgba);
+ &lambda, &rgba);
color[0] = CHAN_TO_FLOAT(rgba[0]);
color[1] = CHAN_TO_FLOAT(rgba[1]);
color[2] = CHAN_TO_FLOAT(rgba[2]);
@@ -347,6 +349,15 @@ store_vector4( const struct fp_instruction *inst,
const GLboolean *writeMask = dest->WriteMask;
GLboolean condWriteMask[4];
+#if DEBUG_FRAG
+ if (value[0] > 1.0e10 ||
+ IS_INF_OR_NAN(value[0]) ||
+ IS_INF_OR_NAN(value[1]) ||
+ IS_INF_OR_NAN(value[2]) ||
+ IS_INF_OR_NAN(value[3]) )
+ printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]);
+#endif
+
if (clamp) {
clampedValue[0] = CLAMP(value[0], 0.0F, 1.0F);
clampedValue[1] = CLAMP(value[1], 0.0F, 1.0F);
@@ -501,9 +512,14 @@ init_machine_deriv( GLcontext *ctx,
static GLboolean
execute_program( GLcontext *ctx,
const struct fragment_program *program, GLuint maxInst,
- struct fp_machine *machine, const struct sw_span *span )
+ struct fp_machine *machine, const struct sw_span *span,
+ GLuint column )
{
- GLuint pc = 0;
+ GLuint pc;
+
+#if DEBUG_FRAG
+ printf("execute fragment program --------------------\n");
+#endif
for (pc = 0; pc < maxInst; pc++) {
const struct fp_instruction *inst = program->Instructions + pc;
@@ -542,7 +558,7 @@ execute_program( GLcontext *ctx,
*/
init_machine_deriv(ctx, machine, program, span,
'X', &dMachine);
- execute_program(ctx, program, pc, &dMachine, span);
+ execute_program(ctx, program, pc, &dMachine, span, column);
fetch_vector4( &inst->SrcReg[0], &dMachine, program, aNext );
result[0] = aNext[0] - a[0];
result[1] = aNext[1] - a[1];
@@ -559,7 +575,7 @@ execute_program( GLcontext *ctx,
if (!fetch_vector4_deriv(&inst->SrcReg[0], span, 'Y', result)) {
init_machine_deriv(ctx, machine, program, span,
'Y', &dMachine);
- execute_program(ctx, program, pc, &dMachine, span);
+ execute_program(ctx, program, pc, &dMachine, span, column);
fetch_vector4( &inst->SrcReg[0], &dMachine, program, aNext );
result[0] = aNext[0] - a[0];
result[1] = aNext[1] - a[1];
@@ -575,8 +591,12 @@ execute_program( GLcontext *ctx,
fetch_vector4( &inst->SrcReg[0], machine, program, a );
fetch_vector4( &inst->SrcReg[1], machine, program, b );
result[0] = result[1] = result[2] = result[3] =
- a[0] + b[0] + a[1] * b[1] + a[2] * b[2];
+ a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("DP3 %g = (%g %g %g) . (%g %g %g)\n",
+ result[0], a[0], a[1], a[2], b[0], b[1], b[2]);
+#endif
}
break;
case FP_OPCODE_DP4:
@@ -585,7 +605,7 @@ execute_program( GLcontext *ctx,
fetch_vector4( &inst->SrcReg[0], machine, program, a );
fetch_vector4( &inst->SrcReg[1], machine, program, b );
result[0] = result[1] = result[2] = result[3] =
- a[0] + b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
+ a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
store_vector4( inst, machine, result );
}
break;
@@ -734,6 +754,12 @@ execute_program( GLcontext *ctx,
result[2] = a[2] * b[2];
result[3] = a[3] * b[3];
store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("MUL (%g %g %g %g) = (%g %g %g %g) * (%g %g %g %g)\n",
+ result[0], result[1], result[2], result[3],
+ a[0], a[1], a[2], a[3],
+ b[0], b[1], b[2], b[3]);
+#endif
}
break;
case FP_OPCODE_PK2H: /* pack two 16-bit floats */
@@ -812,6 +838,12 @@ execute_program( GLcontext *ctx,
{
GLfloat a[4], result[4];
fetch_vector1( &inst->SrcReg[0], machine, program, a );
+#if DEBUG_FRAG
+ if (a[0] == 0)
+ printf("RCP(0)\n");
+ else if (IS_INF_OR_NAN(a[0]))
+ printf("RCP(inf)\n");
+#endif
result[0] = result[1] = result[2] = result[3]
= 1.0F / a[0];
store_vector4( inst, machine, result );
@@ -841,6 +873,9 @@ execute_program( GLcontext *ctx,
fetch_vector1( &inst->SrcReg[0], machine, program, a );
result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("RSQ %g = 1/sqrt(%g)\n", result[0], a[0]);
+#endif
}
break;
case FP_OPCODE_SEQ: /* set on equal */
@@ -953,7 +988,9 @@ execute_program( GLcontext *ctx,
GLfloat texcoord[4], color[4];
fetch_vector4( &inst->SrcReg[0], machine, program, texcoord );
/* XXX: Undo perspective divide from interpolate_texcoords() */
- fetch_texel( ctx, texcoord, inst->TexSrcUnit, color );
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
store_vector4( inst, machine, color );
}
break;
@@ -975,7 +1012,9 @@ execute_program( GLcontext *ctx,
GLfloat texcoord[4], color[4];
fetch_vector4( &inst->SrcReg[0], machine, program, texcoord );
/* Already did perspective divide in interpolate_texcoords() */
- fetch_texel( ctx, texcoord, inst->TexSrcUnit, color );
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
store_vector4( inst, machine, color );
}
break;
@@ -1103,12 +1142,9 @@ init_machine( GLcontext *ctx, struct fp_machine *machine,
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
if (program->InputsRead & (1 << (FRAG_ATTRIB_TEX0 + u))) {
GLfloat *tex = machine->Registers[FP_INPUT_REG_START+FRAG_ATTRIB_TEX0+u];
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
- COPY_4V(tex, span->array->texcoords[u][col]);
- }
- else {
- COPY_4V(tex, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]);
- }
+ ASSERT(ctx->Texture._EnabledCoordUnits & (1 << u));
+ COPY_4V(tex, span->array->texcoords[u][col]);
+ ASSERT(tex[0] != 0 || tex[1] != 0 || tex[2] != 0);
}
}
}
@@ -1126,7 +1162,7 @@ _swrast_exec_nv_fragment_program( GLcontext *ctx, struct sw_span *span )
ctx->FragmentProgram.Current, span, i);
if (!execute_program(ctx, program, ~0,
- &ctx->FragmentProgram.Machine, span))
+ &ctx->FragmentProgram.Machine, span, i))
span->array->mask[i] = GL_FALSE; /* killed fragment */
/* Store output registers */
diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index 640a70ac92..1b5e502f41 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -1,10 +1,8 @@
-/* $Id: s_points.c,v 1.21 2003/03/25 02:23:47 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -214,7 +212,7 @@ _swrast_choose_point( GLcontext *ctx )
if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
USE(atten_antialiased_rgba_point);
}
- else if (ctx->Texture._EnabledUnits) {
+ else if (ctx->Texture._EnabledCoordUnits) {
USE(antialiased_tex_rgba_point);
}
else {
@@ -227,7 +225,7 @@ _swrast_choose_point( GLcontext *ctx )
}
else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
if (rgbMode) {
- if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledCoordUnits) {
if (ctx->Point.SmoothFlag) {
USE(atten_antialiased_rgba_point);
}
@@ -244,7 +242,7 @@ _swrast_choose_point( GLcontext *ctx )
USE(atten_general_ci_point);
}
}
- else if (ctx->Texture._EnabledUnits && rgbMode) {
+ else if (ctx->Texture._EnabledCoordUnits && rgbMode) {
/* textured */
USE(textured_rgba_point);
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index d6959e1f4c..231e549c5a 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -1,5 +1,3 @@
-/* $Id: s_span.c,v 1.60 2003/03/25 02:23:47 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
@@ -353,21 +351,30 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
ASSERT(span->interpMask & SPAN_TEXTURE);
ASSERT(!(span->arrayMask & SPAN_TEXTURE));
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
/* multitexture */
GLuint u;
span->arrayMask |= SPAN_TEXTURE;
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
const struct gl_texture_object *obj =ctx->Texture.Unit[u]._Current;
- const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
- const GLboolean needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram.Enabled;
+ GLfloat texW, texH;
+ GLboolean needLambda;
+ if (obj) {
+ const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
+ needLambda = (obj->MinFilter != obj->MagFilter)
+ || ctx->FragmentProgram.Enabled;
+ texW = img->WidthScale;
+ texH = img->HeightScale;
+ }
+ else {
+ texW = 1.0;
+ texH = 1.0;
+ needLambda = GL_FALSE;
+ }
if (needLambda) {
GLfloat (*texcoord)[4] = span->array->texcoords[u];
GLfloat *lambda = span->array->lambda[u];
- const GLfloat texW = (GLfloat) img->WidthScale;
- const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[u][0];
const GLfloat dsdy = span->texStepY[u][0];
const GLfloat dtdx = span->texStepX[u][1];
@@ -415,6 +422,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
texcoord[i][0] = s * invQ;
texcoord[i][1] = t * invQ;
texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
lambda[i] = 0.0;
s += dsdx;
t += dtdx;
@@ -427,6 +435,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
texcoord[i][0] = s * invQ;
texcoord[i][1] = t * invQ;
texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
lambda[i] = 0.0;
s += dsdx;
t += dtdx;
@@ -441,16 +450,24 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
else {
/* single texture */
const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
- const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
- const GLboolean needLambda = (obj->MinFilter != obj->MagFilter)
- || ctx->FragmentProgram.Enabled;
+ GLfloat texW, texH;
+ GLboolean needLambda;
+ if (obj) {
+ const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
+ needLambda = (obj->MinFilter != obj->MagFilter)
+ || ctx->FragmentProgram.Enabled;
+ texW = (GLfloat) img->WidthScale;
+ texH = (GLfloat) img->HeightScale;
+ }
+ else {
+ needLambda = GL_FALSE;
+ texW = texH = 1.0;
+ }
span->arrayMask |= SPAN_TEXTURE;
if (needLambda) {
/* just texture unit 0, with lambda */
GLfloat (*texcoord)[4] = span->array->texcoords[0];
GLfloat *lambda = span->array->lambda[0];
- const GLfloat texW = (GLfloat) img->WidthScale;
- const GLfloat texH = (GLfloat) img->HeightScale;
const GLfloat dsdx = span->texStepX[0][0];
const GLfloat dsdy = span->texStepY[0][0];
const GLfloat dtdx = span->texStepX[0][1];
@@ -972,6 +989,9 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
interpolate_colors(ctx, span);
span->interpMask &= ~SPAN_RGBA;
}
+ if (span->interpMask & SPAN_SPEC) {
+ interpolate_specular(ctx, span);
+ }
_swrast_exec_nv_fragment_program(ctx, span);
monoColor = GL_FALSE;
}
@@ -1154,7 +1174,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
span->primitive == GL_POLYGON || span->primitive == GL_BITMAP);
ASSERT(span->end <= MAX_WIDTH);
ASSERT((span->interpMask & span->arrayMask) == 0);
- ASSERT(ctx->Texture._EnabledUnits);
+ ASSERT(ctx->Texture._EnabledCoordUnits);
/*
printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);
@@ -1207,6 +1227,10 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0)
interpolate_colors(ctx, span);
+ if (span->interpMask & SPAN_SPEC) {
+ interpolate_specular(ctx, span);
+ }
+
/* Texturing without alpha is done after depth-testing which
* gives a potential speed-up.
*/
@@ -1262,6 +1286,10 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0)
interpolate_colors(ctx, span);
+ if (span->interpMask & SPAN_SPEC) {
+ interpolate_specular(ctx, span);
+ }
+
if (ctx->FragmentProgram.Enabled)
_swrast_exec_nv_fragment_program( ctx, span );
else
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index aee92aecbb..3c2143110c 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1,10 +1,8 @@
-/* $Id: s_triangle.c,v 1.70 2003/03/25 02:23:48 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -105,7 +103,7 @@ GLboolean _swrast_culltriangle( GLcontext *ctx,
#define INTERP_FOG 1
#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
- ASSERT(ctx->Texture._EnabledUnits == 0); \
+ ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
span.interpMask |= SPAN_RGBA; \
span.red = ChanToFixed(v2->color[0]); \
@@ -133,7 +131,7 @@ GLboolean _swrast_culltriangle( GLcontext *ctx,
#define SETUP_CODE \
{ \
/* texturing must be off */ \
- ASSERT(ctx->Texture._EnabledUnits == 0); \
+ ASSERT(ctx->Texture._EnabledCoordUnits == 0); \
ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
}
#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
@@ -1053,7 +1051,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
- if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram.Enabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
const struct gl_texture_image *texImg;
@@ -1067,7 +1065,7 @@ _swrast_choose_triangle( GLcontext *ctx )
envMode = ctx->Texture.Unit[0].EnvMode;
/* First see if we can use an optimized 2-D texture function */
- if (ctx->Texture._EnabledUnits == 1
+ if (ctx->Texture._EnabledCoordUnits == 1
&& !ctx->FragmentProgram.Enabled
&& ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
&& texObj2D->WrapS==GL_REPEAT
@@ -1112,7 +1110,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
else {
/* general case textured triangles */
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
USE(multitextured_triangle);
}
else {
@@ -1121,7 +1119,7 @@ _swrast_choose_triangle( GLcontext *ctx )
}
}
else {
- ASSERT(!ctx->Texture._EnabledUnits);
+ ASSERT(!ctx->Texture._EnabledCoordUnits);
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
if (rgbmode) {
diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h
index 1874966896..bb6f822cbc 100644
--- a/src/mesa/swrast/s_tritemp.h
+++ b/src/mesa/swrast/s_tritemp.h
@@ -1,4 +1,4 @@
-/* $Id: s_tritemp.h,v 1.48 2003/03/25 02:23:48 brianp Exp $ */
+/* $Id: s_tritemp.h,v 1.49 2003/04/08 02:27:18 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -86,7 +86,7 @@
{ \
GLuint u; \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
- if (ctx->Texture.Unit[u]._ReallyEnabled) { \
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) { \
CODE \
} \
} \