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

Samuel Iglesias Gonsalvez siglesias at igalia.com
Wed Jul 29 07:01:27 PDT 2015


From: Eduardo Lima Mitev <elima at igalia.com>

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 c71b818..0b755ea 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2493,19 +2493,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_enum_to_string(format),
-                     _mesa_enum_to_string(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);
@@ -2517,6 +2510,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_enum_to_string(format),
+                        _mesa_enum_to_string(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_enum_to_string(format),
+                        _mesa_enum_to_string(type),
+                        _mesa_enum_to_string(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,
@@ -2524,14 +2547,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.4.3



More information about the mesa-dev mailing list