On 02/03/17 17:17, Ilia Mirkin wrote:
On Thu, Mar 2, 2017 at 1:08 AM, Timothy Arceri <tarc...@itsqueeze.com> wrote:
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

This seems incomplete.

It's complete enough for what we currently support. Maybe could add powerpc but wouldn't be hard to add if someone was worried about that.

There was this suggestion on irc https://paste.debian.net/plainh/fdd6c185

But I don't really like that as the string is not guaranteed to be consistent.

How about using uname(2)'s machine value? (Will
need a bit of plumbing to detect whether uname is available in libc.)

Doesn't this just return the arch of the kernel? Wouldn't it always return x86_64 even when running a 32bit application?


+
 /* 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

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to