From 18f4241b89b9f9869c89a291e0ab1d54e6e74fbf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jan 2018 14:28:01 -0700 Subject: [PATCH] vbo: add assertions, comments in vbo_exec_api.c Reviewed-by: Ian Romanick Reviewed-by: Roland Scheidegger Reviewed-by: Emil Velikov --- src/mesa/vbo/vbo_exec_api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 019f986f0bb..800fac85c45 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -270,6 +270,7 @@ vbo_exec_copy_from_current(struct vbo_exec_context *exec) * to a larger one. Ex: glTexCoord2f -> glTexCoord4f. * We need to go back over the previous 2-component texcoords and insert * zero and one values. + * \param attr VBO_ATTRIB_x vertex attribute value */ static void vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, @@ -283,6 +284,8 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, const GLuint oldSize = exec->vtx.attrsz[attr]; GLuint i; + assert(attr < VBO_ATTRIB_MAX); + /* Run pipeline on current vertices, copy wrapped vertices * to exec->vtx.copied. */ @@ -401,6 +404,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, * For example, we saw a bunch of glTexCoord2f() calls and now we got a * glTexCoord4f() call. We promote the array from size=2 to size=4. * \param newSize size of new vertex (number of 32-bit words). + * \param attr VBO_ATTRIB_x vertex attribute value */ static void vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, @@ -408,6 +412,8 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, { struct vbo_exec_context *exec = &vbo_context(ctx)->exec; + assert(attr < VBO_ATTRIB_MAX); + if (newSize > exec->vtx.attrsz[attr] || newType != exec->vtx.attrtype[attr]) { /* New size is larger. Need to flush existing vertices and get @@ -459,7 +465,7 @@ vbo_exec_begin_vertices(struct gl_context *ctx) /** * This macro is used to implement all the glVertex, glColor, glTexCoord, * glVertexAttrib, etc functions. - * \param A attribute index + * \param A VBO_ATTRIB_x attribute index * \param N attribute size (1..4) * \param T type (GL_FLOAT, GL_DOUBLE, GL_INT, GL_UNSIGNED_INT) * \param C cast type (fi_type or double) -- 2.30.2