util/disk_cache: add new driver_flags param to cache keys

This will be used for things such as adding driver specific environment
variables to the key. Allowing us to set environment vars that change
the shader and not have the driver ignore them if it finds existing
shaders in the cache.

Reviewed-by: Eduardo Lima Mitev <elima@igalia.com>
This commit is contained in:
Timothy Arceri
2017-05-20 11:06:25 +10:00
parent d970f773f4
commit 0bbcfbfc0b
5 changed files with 23 additions and 15 deletions
+7 -1
View File
@@ -161,7 +161,8 @@ concatenate_and_mkdir(void *ctx, const char *path, const char *name)
}
struct disk_cache *
disk_cache_create(const char *gpu_name, const char *timestamp)
disk_cache_create(const char *gpu_name, const char *timestamp,
uint64_t driver_flags)
{
void *local;
struct disk_cache *cache = NULL;
@@ -356,6 +357,9 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
size_t ptr_size_size = sizeof(ptr_size);
cache->driver_keys_blob_size += ptr_size_size;
size_t driver_flags_size = sizeof(driver_flags);
cache->driver_keys_blob_size += driver_flags_size;
cache->driver_keys_blob =
ralloc_size(cache, cache->driver_keys_blob_size);
if (!cache->driver_keys_blob)
@@ -365,6 +369,8 @@ disk_cache_create(const char *gpu_name, const char *timestamp)
memcpy(cache->driver_keys_blob + ts_size, gpu_name, gpu_name_size);
memcpy(cache->driver_keys_blob + ts_size + gpu_name_size, &ptr_size,
ptr_size_size);
memcpy(cache->driver_keys_blob + ts_size + gpu_name_size + ptr_size_size,
&driver_flags, driver_flags_size);
/* Seed our rand function */
s_rand_xorshift128plus(cache->seed_xorshift128plus, true);
+4 -2
View File
@@ -93,7 +93,8 @@ disk_cache_get_function_timestamp(void *ptr, uint32_t* timestamp)
* assistance in computing SHA-1 signatures.
*/
struct disk_cache *
disk_cache_create(const char *gpu_name, const char *timestamp);
disk_cache_create(const char *gpu_name, const char *timestamp,
uint64_t driver_flags);
/**
* Destroy a cache object, (freeing all associated resources).
@@ -171,7 +172,8 @@ disk_cache_compute_key(struct disk_cache *cache, const void *data, size_t size,
#else
static inline struct disk_cache *
disk_cache_create(const char *gpu_name, const char *timestamp)
disk_cache_create(const char *gpu_name, const char *timestamp,
uint64_t driver_flags)
{
return NULL;
}