diff options
author | Mathias Fröhlich <[email protected]> | 2011-10-31 22:23:51 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2011-11-29 06:37:19 +0100 |
commit | 762c9766c93697af8d7fbaa729aed118789dbe8e (patch) | |
tree | cff8bf8eaa64b2a47226c9f02f0e5e85c42949d0 /src/mesa/main/state.c | |
parent | dca6a28a14f22d77273d79d44f57b0d853c0242d (diff) |
mesa: Use VERT_ATTRIB_* indexed array in gl_array_object.
Replace the distinct struct gl_client_array members in gl_array_object by
an array of gl_client_arrays indexed by VERT_ATTRIB_*.
Renumber the vertex attributes slightly to keep the old semantics of the
distinct array members. Make use of the upper 32 bits in VERT_BIT_*.
Update all occurances of the distinct struct members with the array
equivalents.
Signed-off-by: Mathias Froehlich <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main/state.c')
-rw-r--r-- | src/mesa/main/state.c | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 12ebd6d2568..7e43563bd01 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -83,98 +83,101 @@ update_arrays( struct gl_context *ctx ) struct gl_array_object *arrayObj = ctx->Array.ArrayObj; GLuint i, min = ~0; - /* find min of _MaxElement values for all enabled arrays */ + /* find min of _MaxElement values for all enabled arrays. + * Note that the generic arrays always take precedence over + * the legacy arrays. + */ /* 0 */ if (ctx->VertexProgram._Current - && arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]); } - else if (arrayObj->Vertex.Enabled) { - min = update_min(min, &arrayObj->Vertex); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]); } /* 1 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_WEIGHT]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1]); } /* no conventional vertex weight array */ /* 2 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2]); } - else if (arrayObj->Normal.Enabled) { - min = update_min(min, &arrayObj->Normal); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]); } /* 3 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3]); } - else if (arrayObj->Color.Enabled) { - min = update_min(min, &arrayObj->Color); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]); } /* 4 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4]); } - else if (arrayObj->SecondaryColor.Enabled) { - min = update_min(min, &arrayObj->SecondaryColor); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]); } /* 5 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5]); } - else if (arrayObj->FogCoord.Enabled) { - min = update_min(min, &arrayObj->FogCoord); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]); } /* 6 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6]); } - else if (arrayObj->Index.Enabled) { - min = update_min(min, &arrayObj->Index); + else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]); } /* 7 */ if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7]); } /* 8..15 */ - for (i = VERT_ATTRIB_TEX0; i <= VERT_ATTRIB_TEX7; i++) { + for (i = 0; i < VERT_ATTRIB_TEX_MAX; i++) { if (ctx->VertexProgram._Enabled - && arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); + && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i]); } - else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits - && arrayObj->TexCoord[i - VERT_ATTRIB_TEX0].Enabled) { - min = update_min(min, &arrayObj->TexCoord[i - VERT_ATTRIB_TEX0]); + else if (i < ctx->Const.MaxTextureCoordUnits + && arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]); } } /* 16..31 */ if (ctx->VertexProgram._Current) { - for (i = 0; i < Elements(arrayObj->VertexAttrib); i++) { - if (arrayObj->VertexAttrib[i].Enabled) { - min = update_min(min, &arrayObj->VertexAttrib[i]); + for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) { + if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]); } } } - if (arrayObj->EdgeFlag.Enabled) { - min = update_min(min, &arrayObj->EdgeFlag); + if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) { + min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]); } /* _MaxElement is one past the last legal array element */ |