mesa/es: Validate EGLImageTargetTexture2DOES target in Mesa code rather than the...
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 23:13:33 +0000 (16:13 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 23 Aug 2012 17:15:30 +0000 (10:15 -0700)
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 7acade2ce11d8184dcdb315b65cfb4af23383047..1306ac7a97196ebf709d148e43d28e38ea5e9b47 100644 (file)
                <param name="target" type="GLenum"/>
                <param name="image" type="GLeglImageOES"/>
        </proto>
-
-       <desc name="target">
-               <value name="GL_TEXTURE_2D"/>
-               <value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/>
-       </desc>
 </template>
 
 <template name="EGLImageTargetRenderbufferStorage">
index 27294ba8018a61d151c26241ad8338079ddcedf1..095db4ff9c1d1f8aa0b0a633555a1ab91dd64d7f 100644 (file)
@@ -28,7 +28,7 @@
  * Texture image-related functions.
  */
 
-
+#include <stdbool.h>
 #include "glheader.h"
 #include "bufferobj.h"
 #include "context.h"
@@ -2670,13 +2670,23 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
 {
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
+   bool valid_target;
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
-   if ((target == GL_TEXTURE_2D &&
-        !ctx->Extensions.OES_EGL_image) ||
-       (target == GL_TEXTURE_EXTERNAL_OES &&
-        !ctx->Extensions.OES_EGL_image_external)) {
+   switch (target) {
+   case GL_TEXTURE_2D:
+      valid_target = ctx->Extensions.OES_EGL_image;
+      break;
+   case GL_TEXTURE_EXTERNAL_OES:
+      valid_target = ctx->Extensions.OES_EGL_image_external;
+      break;
+   default:
+      valid_target = false;
+      break;
+   }
+
+   if (!valid_target) {
       _mesa_error(ctx, GL_INVALID_ENUM,
                  "glEGLImageTargetTexture2D(target=%d)", target);
       return;