diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/dd.h | 11 | ||||
-rw-r--r-- | src/mesa/main/light.c | 66 | ||||
-rw-r--r-- | src/mesa/main/light.h | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 162 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 5 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 7 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_alloc.c | 8 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_api.c | 21 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_dlist.c | 79 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.c | 59 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_exec.h | 6 | ||||
-rw-r--r-- | src/mesa/tnl/t_imm_fixup.c | 19 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.c | 7 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_normals.c | 11 |
14 files changed, 218 insertions, 249 deletions
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 4d4264978f3..818a6143f2d 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -1,4 +1,4 @@ -/* $Id: dd.h,v 1.51 2001/02/06 21:42:48 brianp Exp $ */ +/* $Id: dd.h,v 1.52 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -815,6 +815,15 @@ struct dd_function_table { void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr); + /*** + *** TNL Pipeline + ***/ + + void (*PipelineStart)(GLcontext *ctx); + void (*PipelineFinish)(GLcontext *ctx); + /* Called before and after all pipeline stages. + * These are a suitable place for grabbing/releasing hardware locks. + */ /*** *** Rendering diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 50bd041f190..155792af52b 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,4 +1,4 @@ -/* $Id: light.c,v 1.36 2001/02/13 23:55:30 brianp Exp $ */ +/* $Id: light.c,v 1.37 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -535,6 +535,54 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, } +/* Perform a straight copy between pairs of materials. + */ +void gl_copy_material_pairs( struct gl_material dst[2], + const struct gl_material src[2], + GLuint bitmask ) +{ + if (bitmask & FRONT_EMISSION_BIT) { + COPY_4FV( dst[0].Emission, src[0].Emission ); + } + if (bitmask & BACK_EMISSION_BIT) { + COPY_4FV( dst[1].Emission, src[1].Emission ); + } + if (bitmask & FRONT_AMBIENT_BIT) { + COPY_4FV( dst[0].Ambient, src[0].Ambient ); + } + if (bitmask & BACK_AMBIENT_BIT) { + COPY_4FV( dst[1].Ambient, src[1].Ambient ); + } + if (bitmask & FRONT_DIFFUSE_BIT) { + COPY_4FV( dst[0].Diffuse, src[0].Diffuse ); + } + if (bitmask & BACK_DIFFUSE_BIT) { + COPY_4FV( dst[1].Diffuse, src[1].Diffuse ); + } + if (bitmask & FRONT_SPECULAR_BIT) { + COPY_4FV( dst[0].Specular, src[0].Specular ); + } + if (bitmask & BACK_SPECULAR_BIT) { + COPY_4FV( dst[1].Specular, src[1].Specular ); + } + if (bitmask & FRONT_SHININESS_BIT) { + dst[0].Shininess = src[0].Shininess; + } + if (bitmask & BACK_SHININESS_BIT) { + dst[1].Shininess = src[1].Shininess; + } + if (bitmask & FRONT_INDEXES_BIT) { + dst[0].AmbientIndex = src[0].AmbientIndex; + dst[0].DiffuseIndex = src[0].DiffuseIndex; + dst[0].SpecularIndex = src[0].SpecularIndex; + } + if (bitmask & BACK_INDEXES_BIT) { + dst[1].AmbientIndex = src[1].AmbientIndex; + dst[1].DiffuseIndex = src[1].DiffuseIndex; + dst[1].SpecularIndex = src[1].SpecularIndex; + } +} + /* * Check if the global material has to be updated with info that was @@ -545,11 +593,7 @@ GLuint gl_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, * * src[0] is front material, src[1] is back material * - * KW: Added code here to keep the precomputed variables uptodate. - * This means we can use the faster shade functions when using - * GL_COLOR_MATERIAL, and we can also now use the precomputed - * values in the slower shading functions, which further offsets - * the cost of doing this here. + * Additionally keeps the precomputed lighting state uptodate. */ void gl_update_material( GLcontext *ctx, const struct gl_material src[2], @@ -610,9 +654,6 @@ void gl_update_material( GLcontext *ctx, if (bitmask & FRONT_DIFFUSE_BIT) { struct gl_material *mat = &ctx->Light.Material[0]; COPY_4FV( mat->Diffuse, src[0].Diffuse ); -/* fprintf(stderr, "FRONT_DIFFUSE %f %f %f %f\n", */ -/* mat->Diffuse[0], mat->Diffuse[1], */ -/* mat->Diffuse[2], mat->Diffuse[3]); */ foreach (light, list) { SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); } @@ -621,9 +662,6 @@ void gl_update_material( GLcontext *ctx, if (bitmask & BACK_DIFFUSE_BIT) { struct gl_material *mat = &ctx->Light.Material[1]; COPY_4FV( mat->Diffuse, src[1].Diffuse ); -/* fprintf(stderr, "BACK_DIFFUSE %f %f %f %f\n", */ -/* mat->Diffuse[0], mat->Diffuse[1], */ -/* mat->Diffuse[2], mat->Diffuse[3]); */ foreach (light, list) { SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); } @@ -647,7 +685,6 @@ void gl_update_material( GLcontext *ctx, } if (bitmask & FRONT_SHININESS_BIT) { -/* fprintf(stderr, "FRONT_SHININESS_BIT %f\n", src[0].Shininess); */ ctx->Light.Material[0].Shininess = src[0].Shininess; gl_invalidate_shine_table( ctx, 0 ); } @@ -692,6 +729,9 @@ void gl_update_material( GLcontext *ctx, + + + /* * Update the current materials from the given rgba color * according to the bitmask in ColorMaterialBitmask, which is diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index b39aa002d87..38ca33815f8 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -1,4 +1,4 @@ -/* $Id: light.h,v 1.9 2001/02/06 04:06:35 keithw Exp $ */ +/* $Id: light.h,v 1.10 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -114,6 +114,10 @@ extern void gl_update_material( GLcontext *ctx, const struct gl_material src[2], GLuint bitmask ); +extern void gl_copy_material_pairs( struct gl_material dst[2], + const struct gl_material src[2], + GLuint bitmask ); + extern void gl_update_color_material( GLcontext *ctx, const GLchan rgba[4] ); diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 0c61dee780e..900467c98d0 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.5 2001/02/04 00:44:36 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.6 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -90,6 +90,79 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, } +static void _tnl_draw_elements( GLcontext *ctx, GLenum mode, GLsizei count, + const GLuint *indices) +{ +#if 1 + /* Optimized code that fakes the effect of calling + * _tnl_array_element for each index in the list. + */ + if (_tnl_hard_begin( ctx, mode )) { + GLuint i,j; + for (j = 0 ; j < count ; ) { + struct immediate *IM = TNL_CURRENT_IM(ctx); + GLuint start = IM->Start; + GLuint nr = MIN2( IMM_MAXDATA - start, count - j ) + start; + GLuint sf = IM->Flag[start]; + IM->FlushElt |= 1; + + for (i = start ; i < nr ; i++) { + IM->Elt[i] = (GLuint) *indices++; + IM->Flag[i] = VERT_ELT; + } + + if (j == 0) IM->Flag[start] |= sf; + + IM->Count = nr; + j += nr - start; + + if (j == count) + _tnl_end( ctx ); + + _tnl_flush_immediate( IM ); + } + } +#else + /* Simple version of the above code. + */ + if (_tnl_hard_begin(ctx, mode)) { + GLuint i; + for (i = 0 ; i < count ; i++) + _tnl_array_element( ctx, indices[i] ); + _tnl_end( ctx ); + } +#endif +} + + +static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, + GLuint start, GLuint end, + GLsizei count, const GLuint *indices ) + +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); + FLUSH_CURRENT( ctx, 0 ); + + _tnl_vb_bind_arrays( ctx, start, end ); + + tnl->vb.FirstPrimitive = 0; + tnl->vb.Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + tnl->vb.PrimitiveLength[0] = count; + tnl->vb.Elts = (GLuint *)indices; + + if (ctx->Array.LockCount) + _tnl_run_pipeline( ctx ); + else { + /* Note that arrays may have changed before/after execution. + */ + tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + _tnl_run_pipeline( ctx ); + tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + } +} + + + void _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) @@ -162,81 +235,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) } - -static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, - GLuint start, GLuint end, - GLsizei count, const GLuint *indices ) - -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - FLUSH_CURRENT( ctx, 0 ); - - _tnl_vb_bind_arrays( ctx, start, end ); - - tnl->vb.FirstPrimitive = 0; - tnl->vb.Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; - tnl->vb.PrimitiveLength[0] = count; - tnl->vb.Elts = (GLuint *)indices; - - if (ctx->Array.LockCount) - _tnl_run_pipeline( ctx ); - else { - /* Note that arrays may have changed before/after execution. - */ - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; - _tnl_run_pipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; - } -} - - - - -static void _tnl_draw_elements( GLcontext *ctx, GLenum mode, GLsizei count, - const GLuint *indices) -{ -#if 1 - /* Optimized code that fakes the effect of calling - * _tnl_array_element for each index in the list. - */ - if (_tnl_hard_begin( ctx, mode )) { - GLuint i,j; - for (j = 0 ; j < count ; ) { - struct immediate *IM = TNL_CURRENT_IM(ctx); - GLuint start = IM->Start; - GLuint nr = MIN2( IMM_MAXDATA - start, count - j ) + start; - GLuint sf = IM->Flag[start]; - IM->FlushElt |= 1; - - for (i = start ; i < nr ; i++) { - IM->Elt[i] = (GLuint) *indices++; - IM->Flag[i] = VERT_ELT; - } - - if (j == 0) IM->Flag[start] |= sf; - - IM->Count = nr; - j += nr - start; - - if (j == count) - _tnl_end( ctx ); - - _tnl_flush_immediate( IM ); - } - } -#else - /* Simple version of the above code. - */ - if (_tnl_hard_begin(ctx, mode)) { - GLuint i; - for (i = 0 ; i < count ; i++) - _tnl_array_element( ctx, indices[i] ); - _tnl_end( ctx ); - } -#endif -} - - void _tnl_DrawRangeElements(GLenum mode, GLuint start, GLuint end, @@ -276,6 +274,8 @@ _tnl_DrawRangeElements(GLenum mode, * May be able to get away with just setting LockCount==0, * though this raises the problems of dependent state. May * have to call glUnlockArrays() directly? + * + * Or scan the list and replace bad indices? */ gl_problem( ctx, "DrawRangeElements references " @@ -283,8 +283,8 @@ _tnl_DrawRangeElements(GLenum mode, } } else if (end + 1 - start < ctx->Const.MaxArrayLockSize) { - /* The arrays aren't locked but we can still fit them inside a single - * vertexbuffer. + /* The arrays aren't locked but we can still fit them inside a + * single vertexbuffer. */ _tnl_draw_range_elements( ctx, mode, start, end + 1, count, ui_indices ); } else { @@ -315,7 +315,6 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT, count, type, indices ); -#if 1 if (ctx->Array.LockCount) { _tnl_draw_range_elements( ctx, mode, ctx->Array.LockFirst, @@ -333,13 +332,10 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, if (max_elt < ctx->Const.MaxArrayLockSize && /* can we use it? */ max_elt < count) /* do we want to use it? */ - _tnl_draw_range_elements( ctx, mode, 0, max_elt + 1, count, ui_indices ); + _tnl_draw_range_elements( ctx, mode, 0, max_elt+1, count, ui_indices ); else _tnl_draw_elements( ctx, mode, count, ui_indices ); } -#else - _tnl_draw_elements( ctx, mode, count, ui_indices ); -#endif } diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index b88391c8522..6aec1b0be6a 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.7 2001/01/24 00:04:59 brianp Exp $ */ +/* $Id: t_array_import.c,v 1.8 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -316,6 +316,9 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) GLuint imports; struct vertex_arrays *tmp = &tnl->array_inputs; +/* fprintf(stderr, "_tnl_vb_bind_arrays %d..%d // %d..%d\n", */ +/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */ + if (ctx->Array.LockCount) { ASSERT(start == ctx->Array.LockFirst); ASSERT(count == ctx->Array.LockCount); diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index c15dd130876..a1707673422 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.13 2001/01/29 20:47:39 keithw Exp $ */ +/* $Id: t_context.h,v 1.14 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -192,7 +192,9 @@ struct immediate */ struct gl_material (*Material)[2]; GLuint *MaterialMask; - GLfloat *NormalLengths; + GLuint LastMaterial; + GLuint MaterialOrMask; + GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4]; GLuint Primitive[IMM_SIZE]; /* BEGIN/END */ @@ -258,7 +260,6 @@ typedef struct vertex_buffer GLubyte ClipOrMask; /* VERT_CLIP (3) */ GLubyte *ClipMask; /* VERT_CLIP (4) */ GLvector3f *NormalPtr; /* VERT_NORM */ - GLfloat *NormalLengthPtr; /* VERT_NORM (optional) */ GLboolean *EdgeFlag; /* VERT_EDGE */ GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */ GLvector1ui *IndexPtr[2]; /* VERT_INDEX */ diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c index e6a37f81015..b63d0096a3e 100644 --- a/src/mesa/tnl/t_imm_alloc.c +++ b/src/mesa/tnl/t_imm_alloc.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_alloc.c,v 1.2 2000/12/28 22:11:05 keithw Exp $ */ +/* $Id: t_imm_alloc.c,v 1.3 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -47,7 +47,6 @@ struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) IM->id = id++; IM->ref_count = 0; IM->backref = ctx; - IM->NormalLengths = 0; IM->FlushElt = 0; IM->LastPrimitive = IMM_MAX_COPIED_VERTS; IM->Count = IMM_MAX_COPIED_VERTS; @@ -83,11 +82,6 @@ void _tnl_free_immediate( struct immediate *IM ) static int freed = 0; GLuint j; - if (IM->NormalLengths) { - FREE( IM->NormalLengths ); - IM->NormalLengths = 0; - } - if (IM->Material) { FREE( IM->Material ); FREE( IM->MaterialMask ); diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 0ba46b9b7c8..5dd287cedcc 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1229,17 +1229,24 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (bitmask == 0) return; - if (!IM->Material) { - IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) * - IMM_SIZE * 2 ); - IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); - } - if (!(IM->Flag[count] & VERT_MATERIAL)) { + if (!IM->Material) { + IM->Material = (GLmaterial (*)[2]) MALLOC( sizeof(GLmaterial) * + IMM_SIZE * 2 ); + IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); + } + else if (IM->MaterialOrMask & ~bitmask) { + gl_copy_material_pairs( IM->Material[count], + IM->Material[IM->LastMaterial], + IM->MaterialOrMask & ~bitmask ); + } + IM->Flag[count] |= VERT_MATERIAL; + IM->LastMaterial = count; IM->MaterialMask[count] = 0; } - + + IM->MaterialOrMask |= bitmask; IM->MaterialMask[count] |= bitmask; mat = IM->Material[count]; diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index 3cd08ba4c11..c0393cec9ad 100644 --- a/src/mesa/tnl/t_imm_dlist.c +++ b/src/mesa/tnl/t_imm_dlist.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_dlist.c,v 1.7 2001/02/13 23:51:34 brianp Exp $ */ +/* $Id: t_imm_dlist.c,v 1.8 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -57,7 +57,8 @@ typedef struct { GLuint TexSize; GLuint LastData; GLuint LastPrimitive; - GLboolean have_normal_lengths; + GLuint LastMaterial; + GLuint MaterialOrMask; } TNLvertexcassette; static void execute_compiled_cassette( GLcontext *ctx, void *data ); @@ -121,7 +122,8 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) node->AndFlag = im->AndFlag; node->LastData = im->LastData; node->LastPrimitive = im->LastPrimitive; - node->have_normal_lengths = GL_FALSE; + node->LastMaterial = im->LastMaterial; + node->MaterialOrMask = im->MaterialOrMask; if (ctx->ExecuteFlag) { execute_compiled_cassette( ctx, (void *)node ); @@ -155,34 +157,6 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) } - -#if 0 -/* Drivers to turn this on? - */ -static void calc_normal_lengths( GLfloat *dest, - CONST GLfloat (*data)[3], - GLuint *flags, - GLuint count ) -{ - GLuint i; - GLint tmpflag = flags[0]; - - flags[0] |= VERT_NORM; - - for (i = 0 ; i < count ; i++ ) - if (flags[i] & VERT_NORM) { - GLfloat tmp = (GLfloat) LEN_3FV( data[i] ); - dest[i] = 0; - if (tmp > 0) - dest[i] = 1.0F / tmp; - } else - dest[i] = dest[i-1]; - - flags[0] = tmpflag; -} -#endif - - static void execute_compiled_cassette( GLcontext *ctx, void *data ) { @@ -219,7 +193,7 @@ execute_compiled_cassette( GLcontext *ctx, void *data ) } if (IM->Count == IM->Start) { - _tnl_run_empty_cassette( ctx, IM ); + _tnl_copy_to_current( ctx, IM, IM->OrFlag ); return; } @@ -227,40 +201,16 @@ execute_compiled_cassette( GLcontext *ctx, void *data ) if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) tnl->ReplayHardBeginEnd = 1; if (!tnl->ReplayHardBeginEnd) { - /* XXX is this really an OpenGL error or an implementation problem? */ + /* This is a user error. Whatever operation (like glRectf) + * decomposed to this hard begin/end pair is now being run + * inside a begin/end object -- illegally. Reject it and + * raise an error. + */ gl_error(ctx, GL_INVALID_OPERATION, "hard replay"); return; } } - - /* Lazy optimization of the cassette. Need to make these switchable - * or otherwise more useful for t&l cards. - */ -#if 0 - if (ctx->Transform.Normalize && !node->have_normal_lengths) { - - if (!IM->NormalLengths) - IM->NormalLengths = (GLfloat *)MALLOC(sizeof(GLfloat) * IMM_SIZE); - - calc_normal_lengths( IM->NormalLengths + IM->Start, - (const GLfloat (*)[3])(IM->Normal + IM->Start), - IM->Flag + IM->Start, - IM->Count - IM->Start); - - node->have_normal_lengths = GL_TRUE; - } -#endif - - -#if 0 - if (0 && im->v.Obj.size < 4 && im->Count > 15) { - im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat)); - (_tnl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj ); - } -#endif - - _tnl_fixup_compiled_cassette( ctx, IM ); _tnl_get_exec_copy_verts( ctx, IM ); _tnl_run_cassette( ctx, IM ); @@ -275,10 +225,6 @@ destroy_compiled_cassette( GLcontext *ctx, void *data ) { TNLvertexcassette *node = (TNLvertexcassette *)data; -/* fprintf(stderr, "destroy_compiled_cassette node->IM id %d ref_count: %d\n", */ -/* node->IM->id, */ -/* node->IM->ref_count-1); */ - if ( --node->IM->ref_count == 0 ) _tnl_free_immediate( node->IM ); } @@ -301,6 +247,8 @@ print_compiled_cassette( GLcontext *ctx, void *data ) IM->AndFlag = node->AndFlag; IM->LastData = node->LastData; IM->LastPrimitive = node->LastPrimitive; + IM->LastMaterial = node->LastMaterial; + IM->MaterialOrMask = node->MaterialOrMask; _tnl_print_cassette( node->IM ); } @@ -359,7 +307,6 @@ _tnl_EndList( GLcontext *ctx ) tnl->ExecCopySource = IM; IM->ref_count++; - SET_IMMEDIATE( ctx, IM ); IM->ref_count++; diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 215749beb9b..80e5ce54400 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.10 2001/02/06 21:42:49 brianp Exp $ */ +/* $Id: t_imm_exec.c,v 1.11 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -84,8 +84,8 @@ void _tnl_reset_input( GLcontext *ctx, -static void copy_to_current( GLcontext *ctx, struct immediate *IM, - GLuint flag ) +void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, + GLuint flag ) { GLuint count = IM->LastData; @@ -101,8 +101,13 @@ static void copy_to_current( GLcontext *ctx, struct immediate *IM, if (flag & VERT_EDGE) ctx->Current.EdgeFlag = IM->EdgeFlag[count]; - if (flag & VERT_RGBA) + if (flag & VERT_RGBA) { COPY_4UBV(ctx->Current.Color, IM->Color[count]); + if (ctx->Light.ColorMaterialEnabled) { + gl_update_color_material( ctx, ctx->Current.Color ); + gl_validate_all_lighting_tables( ctx ); + } + } if (flag & VERT_SPEC_RGB) COPY_4UBV(ctx->Current.SecondaryColor, IM->SecondaryColor[count]); @@ -118,6 +123,14 @@ static void copy_to_current( GLcontext *ctx, struct immediate *IM, } } } + + if (flag & VERT_MATERIAL) { + gl_update_material( ctx, + IM->Material[IM->LastMaterial], + IM->MaterialOrMask ); + + gl_validate_all_lighting_tables( ctx ); + } } @@ -142,8 +155,8 @@ void _tnl_compute_orflag( struct immediate *IM ) /* It is possible there will be data in the buffer arising from * calls like 'glNormal', 'glMaterial' that occur after the final * glVertex, glEval, etc. Additionally, a buffer can consist of - * only a single glMaterial call, in which case IM->Start == - * IM->Count, but the buffer is definitely not empty. + * eg. a single glMaterial call, in which case IM->Start == + * IM->Count, but the buffer is definitely not empty. */ if (IM->Flag[i] & VERT_DATA) { IM->LastData++; @@ -195,7 +208,6 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) /* TexCoordPtr's are zeroed in loop below. */ VB->NormalPtr = 0; - VB->NormalLengthPtr = 0; VB->FogCoordPtr = 0; VB->EdgeFlag = 0; VB->IndexPtr[0] = 0; @@ -232,8 +244,6 @@ static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) tmp->Normal.start = (GLfloat *)(IM->Normal + start); tmp->Normal.count = count; VB->NormalPtr = &tmp->Normal; - if (IM->NormalLengths) - VB->NormalLengthPtr = IM->NormalLengths + start; } if (inputs & VERT_INDEX) { @@ -317,7 +327,7 @@ void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM ) _tnl_run_pipeline( ctx ); tnl->pipeline.run_input_changes |= tnl->pipeline.inputs; - copy_to_current( ctx, IM, IM->OrFlag ); + _tnl_copy_to_current( ctx, IM, IM->OrFlag ); } @@ -347,31 +357,10 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM ) */ if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) { _tnl_translate_array_elts( ctx, IM, IM->LastData, IM->LastData ); - copy_to_current( ctx, IM, ctx->Array._Enabled ); + _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled ); } } -/* Called for cassettes where CopyStart == Count -- no need to run the - * pipeline. - */ -void _tnl_run_empty_cassette( GLcontext *ctx, struct immediate *IM ) -{ - copy_to_current( ctx, IM, IM->OrFlag ); - - if (IM->OrFlag & (VERT_RGBA|VERT_MATERIAL)) { - GLuint start = IM->CopyStart; - - if (IM->OrFlag & VERT_MATERIAL) - gl_update_material( ctx, IM->Material[start], - IM->MaterialMask[start] ); - - if (IM->OrFlag & VERT_RGBA) - if (ctx->Light.ColorMaterialEnabled) - gl_update_color_material( ctx, ctx->Current.Color ); - - gl_validate_all_lighting_tables( ctx ); - } -} /* Called for regular vertex cassettes. @@ -413,14 +402,11 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) _tnl_compute_orflag( IM ); -/* _tnl_print_cassette( IM ); */ - /* Mark the last primitive: */ IM->PrimitiveLength[IM->LastPrimitive] = IM->Count - IM->LastPrimitive; ASSERT(IM->Primitive[IM->LastPrimitive] & PRIM_LAST); - if (tnl->pipeline.build_state_changes) _tnl_validate_pipeline( ctx ); @@ -430,8 +416,7 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) if (IM->OrFlag & VERT_ELT) _tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->CopyStart ); - _tnl_fixup_input( ctx, IM ); /* shouldn't be needed? (demos/fire) */ - _tnl_run_empty_cassette( ctx, IM ); + _tnl_copy_to_current( ctx, IM, IM->OrFlag ); } else if ((IM->OrFlag & VERT_DATA) == VERT_ELT && ctx->Array.LockCount && diff --git a/src/mesa/tnl/t_imm_exec.h b/src/mesa/tnl/t_imm_exec.h index 84cf1f0f8af..ab5fa292d71 100644 --- a/src/mesa/tnl/t_imm_exec.h +++ b/src/mesa/tnl/t_imm_exec.h @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.h,v 1.2 2000/12/27 21:49:40 keithw Exp $ */ +/* $Id: t_imm_exec.h,v 1.3 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -43,7 +43,8 @@ extern void _tnl_flush_immediate( struct immediate *IM ); /* Called from imm_dlist.c and _tnl_flush_immediate: */ extern void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM ); -extern void _tnl_run_empty_cassette( GLcontext *ctx, struct immediate *IM ); +extern void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, + GLuint flag ); /* Initialize some stuff: */ @@ -60,4 +61,5 @@ extern void _tnl_compute_orflag( struct immediate *IM ); extern void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ); + #endif diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 54fd6670b1d..5429994b6cc 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.6 2001/02/13 23:51:34 brianp Exp $ */ +/* $Id: t_imm_fixup.c,v 1.7 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -416,20 +416,6 @@ static void copy_vertices( GLcontext *ctx, next->CopyAndFlag &= prev->Flag[src]; /* redundant for current_im */ } - /* Only needed when copying to a compiled cassette - */ - if (next->NormalLengths) { - for (i = 0 ; i < count ; i++) - { - GLuint src = elts[i+offset]; - GLuint dst = next->CopyStart+i; - - if (prev->NormalLengths) - next->NormalLengths[dst] = prev->NormalLengths[src]; - else - next->NormalLengths[dst] = 1.0/LEN_3FV(prev->Normal[src]); - } - } ASSERT(prev == tnl->ExecCopySource); @@ -549,9 +535,6 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) if (fixup & VERT_NORM) { fixup_first_3f(IM->Normal, IM->Flag, VERT_NORM, start, ctx->Current.Normal ); - if (IM->NormalLengths) - fixup_first_1f(IM->NormalLengths, IM->Flag, VERT_NORM, start, - 1.0F / (GLfloat) LEN_3FV(ctx->Current.Normal) ); } } diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index 942b8ba21eb..467074abaa3 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.c,v 1.11 2001/01/29 20:47:39 keithw Exp $ */ +/* $Id: t_pipeline.c,v 1.12 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -132,6 +132,8 @@ void _tnl_run_pipeline( GLcontext *ctx ) ASSERT(pipe->build_state_changes == 0); START_FAST_MATH(__tmp); + if (ctx->Driver.PipelineStart) + ctx->Driver.PipelineStart( ctx ); /* If something changes in the pipeline, tag all subsequent stages * using this value for recalculation. @@ -157,6 +159,9 @@ void _tnl_run_pipeline( GLcontext *ctx ) } } } + + if (ctx->Driver.PipelineFinish) + ctx->Driver.PipelineFinish( ctx ); END_FAST_MATH(__tmp); pipe->run_state_changes = 0; diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index e55520cb5c2..8c33d244425 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_normals.c,v 1.2 2000/12/27 19:57:37 keithw Exp $ */ +/* $Id: t_vb_normals.c,v 1.3 2001/02/15 01:33:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -61,18 +61,11 @@ static GLboolean run_normal_stage( GLcontext *ctx, ASSERT(store->NormalTransform); - if (VB->NormalLengthPtr) { - GLfloat diff = VB->NormalLengthPtr[0] - - 1.0/LEN_3FV(VB->NormalPtr->data[0]); - (void)diff; - ASSERT((diff*diff) < .01); - } - if (stage->changed_inputs) (store->NormalTransform[0])(&ctx->ModelView, ctx->_ModelViewInvScale, VB->NormalPtr, - VB->NormalLengthPtr, + 0, 0, &store->normal); |