[Mesa-dev] [PATCH 3/4] mesa: remove MESA_GLSL=no_opts env option

Brian Paul brianp at vmware.com
Thu Mar 30 16:44:42 UTC 2017


On 03/30/2017 05:26 AM, Timothy Arceri wrote:
> This is confusing because is only applys to ARB shaders, and because

s/ARB shaders/GL_ARB_vertex/fragment_program/

> of that its also not very useful.
>
> If someone requires this for debugging they can just make an ad-hoc
> code change.

I think I'm the original author of this and my intention was that if a 
user ran into a suspected shader compiler bug, they could set this env 
var to see if disabling optimizations worked around the issue.  Seems 
like a useful thing to me, but I'm not sure it got much/any use.  I'm 
pretty certain an earlier version of the GLSL compiler respected it too. 
  But it probably was overlooked and dropped at some point.

I still think this env option could be useful.  But for lack of use, I 
guess it can go.

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


> ---
>   docs/shading.html               |  1 -
>   src/mesa/main/mtypes.h          | 15 +++++++--------
>   src/mesa/main/shaderapi.c       |  2 --
>   src/mesa/program/arbprogparse.c |  3 +--
>   src/mesa/program/ir_to_mesa.cpp |  4 +---
>   5 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/docs/shading.html b/docs/shading.html
> index a28c5b3..cd01af0 100644
> --- a/docs/shading.html
> +++ b/docs/shading.html
> @@ -43,21 +43,20 @@ Contents
>   The <b>MESA_GLSL</b> environment variable can be set to a comma-separated
>   list of keywords to control some aspects of the GLSL compiler and shader
>   execution.  These are generally used for debugging.
>   </p>
>   <ul>
>   <li><b>dump</b> - print GLSL shader code to stdout at link time
>   <li><b>log</b> - log all GLSL shaders to files.
>       The filenames will be "shader_X.vert" or "shader_X.frag" where X
>       the shader ID.
>   <li><b>cache_info</b> - print debug information about shader cache
> -<li><b>nopt</b> - disable compiler optimizations
>   <li><b>opt</b> - force compiler optimizations
>   <li><b>uniform</b> - print message to stdout when glUniform is called
>   <li><b>nopvert</b> - force vertex shaders to be a simple shader that just transforms
>       the vertex position with ftransform() and passes through the color and
>       texcoord[0] attributes.
>   <li><b>nopfrag</b> - force fragment shader to be a simple shader that passes
>       through the color attribute.
>   <li><b>useprog</b> - log glUseProgram calls to stderr
>   </ul>
>   <p>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 45e49a6..daccb2b 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2877,28 +2877,27 @@ struct gl_shader_program
>      /* True if any of the fragment shaders attached to this program use:
>       * #extension ARB_fragment_coord_conventions: enable
>       */
>      GLboolean ARB_fragment_coord_conventions_enable;
>   };
>
>
>   #define GLSL_DUMP      0x1  /**< Dump shaders to stdout */
>   #define GLSL_LOG       0x2  /**< Write shaders to files */
>   #define GLSL_OPT       0x4  /**< Force optimizations (override pragmas) */
> -#define GLSL_NO_OPT    0x8  /**< Force no optimizations (override pragmas) */
> -#define GLSL_UNIFORMS 0x10  /**< Print glUniform calls */
> -#define GLSL_NOP_VERT 0x20  /**< Force no-op vertex shaders */
> -#define GLSL_NOP_FRAG 0x40  /**< Force no-op fragment shaders */
> -#define GLSL_USE_PROG 0x80  /**< Log glUseProgram calls */
> -#define GLSL_REPORT_ERRORS 0x100  /**< Print compilation errors */
> -#define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error */
> -#define GLSL_CACHE_INFO 0x400 /**< Print debug information about shader cache */
> +#define GLSL_UNIFORMS  0x8  /**< Print glUniform calls */
> +#define GLSL_NOP_VERT 0x10  /**< Force no-op vertex shaders */
> +#define GLSL_NOP_FRAG 0x20  /**< Force no-op fragment shaders */
> +#define GLSL_USE_PROG 0x40  /**< Log glUseProgram calls */
> +#define GLSL_REPORT_ERRORS 0x80  /**< Print compilation errors */
> +#define GLSL_DUMP_ON_ERROR 0x100 /**< Dump shaders to stderr on compile error */
> +#define GLSL_CACHE_INFO 0x200 /**< Print debug information about shader cache */
>
>
>   /**
>    * Context state for GLSL vertex/fragment shaders.
>    * Extended to support pipeline object
>    */
>   struct gl_pipeline_object
>   {
>      /** Name of the pipeline object as received from glGenProgramPipelines.
>       * It would be 0 for shaders without separate shader objects.
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index ba69ede..3d77448 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -76,22 +76,20 @@ _mesa_get_shader_flags(void)
>         else if (strstr(env, "dump"))
>            flags |= GLSL_DUMP;
>         if (strstr(env, "log"))
>            flags |= GLSL_LOG;
>         if (strstr(env, "cache_info"))
>            flags |= GLSL_CACHE_INFO;
>         if (strstr(env, "nopvert"))
>            flags |= GLSL_NOP_VERT;
>         if (strstr(env, "nopfrag"))
>            flags |= GLSL_NOP_FRAG;
> -      if (strstr(env, "nopt"))
> -         flags |= GLSL_NO_OPT;
>         else if (strstr(env, "opt"))
>            flags |= GLSL_OPT;
>         if (strstr(env, "uniform"))
>            flags |= GLSL_UNIFORMS;
>         if (strstr(env, "useprog"))
>            flags |= GLSL_USE_PROG;
>         if (strstr(env, "errors"))
>            flags |= GLSL_REPORT_ERRORS;
>      }
>
> diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c
> index 9b843f6..07bdf16 100644
> --- a/src/mesa/program/arbprogparse.c
> +++ b/src/mesa/program/arbprogparse.c
> @@ -173,22 +173,21 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target,
>      state.mem_ctx = program;
>
>      if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len,
>   				&state)) {
>         ralloc_free(prog.arb.Instructions);
>         ralloc_free(prog.String);
>         _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)");
>         return;
>      }
>
> -   if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0)
> -      _mesa_optimize_program(ctx, &prog, program);
> +   _mesa_optimize_program(ctx, &prog, program);
>
>      ralloc_free(program->String);
>
>      /* Copy the relevant contents of the arb_program struct into the
>       * vertex_program struct.
>       */
>      program->String          = prog.String;
>      program->arb.NumInstructions = prog.arb.NumInstructions;
>      program->arb.NumTemporaries  = prog.arb.NumTemporaries;
>      program->arb.NumParameters   = prog.arb.NumParameters;
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index 3898cb8..a2476dd 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -2972,23 +2972,21 @@ get_mesa_program(struct gl_context *ctx,
>
>      prog->ShadowSamplers = shader->shadow_samplers;
>      prog->ExternalSamplersUsed = gl_external_samplers(prog);
>      _mesa_update_shader_textures_used(shader_program, prog);
>
>      /* Set the gl_FragDepth layout. */
>      if (target == GL_FRAGMENT_PROGRAM_ARB) {
>         prog->info.fs.depth_layout = shader_program->FragDepthLayout;
>      }
>
> -   if ((ctx->_Shader->Flags & GLSL_NO_OPT) == 0) {
> -      _mesa_optimize_program(ctx, prog, prog);
> -   }
> +   _mesa_optimize_program(ctx, prog, prog);
>
>      /* This has to be done last.  Any operation that can cause
>       * prog->ParameterValues to get reallocated (e.g., anything that adds a
>       * program constant) has to happen before creating this linkage.
>       */
>      _mesa_associate_uniform_storage(ctx, shader_program, prog->Parameters,
>                                      true);
>      if (!shader_program->data->LinkStatus) {
>         goto fail_exit;
>      }
>



More information about the mesa-dev mailing list