[Mesa-dev] [PATCH v2] glsl: Enable debug prints for do_common_optimization

Kenneth Graunke kenneth at whitecape.org
Sat Jan 23 11:06:48 PST 2016


On Thursday, January 21, 2016 11:35:31 PM PST Jordan Justen wrote:
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> 
>  I tested a release build. I think v1 produced comparable code to
>  before the patch, but it was a bit larger. I found that this v2 code
>  would produce identical code to our current code for release builds.
> 
>  Timothy, should I add your r-b for v2?
> 
>  src/glsl/glsl_parser_extras.cpp | 81 ++++++++++++++++++++++++
+----------------
>  1 file changed, 49 insertions(+), 32 deletions(-)
> 
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/
glsl_parser_extras.cpp
> index 1d74db5..1c1bf78 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -1864,59 +1864,76 @@ do_common_optimization(exec_list *ir, bool linked,
>                         const struct gl_shader_compiler_options *options,
>                         bool native_integers)
>  {
> +   const bool debug = false;
>     GLboolean progress = GL_FALSE;
>  
> -   progress = lower_instructions(ir, SUB_TO_ADD_NEG) || progress;
> +#define OPT(PASS, ...) do {                                     \
> +      if (debug) {                                              \
> +         printf("START GLSL optimization %s\n", #PASS);         \

Can we use stderr rather than stdout?  Most of our debugging messages
go there already, and if we use both, things just get jumbled.

fprintf(stderr, ...

> +         const bool opt_progress = PASS(__VA_ARGS__);           \
> +         progress = opt_progress || progress;                   \
> +         if (opt_progress)                                      \
> +            _mesa_print_ir(stdout, ir, NULL);                   \

stderr

> +         printf("GLSL optimization %s: %s progress\n",          \
> +                #PASS, opt_progress ? "made" : "no");           \

fprintf(stderr, ...

Either way,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Thanks so much for doing this.  I'd hacked this up several times,
but always threw it away after debugging my problem.  That was
arguably pretty stupid; I'm really glad to see this land properly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20160123/5c268cac/attachment.sig>


More information about the mesa-dev mailing list