[Mesa-dev] [PATCH 3/3] glsl: don't run the GLSL pre-processor when we are skipping compilation

Matt Turner mattst88 at gmail.com
Mon Mar 27 04:26:18 UTC 2017


On Sun, Mar 26, 2017 at 8:14 PM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> Improves Deus Ex start-up times from ~30 seconds to ~22 seconds.
>
> Also fixes the leaking of state.
> ---
>  src/compiler/glsl/glsl_parser_extras.cpp | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
> index 7fc35df..23fd6a8 100644
> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> @@ -1999,32 +1999,23 @@ opt_shader_and_create_symbol_table(struct gl_context *ctx,
>        }
>     }
>
>     _mesa_glsl_initialize_derived_variables(ctx, shader);
>  }
>
>  void
>  _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
>                            bool dump_ast, bool dump_hir, bool force_recompile)
>  {
> -   struct _mesa_glsl_parse_state *state =
> -      new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
>     const char *source = force_recompile && shader->FallbackSource ?
>        shader->FallbackSource : shader->Source;
>
> -   if (ctx->Const.GenerateTemporaryNames)
> -      (void) p_atomic_cmpxchg(&ir_variable::temporaries_allocate_names,
> -                              false, true);
> -
> -   state->error = glcpp_preprocess(state, &source, &state->info_log,
> -                             add_builtin_defines, state, ctx);
> -
>     if (!force_recompile) {
>        if (ctx->Cache) {
>           char buf[41];
>           disk_cache_compute_key(ctx->Cache, source, strlen(source),
>                                  shader->sha1);
>           if (disk_cache_has_key(ctx->Cache, shader->sha1)) {
>              /* We've seen this shader before and know it compiles */
>              if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
>                 _mesa_sha1_format(buf, shader->sha1);
>                 fprintf(stderr, "deferring compile of shader: %s\n", buf);
> @@ -2044,20 +2035,30 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
>        if (shader->CompileStatus == compile_success)
>           return;
>
>        if (shader->CompileStatus == compiled_no_opts) {
>           opt_shader_and_create_symbol_table(ctx, shader);
>           shader->CompileStatus = compile_success;
>           return;
>        }
>     }
>
> +   struct _mesa_glsl_parse_state *state =
> +      new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
> +
> +   if (ctx->Const.GenerateTemporaryNames)
> +      (void) p_atomic_cmpxchg(&ir_variable::temporaries_allocate_names,
> +                              false, true);
> +
> +   state->error = glcpp_preprocess(state, &source, &state->info_log,
> +                             add_builtin_defines, state, ctx);

Please fix the indentation while we're moving the line.


More information about the mesa-dev mailing list