Fixed some vertex array / vertex program glitches with glDrawElements.
Fixed some fragment program runtime bugs.
Non-trivial Cg programs are running now.
-/* $Id: ac_import.c,v 1.23 2003/03/01 01:50:24 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"),
static void reset_attrib( GLcontext *ctx, GLuint index )
{
ACcontext *ac = AC_CONTEXT(ctx);
- GLboolean fallback = GL_FALSE;
- /*
- * The 16 NV vertex attribute arrays have top priority. If one of those
- * is not enabled, look if a corresponding conventional array is enabled.
- * If nothing else, use the fallback (ctx->Current.Attrib) values.
- */
- if (ctx->Array._Enabled & _NEW_ARRAY_ATTRIB(index)) {
+ if (ctx->Array.VertexAttrib[index].Enabled) {
ac->Raw.Attrib[index] = ctx->Array.VertexAttrib[index];
STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
}
- else if (ctx->Array._Enabled & (1 << index)) {
- /* use conventional vertex array if possible */
- if (index == VERT_ATTRIB_POS) {
- ac->Raw.Attrib[index] = ctx->Array.Vertex;
- }
- else if (index == VERT_ATTRIB_NORMAL) {
- ac->Raw.Attrib[index] = ctx->Array.Normal;
- }
- else if (index == VERT_ATTRIB_COLOR0) {
- ac->Raw.Attrib[index] = ctx->Array.Color;
- }
- else if (index == VERT_ATTRIB_COLOR1) {
- ac->Raw.Attrib[index] = ctx->Array.SecondaryColor;
- }
- else if (index == VERT_ATTRIB_FOG) {
- ac->Raw.Attrib[index] = ctx->Array.FogCoord;
- }
- else if (index >= VERT_ATTRIB_TEX0 && index <= VERT_ATTRIB_TEX7) {
- GLuint unit = index - VERT_ATTRIB_TEX0;
- ASSERT(unit < MAX_TEXTURE_COORD_UNITS);
- ac->Raw.Attrib[index] = ctx->Array.TexCoord[unit];
- }
- else {
- /* missing conventional array (vertex weight, for example) */
- fallback = GL_TRUE;
- }
- if (!fallback)
- STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
- }
- else {
- fallback = GL_TRUE;
- }
-
- if (fallback) {
- /* fallback to ctx->Current.Attrib values */
+ else
ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
- if (ctx->Current.Attrib[index][3] != 1.0)
- ac->Raw.Attrib[index].Size = 4;
- else if (ctx->Current.Attrib[index][2] != 0.0)
- ac->Raw.Attrib[index].Size = 3;
- else
- ac->Raw.Attrib[index].Size = 2;
- }
-
ac->IsCached.Attrib[index] = GL_FALSE;
ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index);
}
/* Can we keep the existing version?
*/
- if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index)) {
+ if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
reset_attrib( ctx, index );
- }
- else if (ac->NewArrayState & (1 << index)) {
- /* Also need to check conventional attributes */
- reset_attrib( ctx, index );
- }
/* Is the request impossible?
*/
-/* $Id: mtypes.h,v 1.109 2003/04/05 00:38:09 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"),
GLuint CurrentUnit; /* Active texture unit */
GLuint _EnabledUnits; /* one bit set for each really-enabled unit */
+ GLuint _EnabledCoordUnits; /* one bit per enabled coordinate unit */
GLuint _GenFlags; /* for texgen */
GLuint _TexGenEnabled;
GLuint _TexMatEnabled;
#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
-#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
+#define _NEW_ARRAY_ATTRIB_0 0x1 /* alias conventional arrays */
#define _NEW_ARRAY_ALL 0xffffffff
-/* $Id: nvfragparse.c,v 1.19 2003/04/07 23:12:00 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-
/**
* \file nvfragparse.c
* \brief NVIDIA fragment program parser.
#include "nvprogram.h"
-/* XXX move into imports.[ch] eventually */
-static void *
-_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
-{
- size_t copySize = MIN2(oldSize, newSize);
- void *newBuffer = _mesa_malloc(newSize);
- if (newBuffer && copySize > 0)
- _mesa_memcpy(newBuffer, oldBuffer, copySize);
- if (oldBuffer)
- _mesa_free(oldBuffer);
- return newBuffer;
-}
-
-
#define INPUT_1V 1
#define INPUT_2V 2
#define INPUT_3V 3
-/* $Id: nvprogram.c,v 1.11 2003/04/05 00:38:09 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
fragProg = (struct fragment_program *) prog;
for (i = 0; i < fragProg->NumParameters; i++) {
- printf("test %d %s\n", i, fragProg->Parameters[i].Name);
if (!_mesa_strcmp(fragProg->Parameters[i].Name, (const char *) name)) {
ASSERT(!fragProg->Parameters[i].Constant);
fragProg->Parameters[i].Values[0] = x;
-/* $Id: state.c,v 1.102 2003/03/29 17:01:01 brianp Exp $ */
+/* $Id: state.c,v 1.103 2003/04/08 02:27:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
#include "nvprogram.h"
#endif
+#if FEATURE_NV_fragment_program
+#include "nvfragprog.h"
+#endif
#include "math/m_matrix.h"
#include "math/m_xform.h"
if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) {
ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN;
}
+
+ ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
+ /* Fragment programs may need texture coordinates but not the
+ * corresponding texture images.
+ */
+ if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) {
+ ctx->Texture._EnabledCoordUnits |=
+ (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0);
+ }
}
+/*
+ * Update items which depend on vertex/fragment programs.
+ */
+static void
+update_program( GLcontext *ctx )
+{
+ if (ctx->FragmentProgram.Enabled && ctx->FragmentProgram.Current) {
+ if (ctx->FragmentProgram.Current->InputsRead & (1 << FRAG_ATTRIB_COL1))
+ ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
+ }
+}
+
/*
* If ctx->NewState is non-zero then this function MUST be called before
ctx->_NeedEyeCoords |= NEED_EYE_LIGHT_MODELVIEW;
}
+ if (new_state & _NEW_PROGRAM)
+ update_program( ctx );
#if 0
/* XXX this is a bit of a hack. We should be checking elsewhere if
-/* $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.
*
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)
-/* $Id: s_aatriangle.c,v 1.31 2003/03/25 02:23:44 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
{
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 {
}
}
else {
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
}
else {
-/* $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"),
_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++) {
_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++) {
-/* $Id: s_context.c,v 1.48 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
/* 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));
-/* $Id: s_copypix.c,v 1.44 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
-/* $Id: s_drawpix.c,v 1.47 2003/03/25 02:23:45 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
_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) {
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
_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
-/* $Id: s_lines.c,v 1.36 2003/03/25 02:23:46 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
_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);
}
-/* $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
*/
-
#include "glheader.h"
#include "colormac.h"
#include "context.h"
#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]);
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);
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;
*/
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];
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];
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:
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;
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 */
{
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 );
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 */
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;
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;
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);
}
}
}
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 */
-/* $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"),
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 {
}
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);
}
USE(atten_general_ci_point);
}
}
- else if (ctx->Texture._EnabledUnits && rgbMode) {
+ else if (ctx->Texture._EnabledCoordUnits && rgbMode) {
/* textured */
USE(textured_rgba_point);
}
-/* $Id: s_span.c,v 1.60 2003/03/25 02:23:47 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
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];
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;
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;
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];
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;
}
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);
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.
*/
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
-/* $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"),
#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]); \
#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);
}
}
- 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;
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
}
else {
/* general case textured triangles */
- if (ctx->Texture._EnabledUnits > 1) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
USE(multitextured_triangle);
}
else {
}
}
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) {
-/* $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
{ \
GLuint u; \
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
- if (ctx->Texture.Unit[u]._ReallyEnabled) { \
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) { \
CODE \
} \
} \
-/* $Id: ss_vb.c,v 1.22 2002/10/29 20:29:00 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"),
if (ctx->Visual.rgbMode) {
funcindex = COLOR;
- if (ctx->Texture._EnabledUnits > 1)
+ if (ctx->Texture._EnabledCoordUnits > 1)
funcindex |= MULTITEX; /* a unit above unit[0] is enabled */
- else if (ctx->Texture._EnabledUnits == 1)
+ else if (ctx->Texture._EnabledCoordUnits == 1)
funcindex |= TEX0; /* only unit 0 is enabled */
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
-/* $Id: t_array_import.c,v 1.28 2003/03/01 01:50:26 brianp Exp $ */
+/* $Id: t_array_import.c,v 1.29 2003/04/08 02:27:19 brianp Exp $ */
/*
* Mesa 3-D graphics library
_ac_import_range( ctx, start, count );
+ /* When vertex program mode is enabled, the generic vertex program
+ * attribute arrays have priority over the conventional attributes.
+ * Try to use them now.
+ */
+ if (ctx->VertexProgram.Enabled) {
+ GLuint index;
+ for (index = 0; index < VERT_ATTRIB_MAX; index++) {
+ /* XXX check program->InputsRead to reduce work here */
+ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
+ VB->AttribPtr[index] = &tmp->Attribs[index];
+ }
+ }
+
+ /*
+ * Conventional attributes
+ */
if (inputs & VERT_BIT_POS) {
_tnl_import_vertex( ctx, 0, 0 );
tmp->Obj.count = VB->Count;
VB->SecondaryColorPtr[1] = 0;
}
}
-
- /* XXX not 100% sure this is finished. Keith should probably inspect. */
- if (ctx->VertexProgram.Enabled) {
- GLuint index;
- for (index = 0; index < VERT_ATTRIB_MAX; index++) {
- /* XXX check program->InputsRead to reduce work here */
- _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
- VB->AttribPtr[index] = &tmp->Attribs[index];
- }
- }
}
-/* $Id: t_context.c,v 1.31 2003/02/04 14:40:56 brianp Exp $ */
+/* $Id: t_context.c,v 1.32 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
IM->ArrayEltFlags = ~ctx->Array._Enabled;
IM->ArrayEltFlush = (ctx->Array.LockCount
? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER);
- IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
+ IM->ArrayEltIncr = (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled)) ? 1 : 0;
tnl->pipeline.run_input_changes |= ctx->Array.NewState; /* overkill */
}
GLuint *flags = IM->Flag;
const GLuint *elts = IM->Elt;
GLuint translate = ctx->Array._Enabled;
- GLuint i, attr;
+ GLuint translateConventional;
+ GLuint attr;
if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
_mesa_debug(ctx, "exec_array_elements %d .. %d\n", start, count);
}
}
+ translateConventional = translate;
- if (translate & VERT_BIT_POS) {
+ /*
+ * When vertex program mode is enabled, the generic vertex attribute arrays
+ * have priority over the conventional arrays. Process those arrays now.
+ * When we're done here, translateConventional will indicate which
+ * conventional arrays still have to be translated when we're done.
+ */
+ if (ctx->VertexProgram.Enabled) {
+ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ const GLuint attrBit = 1 << attr;
+ if ((translate & attrBit) && ctx->Array.VertexAttrib[attr].Enabled) {
+ _tnl_trans_elt_4f( IM->Attrib[attr],
+ &ctx->Array.VertexAttrib[attr],
+ flags, elts, (VERT_BIT_ELT | attrBit),
+ start, count);
+ /* special case stuff */
+ if (attr == VERT_ATTRIB_POS) {
+ if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 4)
+ translate |= VERT_BITS_OBJ_234;
+ else if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 3)
+ translate |= VERT_BITS_OBJ_23;
+ }
+ else if (attr >= VERT_ATTRIB_TEX0 && attr <= VERT_ATTRIB_TEX7) {
+ if (ctx->Array.VertexAttrib[attr].Size == 4)
+ IM->TexSize |= TEX_SIZE_4(attr - VERT_ATTRIB_TEX0);
+ else if (ctx->Array.VertexAttrib[attr].Size == 3)
+ IM->TexSize |= TEX_SIZE_3(attr - VERT_ATTRIB_TEX0);
+ }
+ /* override the conventional array */
+ translateConventional &= ~attrBit;
+ }
+ }
+ }
+
+ /*
+ * Check which conventional arrays are needed.
+ */
+ if (translateConventional & VERT_BIT_POS) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_POS],
- &ctx->Array.Vertex,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
- start, count);
+ &ctx->Array.Vertex,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
+ start, count);
if (ctx->Array.Vertex.Size == 4)
- translate |= VERT_BITS_OBJ_234;
+ translate |= VERT_BITS_OBJ_234;
else if (ctx->Array.Vertex.Size == 3)
- translate |= VERT_BITS_OBJ_23;
+ translate |= VERT_BITS_OBJ_23;
}
- if (translate & VERT_BIT_NORMAL)
+ if (translateConventional & VERT_BIT_NORMAL) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_NORMAL],
- &ctx->Array.Normal,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
- start, count);
+ &ctx->Array.Normal,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
+ start, count);
+ }
- if (translate & VERT_BIT_COLOR0) {
+ if (translateConventional & VERT_BIT_COLOR0) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR0],
- &ctx->Array.Color,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
- start, count);
+ &ctx->Array.Color,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
+ start, count);
}
- if (translate & VERT_BIT_COLOR1) {
+ if (translateConventional & VERT_BIT_COLOR1) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR1],
- &ctx->Array.SecondaryColor,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
- start, count);
+ &ctx->Array.SecondaryColor,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
+ start, count);
}
- if (translate & VERT_BIT_FOG)
+ if (translateConventional & VERT_BIT_FOG) {
_tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_FOG],
- &ctx->Array.FogCoord,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
- start, count);
+ &ctx->Array.FogCoord,
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
+ start, count);
+ }
- if (translate & VERT_BITS_TEX_ANY) {
+ if (translateConventional & VERT_BITS_TEX_ANY) {
+ GLuint i;
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
- if (translate & VERT_BIT_TEX(i)) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
- &ctx->Array.TexCoord[i],
- flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
- start, count);
-
- if (ctx->Array.TexCoord[i].Size == 4)
- IM->TexSize |= TEX_SIZE_4(i);
- else if (ctx->Array.TexCoord[i].Size == 3)
- IM->TexSize |= TEX_SIZE_3(i);
+ if (translateConventional & VERT_BIT_TEX(i)) {
+ _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
+ &ctx->Array.TexCoord[i],
+ flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
+ start, count);
+
+ if (ctx->Array.TexCoord[i].Size == 4)
+ IM->TexSize |= TEX_SIZE_4(i);
+ else if (ctx->Array.TexCoord[i].Size == 3)
+ IM->TexSize |= TEX_SIZE_3(i);
}
}
flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG),
start, count);
- for (i = start ; i < count ; i++)
- if (flags[i] & VERT_BIT_ELT)
- flags[i] |= translate;
+ {
+ GLuint i;
+ for (i = start ; i < count ; i++)
+ if (flags[i] & VERT_BIT_ELT)
+ flags[i] |= translate;
+ }
IM->FlushElt = 0;
}
-/* $Id: t_imm_exec.c,v 1.45 2003/04/07 14:53:28 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.46 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
IM->MaterialMask[IM->Start] = 0;
IM->ArrayEltFlags = ~ctx->Array._Enabled;
- IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0;
+ IM->ArrayEltIncr = (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled)) ? 1 : 0;
IM->ArrayEltFlush = ctx->Array.LockCount ? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER;
}
}
else if ((IM->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT &&
ctx->Array.LockCount &&
- ctx->Array.Vertex.Enabled) {
+ (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled &&
+ ctx->Array.VertexAttrib[0].Enabled))) {
exec_elt_cassette( ctx, IM );
}
else {
if ((prev->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT &&
ctx->Array.LockCount &&
- ctx->Array.Vertex.Enabled)
+ (ctx->Array.Vertex.Enabled ||
+ (ctx->VertexProgram.Enabled && ctx->Array.VertexAttrib[0].Enabled)))
{
/* Copy Elt values only
*/
-/* $Id: t_vb_render.c,v 1.34 2003/03/01 01:50:27 brianp Exp $ */
+/* $Id: t_vb_render.c,v 1.35 2003/04/08 02:27:20 brianp Exp $ */
/*
* Mesa 3-D graphics library
if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
inputs |= VERT_BIT_COLOR1;
- if (ctx->Texture._EnabledUnits) {
+ if (ctx->Texture._EnabledCoordUnits) {
for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
- if (ctx->Texture.Unit[i]._ReallyEnabled)
+ if (ctx->Texture._EnabledCoordUnits & (1 << i))
inputs |= VERT_BIT_TEX(i);
}
}