diff options
author | Brian Paul <[email protected]> | 2003-11-29 19:33:33 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-11-29 19:33:33 +0000 |
commit | e90de7883a3bd9afd27ac83314f08cf9f03f60e3 (patch) | |
tree | bcbdd5ba61e8f1b93d3a2466ac0e7be85a35024c /src/mesa/tnl/t_array_import.c | |
parent | afb6fe034c3df9377ca8c0393a60c7996af92faf (diff) |
Fix generic/conventional vertex array glitches.
Changed _NEW_ARRAY_ATTRIB_0 back to 0x10000 so that the conventional and
generic enable bits do not alias.
In ac_import.c test Array.Normal.Enabled instead of Array._Enabled & _NEW_ARRAY_COLOR0, etc.
In t_array_import.c give priority for generic arrays over conventional
arrays on an individual basis, not all or none.
Diffstat (limited to 'src/mesa/tnl/t_array_import.c')
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 8f14aaf3810..44ca2663c82 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -79,6 +79,7 @@ static void _tnl_import_normal( GLcontext *ctx, inputs->Normal.data = (GLfloat (*)[4]) data; inputs->Normal.start = (GLfloat *) data; inputs->Normal.stride = tmp->StrideB; + inputs->Normal.size = 3; /* XXX is this right? */ } @@ -246,7 +247,7 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) struct vertex_buffer *VB = &tnl->vb; GLuint inputs = tnl->pipeline.inputs; struct tnl_vertex_arrays *tmp = &tnl->array_inputs; - GLuint i; + GLuint i, index; VB->Count = count - start; VB->Elts = NULL; @@ -262,72 +263,76 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) * 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 */ + for (index = 0; index < VERT_ATTRIB_MAX; index++) { + /* When vertex program mode is enabled, the generic vertex attribute + * arrays have priority over the conventional vertex arrays. + */ + if (ctx->VertexProgram.Enabled + && ctx->Array.VertexAttrib[index].Enabled) { + /* Use generic attribute array */ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE ); VB->AttribPtr[index] = &tmp->Attribs[index]; } - } - else { - - /* - * Conventional attributes - */ - if (inputs & _TNL_BIT_POS) { - _tnl_import_vertex( ctx, 0, 0 ); - tmp->Obj.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_POS] = &tmp->Obj; + /* use conventional arrays... */ + else if (index == VERT_ATTRIB_POS) { + if (inputs & _TNL_BIT_POS) { + _tnl_import_vertex( ctx, 0, 0 ); + tmp->Obj.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_POS] = &tmp->Obj; + } } - - if (inputs & _TNL_BIT_NORMAL) { - _tnl_import_normal( ctx, 0, 0 ); - tmp->Normal.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &tmp->Normal; + else if (index == VERT_ATTRIB_NORMAL) { + if (inputs & _TNL_BIT_NORMAL) { + _tnl_import_normal( ctx, 0, 0 ); + tmp->Normal.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &tmp->Normal; + } } - - if (inputs & _TNL_BIT_COLOR0) { - _tnl_import_color( ctx, 0, 0 ); - tmp->Color.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &tmp->Color; + else if (index == VERT_ATTRIB_COLOR0) { + if (inputs & _TNL_BIT_COLOR0) { + _tnl_import_color( ctx, 0, 0 ); + tmp->Color.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &tmp->Color; + } } - - if (inputs & _TNL_BIT_INDEX) { - _tnl_import_index( ctx, 0, 0 ); - tmp->Index.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_INDEX] = &tmp->Index; + else if (index == VERT_ATTRIB_COLOR1) { + if (inputs & _TNL_BIT_COLOR1) { + _tnl_import_secondarycolor( ctx, 0, 0 ); + tmp->SecondaryColor.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &tmp->SecondaryColor; + } } - - if (inputs & _TNL_BIT_FOG) { - _tnl_import_fogcoord( ctx, 0, 0 ); - tmp->FogCoord.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_FOG] = &tmp->FogCoord; + else if (index == VERT_ATTRIB_FOG) { + if (inputs & _TNL_BIT_FOG) { + _tnl_import_fogcoord( ctx, 0, 0 ); + tmp->FogCoord.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_FOG] = &tmp->FogCoord; + } } - - if (inputs & _TNL_BIT_EDGEFLAG) { - _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); - VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag; - } - - if (inputs & _TNL_BIT_COLOR1) { - _tnl_import_secondarycolor( ctx, 0, 0 ); - tmp->SecondaryColor.count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &tmp->SecondaryColor; + else if (index >= VERT_ATTRIB_TEX0 && index <= VERT_ATTRIB_TEX7) { + if (inputs & _TNL_BITS_TEX_ANY) { + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { + if (inputs & _TNL_BIT_TEX(i)) { + _tnl_import_texcoord( ctx, i, GL_FALSE, GL_FALSE ); + tmp->TexCoord[i].count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &tmp->TexCoord[i]; + } + } + } } + } - - if (inputs & _TNL_BITS_TEX_ANY) { - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - if (inputs & _TNL_BIT_TEX(i)) { - _tnl_import_texcoord( ctx, i, GL_FALSE, GL_FALSE ); - tmp->TexCoord[i].count = VB->Count; - VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &tmp->TexCoord[i]; - } - } - } + /* odd-ball vertex attributes */ + if (inputs & _TNL_BIT_INDEX) { + _tnl_import_index( ctx, 0, 0 ); + tmp->Index.count = VB->Count; + VB->AttribPtr[_TNL_ATTRIB_INDEX] = &tmp->Index; } + if (inputs & _TNL_BIT_EDGEFLAG) { + _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); + VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag; + } /* These are constant & can be precalculated: */ |