[Mesa-dev] [PATCH 03/18] mesa/es: Validate glTexParameter targets in Mesa code rather than the ES wrapper

Ian Romanick idr at freedesktop.org
Mon Aug 20 17:06:29 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

Ditto for glGetTexParameter targets.

v2: Add proper core-profile and GLES3 filtering.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/APIspec.xml      |   16 ----------------
 src/mesa/main/es1_conversion.c |   10 ----------
 src/mesa/main/texparam.c       |   23 +++++++++++++++--------
 3 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 6d7dbfd..7acade2 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -227,14 +227,6 @@
 		</vector>
 	</proto>
 
-	<desc name="target">
-		<value name="GL_TEXTURE_2D"/>
-		<value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
-		<value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
-		<value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
-		<value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/>
-	</desc>
-
 	<desc name="pname">
 		<value name="GL_TEXTURE_WRAP_S"/>
 		<value name="GL_TEXTURE_WRAP_T"/>
@@ -1222,14 +1214,6 @@
 		<vector name="params" type="GLtype *" size="dynamic"/>
 	</proto>
 
-	<desc name="target">
-		<value name="GL_TEXTURE_2D"/>
-		<value name="GL_TEXTURE_CUBE_MAP" category="GLES2.0"/>
-		<value name="GL_TEXTURE_CUBE_MAP_OES" category="OES_texture_cube_map"/>
-		<value name="GL_TEXTURE_3D_OES" category="OES_texture_3D"/>
-		<value name="GL_TEXTURE_EXTERNAL_OES" category="OES_EGL_image_external"/>
-	</desc>
-
 	<desc name="pname">
 		<value name="GL_TEXTURE_WRAP_S"/>
 		<value name="GL_TEXTURE_WRAP_T"/>
diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c
index 0d9f5b4..247a038 100644
--- a/src/mesa/main/es1_conversion.c
+++ b/src/mesa/main/es1_conversion.c
@@ -1240,16 +1240,6 @@ _es_TexParameterx(GLenum target, GLenum pname, GLfixed param)
    GLfloat converted_param;
    bool convert_param_value = true;
 
-   switch(target) {
-   case GL_TEXTURE_2D:
-   case GL_TEXTURE_CUBE_MAP:
-   case GL_TEXTURE_EXTERNAL_OES:
-      break;
-   default:
-      _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM,
-                  "glTexParameterx(target=0x%x)", target);
-      return;
-   }
    switch(pname) {
    case GL_TEXTURE_WRAP_S:
    case GL_TEXTURE_WRAP_T:
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index a0f736c..bb16228 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -131,35 +131,42 @@ get_texobj(struct gl_context *ctx, GLenum target, GLboolean get)
 
    switch (target) {
    case GL_TEXTURE_1D:
-      return texUnit->CurrentTex[TEXTURE_1D_INDEX];
+      if (_mesa_is_desktop_gl(ctx))
+         return texUnit->CurrentTex[TEXTURE_1D_INDEX];
+      break;
    case GL_TEXTURE_2D:
       return texUnit->CurrentTex[TEXTURE_2D_INDEX];
    case GL_TEXTURE_3D:
-      return texUnit->CurrentTex[TEXTURE_3D_INDEX];
+      if (ctx->API != API_OPENGLES)
+         return texUnit->CurrentTex[TEXTURE_3D_INDEX];
+      break;
    case GL_TEXTURE_CUBE_MAP:
       if (ctx->Extensions.ARB_texture_cube_map) {
          return texUnit->CurrentTex[TEXTURE_CUBE_INDEX];
       }
       break;
    case GL_TEXTURE_RECTANGLE_NV:
-      if (ctx->Extensions.NV_texture_rectangle) {
+      if (_mesa_is_desktop_gl(ctx)
+          && ctx->Extensions.NV_texture_rectangle) {
          return texUnit->CurrentTex[TEXTURE_RECT_INDEX];
       }
       break;
    case GL_TEXTURE_1D_ARRAY_EXT:
-      if (ctx->Extensions.MESA_texture_array ||
-          ctx->Extensions.EXT_texture_array) {
+      if (_mesa_is_desktop_gl(ctx)
+          && (ctx->Extensions.MESA_texture_array ||
+              ctx->Extensions.EXT_texture_array)) {
          return texUnit->CurrentTex[TEXTURE_1D_ARRAY_INDEX];
       }
       break;
    case GL_TEXTURE_2D_ARRAY_EXT:
-      if (ctx->Extensions.MESA_texture_array ||
-          ctx->Extensions.EXT_texture_array) {
+      if ((_mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx))
+          && (ctx->Extensions.MESA_texture_array ||
+              ctx->Extensions.EXT_texture_array)) {
          return texUnit->CurrentTex[TEXTURE_2D_ARRAY_INDEX];
       }
       break;
    case GL_TEXTURE_EXTERNAL_OES:
-      if (ctx->Extensions.OES_EGL_image_external) {
+      if (_mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external) {
          return texUnit->CurrentTex[TEXTURE_EXTERNAL_INDEX];
       }
       break;
-- 
1.7.6.5



More information about the mesa-dev mailing list