From a66cb80e8554745525f3ce379b2b7abfd0aab77e Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 17 Oct 2017 16:38:48 -0700 Subject: disk_cache: Add support for MESA_GLSL_CACHE_TIMESTAMP in debug builds 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 --- 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 -- cgit v1.2.3