diff options
author | Mathias Fröhlich <[email protected]> | 2018-11-17 07:13:11 +0100 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-11-21 06:27:19 +0100 |
commit | 1b743e29666fde9ddc38c447118ecdcc38989eb5 (patch) | |
tree | acb145985d7c1c49cd5179e26d6f4669693f1b77 /src/mesa/main/varray.c | |
parent | 3c46fa59888cf5c8ca36be849512b2ef0492760d (diff) |
mesa: Work with bitmasks when en/dis-abling VAO arrays.
For enabling or disabling VAO arrays it is now possible to
change a set of arrays with a single call without the need to
iterate the attributes.
Make use of this technique in the vao module.
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/main/varray.c')
-rw-r--r-- | src/mesa/main/varray.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index bcaa4956478..a6d00c6ef9c 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -1071,24 +1071,25 @@ _mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type, void -_mesa_enable_vertex_array_attrib(struct gl_context *ctx, - struct gl_vertex_array_object *vao, - gl_vert_attrib attrib) +_mesa_enable_vertex_array_attribs(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLbitfield attrib_bits) { - assert(attrib < ARRAY_SIZE(vao->VertexAttrib)); + assert((attrib_bits & ~VERT_BIT_ALL) == 0); assert(!vao->SharedAndImmutable); - const GLbitfield array_bit = VERT_BIT(attrib); - if ((vao->Enabled & array_bit) == 0) { + /* Only work on bits that are disabled */ + attrib_bits &= ~vao->Enabled; + if (attrib_bits) { /* was disabled, now being enabled */ - vao->Enabled |= array_bit; - vao->NewArrays |= array_bit; + vao->Enabled |= attrib_bits; + vao->NewArrays |= attrib_bits; if (vao == ctx->Array.VAO) ctx->NewState |= _NEW_ARRAY; /* Update the map mode if needed */ - if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0)) + if (attrib_bits & (VERT_BIT_POS|VERT_BIT_GENERIC0)) update_attribute_map_mode(ctx, vao); } } @@ -1157,24 +1158,25 @@ _mesa_EnableVertexArrayAttrib_no_error(GLuint vaobj, GLuint index) void -_mesa_disable_vertex_array_attrib(struct gl_context *ctx, - struct gl_vertex_array_object *vao, - gl_vert_attrib attrib) +_mesa_disable_vertex_array_attribs(struct gl_context *ctx, + struct gl_vertex_array_object *vao, + GLbitfield attrib_bits) { - assert(attrib < ARRAY_SIZE(vao->VertexAttrib)); + assert((attrib_bits & ~VERT_BIT_ALL) == 0); assert(!vao->SharedAndImmutable); - const GLbitfield array_bit = VERT_BIT(attrib); - if (vao->Enabled & array_bit) { + /* Only work on bits that are enabled */ + attrib_bits &= vao->Enabled; + if (attrib_bits) { /* was enabled, now being disabled */ - vao->Enabled &= ~array_bit; - vao->NewArrays |= array_bit; + vao->Enabled &= ~attrib_bits; + vao->NewArrays |= attrib_bits; if (vao == ctx->Array.VAO) ctx->NewState |= _NEW_ARRAY; /* Update the map mode if needed */ - if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0)) + if (attrib_bits & (VERT_BIT_POS|VERT_BIT_GENERIC0)) update_attribute_map_mode(ctx, vao); } } |