[Mesa-dev] [PATCH 25/87] glsl: add support for skipping shader cache to compiler and linker

Timothy Arceri timothy.arceri at collabora.com
Wed Jul 13 02:47:20 UTC 2016


---
 src/compiler/glsl/linker.cpp         | 5 +++--
 src/compiler/glsl/program.h          | 3 ++-
 src/compiler/glsl/standalone.cpp     | 2 +-
 src/mesa/main/ff_fragment_shader.cpp | 2 +-
 src/mesa/main/shaderapi.c            | 2 +-
 src/mesa/program/ir_to_mesa.cpp      | 5 +++--
 src/mesa/program/ir_to_mesa.h        | 5 ++++-
 7 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 84f64cb..a6b9c26 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4479,7 +4479,8 @@ disable_varying_optimizations_for_sso(struct gl_shader_program *prog)
 }
 
 void
-link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
+link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
+             bool is_cache_fallback)
 {
    prog->LinkStatus = true; /* All error paths will set this to false */
    prog->Validated = false;
@@ -4511,7 +4512,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    tfeedback_decl *tfeedback_decls = NULL;
 
 #ifdef ENABLE_SHADER_CACHE
-   if (shader_cache_read_program_metadata(ctx, prog))
+   if (!is_cache_fallback && shader_cache_read_program_metadata(ctx, prog))
       return;
 #endif
 
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 58a7069..bb9bbb0 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -40,7 +40,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
 #endif
 
 extern void
-link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
+link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
+             bool is_cache_fallback);
 
 extern void
 build_program_resource_list(struct gl_context *ctx,
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 6eca52b..5e0127f 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -404,7 +404,7 @@ standalone_compile_shader(const struct standalone_options *_options,
    if ((status == EXIT_SUCCESS) && options->do_link)  {
       _mesa_clear_shader_program_data(whole_program);
 
-      link_shaders(ctx, whole_program);
+      link_shaders(ctx, whole_program, true);
       status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
 
       if (strlen(whole_program->InfoLog) > 0) {
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 1f9a7cf..8537134 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1266,7 +1266,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    p.shader_program->Shaders[0] = p.shader;
    p.shader_program->NumShaders = 1;
 
-   _mesa_glsl_link_shader(ctx, p.shader_program);
+   _mesa_glsl_link_shader(ctx, p.shader_program, false);
 
    if (!p.shader_program->LinkStatus)
       _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9009fff..e15a7ee 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1092,7 +1092,7 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
-   _mesa_glsl_link_shader(ctx, shProg);
+   _mesa_glsl_link_shader(ctx, shProg, false);
 
    /* Capture .shader_test files. */
    const char *capture_path = _mesa_get_shader_capture_path();
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 69f2ef2..781130e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3051,7 +3051,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
  * Link a GLSL shader program.  Called via glLinkProgram().
  */
 void
-_mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
+_mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog,
+                       bool is_cache_fallback)
 {
    unsigned int i;
 
@@ -3066,7 +3067,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
    }
 
    if (prog->LinkStatus) {
-      link_shaders(ctx, prog);
+      link_shaders(ctx, prog, is_cache_fallback);
    }
 
    /* FIXME: We look at prog->Version to determine whether we actually linked
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index be45ba0..54d98a8 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -33,7 +33,10 @@ struct gl_context;
 struct gl_shader;
 struct gl_shader_program;
 
-void _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
+void _mesa_glsl_link_shader(struct gl_context *ctx,
+                            struct gl_shader_program *prog,
+                            bool is_shader_cache);
+
 GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
 
 void
-- 
2.7.4



More information about the mesa-dev mailing list