Mesa (master): mesa/es: Validate glCopyTexImage internalFormat in Mesa code rather than the ES wrapper

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 23 17:20:51 UTC 2012


Module: Mesa
Branch: master
Commit: c11096e94a68ce0a1d7c9cda0f178ceca44ce25d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c11096e94a68ce0a1d7c9cda0f178ceca44ce25d

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jul 27 06:45:54 2012 -0700

mesa/es: Validate glCopyTexImage internalFormat in Mesa code rather than the ES wrapper

v2: Add GLES3 filtering.  I'm not 100% sure this is correct.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/mesa/main/APIspec.xml |    8 --------
 src/mesa/main/teximage.c  |   18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 7b6e25e..b9332ab 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -1418,14 +1418,6 @@
 		<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">
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 3cd9d40..5cf9118 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -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,




More information about the mesa-commit mailing list