[Mesa-dev] [PATCH 3/3] vbo: Make sure the internal VAO's stay within limits.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Fri Mar 23 18:39:48 UTC 2018


From: Mathias Fröhlich <mathias.froehlich at web.de>

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/vbo/vbo_exec_draw.c | 5 ++++-
 src/mesa/vbo/vbo_save_api.c  | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 026b7be129..31d7700225 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -200,8 +200,10 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
    assert((~vao_enabled & vao->_Enabled) == 0);
 
    /* Bind the buffer object */
+   const GLuint stride = exec->vtx.vertex_size*sizeof(GLfloat);
+   assert(stride <= ctx->Const.MaxVertexAttribStride);
    _mesa_bind_vertex_buffer(ctx, vao, 0, exec->vtx.bufferobj, buffer_offset,
-                            exec->vtx.vertex_size*sizeof(GLfloat), false);
+                            stride, false);
 
    /* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
     * Note that the position/generic0 aliasing is done in the VAO.
@@ -217,6 +219,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
       const GLenum16 type = exec->vtx.attrtype[vbo_attr];
       const GLuint offset = (GLuint)((GLbyte *)exec->vtx.attrptr[vbo_attr] -
                                      (GLbyte *)exec->vtx.vertex);
+      assert(offset <= ctx->Const.MaxVertexAttribRelativeOffset);
 
       /* Set and enable */
       _vbo_set_attrib_format(ctx, vao, vao_attr, buffer_offset,
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 9dd9c7d7d2..a367a569c8 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -493,6 +493,7 @@ update_vao(struct gl_context *ctx,
    *vao = _mesa_new_vao(ctx, ~((GLuint)0));
 
    /* Bind the buffer object at binding point 0 */
+   assert(stride <= ctx->Const.MaxVertexAttribStride);
    _mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride, false);
 
    /* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
@@ -504,6 +505,7 @@ update_vao(struct gl_context *ctx,
    while (mask) {
       const int vao_attr = u_bit_scan(&mask);
       const GLubyte vbo_attr = vao_to_vbo_map[vao_attr];
+      assert(offset[vbo_attr] <= ctx->Const.MaxVertexAttribRelativeOffset);
 
       _vbo_set_attrib_format(ctx, *vao, vao_attr, buffer_offset,
                              size[vbo_attr], type[vbo_attr], offset[vbo_attr]);
-- 
2.14.3



More information about the mesa-dev mailing list