mesa/es: Validate glCopyTexImage internalFormat in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 27 Jul 2012 13:45:54 +0000 (06:45 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 23 Aug 2012 17:15:31 +0000 (10:15 -0700)
v2: Add GLES3 filtering.  I'm not 100% sure this is correct.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/mesa/main/APIspec.xml
src/mesa/main/teximage.c

index 7b6e25ebdf85e574b478c562c9ea564109da0e61..b9332ab802844dc7a0a9c0c1cf1c6cec18bd6ef2 100644 (file)
                <param name="height" type="GLsizei"/>
                <param name="border" type="GLint"/>
        </proto>
-
-       <desc name="internalFormat" error="GL_INVALID_VALUE">
-               <value name="GL_ALPHA"/>
-               <value name="GL_RGB"/>
-               <value name="GL_RGBA"/>
-               <value name="GL_LUMINANCE"/>
-               <value name="GL_LUMINANCE_ALPHA"/>
-       </desc>
 </template>
 
 <template name="CopyTexSubImage2D">
index 3cd9d40155397ef32a8fecd242aad33534127e34..5cf91183a204a1ceb4c96ee6725a97e835ee5310 100644 (file)
@@ -2127,6 +2127,24 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
       return GL_TRUE;
    }
 
+   /* OpenGL ES 1.x and OpenGL ES 2.0 impose additional restrictions on the
+    * internalFormat.
+    */
+   if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) {
+      switch (internalFormat) {
+      case GL_ALPHA:
+      case GL_RGB:
+      case GL_RGBA:
+      case GL_LUMINANCE:
+      case GL_LUMINANCE_ALPHA:
+         break;
+      default:
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glCopyTexImage%dD(internalFormat)", dimensions);
+         return GL_TRUE;
+      }
+   }
+
    baseFormat = _mesa_base_tex_format(ctx, internalFormat);
    if (baseFormat < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE,