[Mesa-dev] [PATCH 1/2] util/disk_cache: support caches for multiple architectures
Timothy Arceri
tarceri at itsqueeze.com
Thu Mar 2 06:08:33 UTC 2017
Previously we were deleting the entire cache if a user switched
between 32 and 64 bit applications.
---
src/util/disk_cache.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 3abdec4..1a91c69 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -40,20 +40,32 @@
#include "zlib.h"
#include "util/crc32.h"
#include "util/u_atomic.h"
#include "util/mesa-sha1.h"
#include "util/ralloc.h"
#include "main/errors.h"
#include "disk_cache.h"
+#if defined(__x86_64__)
+#if defined(__ILP32__)
+#define CACHE_ARCH "x32"
+#else
+#define CACHE_ARCH "x86_64"
+#endif
+#elif defined(__i386__)
+#define CACHE_ARCH "i386"
+#else
+#define CACHE_ARCH "unknown_arch"
+#endif
+
/* Number of bits to mask off from a cache key to get an index. */
#define CACHE_INDEX_KEY_BITS 16
/* Mask for computing an index from a key. */
#define CACHE_INDEX_KEY_MASK ((1 << CACHE_INDEX_KEY_BITS) - 1)
/* The number of keys that can be stored in the index. */
#define CACHE_INDEX_MAX_KEYS (1 << CACHE_INDEX_KEY_BITS)
struct disk_cache {
@@ -170,20 +182,29 @@ remove_old_cache_directories(void *mem_ctx, char *path, const char *timestamp)
}
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;
+ /* Create a parent architecture directory so that we don't remove cache
+ * files for other architectures. In theory we could share the cache
+ * between architectures but we have no way of knowing if they were created
+ * by a compatible Mesa version.
+ */
+ new_path = concatenate_and_mkdir(mem_ctx, new_path, CACHE_ARCH);
+ if (new_path == NULL)
+ return NULL;
+
/* Remove cache directories for old Mesa versions */
remove_old_cache_directories(mem_ctx, new_path, timestamp);
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;
--
2.9.3
More information about the mesa-dev
mailing list