diff options
author | Mathias Fröhlich <[email protected]> | 2018-02-03 20:25:39 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-02-06 21:20:14 +0100 |
commit | e8a9473d32149ed0f8b9b188652a7ef951324f72 (patch) | |
tree | 97eac570b05d85744e75e90254b8a51879931a5b /src/mesa/main/varray.c | |
parent | 236657842b56e08055a4a9be8def8e440de78b58 (diff) |
mesa: Factor out _mesa_disable_vertex_array_attrib.
And use it in the enable code path.
Move _mesa_update_attribute_map_mode into its only remaining file.
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.c | 58 |
1 files changed, 44 insertions, 14 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 81b8fbe8ca7..b268aaa9a3c 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -126,6 +126,32 @@ type_to_bit(const struct gl_context *ctx, GLenum type) /** + * Depending on the position and generic0 attributes enable flags select + * the one that is used for both attributes. + * The generic0 attribute takes precedence. + */ +static inline void +update_attribute_map_mode(const struct gl_context *ctx, + struct gl_vertex_array_object *vao) +{ + /* + * There is no need to change the mapping away from the + * identity mapping if we are not in compat mode. + */ + if (ctx->API != API_OPENGL_COMPAT) + return; + /* The generic0 attribute superseeds the position attribute */ + const GLbitfield enabled = vao->_Enabled; + if (enabled & VERT_BIT_GENERIC0) + vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_GENERIC0; + else if (enabled & VERT_BIT_POS) + vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_POSITION; + else + vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_IDENTITY; +} + + +/** * Sets the BufferBindingIndex field for the vertex attribute given by * attribIndex. */ @@ -1077,7 +1103,7 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx, /* Update the map mode if needed */ if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0)) - _mesa_update_attribute_map_mode(ctx, vao); + update_attribute_map_mode(ctx, vao); } } @@ -1144,24 +1170,24 @@ _mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index) } -static void -disable_vertex_array_attrib(struct gl_context *ctx, - struct gl_vertex_array_object *vao, - GLuint index) +void +_mesa_disable_vertex_array_attrib(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + gl_vert_attrib attrib) { - assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib)); + assert(attrib < ARRAY_SIZE(vao->VertexAttrib)); - if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) { + if (vao->VertexAttrib[attrib].Enabled) { /* was enabled, now being disabled */ FLUSH_VERTICES(ctx, _NEW_ARRAY); - vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled = GL_FALSE; - const GLbitfield array_bit = VERT_BIT_GENERIC(index); + vao->VertexAttrib[attrib].Enabled = GL_FALSE; + 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); + update_attribute_map_mode(ctx, vao); } } @@ -1176,7 +1202,8 @@ _mesa_DisableVertexAttribArray(GLuint index) return; } - disable_vertex_array_attrib(ctx, ctx->Array.VAO, index); + const gl_vert_attrib attrib = VERT_ATTRIB_GENERIC(index); + _mesa_disable_vertex_array_attrib(ctx, ctx->Array.VAO, attrib); } @@ -1184,7 +1211,8 @@ void GLAPIENTRY _mesa_DisableVertexAttribArray_no_error(GLuint index) { GET_CURRENT_CONTEXT(ctx); - disable_vertex_array_attrib(ctx, ctx->Array.VAO, index); + const gl_vert_attrib attrib = VERT_ATTRIB_GENERIC(index); + _mesa_disable_vertex_array_attrib(ctx, ctx->Array.VAO, attrib); } @@ -1210,7 +1238,8 @@ _mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index) return; } - disable_vertex_array_attrib(ctx, vao, index); + const gl_vert_attrib attrib = VERT_ATTRIB_GENERIC(index); + _mesa_disable_vertex_array_attrib(ctx, vao, attrib); } @@ -1219,7 +1248,8 @@ _mesa_DisableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index) { GET_CURRENT_CONTEXT(ctx); struct gl_vertex_array_object *vao = _mesa_lookup_vao(ctx, vaobj); - disable_vertex_array_attrib(ctx, vao, index); + const gl_vert_attrib attrib = VERT_ATTRIB_GENERIC(index); + _mesa_disable_vertex_array_attrib(ctx, vao, attrib); } |