[Mesa-dev] [PATCH 18/65] glsl: add param to force shader recompile

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


This will be used to skip checking the cache and force a recompile.
---
 src/compiler/glsl/glsl_parser_extras.cpp | 20 +++++++++++---------
 src/compiler/glsl/main.cpp               |  2 +-
 src/compiler/glsl/program.h              |  2 +-
 src/mesa/main/shaderapi.c                |  2 +-
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 762b192..2cbc113 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1750,7 +1750,7 @@ extern "C" {
 
 void
 _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
-                          bool dump_ast, bool dump_hir)
+                          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);
@@ -1764,14 +1764,16 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
                              &ctx->Extensions, ctx);
 
 #ifdef ENABLE_SHADER_CACHE
-   char buf[41];
-   _mesa_sha1_compute(source, strlen(source), shader->sha1);
-   if (ctx->Cache && cache_has_key(ctx->Cache, shader->sha1)) {
-      /* We've seen this shader before and know it compiles */
-      printf("deferring compile of shader: %s\n",
-             _mesa_sha1_format(buf, shader->sha1));
-      shader->CompileStatus = true;
-      return;
+   if (!force_recompile) {
+      char buf[41];
+      _mesa_sha1_compute(source, strlen(source), shader->sha1);
+      if (ctx->Cache && cache_has_key(ctx->Cache, shader->sha1)) {
+         /* We've seen this shader before and know it compiles */
+         printf("deferring compile of shader: %s\n",
+                _mesa_sha1_format(buf, shader->sha1));
+         shader->CompileStatus = true;
+         return;
+      }
    }
 #endif
 
diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index d253575..56d44a9 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -309,7 +309,7 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader)
    struct _mesa_glsl_parse_state *state =
       new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
 
-   _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_hir);
+   _mesa_glsl_compile_shader(ctx, shader, dump_ast, dump_hir, true);
 
    /* Print out the resulting IR */
    if (!state->error && dump_lir) {
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 8f5a31b..58a7069 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -33,7 +33,7 @@ struct gl_shader_program;
 
 extern void
 _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
-			  bool dump_ast, bool dump_hir);
+			  bool dump_ast, bool dump_hir, bool force_recompile);
 
 #ifdef __cplusplus
 } /* extern "C" */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index b972f8e..5aaf043 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -980,7 +980,7 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
       /* this call will set the shader->CompileStatus field to indicate if
        * compilation was successful.
        */
-      _mesa_glsl_compile_shader(ctx, sh, false, false);
+      _mesa_glsl_compile_shader(ctx, sh, false, false, false);
 
       if (ctx->_Shader->Flags & GLSL_LOG) {
          _mesa_write_shader_to_file(sh);
-- 
2.5.5



More information about the mesa-dev mailing list