[Mesa-dev] [PATCH 04/18] mesa/es: Validate EGLImageTargetTexture2DOES target in Mesa code rather than the ES wrapper
Ian Romanick
idr at freedesktop.org
Mon Aug 20 17:06:30 PDT 2012
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/main/APIspec.xml | 5 -----
src/mesa/main/teximage.c | 20 +++++++++++++++-----
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 7acade2..1306ac7 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -3114,11 +3114,6 @@
<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">
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index fd02a1b..78e4b3b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -28,7 +28,7 @@
* Texture image-related functions.
*/
-
+#include <stdbool.h>
#include "glheader.h"
#include "bufferobj.h"
#include "context.h"
@@ -2698,13 +2698,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;
--
1.7.6.5
More information about the mesa-dev
mailing list