diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/array_cache/ac_import.c | 14 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 21 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 115 |
4 files changed, 85 insertions, 67 deletions
diff --git a/src/mesa/array_cache/ac_import.c b/src/mesa/array_cache/ac_import.c index 78f54356359..7ec1d00ee58 100644 --- a/src/mesa/array_cache/ac_import.c +++ b/src/mesa/array_cache/ac_import.c @@ -49,7 +49,7 @@ static void reset_texcoord( GLcontext *ctx, GLuint unit ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_TEXCOORD(unit)) { + if (ctx->Array.TexCoord[unit].Enabled) { ac->Raw.TexCoord[unit] = ctx->Array.TexCoord[unit]; STRIDE_ARRAY(ac->Raw.TexCoord[unit], ac->start); } @@ -84,7 +84,7 @@ static void reset_normal( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_NORMAL) { + if (ctx->Array.Normal.Enabled) { ac->Raw.Normal = ctx->Array.Normal; STRIDE_ARRAY(ac->Raw.Normal, ac->start); } @@ -102,7 +102,7 @@ static void reset_color( GLcontext *ctx ) ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_COLOR0) { + if (ctx->Array.Color.Enabled) { ac->Raw.Color = ctx->Array.Color; STRIDE_ARRAY(ac->Raw.Color, ac->start); } @@ -118,7 +118,7 @@ static void reset_secondarycolor( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_COLOR1) { + if (ctx->Array.SecondaryColor.Enabled & _NEW_ARRAY_COLOR1) { ac->Raw.SecondaryColor = ctx->Array.SecondaryColor; STRIDE_ARRAY(ac->Raw.SecondaryColor, ac->start); } @@ -134,7 +134,7 @@ static void reset_index( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_INDEX) { + if (ctx->Array.Index.Enabled & _NEW_ARRAY_INDEX) { ac->Raw.Index = ctx->Array.Index; STRIDE_ARRAY(ac->Raw.Index, ac->start); } @@ -150,7 +150,7 @@ static void reset_fogcoord( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_FOGCOORD) { + if (ctx->Array.FogCoord.Enabled & _NEW_ARRAY_FOGCOORD) { ac->Raw.FogCoord = ctx->Array.FogCoord; STRIDE_ARRAY(ac->Raw.FogCoord, ac->start); } @@ -166,7 +166,7 @@ static void reset_edgeflag( GLcontext *ctx ) { ACcontext *ac = AC_CONTEXT(ctx); - if (ctx->Array._Enabled & _NEW_ARRAY_EDGEFLAG) { + if (ctx->Array.EdgeFlag.Enabled & _NEW_ARRAY_EDGEFLAG) { ac->Raw.EdgeFlag = ctx->Array.EdgeFlag; STRIDE_ARRAY(ac->Raw.EdgeFlag, ac->start); } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 1e0a0633cd4..686dd4aac8d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1929,7 +1929,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 0x1 /* alias conventional arrays */ +#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */ #define _NEW_ARRAY_ALL 0xffffffff diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index f9f5fe99511..2b10a9d1c2c 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -107,11 +107,16 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, if (ctx->Array.LockCount) tnl->Driver.RunPipeline( ctx ); else { + /* The lower 16 bits represent the conventional arrays while the + * upper 16 bits represent the generic arrays. OR those bits + * together to indicate which vertex attribs are in effect. + */ + GLuint enabledArrays = ctx->Array._Enabled | (ctx->Array._Enabled >> 16); /* Note that arrays may have changed before/after execution. */ - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes |= enabledArrays; tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes |= enabledArrays; } if (start) @@ -130,6 +135,7 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) GET_CURRENT_CONTEXT(ctx); TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10; + GLuint enabledArrays; if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(NULL, "_tnl_DrawArrays %d %d\n", start, count); @@ -267,9 +273,16 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) tnl->vb.Primitive[0].count = nr + minimum; tnl->vb.PrimitiveCount = 1; - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + /* The lower 16 bits represent the conventional arrays while the + * upper 16 bits represent the generic arrays. OR those bits + * together to indicate which vertex attribs are in effect. + */ + enabledArrays = ctx->Array._Enabled | (ctx->Array._Enabled >> 16); + /* Note that arrays may have changed before/after execution. + */ + tnl->pipeline.run_input_changes |= enabledArrays; tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes |= enabledArrays; } } } 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: */ |