mesa/es: Validate glGetVertexAttribf pname in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 23:21:49 +0000 (16:21 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 29 Aug 2012 22:09:34 +0000 (15:09 -0700)
v2: Add proper core-profile and GLES3 filtering.

v3: Allow glGetVertexAttribfv(0, GL_CURRENT_VERTEX_ATTRIB_ARB, param) in
OpenGL 3.1, just like OpenGL ES 2.0.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/APIspec.xml
src/mesa/main/varray.c

index de7364091b9cf9b4eba2b369b9f6b5f83988b8a7..6b20baa38dfa38391130f934160e654d66ee3715 100644 (file)
                <param name="pname" type="GLenum"/>
                <vector name="params" type="GLtype *" size="dynamic"/>
        </proto>
-
-       <desc name="pname">
-               <value name="GL_VERTEX_ATTRIB_ARRAY_ENABLED"/>
-               <value name="GL_VERTEX_ATTRIB_ARRAY_SIZE"/>
-               <value name="GL_VERTEX_ATTRIB_ARRAY_STRIDE"/>
-               <value name="GL_VERTEX_ATTRIB_ARRAY_TYPE"/>
-               <value name="GL_VERTEX_ATTRIB_ARRAY_NORMALIZED"/>
-               <value name="GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING"/>
-
-               <desc name="params" vector_size="1" convert="false"/>
-       </desc>
-
-       <desc name="pname">
-               <value name="GL_CURRENT_VERTEX_ATTRIB"/>
-               <desc name="params" vector_size="16?" convert="false"/>
-       </desc>
 </template>
 
 <template name="GetVertexAttribPointer" direction="get">
index 8c3ddc524aaa97b34351fb55d14e735f205412fe..8a1233371545481420c86fbe81fc276a34f56e95 100644 (file)
@@ -590,12 +590,15 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
    case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
       return array->BufferObj->Name;
    case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
-      if (ctx->Version >= 30 || ctx->Extensions.EXT_gpu_shader4) {
+      if ((_mesa_is_desktop_gl(ctx)
+           && (ctx->Version >= 30 || ctx->Extensions.EXT_gpu_shader4))
+          || _mesa_is_gles3(ctx)) {
          return array->Integer;
       }
       goto error;
    case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB:
-      if (ctx->Extensions.ARB_instanced_arrays) {
+      if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_instanced_arrays)
+          || _mesa_is_gles3(ctx)) {
          return array->InstanceDivisor;
       }
       goto error;
@@ -613,7 +616,13 @@ static const GLfloat *
 get_current_attrib(struct gl_context *ctx, GLuint index, const char *function)
 {
    if (index == 0) {
-      if (ctx->API != API_OPENGLES2) {
+      /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
+       * 2.0.  Note that we cannot just check for API_OPENGL_CORE here because
+       * that will erroneously allow this usage in a 3.0 forward-compatible
+       * context too.
+       */
+      if ((ctx->API != API_OPENGL_CORE || ctx->Version < 31)
+          && ctx->API != API_OPENGLES2) {
         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(index==0)", function);
         return NULL;
       }