aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorEduardo Lima Mitev <[email protected]>2015-07-29 16:01:27 +0200
committerEduardo Lima Mitev <[email protected]>2015-08-05 08:20:16 +0200
commit03b7221dbb93e2439f30b2e0918f6215eb741979 (patch)
treed15a98364b2e7cad1b40e9e505770352a2b8ed2a /src/mesa/main
parent4b07e9a033ddb6733eba206b5bd47a2373756f7d (diff)
mesa: Add missing check of format and type in glTexSubImageXD on GLES 3.0
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 on GLES into a new function texture_format_error_check_gles(), to factorize similar code in texture_format_error_check(). Fixes 2 dEQP tests: * dEQP-GLES3.functional.negative_api.texture.texsubimage2d * dEQP-GLES3.functional.negative_api.texture.texsubimage3d Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/teximage.c116
1 files changed, 69 insertions, 47 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index d19ad641a5f..fc69387204f 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2089,6 +2089,53 @@ texture_formats_agree(GLenum internalFormat,
}
/**
+ * Test the combination of format, type and internal format arguments of
+ * different texture operations on GLES.
+ *
+ * \param ctx GL context.
+ * \param format pixel data format given by the user.
+ * \param type pixel data type given by the user.
+ * \param internalFormat internal format given by the user.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param callerName name of the caller function to print in the error message
+ *
+ * \return true if a error is found, false otherwise
+ *
+ * Currently, it is used by texture_error_check() and texsubimage_error_check().
+ */
+static bool
+texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
+ GLenum type, GLenum internalFormat,
+ GLuint dimensions, const char *callerName)
+{
+ GLenum err;
+
+ if (_mesa_is_gles3(ctx)) {
+ err = _mesa_es3_error_check_format_and_type(ctx, format, type,
+ internalFormat);
+ if (err != GL_NO_ERROR) {
+ _mesa_error(ctx, err,
+ "%s(format = %s, type = %s, internalformat = %s)",
+ callerName, _mesa_enum_to_string(format),
+ _mesa_enum_to_string(type),
+ _mesa_enum_to_string(internalFormat));
+ return true;
+ }
+ }
+ else {
+ 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 true;
+ }
+ }
+
+ return false;
+}
+
+/**
* Test the glTexImage[123]D() parameters for errors.
*
* \param ctx GL context.
@@ -2159,32 +2206,10 @@ texture_error_check( struct gl_context *ctx,
* 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_es3_error_check_format_and_type(ctx, format, type,
- internalFormat);
- } else {
- if (format != internalFormat) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glTexImage%dD(format = %s, internalFormat = %s)",
- dimensions,
- _mesa_enum_to_string(format),
- _mesa_enum_to_string(internalFormat));
- return GL_TRUE;
- }
-
- err = _mesa_es_error_check_format_and_type(format, type, dimensions);
- }
- if (err != GL_NO_ERROR) {
- _mesa_error(ctx, err,
- "glTexImage%dD(format = %s, type = %s, internalFormat = %s)",
- dimensions,
- _mesa_enum_to_string(format),
- _mesa_enum_to_string(type),
- _mesa_enum_to_string(internalFormat));
- return GL_TRUE;
- }
+ if (_mesa_is_gles(ctx) &&
+ texture_format_error_check_gles(ctx, format, type, internalFormat,
+ dimensions, "glTexImage%dD")) {
+ return GL_TRUE;
}
/* Check internalFormat */
@@ -2493,19 +2518,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 +2535,18 @@ 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, internalFormat, 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) &&
+ texture_format_error_check_gles(ctx, format, type,
+ texImage->InternalFormat,
+ dimensions, callerName)) {
+ 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 +2554,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)) {