mesa: implement GL_MAX_VERTEX_ATTRIB_STRIDE
authorTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 14 Aug 2014 14:16:09 +0000 (00:16 +1000)
committerTimothy Arceri <t_arceri@yahoo.com.au>
Thu, 28 Aug 2014 06:35:56 +0000 (20:35 -1000)
V2: moved test for the VertexAttrib*Pointer() functions
 to update_array(), and made constant available for drivers to set

Signed-off-by: Timothy Arceri <t_arceri@yahoo.com.au>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml
src/mesa/main/context.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h
src/mesa/main/varray.c

index 0ee6a3c00bedcf050e9a575575b71820f508eceb..7e62688779d824de914f8891a021a27b4dfd2ce1 100644 (file)
@@ -53,6 +53,7 @@
     <enum name="VERTEX_BINDING_STRIDE" value="0x82D8"/>
     <enum name="MAX_VERTEX_ATTRIB_RELATIVE_OFFSET" value="0x82D9"/>
     <enum name="MAX_VERTEX_ATTRIB_BINDINGS" value="0x82DA"/>
+    <enum name="MAX_VERTEX_ATTRIB_STRIDE" value="0x82E5"/>
 
 </category>
 </OpenGLAPI>
index 232084267d4727b3ee66b51318e22bc2fb635b40..fbdbd680a2e6e6b35f327b5ae4d3993ba485f22f 100644 (file)
@@ -670,6 +670,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
                           ? GL_CONTEXT_CORE_PROFILE_BIT
                           : GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
 
+   /* GL 4.4 */
+   consts->MaxVertexAttribStride = 2048;
+
    /** GL_EXT_gpu_shader4 */
    consts->MinProgramTexelOffset = -8;
    consts->MaxProgramTexelOffset = 7;
index ff858207b873026c5753733a80a3358a06d4aeca..aace8a5b5dfff8f6f7823736e2e8342de2d543f2 100644 (file)
@@ -712,6 +712,9 @@ descriptor=[
   [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32" ],
   [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32" ],
 
+# GL 4.4
+  [ "MAX_VERTEX_ATTRIB_STRIDE", "CONTEXT_ENUM(Const.MaxVertexAttribStride), NO_EXTRA" ],
+
 # GL_ARB_robustness
   [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ],
 
index cb2a4df4f2f464073331e33de03a7181bff459cd..adb6788e3b8f5d5e6bba72190f65c41698690325 100644 (file)
@@ -3414,6 +3414,9 @@ struct gl_constants
    /** OpenGL version 3.2 */
    GLbitfield ProfileMask;   /**< Mask of CONTEXT_x_PROFILE_BIT */
 
+   /** OpenGL version 4.4 */
+   GLuint MaxVertexAttribStride;
+
    /** GL_EXT_transform_feedback */
    GLuint MaxTransformFeedbackBuffers;
    GLuint MaxTransformFeedbackSeparateComponents;
index 5d3cc2a70c6052b1ecb2657fdaaca7b3400b49d2..7d169f9d49b6085a162041bdbf23a30e6619cb87 100644 (file)
@@ -424,6 +424,13 @@ update_array(struct gl_context *ctx,
       return;
    }
 
+   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+       stride > ctx->Const.MaxVertexAttribStride) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
+                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
+      return;
+   }
+
    /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
     *
     *     "An INVALID_OPERATION error is generated under any of the following
@@ -1437,6 +1444,13 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
       return;
    }
 
+   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+       stride > ctx->Const.MaxVertexAttribStride) {
+      _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffer(stride=%d > "
+                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
+      return;
+   }
+
    if (buffer == vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) {
       vbo = vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj;
    } else if (buffer != 0) {
@@ -1565,6 +1579,14 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
          continue;
       }
 
+      if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
+          strides[i] > ctx->Const.MaxVertexAttribStride) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glBindVertexBuffers(strides[%u]=%d > "
+                     "GL_MAX_VERTEX_ATTRIB_STRIDE)", i, strides[i]);
+         continue;
+      }
+
       if (buffers[i]) {
          struct gl_vertex_buffer_binding *binding =
             &vao->VertexBinding[VERT_ATTRIB_GENERIC(first + i)];