From 7575a0a25120b9637d50fcf2b55a4859b505f781 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 3 Feb 2020 19:43:42 -0500 Subject: [PATCH] vbo: clean up resetting vertex attribs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Mathias Fröhlich Part-of: --- src/mesa/vbo/vbo_exec_api.c | 52 ++++++++++++++----------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 1d59f38bb28..9d048363782 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -1011,11 +1011,27 @@ vbo_use_buffer_objects(struct gl_context *ctx) } +static void +vbo_reset_all_attr(struct vbo_exec_context *exec) +{ + while (exec->vtx.enabled) { + const int i = u_bit_scan64(&exec->vtx.enabled); + + /* Reset the vertex attribute by setting its size to zero. */ + exec->vtx.attr[i].size = 0; + exec->vtx.attr[i].type = GL_FLOAT; + exec->vtx.attr[i].active_size = 0; + exec->vtx.attrptr[i] = NULL; + } + + exec->vtx.vertex_size = 0; +} + + void vbo_exec_vtx_init(struct vbo_exec_context *exec) { struct gl_context *ctx = exec->ctx; - GLuint i; /* Allocate a buffer object. Will just reuse this object * continuously, unless vbo_use_buffer_objects() is called to enable @@ -1032,14 +1048,8 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec) vbo_exec_vtxfmt_init(exec); _mesa_noop_vtxfmt_init(ctx, &exec->vtxfmt_noop); - exec->vtx.enabled = 0; - for (i = 0 ; i < ARRAY_SIZE(exec->vtx.attr); i++) { - exec->vtx.attr[i].size = 0; - exec->vtx.attr[i].type = GL_FLOAT; - exec->vtx.attr[i].active_size = 0; - } - - exec->vtx.vertex_size = 0; + exec->vtx.enabled = u_bit_consecutive64(0, VBO_ATTRIB_MAX); /* reset all */ + vbo_reset_all_attr(exec); } @@ -1111,30 +1121,6 @@ vbo_exec_FlushVertices(struct gl_context *ctx, GLuint flags) } -/** - * Reset the vertex attribute by setting its size to zero. - */ -static void -vbo_reset_attr(struct vbo_exec_context *exec, GLuint attr) -{ - exec->vtx.attr[attr].size = 0; - exec->vtx.attr[attr].type = GL_FLOAT; - exec->vtx.attr[attr].active_size = 0; -} - - -static void -vbo_reset_all_attr(struct vbo_exec_context *exec) -{ - while (exec->vtx.enabled) { - const int i = u_bit_scan64(&exec->vtx.enabled); - vbo_reset_attr(exec, i); - } - - exec->vtx.vertex_size = 0; -} - - void GLAPIENTRY _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { -- 2.30.2