summaryrefslogtreecommitdiffstats
path: root/src/util/disk_cache.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-02-06 12:56:08 +1100
committerTimothy Arceri <[email protected]>2017-02-17 11:18:43 +1100
commit3342ce452cf33dc70ffad03b676579e0631182b3 (patch)
tree7b58780247b71783890283ef905710efedafc91c /src/util/disk_cache.c
parent87009681a53436700a477c45cb13272fa4a881fd (diff)
util/disk_cache: allow drivers to pass a directory structure
In order to avoid costly fallback recompiles when cache items are created with an old version of Mesa or for a different gpu on the same system we want to create directories that look like this: ./{TIMESTAMP}_{LLVM_TIMESTAMP}/{GPU_ID} Note: The disk cache util will take a single timestamp string, it is up to the backend to concatenate the llvm string with the mesa string if applicable. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/util/disk_cache.c')
-rw-r--r--src/util/disk_cache.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 46d16144166..6ded0d3adac 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -115,7 +115,7 @@ mkdir_if_needed(char *path)
* <path>/<name> cannot be created as a directory
*/
static char *
-concatenate_and_mkdir(void *ctx, char *path, char *name)
+concatenate_and_mkdir(void *ctx, char *path, const char *name)
{
char *new_path;
struct stat sb;
@@ -131,8 +131,27 @@ concatenate_and_mkdir(void *ctx, char *path, char *name)
return NULL;
}
+static char *
+create_mesa_cache_dir(void *mem_ctx, char *path, const char *timestamp,
+ const char *gpu_name)
+{
+ char *new_path = concatenate_and_mkdir(mem_ctx, path, "mesa");
+ if (new_path == NULL)
+ return NULL;
+
+ new_path = concatenate_and_mkdir(mem_ctx, new_path, timestamp);
+ if (new_path == NULL)
+ return NULL;
+
+ new_path = concatenate_and_mkdir(mem_ctx, new_path, gpu_name);
+ if (new_path == NULL)
+ return NULL;
+
+ return new_path;
+}
+
struct disk_cache *
-disk_cache_create(void)
+disk_cache_create(const char *gpu_name, const char *timestamp)
{
void *local;
struct disk_cache *cache = NULL;
@@ -176,7 +195,8 @@ disk_cache_create(void)
if (mkdir_if_needed(xdg_cache_home) == -1)
goto fail;
- path = concatenate_and_mkdir(local, xdg_cache_home, "mesa");
+ path = create_mesa_cache_dir(local, xdg_cache_home, timestamp,
+ gpu_name);
if (path == NULL)
goto fail;
}
@@ -212,7 +232,7 @@ disk_cache_create(void)
if (path == NULL)
goto fail;
- path = concatenate_and_mkdir(local, path, "mesa");
+ path = create_mesa_cache_dir(local, path, timestamp, gpu_name);
if (path == NULL)
goto fail;
}