[Mesa-dev] [PATCH] main: Simplify debug messages for CopyTex*SubImage*D.
Anuj Phogat
anuj.phogat at gmail.com
Thu Mar 19 11:10:54 PDT 2015
On Thu, Mar 19, 2015 at 10:48 AM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> ---
> src/mesa/main/teximage.c | 86 +++++++++++++++++++++---------------------------
> src/mesa/main/teximage.h | 3 +-
> 2 files changed, 39 insertions(+), 50 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 8b56d5b..7f0f7b7 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -2826,10 +2826,9 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
> const struct gl_texture_object *texObj,
> GLenum target, GLint level,
> GLint xoffset, GLint yoffset, GLint zoffset,
> - GLint width, GLint height, bool dsa)
> + GLint width, GLint height, const char *caller)
> {
> struct gl_texture_image *texImage;
> - const char *suffix = dsa ? "ture" : "";
>
> /* Check that the source buffer is complete */
> if (_mesa_is_user_fbo(ctx->ReadBuffer)) {
> @@ -2838,31 +2837,26 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
> }
> if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
> _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
> - "glCopyTex%sSubImage%dD(invalid readbuffer)",
> - suffix, dimensions);
> + "%s(invalid readbuffer)", caller);
> return GL_TRUE;
> }
>
> if (ctx->ReadBuffer->Visual.samples > 0) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCopyTex%sSubImage%dD(multisample FBO)", suffix,
> - dimensions);
> + "%s(multisample FBO)", caller);
> return GL_TRUE;
> }
> }
>
> /* Check level */
> if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
> - _mesa_error(ctx, GL_INVALID_VALUE,
> - "glCopyTex%sSubImage%dD(level=%d)", suffix,
> - dimensions, level);
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(level=%d)", caller, level);
> return GL_TRUE;
> }
>
> /* Get dest image pointers */
> if (!texObj) {
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTex%sSubImage%dD()",
> - suffix, dimensions);
> + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", caller);
> return GL_TRUE;
> }
>
> @@ -2870,37 +2864,33 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
> if (!texImage) {
> /* destination image does not exist */
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCopyTex%sSubImage%dD(invalid texture image)",
> - suffix, dimensions);
> + "%s(invalid texture image)", caller);
> return GL_TRUE;
> }
>
> if (error_check_subtexture_dimensions(ctx, dimensions, texImage,
> xoffset, yoffset, zoffset,
> - width, height, 1, dsa ?
> - "glCompressedTextureSubImage" :
> - "glCompressedTexSubImage")) {
> + width, height, 1, caller)) {
> return GL_TRUE;
> }
>
> if (_mesa_is_format_compressed(texImage->TexFormat)) {
> if (compressedteximage_only_format(ctx, texImage->InternalFormat)) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCopyTex%sSubImage%dD(no compression for format)",
> - suffix, dimensions);
> + "%s(no compression for format)", caller);
> return GL_TRUE;
> }
> }
>
> if (texImage->InternalFormat == GL_YCBCR_MESA) {
> - _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTex%sSubImage2D", suffix);
> + _mesa_error(ctx, GL_INVALID_OPERATION, "%s()", caller);
> return GL_TRUE;
> }
>
> if (!_mesa_source_buffer_exists(ctx, texImage->_BaseFormat)) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCopyTex%sSubImage%dD(missing readbuffer, format=0x%x)",
> - suffix, dimensions, texImage->_BaseFormat);
> + "%s(missing readbuffer, format=0x%x)", caller,
> + texImage->_BaseFormat);
> return GL_TRUE;
> }
>
> @@ -2918,8 +2908,7 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
> if (_mesa_is_format_integer_color(rb->Format) !=
> _mesa_is_format_integer_color(texImage->TexFormat)) {
> _mesa_error(ctx, GL_INVALID_OPERATION,
> - "glCopyTex%sSubImage%dD(integer vs non-integer)",
> - suffix, dimensions);
> + "%s(integer vs non-integer)", caller);
> return GL_TRUE;
> }
> }
> @@ -4043,15 +4032,14 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
> GLint xoffset, GLint yoffset, GLint zoffset,
> GLint x, GLint y,
> GLsizei width, GLsizei height,
> - bool dsa)
> + const char *caller)
> {
> struct gl_texture_image *texImage;
>
> FLUSH_VERTICES(ctx, 0);
>
> if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
> - _mesa_debug(ctx, "glCopyTex%sSubImage%uD %s %d %d %d %d %d %d %d %d\n",
> - dsa ? "ture" : "", dims,
> + _mesa_debug(ctx, "%s %s %d %d %d %d %d %d %d %d\n", caller,
> _mesa_lookup_enum_by_nr(target),
> level, xoffset, yoffset, zoffset, x, y, width, height);
>
> @@ -4060,7 +4048,7 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
>
> if (copytexsubimage_error_check(ctx, dims, texObj, target, level,
> xoffset, yoffset, zoffset,
> - width, height, dsa)) {
> + width, height, caller)) {
> return;
> }
>
> @@ -4106,14 +4094,14 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
> GLint xoffset, GLint x, GLint y, GLsizei width )
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTexSubImage1D";
I find the name 'caller' more appropriate. Up to you if you want to change that.
> GET_CURRENT_CONTEXT(ctx);
>
> /* Check target (proxies not allowed). Target must be checked prior to
> * calling _mesa_get_current_tex_object.
> */
> if (!legal_texsubimage_target(ctx, 1, target, false)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTexSubImage1D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(target));
> return;
> }
> @@ -4123,7 +4111,7 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
> return;
>
> _mesa_copy_texture_sub_image(ctx, 1, texObj, target, level, xoffset, 0, 0,
> - x, y, width, 1, false);
> + x, y, width, 1, self);
> }
>
>
> @@ -4134,14 +4122,14 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
> GLint x, GLint y, GLsizei width, GLsizei height )
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTexSubImage2D";
> GET_CURRENT_CONTEXT(ctx);
>
> /* Check target (proxies not allowed). Target must be checked prior to
> * calling _mesa_get_current_tex_object.
> */
> if (!legal_texsubimage_target(ctx, 2, target, false)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTexSubImage2D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(target));
> return;
> }
> @@ -4152,7 +4140,7 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
>
> _mesa_copy_texture_sub_image(ctx, 2, texObj, target, level,
> xoffset, yoffset, 0,
> - x, y, width, height, false);
> + x, y, width, height, self);
> }
>
>
> @@ -4163,14 +4151,14 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
> GLint x, GLint y, GLsizei width, GLsizei height )
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTexSubImage3D";
> GET_CURRENT_CONTEXT(ctx);
>
> /* Check target (proxies not allowed). Target must be checked prior to
> * calling _mesa_get_current_tex_object.
> */
> if (!legal_texsubimage_target(ctx, 3, target, false)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTexSubImage3D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(target));
> return;
> }
> @@ -4181,7 +4169,7 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
>
> _mesa_copy_texture_sub_image(ctx, 3, texObj, target, level,
> xoffset, yoffset, zoffset,
> - x, y, width, height, false);
> + x, y, width, height, self);
> }
>
> void GLAPIENTRY
> @@ -4189,22 +4177,22 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
> GLint xoffset, GLint x, GLint y, GLsizei width)
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTextureSubImage1D";
> GET_CURRENT_CONTEXT(ctx);
>
> - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage1D");
> + texObj = _mesa_lookup_texture_err(ctx, texture, self);
> if (!texObj)
> return;
>
> /* Check target (proxies not allowed). */
> if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTextureSubImage1D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(texObj->Target));
> return;
> }
>
> _mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
> - xoffset, 0, 0, x, y, width, 1, true);
> + xoffset, 0, 0, x, y, width, 1, self);
> }
>
> void GLAPIENTRY
> @@ -4213,23 +4201,23 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
> GLint x, GLint y, GLsizei width, GLsizei height)
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTextureSubImage2D";
> GET_CURRENT_CONTEXT(ctx);
>
> - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage2D");
> + texObj = _mesa_lookup_texture_err(ctx, texture, self);
> if (!texObj)
> return;
>
> /* Check target (proxies not allowed). */
> if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTextureSubImage2D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(texObj->Target));
> return;
> }
>
> _mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level,
> xoffset, yoffset, 0,
> - x, y, width, height, true);
> + x, y, width, height, self);
> }
>
>
> @@ -4240,16 +4228,16 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
> GLint x, GLint y, GLsizei width, GLsizei height)
> {
> struct gl_texture_object* texObj;
> + const char *self = "glCopyTextureSubImage3D";
> GET_CURRENT_CONTEXT(ctx);
>
> - texObj = _mesa_lookup_texture_err(ctx, texture, "glCopyTextureSubImage3D");
> + texObj = _mesa_lookup_texture_err(ctx, texture, self);
> if (!texObj)
> return;
>
> /* Check target (proxies not allowed). */
> if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) {
> - _mesa_error(ctx, GL_INVALID_ENUM,
> - "glCopyTextureSubImage3D(invalid target %s)",
> + _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
> _mesa_lookup_enum_by_nr(texObj->Target));
> return;
> }
> @@ -4260,12 +4248,12 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
> GL_TEXTURE_CUBE_MAP_POSITIVE_X + zoffset,
> level,
> xoffset, yoffset, 0,
> - x, y, width, height, false);
> + x, y, width, height, self);
> }
> else
> _mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level,
> xoffset, yoffset, zoffset,
> - x, y, width, height, true);
> + x, y, width, height, self);
> }
>
> static bool
> diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
> index 0ce4a30..1eebaa8 100644
> --- a/src/mesa/main/teximage.h
> +++ b/src/mesa/main/teximage.h
> @@ -196,7 +196,8 @@ _mesa_copy_texture_sub_image(struct gl_context *ctx, GLuint dims,
> GLenum target, GLint level,
> GLint xoffset, GLint yoffset, GLint zoffset,
> GLint x, GLint y,
> - GLsizei width, GLsizei height, bool dsa);
> + GLsizei width, GLsizei height,
> + const char *caller);
>
> extern void
> _mesa_texture_image_multisample(struct gl_context *ctx, GLuint dims,
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the mesa-dev
mailing list