[Mesa-dev] [PATCH v2 32/32] disk_cache: Add support for MESA_GLSL_CACHE_TIMESTAMP in debug builds

Jordan Justen jordan.l.justen at intel.com
Thu Oct 19 05:32:20 UTC 2017


The MESA_GLSL_CACHE_TIMESTAMP environment variable can be set to
override the driver timestamp. Usually the driver will specify a hash
of their driver build so the cache items become invalid with each
driver build.

We don't guarantee a stable serialized shader cache format, so
changing the timestamp for each build is required for safety.

Nevertheless, during debug, making small changes to the driver may be
known to be safe. The driver developer can use this variable to keep
the timestamp consistent. When debugging issues on an application for
which the shader cache greatly lowers the startup time, this can save
the developer significant time.

Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/util/disk_cache.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index fde6e2e097..54f48a8ba5 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -208,6 +208,18 @@ disk_cache_create(const char *gpu_name, const char *timestamp,
    if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
       goto fail;
 
+#ifdef DEBUG
+   /* For debug builds, MESA_GLSL_CACHE_TIMESTAMP can be set to override the
+    * driver specified timestamp. This will allow small changes to be made to
+    * the driver without invalidating the cache. Given that this is normally
+    * unsafe, it is only allowed for debug builds.
+    */
+   const char *timestamp_override = getenv("MESA_GLSL_CACHE_TIMESTAMP");
+   if (timestamp_override) {
+      timestamp = timestamp_override;
+   }
+#endif
+
    /* Determine path for cache based on the first defined name as follows:
     *
     *   $MESA_GLSL_CACHE_DIR
-- 
2.15.0.rc0



More information about the mesa-dev mailing list