From: Mathias Fröhlich <mathias.froehl...@web.de>

Bail out with out of memory, when the required stride exceeds the
maximum possible stride as stored in Const.MaxVertexAttribStride.
Etnaviv can only handle less than the OpenGL standard mandated
minimum of 2048. For this one, at least give some 'resource
exhaustion error' to the application.
The virgl driver provides 0 for Const.MaxVertexAttribStride
as it may not be able to query the relevant informatition from the
underlying OpenGL stack. In this case we just make the assumption
that the underlying OpenGL stack is able to cope with then commonly
seen small strides. Note that this is the same than what applications
had to do before the queries to GL_MAX_VERTEX_ATTRIB_STRIDE, they had to
hope for the best that the driver and hardware can safely handle the
used stride values.

Signed-off-by: Mathias Fröhlich <mathias.froehl...@web.de>
---
 src/mesa/vbo/vbo_save_api.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 945a0c8bff..c3776ae624 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -492,11 +492,27 @@ update_vao(struct gl_context *ctx,
    _mesa_reference_vao(ctx, vao, NULL);
    *vao = _mesa_new_vao(ctx, ~((GLuint)0));
 
-   /*
-    * assert(stride <= ctx->Const.MaxVertexAttribStride);
-    * MaxVertexAttribStride is not set for drivers that does not
-    * expose GL 44 or GLES 31.
+   /* Bail out with out of memory, when the required stride exceeds the
+    * maximum possible stride.
+    * Etnaviv can only handle less than the OpenGL standard mandated
+    * minimum of 2048. For this one, at least give some 'resource
+    * exhaustion error' to the application.
+    * The virgl driver provides 0 for Const.MaxVertexAttribStride
+    * as it may not be able to query the relevant informatition from the
+    * underlying OpenGL stack. In this case we just make the assumption
+    * that the underlying OpenGL stack is able to cope with then commonly
+    * seen small strides. Note that this is the same than what applications
+    * had to do before the queries to GL_MAX_VERTEX_ATTRIB_STRIDE, they had to
+    * hope for the best that the driver and hardware can safely handle the
+    * used stride values.
     */
+   if (ctx->Const.MaxVertexAttribStride &&
+       stride > ctx->Const.MaxVertexAttribStride) {
+      /* Finalize and freeze also the empty VAO */
+      _mesa_set_vao_immutable(ctx, *vao);
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "Max VAO binding stride exceeded");
+      return;
+   }
 
    /* Bind the buffer object at binding point 0 */
    _mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride);
-- 
2.17.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to