diff options
author | Mathias Fröhlich <[email protected]> | 2018-01-27 16:07:22 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-02-01 22:39:06 +0100 |
commit | b4fd63015ac7fd73e0147ff078caec47be729e87 (patch) | |
tree | df1ee50284dc622f78a5626f391b53585eb4faab /src/mesa/main/arrayobj.c | |
parent | 186f03cfb021223f0a6f238da036517fbf240d26 (diff) |
mesa: Track position/generic0 aliasing in the VAO.
Since the first material attribute no longer aliases with
the generic0 attribute, only aliasing between generic0 and
position is left and entirely dependent on the enabled
state of the VAO. So introduce a gl_attribute_map_mode
in the VAO that is used to track how the position
and the generic 0 attribute alias.
Provide a static const array that can be used to
map from vertex program input indices to VERT_ATTRIB_*
indices. The outer dimension of the array is meant to
be indexed directly by the new VAO member variable.
Also provide methods on the VAO to convert bitmasks of
VERT_BIT's from the VAO numbering to the vertex processing
inputs numbering.
v2: s,unsigned char,GLubyte,g
s,_ATTRIBUTE_MAP_MODE_MAX,ATTRIBUTE_MAP_MODE_MAX,g
Change comment style, add comments.
Signed-off-by: Mathias Fröhlich <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/arrayobj.c')
-rw-r--r-- | src/mesa/main/arrayobj.c | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 7208f4c534f..360d097ec1d 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -54,6 +54,135 @@ #include "util/bitscan.h" +const GLubyte +_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] = +{ + /* ATTRIBUTE_MAP_MODE_IDENTITY + * + * Grab vertex processing attribute VERT_ATTRIB_POS from + * the VAO attribute VERT_ATTRIB_POS, and grab vertex processing + * attribute VERT_ATTRIB_GENERIC0 from the VAO attribute + * VERT_ATTRIB_GENERIC0. + */ + { + VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */ + VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */ + VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */ + VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */ + VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */ + VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */ + VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */ + VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */ + VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */ + VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */ + VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */ + VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */ + VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */ + VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */ + VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */ + VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */ + VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_GENERIC0 */ + VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */ + VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */ + VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */ + VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */ + VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */ + VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */ + VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */ + VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */ + VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */ + VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */ + VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */ + VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */ + VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */ + VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */ + VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */ + }, + + /* ATTRIBUTE_MAP_MODE_POSITION + * + * Grab vertex processing attribute VERT_ATTRIB_POS as well as + * vertex processing attribute VERT_ATTRIB_GENERIC0 from the + * VAO attribute VERT_ATTRIB_POS. + */ + { + VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */ + VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */ + VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */ + VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */ + VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */ + VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */ + VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */ + VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */ + VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */ + VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */ + VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */ + VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */ + VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */ + VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */ + VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */ + VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */ + VERT_ATTRIB_POS, /* VERT_ATTRIB_GENERIC0 */ + VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */ + VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */ + VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */ + VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */ + VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */ + VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */ + VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */ + VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */ + VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */ + VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */ + VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */ + VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */ + VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */ + VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */ + VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */ + }, + + /* ATTRIBUTE_MAP_MODE_GENERIC0 + * + * Grab vertex processing attribute VERT_ATTRIB_POS as well as + * vertex processing attribute VERT_ATTRIB_GENERIC0 from the + * VAO attribute VERT_ATTRIB_GENERIC0. + */ + { + VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_POS */ + VERT_ATTRIB_NORMAL, /* VERT_ATTRIB_NORMAL */ + VERT_ATTRIB_COLOR0, /* VERT_ATTRIB_COLOR0 */ + VERT_ATTRIB_COLOR1, /* VERT_ATTRIB_COLOR1 */ + VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */ + VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */ + VERT_ATTRIB_EDGEFLAG, /* VERT_ATTRIB_EDGEFLAG */ + VERT_ATTRIB_TEX0, /* VERT_ATTRIB_TEX0 */ + VERT_ATTRIB_TEX1, /* VERT_ATTRIB_TEX1 */ + VERT_ATTRIB_TEX2, /* VERT_ATTRIB_TEX2 */ + VERT_ATTRIB_TEX3, /* VERT_ATTRIB_TEX3 */ + VERT_ATTRIB_TEX4, /* VERT_ATTRIB_TEX4 */ + VERT_ATTRIB_TEX5, /* VERT_ATTRIB_TEX5 */ + VERT_ATTRIB_TEX6, /* VERT_ATTRIB_TEX6 */ + VERT_ATTRIB_TEX7, /* VERT_ATTRIB_TEX7 */ + VERT_ATTRIB_POINT_SIZE, /* VERT_ATTRIB_POINT_SIZE */ + VERT_ATTRIB_GENERIC0, /* VERT_ATTRIB_GENERIC0 */ + VERT_ATTRIB_GENERIC1, /* VERT_ATTRIB_GENERIC1 */ + VERT_ATTRIB_GENERIC2, /* VERT_ATTRIB_GENERIC2 */ + VERT_ATTRIB_GENERIC3, /* VERT_ATTRIB_GENERIC3 */ + VERT_ATTRIB_GENERIC4, /* VERT_ATTRIB_GENERIC4 */ + VERT_ATTRIB_GENERIC5, /* VERT_ATTRIB_GENERIC5 */ + VERT_ATTRIB_GENERIC6, /* VERT_ATTRIB_GENERIC6 */ + VERT_ATTRIB_GENERIC7, /* VERT_ATTRIB_GENERIC7 */ + VERT_ATTRIB_GENERIC8, /* VERT_ATTRIB_GENERIC8 */ + VERT_ATTRIB_GENERIC9, /* VERT_ATTRIB_GENERIC9 */ + VERT_ATTRIB_GENERIC10, /* VERT_ATTRIB_GENERIC10 */ + VERT_ATTRIB_GENERIC11, /* VERT_ATTRIB_GENERIC11 */ + VERT_ATTRIB_GENERIC12, /* VERT_ATTRIB_GENERIC12 */ + VERT_ATTRIB_GENERIC13, /* VERT_ATTRIB_GENERIC13 */ + VERT_ATTRIB_GENERIC14, /* VERT_ATTRIB_GENERIC14 */ + VERT_ATTRIB_GENERIC15 /* VERT_ATTRIB_GENERIC15 */ + } +}; + + /** * Look up the array object for the given ID. * @@ -305,6 +434,8 @@ _mesa_initialize_vao(struct gl_context *ctx, } } + vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_IDENTITY; + _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, ctx->Shared->NullBufferObj); } |