[Mesa-dev] [PATCH 1/9] glsl: consolidate code

Ian Romanick idr at freedesktop.org
Fri Apr 13 12:15:34 PDT 2012


On 04/13/2012 08:51 AM, nobled wrote:

This just occurred to me... Wouldn't it be easier to push all the 
compiler / linker error messages into the debug log in one shot *after* 
compilation (or linking) is done?  Since the messages all start with 
either warning: or error: and end with a \n, they would be trivial to parse.

That would have a couple advantages:

1. Less churn in the patch series.

2. Less headaches trying to push gl_context deeper into the compiler. 
We intentionally tried to keep gl_context out of the compiler as much as 
possible.

Just a thought...

> This function is about to get longer.
> ---
>   src/glsl/glsl_parser_extras.cpp |   29 +++++++++++++++--------------
>   1 files changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index ae7a365..d14124f 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -134,6 +134,19 @@ _mesa_glsl_shader_target_name(enum
> _mesa_glsl_parser_targets target)
>      return "unknown";
>   }
>
> +static void
> +_mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
> +               bool error, const char *fmt, va_list ap)
> +{
> +   assert(state->info_log != NULL);
> +   ralloc_asprintf_append(&state->info_log, "%u:%u(%u): %s: ",
> +					    locp->source,
> +					    locp->first_line,
> +					    locp->first_column,
> +					    error ? "error" : "warning");
> +   ralloc_vasprintf_append(&state->info_log, fmt, ap);
> +   ralloc_strcat(&state->info_log, "\n");
> +}
>
>   void
>   _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
> @@ -143,15 +156,9 @@ _mesa_glsl_error(YYLTYPE *locp,
> _mesa_glsl_parse_state *state,
>
>      state->error = true;
>
> -   assert(state->info_log != NULL);
> -   ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ",
> -					    locp->source,
> -					    locp->first_line,
> -					    locp->first_column);
>      va_start(ap, fmt);
> -   ralloc_vasprintf_append(&state->info_log, fmt, ap);
> +   _mesa_glsl_msg(locp, state, true, fmt, ap);
>      va_end(ap);
> -   ralloc_strcat(&state->info_log, "\n");
>   }
>
>
> @@ -161,15 +168,9 @@ _mesa_glsl_warning(const YYLTYPE *locp,
> _mesa_glsl_parse_state *state,
>   {
>      va_list ap;
>
> -   assert(state->info_log != NULL);
> -   ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ",
> -					    locp->source,
> -					    locp->first_line,
> -					    locp->first_column);
>      va_start(ap, fmt);
> -   ralloc_vasprintf_append(&state->info_log, fmt, ap);
> +   _mesa_glsl_msg(locp, state, false, fmt, ap);
>      va_end(ap);
> -   ralloc_strcat(&state->info_log, "\n");
>   }
>
>



More information about the mesa-dev mailing list