Mesa (master): mesa: add an env var to force cache fallback

Timothy Arceri tarceri at kemper.freedesktop.org
Fri May 19 22:36:04 UTC 2017


Module: Mesa
Branch: master
Commit: a74300c7ff256b417079134f7bd9aea91153025b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a74300c7ff256b417079134f7bd9aea91153025b

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Thu May 18 15:00:40 2017 +1000

mesa: add an env var to force cache fallback

For the gallium state tracker a tgsi binary may have been evicted
from the cache to make space. In this case we would take the
fallback path and recompile/link the shader.

On i965 there are a number of reasons we can get to the program
upload stage and have neither IR nor a valid cached binary.
For example the binary may have been evicted from the cache or
we need a variant that wasn't previously cached.

This environment variable enables us to force the fallback path that
would be taken in these cases and makes it easier to debug these
otherwise hard to reproduce scenarios.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 docs/shading.html                        | 2 ++
 src/mesa/main/mtypes.h                   | 1 +
 src/mesa/main/shaderapi.c                | 2 ++
 src/mesa/state_tracker/st_shader_cache.c | 6 +++++-
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/docs/shading.html b/docs/shading.html
index 7e3d2e4fce..c789102e64 100644
--- a/docs/shading.html
+++ b/docs/shading.html
@@ -50,6 +50,8 @@ execution.  These are generally used for debugging.
     The filenames will be "shader_X.vert" or "shader_X.frag" where X
     the shader ID.
 <li><b>cache_info</b> - print debug information about shader cache
+<li><b>cache_fb</b> - force cached shaders to be ignored and do a full
+    recompile via the fallback path</li>
 <li><b>uniform</b> - print message to stdout when glUniform is called
 <li><b>nopvert</b> - force vertex shaders to be a simple shader that just transforms
     the vertex position with ftransform() and passes through the color and
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index efc6920254..d060f8f7d3 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2977,6 +2977,7 @@ struct gl_shader_program
 #define GLSL_REPORT_ERRORS 0x40  /**< Print compilation errors */
 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
+#define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
 
 
 /**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 68fb3faf0c..325542e523 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -77,6 +77,8 @@ _mesa_get_shader_flags(void)
          flags |= GLSL_DUMP;
       if (strstr(env, "log"))
          flags |= GLSL_LOG;
+      if (strstr(env, "cache_fb"))
+         flags |= GLSL_CACHE_FALLBACK;
       if (strstr(env, "cache_info"))
          flags |= GLSL_CACHE_INFO;
       if (strstr(env, "nopvert"))
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 175d69d732..45438e56bd 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -225,8 +225,12 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
    if (prog->data->LinkStatus != linking_skipped)
       return false;
 
-   struct st_context *st = st_context(ctx);
    uint8_t *buffer = NULL;
+   if (ctx->_Shader->Flags & GLSL_CACHE_FALLBACK) {
+      goto fallback_recompile;
+   }
+
+   struct st_context *st = st_context(ctx);
    for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
       if (prog->_LinkedShaders[i] == NULL)
          continue;




More information about the mesa-commit mailing list