[Mesa-dev] [PATCH 2/2] glsl: don't recompile a shader on fallback unless needed

Timothy Arceri tarceri at itsqueeze.com
Thu Mar 9 11:58:38 UTC 2017


Because we optimistically skip compiling shaders if we have seen them
before we may need to compile them later at link time if they haven't
yet been use in a specific combination to create a program.

Rather than always recompiling we take advantage of the
gl_compile_status enum introduced in the previous patch to only
compile when we have previously skipped compilation.

This should help with regressions in app start-up times on cold cache
runs, compared with no cache.
---
 src/compiler/glsl/glsl_parser_extras.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 59114a7..776636c 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1945,20 +1945,27 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
          if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
             fprintf(stderr, "deferring compile of shader: %s\n",
                     _mesa_sha1_format(buf, shader->sha1));
          }
          shader->CompileStatus = compile_skipped;
 
          free((void *)shader->FallbackSource);
          shader->FallbackSource = NULL;
          return;
       }
+   } else {
+      /* We should only ever end up here if a re-compile has been forced by a
+       * shader cache miss. In which case we can skip the compile if its
+       * already be done by a previous fallback or the initial compile call.
+       */
+      if (shader->CompileStatus == compile_success)
+         return;
    }
 
    if (!state->error) {
      _mesa_glsl_lexer_ctor(state, source);
      _mesa_glsl_parse(state);
      _mesa_glsl_lexer_dtor(state);
      do_late_parsing_checks(state);
    }
 
    if (dump_ast) {
-- 
2.9.3



More information about the mesa-dev mailing list