diff options
author | Brian Paul <[email protected]> | 2003-04-08 02:27:16 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-04-08 02:27:16 +0000 |
commit | 36a0a3252e1e20df69b53f70ba93bc74c4a4bf0e (patch) | |
tree | 6c680de320af7a288fe70e5a95696bcf0f5faa56 /src | |
parent | 0cebd5822a39ad3b3d7621f8e59efab329bfb5b9 (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')
-rw-r--r-- | src/mesa/array_cache/ac_import.c | 65 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 9 | ||||
-rw-r--r-- | src/mesa/main/nvfragparse.c | 17 | ||||
-rw-r--r-- | src/mesa/main/nvprogram.c | 3 | ||||
-rw-r--r-- | src/mesa/main/state.c | 28 | ||||
-rw-r--r-- | src/mesa/swrast/s_aaline.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_aatriangle.c | 8 | ||||
-rw-r--r-- | src/mesa/swrast/s_bitmap.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 4 | ||||
-rw-r--r-- | src/mesa/swrast/s_copypix.c | 2 | ||||
-rw-r--r-- | src/mesa/swrast/s_drawpix.c | 10 | ||||
-rw-r--r-- | src/mesa/swrast/s_lines.c | 7 | ||||
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 78 | ||||
-rw-r--r-- | src/mesa/swrast/s_points.c | 12 | ||||
-rw-r--r-- | src/mesa/swrast/s_span.c | 58 | ||||
-rw-r--r-- | src/mesa/swrast/s_triangle.c | 16 | ||||
-rw-r--r-- | src/mesa/swrast/s_tritemp.h | 4 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_vb.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 28 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.c | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_elt.c | 118 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 10 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 3 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_render.c | 6 |
24 files changed, 286 insertions, 234 deletions
diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index 58d2c246d04..3a2434f96bc 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -1,10 +1,8 @@ -/* $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"), @@ -183,62 +181,14 @@ static void reset_edgeflag( GLcontext *ctx ) 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); } @@ -806,13 +756,8 @@ struct gl_client_array *_ac_import_attrib( GLcontext *ctx, /* 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? */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 75117902e16..8935f0ad737 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,10 +1,8 @@ -/* $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"), @@ -1006,6 +1004,7 @@ struct gl_texture_attrib { 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; @@ -1562,7 +1561,7 @@ struct matrix_stack #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 diff --git a/src/mesa/main/nvfragparse.c b/src/mesa/main/nvfragparse.c index 5178dfd8d2b..d2c00bdfffd 100644 --- a/src/mesa/main/nvfragparse.c +++ b/src/mesa/main/nvfragparse.c @@ -1,5 +1,3 @@ -/* $Id: nvfragparse.c,v 1.19 2003/04/07 23:12:00 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -24,7 +22,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /** * \file nvfragparse.c * \brief NVIDIA fragment program parser. @@ -42,20 +39,6 @@ #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 diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c index ae0a9081edc..48b56f27e3a 100644 --- a/src/mesa/main/nvprogram.c +++ b/src/mesa/main/nvprogram.c @@ -1,5 +1,3 @@ -/* $Id: nvprogram.c,v 1.11 2003/04/05 00:38:09 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -1060,7 +1058,6 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, 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; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 000a1fd578c..ed3499c8e6c 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -1,4 +1,4 @@ -/* $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 @@ -72,6 +72,9 @@ #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" @@ -943,9 +946,30 @@ update_texture_state( GLcontext *ctx ) 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 @@ -1015,6 +1039,8 @@ void _mesa_update_state( GLcontext *ctx ) 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 diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c index 58cc1456187..bbdc92b92a5 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 b717ee77741..21b8c0437ef 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 f8fc0710994..0e20a20d7fb 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 e36da390302..79ee5b440fa 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 b66cad2dad3..15cedb4c1dd 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 bc791b90784..008b60dcff9 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 c3c5c582f15..a9284d50297 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 b34703b8579..8ab65b8e324 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 640a70ac92b..1b5e502f412 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 d6959e1f4c9..231e549c5ae 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 aee92aecbb1..3c2143110c8 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 18749668961..bb6f822cbcf 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 \ } \ } \ diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c index 71a6b1f7cfe..fa4993434a0 100644 --- a/src/mesa/swrast_setup/ss_vb.c +++ b/src/mesa/swrast_setup/ss_vb.c @@ -1,10 +1,8 @@ -/* $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"), @@ -389,9 +387,9 @@ _swsetup_choose_rastersetup_func(GLcontext *ctx) 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) diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 2a8506aa424..fbcb9b33100 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $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 @@ -363,6 +363,22 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) _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; @@ -418,14 +434,4 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei 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]; - } - } } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 6e8f48aaecd..0b5e575ceaf 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,4 +1,4 @@ -/* $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 @@ -162,7 +162,9 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) 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 */ } diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c index 6ae30ea45b4..74958649c5a 100644 --- a/src/mesa/tnl/t_imm_elt.c +++ b/src/mesa/tnl/t_imm_elt.c @@ -753,7 +753,8 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, 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); @@ -774,57 +775,97 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, } } + 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); } } @@ -840,9 +881,12 @@ void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM, 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; } diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 3c56e2ede28..a50922330f0 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -1,4 +1,4 @@ -/* $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 @@ -85,7 +85,9 @@ static void reset_input( GLcontext *ctx, 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; } @@ -486,7 +488,9 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) } 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 { diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 7fb4d4753ea..cf3aa2ed963 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -367,7 +367,8 @@ _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) 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 */ diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index c0e2bf26b09..bbfa1ae704f 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $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 @@ -352,9 +352,9 @@ static void check_render( GLcontext *ctx, struct gl_pipeline_stage *stage ) 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); } } |