diff options
author | Laura Ekstrand <[email protected]> | 2015-02-25 10:34:03 -0800 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-03-07 18:12:42 +0000 |
commit | 8b4db9c6877fab9ed37a7377fe6592ff76828555 (patch) | |
tree | 832139c7002b0cfff64dd7d1034d0dee5f38d41d /src/mesa/main | |
parent | b0400a58dbbfba8dce7427cf489361a8db2c9312 (diff) |
main: Fix target checking for CompressedTexSubImage*D.
This fixes a dEQP test failure. In the test,
glCompressedTexSubImage2D was called with target = 0 and failed to throw
INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx,
target) being called before the target checking. To remedy this, target
checking was made into its own function and called prior to
_mesa_get_current_tex_object.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89311
Reviewed-by: Anuj Phogat <[email protected]>
(cherry picked from commit 549078cb5a95e0ee381d036b8c36bc41506f21bc)
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/teximage.c | 80 |
1 files changed, 65 insertions, 15 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 74a306a99f9..e1730b5cab9 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -4457,25 +4457,21 @@ out: /** - * Error checking for glCompressedTexSubImage[123]D(). + * Target checking for glCompressedTexSubImage[123]D(). * \return GL_TRUE if error, GL_FALSE if no error + * Must come before other error checking so that the texture object can + * be correctly retrieved using _mesa_get_current_tex_object. */ static GLboolean -compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, - const struct gl_texture_object *texObj, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, - GLenum format, GLsizei imageSize, bool dsa) +compressed_subtexture_target_check(struct gl_context *ctx, GLenum target, + GLint dims, GLenum format, bool dsa, + const char *caller) { - struct gl_texture_image *texImage; - GLint expectedSize; GLboolean targetOK; - const char *suffix = dsa ? "ture" : ""; if (dsa && target == GL_TEXTURE_RECTANGLE) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedSubTexture%dD(target)", dims); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller, + _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } @@ -4538,7 +4534,9 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, } if (invalidformat) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glCompressedTex%sSubImage%uD(target)", suffix, dims); + "%s(invalid target %s for format %s)", caller, + _mesa_lookup_enum_by_nr(target), + _mesa_lookup_enum_by_nr(format)); return GL_TRUE; } } @@ -4552,11 +4550,30 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, } if (!targetOK) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glCompressedTex%sSubImage%uD(target)", suffix, dims); + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller, + _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } + return GL_FALSE; +} + +/** + * Error checking for glCompressedTexSubImage[123]D(). + * \return GL_TRUE if error, GL_FALSE if no error + */ +static GLboolean +compressed_subtexture_error_check(struct gl_context *ctx, GLint dims, + const struct gl_texture_object *texObj, + GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, bool dsa) +{ + struct gl_texture_image *texImage; + GLint expectedSize; + const char *suffix = dsa ? "ture" : ""; + /* this will catch any invalid compressed format token */ if (!_mesa_is_compressed_format(ctx, format)) { _mesa_error(ctx, GL_INVALID_ENUM, @@ -4712,6 +4729,11 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 1, format, false, + "glCompressedTexSubImage1D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4734,6 +4756,12 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 1, format, + true, + "glCompressedTextureSubImage1D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level, xoffset, 0, 0, width, 1, 1, format, imageSize, data, true); @@ -4749,6 +4777,11 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 2, format, false, + "glCompressedTexSubImage2D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4773,6 +4806,12 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format, + true, + "glCompressedTextureSubImage2D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 2, texObj, texObj->Target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, data, true); @@ -4787,6 +4826,11 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, struct gl_texture_object *texObj; GET_CURRENT_CONTEXT(ctx); + if (compressed_subtexture_target_check(ctx, target, 3, format, false, + "glCompressedTexSubImage3D")) { + return; + } + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) return; @@ -4812,6 +4856,12 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset, if (!texObj) return; + if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format, + true, + "glCompressedTextureSubImage3D")) { + return; + } + _mesa_compressed_texture_sub_image(ctx, 3, texObj, texObj->Target, level, xoffset, yoffset, zoffset, width, height, depth, |