[Mesa-dev] [PATCH 2/2 v2] mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0

Eduardo Lima Mitev elima at igalia.com
Wed Mar 25 12:54:17 PDT 2015


Argument validation for glTexSubImageXD is missing a check of format and type
against texture object's internal format when profile is OpenGL-ES 3.0+.

This patch also groups together all format and type checks into a single
block of code for clarity.

Fixes 2 dEQP tests:
* dEQP-GLES3.functional.negative_api.texture.texsubimage2d
* dEQP-GLES3.functional.negative_api.texture.texsubimage3d
---
 src/mesa/main/teximage.c | 57 ++++++++++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 17c9f56..ffa0fd1 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2484,19 +2484,12 @@ texsubimage_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
-    * combinations of format and type that can be used.  Formats and types
-    * that require additional extensions (e.g., GL_FLOAT requires
-    * GL_OES_texture_float) are filtered elsewhere.
-    */
-   if (_mesa_is_gles(ctx) && !_mesa_is_gles3(ctx)) {
-      err = _mesa_es_error_check_format_and_type(format, type, dimensions);
-      if (err != GL_NO_ERROR) {
-         _mesa_error(ctx, err, "%s(format = %s, type = %s)",
-                     callerName, _mesa_lookup_enum_by_nr(format),
-                     _mesa_lookup_enum_by_nr(type));
-         return GL_TRUE;
-      }
+   texImage = _mesa_select_tex_image(texObj, target, level);
+   if (!texImage) {
+      /* non-existant texture level */
+      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)",
+                  callerName);
+      return GL_TRUE;
    }
 
    err = _mesa_error_check_format_and_type(ctx, format, type);
@@ -2508,6 +2501,36 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
       return GL_TRUE;
    }
 
+   /* OpenGL ES impose additional restrictions on the combinations of format
+    * and type that can be used. Formats and types that require additional
+    * extensions (e.g., GL_FLOAT requires GL_OES_texture_float) are filtered
+    * elsewhere.
+    */
+   if (_mesa_is_gles(ctx)) {
+      if (!_mesa_is_gles3(ctx)) {
+         err = _mesa_es_error_check_format_and_type(format, type, dimensions);
+         if (err != GL_NO_ERROR) {
+            _mesa_error(ctx, err, "%s(format = %s, type = %s)",
+                        callerName, _mesa_lookup_enum_by_nr(format),
+                        _mesa_lookup_enum_by_nr(type));
+            return GL_TRUE;
+         }
+      }
+      else {
+         err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+                                                     texImage->InternalFormat);
+         if (err != GL_NO_ERROR) {
+            _mesa_error(ctx, err,
+                        "%s(incompatible format = %s, type = %s, "
+                        "internalformat = %s)",
+                        callerName, _mesa_lookup_enum_by_nr(format),
+                        _mesa_lookup_enum_by_nr(type),
+                        _mesa_lookup_enum_by_nr(texImage->InternalFormat));
+            return GL_TRUE;
+         }
+      }
+   }
+
    /* validate the bound PBO, if any */
    if (!_mesa_validate_pbo_source(ctx, dimensions, &ctx->Unpack,
                                   width, height, depth, format, type,
@@ -2515,14 +2538,6 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
       return GL_TRUE;
    }
 
-   texImage = _mesa_select_tex_image(texObj, target, level);
-   if (!texImage) {
-      /* non-existant texture level */
-      _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture image)",
-                  callerName);
-      return GL_TRUE;
-   }
-
    if (error_check_subtexture_dimensions(ctx, dimensions,
                                          texImage, xoffset, yoffset, zoffset,
                                          width, height, depth, callerName)) {
-- 
2.1.3



More information about the mesa-dev mailing list