From ff56908e09c0351179478deb19677cf56eec1f64 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 5 Aug 2003 18:55:49 +0000 Subject: Store material attributes in an Attrib[] style array. This is a first step to reviving/rescuing the 'vtx' rework from the old mesa tree. --- src/mesa/tnl/t_context.h | 4 +-- src/mesa/tnl/t_imm_api.c | 62 ++++++++++------------------------------ src/mesa/tnl/t_imm_dlist.c | 62 ++++++++++++++++++---------------------- src/mesa/tnl/t_imm_exec.c | 8 ++++-- src/mesa/tnl/t_imm_fixup.c | 20 ++++++------- src/mesa/tnl/t_vb_light.c | 8 ++++++ src/mesa/tnl/t_vb_lighttmp.h | 68 +++++++++++++++++++++----------------------- 7 files changed, 100 insertions(+), 132 deletions(-) (limited to 'src/mesa/tnl') diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 943082d99b..c375a5670b 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -223,7 +223,7 @@ struct immediate /* allocate storage for these on demand: */ - struct gl_material (*Material)[2]; + struct gl_material *Material; GLuint *MaterialMask; GLuint LastMaterial; GLuint MaterialOrMask; @@ -302,7 +302,7 @@ typedef struct vertex_buffer struct gl_client_array *SecondaryColorPtr[2];/* VERT_BIT_COLOR1 */ GLvector4f *PointSizePtr; /* VERT_BIT_POINT_SIZE */ GLvector4f *FogCoordPtr; /* VERT_BIT_FOG */ - struct gl_material (*Material)[2]; /* VERT_BIT_MATERIAL, optional */ + struct gl_material *Material; /* VERT_BIT_MATERIAL, optional */ GLuint *MaterialMask; /* VERT_BIT_MATERIAL, optional */ GLuint *Flag; /* VERT_BIT_* flags, optional */ GLuint *Primitive; /* GL_(mode)|PRIM_* flags */ diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c index 868de64c16..0449504300 100644 --- a/src/mesa/tnl/t_imm_api.c +++ b/src/mesa/tnl/t_imm_api.c @@ -1256,6 +1256,7 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) GLuint count = IM->Count; struct gl_material *mat; GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, "Materialfv"); + int i, nr; if (bitmask == 0) return; @@ -1273,15 +1274,15 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) if (!(IM->Flag[count] & VERT_BIT_MATERIAL)) { if (!IM->Material) { - IM->Material = (struct gl_material (*)[2]) - MALLOC( sizeof(struct gl_material) * IMM_SIZE * 2 ); + IM->Material = (struct gl_material *) + MALLOC( sizeof(struct gl_material) * IMM_SIZE ); IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); IM->MaterialMask[IM->LastMaterial] = 0; } else if (IM->MaterialOrMask & ~bitmask) { - _mesa_copy_material_pairs( IM->Material[count], - IM->Material[IM->LastMaterial], - IM->MaterialOrMask & ~bitmask ); + _mesa_copy_materials( &IM->Material[count], + &IM->Material[IM->LastMaterial], + IM->MaterialOrMask & ~bitmask ); } IM->Flag[count] |= VERT_BIT_MATERIAL; @@ -1292,51 +1293,18 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) IM->MaterialOrMask |= bitmask; IM->MaterialMask[count] |= bitmask; - mat = IM->Material[count]; + mat = &IM->Material[count]; - if (bitmask & FRONT_AMBIENT_BIT) { - COPY_4FV( mat[0].Ambient, params ); - } - if (bitmask & BACK_AMBIENT_BIT) { - COPY_4FV( mat[1].Ambient, params ); - } - if (bitmask & FRONT_DIFFUSE_BIT) { - COPY_4FV( mat[0].Diffuse, params ); - } - if (bitmask & BACK_DIFFUSE_BIT) { - COPY_4FV( mat[1].Diffuse, params ); - } - if (bitmask & FRONT_SPECULAR_BIT) { - COPY_4FV( mat[0].Specular, params ); - } - if (bitmask & BACK_SPECULAR_BIT) { - COPY_4FV( mat[1].Specular, params ); - } - if (bitmask & FRONT_EMISSION_BIT) { - COPY_4FV( mat[0].Emission, params ); - } - if (bitmask & BACK_EMISSION_BIT) { - COPY_4FV( mat[1].Emission, params ); - } - if (bitmask & FRONT_SHININESS_BIT) { - GLfloat shininess = CLAMP( params[0], 0.0F, ctx->Const.MaxShininess ); - mat[0].Shininess = shininess; - } - if (bitmask & BACK_SHININESS_BIT) { - GLfloat shininess = CLAMP( params[0], 0.0F, ctx->Const.MaxShininess ); - mat[1].Shininess = shininess; - } - if (bitmask & FRONT_INDEXES_BIT) { - mat[0].AmbientIndex = params[0]; - mat[0].DiffuseIndex = params[1]; - mat[0].SpecularIndex = params[2]; - } - if (bitmask & BACK_INDEXES_BIT) { - mat[1].AmbientIndex = params[0]; - mat[1].DiffuseIndex = params[1]; - mat[1].SpecularIndex = params[2]; + switch (face) { + case GL_SHININESS: nr = 1; break; + case GL_COLOR_INDEXES: nr = 3; break; + default: nr = 4 ; break; } + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<Attrib[i], nr, params ); + if (tnl->IsolateMaterials && !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */ { diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c index 3efe61592f..8fcc9b25f0 100644 --- a/src/mesa/tnl/t_imm_dlist.c +++ b/src/mesa/tnl/t_imm_dlist.c @@ -527,51 +527,43 @@ _tnl_dlist_init( GLcontext *ctx ) static void emit_material( const struct gl_material *src, GLuint bitmask ) { - if (bitmask & FRONT_EMISSION_BIT) - glMaterialfv( GL_FRONT, GL_EMISSION, src[0].Emission ); + const GLfloat (*attr)[4] = src->Attrib; - if (bitmask & BACK_EMISSION_BIT) - glMaterialfv( GL_BACK, GL_EMISSION, src[1].Emission ); + if (bitmask & MAT_BIT_FRONT_EMISSION) + glMaterialfv( GL_FRONT, GL_EMISSION, attr[MAT_ATTRIB_FRONT_EMISSION] ); - if (bitmask & FRONT_AMBIENT_BIT) - glMaterialfv( GL_FRONT, GL_AMBIENT, src[0].Ambient ); + if (bitmask & MAT_BIT_BACK_EMISSION) + glMaterialfv( GL_BACK, GL_EMISSION, attr[MAT_ATTRIB_BACK_EMISSION] ); - if (bitmask & BACK_AMBIENT_BIT) - glMaterialfv( GL_BACK, GL_AMBIENT, src[1].Ambient ); + if (bitmask & MAT_BIT_FRONT_AMBIENT) + glMaterialfv( GL_FRONT, GL_AMBIENT, attr[MAT_ATTRIB_FRONT_AMBIENT] ); - if (bitmask & FRONT_DIFFUSE_BIT) - glMaterialfv( GL_FRONT, GL_DIFFUSE, src[0].Diffuse ); + if (bitmask & MAT_BIT_BACK_AMBIENT) + glMaterialfv( GL_BACK, GL_AMBIENT, attr[MAT_ATTRIB_BACK_AMBIENT] ); - if (bitmask & BACK_DIFFUSE_BIT) - glMaterialfv( GL_BACK, GL_DIFFUSE, src[1].Diffuse ); + if (bitmask & MAT_BIT_FRONT_DIFFUSE) + glMaterialfv( GL_FRONT, GL_DIFFUSE, attr[MAT_ATTRIB_FRONT_DIFFUSE] ); - if (bitmask & FRONT_SPECULAR_BIT) - glMaterialfv( GL_FRONT, GL_SPECULAR, src[0].Specular ); + if (bitmask & MAT_BIT_BACK_DIFFUSE) + glMaterialfv( GL_BACK, GL_DIFFUSE, attr[MAT_ATTRIB_BACK_DIFFUSE] ); - if (bitmask & BACK_SPECULAR_BIT) - glMaterialfv( GL_BACK, GL_SPECULAR, src[1].Specular ); + if (bitmask & MAT_BIT_FRONT_SPECULAR) + glMaterialfv( GL_FRONT, GL_SPECULAR, attr[MAT_ATTRIB_FRONT_SPECULAR] ); - if (bitmask & FRONT_SHININESS_BIT) - glMaterialfv( GL_FRONT, GL_SHININESS, &src[0].Shininess ); + if (bitmask & MAT_BIT_BACK_SPECULAR) + glMaterialfv( GL_BACK, GL_SPECULAR, attr[MAT_ATTRIB_BACK_SPECULAR] ); - if (bitmask & BACK_SHININESS_BIT) - glMaterialfv( GL_BACK, GL_SHININESS, &src[1].Shininess ); + if (bitmask & MAT_BIT_FRONT_SHININESS) + glMaterialfv( GL_FRONT, GL_SHININESS, attr[MAT_ATTRIB_FRONT_SHININESS] ); - if (bitmask & FRONT_INDEXES_BIT) { - GLfloat ind[3]; - ind[0] = src[0].AmbientIndex; - ind[1] = src[0].DiffuseIndex; - ind[2] = src[0].SpecularIndex; - glMaterialfv( GL_FRONT, GL_COLOR_INDEXES, ind ); - } + if (bitmask & MAT_BIT_BACK_SHININESS) + glMaterialfv( GL_BACK, GL_SHININESS, attr[MAT_ATTRIB_BACK_SHININESS] ); - if (bitmask & BACK_INDEXES_BIT) { - GLfloat ind[3]; - ind[0] = src[1].AmbientIndex; - ind[1] = src[1].DiffuseIndex; - ind[2] = src[1].SpecularIndex; - glMaterialfv( GL_BACK, GL_COLOR_INDEXES, ind ); - } + if (bitmask & MAT_BIT_FRONT_INDEXES) + glMaterialfv( GL_FRONT, GL_COLOR_INDEXES, attr[MAT_ATTRIB_FRONT_INDEXES]); + + if (bitmask & MAT_BIT_BACK_INDEXES) + glMaterialfv( GL_BACK, GL_COLOR_INDEXES, attr[MAT_ATTRIB_BACK_INDEXES] ); } @@ -652,7 +644,7 @@ loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ) glEdgeFlag( IM->EdgeFlag[i] ); if (flags[i] & VERT_BIT_MATERIAL) - emit_material( IM->Material[i], IM->MaterialMask[i] ); + emit_material( &IM->Material[i], IM->MaterialMask[i] ); if (flags[i]&VERT_BITS_OBJ_234) vertex( IM->Attrib[VERT_ATTRIB_POS][i] ); diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 38108785a1..f1d6ee8925 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -154,9 +154,11 @@ void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, } if (flag & VERT_BIT_MATERIAL) { - _mesa_update_material( ctx, - IM->Material[IM->LastMaterial], - IM->MaterialOrMask ); + _mesa_copy_materials( &ctx->Light.Material, + &IM->Material[IM->LastMaterial], + IM->MaterialOrMask ); + + _mesa_update_material( ctx, IM->MaterialOrMask ); TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); } diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index cf3aa2ed96..5f821e7343 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -292,9 +292,9 @@ _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) i++; vulnerable &= ~IM->MaterialMask[i]; - _mesa_copy_material_pairs( IM->Material[i], - ctx->Light.Material, - vulnerable ); + _mesa_copy_materials( &IM->Material[i], + &ctx->Light.Material, + vulnerable ); ++i; @@ -311,14 +311,14 @@ copy_material( struct immediate *next, /* _mesa_debug(NULL, "%s\n", __FUNCTION__); */ if (next->Material == 0) { - next->Material = (struct gl_material (*)[2]) - MALLOC( sizeof(struct gl_material) * IMM_SIZE * 2 ); + next->Material = (struct gl_material *) + MALLOC( sizeof(struct gl_material) * IMM_SIZE ); next->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); } next->MaterialMask[dst] = prev->MaterialOrMask; - MEMCPY(next->Material[dst], prev->Material[src], - 2 * sizeof(struct gl_material)); + MEMCPY(&next->Material[dst], &prev->Material[src], + sizeof(struct gl_material)); } @@ -590,9 +590,9 @@ _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) i++; vulnerable &= ~IM->MaterialMask[i]; - _mesa_copy_material_pairs( IM->Material[i], - ctx->Light.Material, - vulnerable ); + _mesa_copy_materials( &IM->Material[i], + &ctx->Light.Material, + vulnerable ); ++i; diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 8675548634..aedbad4254 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -94,6 +94,14 @@ static void import_color_material( GLcontext *ctx, } +static void update_materials( GLcontext *ctx, + const struct gl_material *src, + GLuint bitmask ) +{ + _mesa_copy_materials( &ctx->Light.Material, src, bitmask ); + _mesa_update_material( ctx, bitmask ); +} + /* Tables for all the shading functions. */ static light_func _tnl_light_tab[MAX_LIGHT_FUNC]; diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index 5ddac76862..db61234253 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -113,7 +113,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, const GLuint nr = VB->Count; const GLuint *flags = VB->Flag; - struct gl_material (*new_material)[2] = VB->Material; + struct gl_material *new_material = VB->Material; const GLuint *new_material_mask = VB->MaterialMask; (void) flags; @@ -135,12 +135,12 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, VB->ColorPtr[0] = &store->LitColor[0]; VB->SecondaryColorPtr[0] = &store->LitSecondary[0]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) { VB->ColorPtr[1] = &store->LitColor[1]; VB->SecondaryColorPtr[1] = &store->LitSecondary[1]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } /* Side-effects done, can we finish now? @@ -159,13 +159,13 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, _mesa_update_color_material( ctx, CMcolor ); if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); + update_materials( ctx, &new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } COPY_3V(sum[0], base[0]); @@ -325,7 +325,7 @@ static void TAG(light_rgba)( GLcontext *ctx, GLchan (*color[2])[4]; const GLuint *flags = VB->Flag; - struct gl_material (*new_material)[2] = VB->Material; + struct gl_material *new_material = VB->Material; const GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; @@ -350,11 +350,11 @@ static void TAG(light_rgba)( GLcontext *ctx, } VB->ColorPtr[0] = &store->LitColor[0]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) { VB->ColorPtr[1] = &store->LitColor[1]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } if (stage->changed_inputs == 0) @@ -371,13 +371,13 @@ static void TAG(light_rgba)( GLcontext *ctx, _mesa_update_color_material( ctx, CMcolor ); if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); + update_materials( ctx, &new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } COPY_3V(sum[0], base[0]); @@ -535,7 +535,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, const GLuint *flags = VB->Flag; GLchan basechan[2][4]; GLuint j = 0; - struct gl_material (*new_material)[2] = VB->Material; + struct gl_material *new_material = VB->Material; const GLuint *new_material_mask = VB->MaterialMask; GLfloat base[2][3]; const GLuint nr = VB->Count; @@ -572,7 +572,7 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, } if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); + update_materials( ctx, &new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); @@ -584,14 +584,14 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, ACC_3V(base[0], ctx->Light._BaseColor[0] ); UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[0], base[0] ); UNCLAMPED_FLOAT_TO_CHAN(basechan[0][3], - ctx->Light.Material[0].Diffuse[3]); + ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) { COPY_3V(base[1], light->_MatAmbient[1]); ACC_3V(base[1], ctx->Light._BaseColor[1]); UNCLAMPED_FLOAT_TO_RGB_CHAN( basechan[1], base[1]); UNCLAMPED_FLOAT_TO_CHAN(basechan[1][3], - ctx->Light.Material[1].Diffuse[3]); + ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } do { @@ -663,7 +663,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr; const GLuint *flags = VB->Flag; GLuint j = 0; - struct gl_material (*new_material)[2] = VB->Material; + struct gl_material *new_material = VB->Material; GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; const struct gl_light *light; @@ -677,8 +677,8 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, (void) nr; (void) nstride; - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); if (IDX & LIGHT_COLORMATERIAL) { if (VB->ColorPtr[0]->Type != GL_FLOAT || @@ -704,14 +704,14 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, _mesa_update_color_material( ctx, CMcolor ); if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); + update_materials( ctx, &new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) { TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]); if (IDX & LIGHT_TWOSIDE) UNCLAMPED_FLOAT_TO_CHAN(sumA[1], - ctx->Light.Material[1].Diffuse[3]); + ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]); } @@ -804,7 +804,7 @@ static void TAG(light_ci)( GLcontext *ctx, GLuint CMstride; const GLuint *flags = VB->Flag; GLuint *indexResult[2]; - struct gl_material (*new_material)[2] = VB->Material; + struct gl_material *new_material = VB->Material; GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; @@ -849,7 +849,7 @@ static void TAG(light_ci)( GLcontext *ctx, _mesa_update_color_material( ctx, CMcolor ); if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); + update_materials( ctx, &new_material[j], new_material_mask[j] ); if ( CHECK_VALIDATE(j) ) TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); @@ -953,22 +953,20 @@ static void TAG(light_ci)( GLcontext *ctx, /* Now compute final color index */ for (side = 0 ; side < NR_SIDES ; side++) { - struct gl_material *mat = &ctx->Light.Material[side]; + const GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES + side]; GLfloat index; if (specular[side] > 1.0F) { - index = mat->SpecularIndex; + index = ind[MAT_INDEX_SPECULAR]; } else { - GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex; - GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex; - - index = mat->AmbientIndex - + diffuse[side] * (1.0F-specular[side]) * d_a - + specular[side] * s_a; - - if (index > mat->SpecularIndex) { - index = mat->SpecularIndex; + GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT]; + GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT]; + GLfloat i = (ind[MAT_INDEX_AMBIENT] + + diffuse[side] * (1.0F-specular[side]) * d_a + + specular[side] * s_a); + if (i > ind[MAT_INDEX_SPECULAR]) { + i = ind[MAT_INDEX_SPECULAR]; } } indexResult[side][j] = (GLuint) (GLint) index; -- cgit v1.2.3