From: Dave Airlie <airl...@redhat.com>

GL 3.2 introduced new language in this area, and CTS enforces it,
this patches checks all the vertex buffers and the index buffer
are mapped in the core profile case. I'm not sure what GLES
expects here.

This fixes
GL33-CTS.draw_elements_base_vertex_tests.invalid_mapped_bos

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/mesa/main/api_validate.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 53c8fb8..8b79d5c 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -34,7 +34,21 @@
 #include "transformfeedback.h"
 #include <stdbool.h>
 
+/* GL3.2 introduces checks for buffer mappings */
+static bool
+check_buffers_are_unmapped(struct gl_vertex_buffer_binding *inputs)
+{
+   GLuint i;
 
+   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+      if (inputs[i].BufferObj) {
+         struct gl_buffer_object *obj = inputs[i].BufferObj;
+         if (_mesa_check_disallowed_mapping(obj))
+            return false;
+      }
+   }
+   return true;
+}
 /**
  * Check if OK to draw arrays/elements.
  */
@@ -58,6 +72,25 @@ check_valid_to_render(struct gl_context *ctx, const char 
*function)
       break;
 
    case API_OPENGL_CORE:
+
+      /* Section 2.9.3 (Mapping and Unmapping Buffer Data" of the OpenGL 4.2
+       * Core Profile says:
+       *    "Most, but not all GL commands will detect attempts to read data
+       *     from a mapped buffer object. When such an attempt is detected, an
+       *     INVALID_OPERATION error will be generated.
+       */
+      if (!check_buffers_are_unmapped(ctx->Array.VAO->VertexBinding)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffers mapped)", 
function);
+         return false;
+      }
+
+      if (ctx->Array.VAO->IndexBufferObj) {
+         if (_mesa_check_disallowed_mapping(ctx->Array.VAO->IndexBufferObj)) {
+            _mesa_error(ctx, GL_INVALID_OPERATION, "%s(buffers mapped)", 
function);
+            return false;
+         }
+      }
+
       /* Section 10.4 (Drawing Commands Using Vertex Arrays) of the OpenGL 4.5
        * Core Profile spec says:
        *
-- 
2.4.3

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

Reply via email to