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

Timothy Arceri timothy.arceri at collabora.com
Fri Apr 29 13:33:27 UTC 2016


---
 src/compiler/glsl/linker.cpp         | 5 +++--
 src/compiler/glsl/main.cpp           | 2 +-
 src/compiler/glsl/program.h          | 3 ++-
 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        | 4 +++-
 7 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 2e30dae..4477768 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4283,7 +4283,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 skip_cache)
 {
    prog->LinkStatus = true; /* All error paths will set this to false */
    prog->Validated = false;
@@ -4315,7 +4316,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 (!skip_cache && shader_cache_read_program_metadata(ctx, prog))
       return;
 #endif
 
diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index 56d44a9..97cedb5 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -426,7 +426,7 @@ main(int argc, char **argv)
    if ((status == EXIT_SUCCESS) && 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/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 58a7069..1bf4ec4 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 skip_cache);
 
 extern void
 build_program_resource_list(struct gl_context *ctx,
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index b0ce8c4..201d49a 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1262,7 +1262,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 5aaf043..3e54709 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1039,7 +1039,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);
 
    if (shProg->LinkStatus == GL_FALSE &&
        (ctx->_Shader->Flags & GLSL_REPORT_ERRORS)) {
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index c061dce..e950f9e 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2987,7 +2987,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 skip_cache)
 {
    unsigned int i;
 
@@ -3002,7 +3003,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, skip_cache);
    }
 
    /* 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 a70f575..abc628a 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -33,7 +33,9 @@ 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 skip_cache);
 GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
 
 void
-- 
2.5.5



More information about the mesa-dev mailing list