summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/varray.c
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2018-01-27 16:07:22 +0100
committerMathias Fröhlich <[email protected]>2018-02-01 22:39:06 +0100
commitb4fd63015ac7fd73e0147ff078caec47be729e87 (patch)
treedf1ee50284dc622f78a5626f391b53585eb4faab /src/mesa/main/varray.c
parent186f03cfb021223f0a6f238da036517fbf240d26 (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/varray.c')
-rw-r--r--src/mesa/main/varray.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index bc0afa6bcf5..81b8fbe8ca7 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1071,8 +1071,13 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
/* was disabled, now being enabled */
FLUSH_VERTICES(ctx, _NEW_ARRAY);
vao->VertexAttrib[attrib].Enabled = GL_TRUE;
- vao->_Enabled |= VERT_BIT(attrib);
- vao->NewArrays |= VERT_BIT(attrib);
+ const GLbitfield array_bit = VERT_BIT(attrib);
+ vao->_Enabled |= array_bit;
+ vao->NewArrays |= array_bit;
+
+ /* Update the map mode if needed */
+ if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))
+ _mesa_update_attribute_map_mode(ctx, vao);
}
}
@@ -1150,8 +1155,13 @@ disable_vertex_array_attrib(struct gl_context *ctx,
/* was enabled, now being disabled */
FLUSH_VERTICES(ctx, _NEW_ARRAY);
vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE;
- vao->_Enabled &= ~VERT_BIT_GENERIC(index);
- vao->NewArrays |= VERT_BIT_GENERIC(index);
+ const GLbitfield array_bit = VERT_BIT_GENERIC(index);
+ vao->_Enabled &= ~array_bit;
+ vao->NewArrays |= array_bit;
+
+ /* Update the map mode if needed */
+ if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))
+ _mesa_update_attribute_map_mode(ctx, vao);
}
}