[Mesa-dev] [PATCH 2/4 v2] mesa: add _mesa_shader_debug()

Brian Paul brianp at vmware.com
Wed May 2 08:00:58 PDT 2012


On 05/01/2012 05:04 PM, nobled wrote:
> This should be the one entrypoint libglsl needs
> for GL_ARB_debug_output.
> ---
>   src/mesa/main/errors.c |   34 ++++++++++++++++++++++++++++++++++
>   src/mesa/main/errors.h |    4 ++++
>   2 files changed, 38 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
> index fcf873f..be271eb 100644
> --- a/src/mesa/main/errors.c
> +++ b/src/mesa/main/errors.c
> @@ -1062,4 +1062,38 @@ _mesa_debug( const struct gl_context *ctx,
> const char *fmtString, ... )
>      (void) fmtString;
>   }
>
> +

Comments on this function?  What is type, error, len?  Should err's 
type be gl_shader_error?  Looks like len=-1 is a special value.


> +void
> +_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint err,
> +                    const char *msg, int len )
> +{
> +   GLenum source = GL_DEBUG_SOURCE_SHADER_COMPILER_ARB,
> +          severity;
> +
> +   switch (type) {
> +   case GL_DEBUG_TYPE_ERROR_ARB:
> +      assert(err<  SHADER_ERROR_COUNT);
> +      severity = GL_DEBUG_SEVERITY_HIGH_ARB;
> +      break;
> +   case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
> +   case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
> +   case GL_DEBUG_TYPE_PORTABILITY_ARB:
> +   case GL_DEBUG_TYPE_PERFORMANCE_ARB:
> +   case GL_DEBUG_TYPE_OTHER_ARB:
> +      assert(0&&  "other categories not implemented yet");
> +   default:
> +      _mesa_problem(ctx, "bad enum in _mesa_shader_debug()");
> +      return;
> +   }
> +
> +   if (len<  0)
> +      len = strlen(msg);
> +
> +   /* Truncate the message if necessary. */
> +   if (len>= MAX_DEBUG_MESSAGE_LENGTH)
> +      len = MAX_DEBUG_MESSAGE_LENGTH - 1;
> +
> +   _mesa_log_msg(ctx, source, type, err, severity, len, msg);
> +}
> +
>   /*@}*/
> diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h
> index ed1c6fc..2b4f5ff 100644
> --- a/src/mesa/main/errors.h
> +++ b/src/mesa/main/errors.h
> @@ -38,6 +38,7 @@
>
>   #include "compiler.h"
>   #include "glheader.h"
> +#include "mtypes.h"
>
>
>   #ifdef __cplusplus
> @@ -68,6 +69,9 @@ _mesa_error( struct gl_context *ctx, GLenum error,
> const char *fmtString, ... )
>   extern void
>   _mesa_debug( const struct gl_context *ctx, const char *fmtString, ...
> ) PRINTFLIKE(2, 3);
>
> +extern void
> +_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint err,
> const char *msg, int len );
> +
>   #ifdef __cplusplus
>   }
>   #endif

Looks OK otherwise.  Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list