aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/libraries/mesa/disk_cache-include-dri-driver-path-in-cache-key.patch
blob: fa78f4ae730ad22f19b244631115b8901fc948b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From 980164fd92f5c2302624cd046d30ff21e6e4ba8a Mon Sep 17 00:00:00 2001
From: David McFarland <corngood@gmail.com>
Date: Mon, 6 Aug 2018 15:52:11 -0300
Subject: [PATCH] disk_cache: include dri driver path in cache key

This fixes invalid cache hits on NixOS where all shared library
timestamps in /nix/store are zero.
---
 meson_options.txt     | 6 ++++++
 src/util/disk_cache.c | 3 +++
 src/util/meson.build  | 7 ++++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/meson_options.txt b/meson_options.txt
index 2d39d13b6ad..daf06480a60 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -368,6 +368,12 @@ option(
   value : true,
   description : 'Enable direct rendering in GLX and EGL for DRI',
 )
+option(
+  'disk-cache-key',
+  type : 'string',
+  value : '',
+  description : 'Mesa cache key.'
+)
 option(
   'prefer-iris',
   type : 'boolean',
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index a92d621927a..3bd65c6890c 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -401,8 +401,10 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
 
    /* Create driver id keys */
    size_t id_size = strlen(driver_id) + 1;
+   size_t key_size = strlen(DISK_CACHE_KEY) + 1;
    size_t gpu_name_size = strlen(gpu_name) + 1;
    cache->driver_keys_blob_size += id_size;
+   cache->driver_keys_blob_size += key_size;
    cache->driver_keys_blob_size += gpu_name_size;
 
    /* We sometimes store entire structs that contains a pointers in the cache,
@@ -423,6 +425,7 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
    uint8_t *drv_key_blob = cache->driver_keys_blob;
    DRV_KEY_CPY(drv_key_blob, &cache_version, cv_size)
    DRV_KEY_CPY(drv_key_blob, driver_id, id_size)
+   DRV_KEY_CPY(drv_key_blob, DISK_CACHE_KEY, key_size)
    DRV_KEY_CPY(drv_key_blob, gpu_name, gpu_name_size)
    DRV_KEY_CPY(drv_key_blob, &ptr_size, ptr_size_size)
    DRV_KEY_CPY(drv_key_blob, &driver_flags, driver_flags_size)
diff --git a/src/util/meson.build b/src/util/meson.build
index 0893f64793b..d46ce85a85f 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -179,7 +179,12 @@ _libmesa_util = static_library(
   include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
   dependencies : deps_for_libmesa_util,
   link_with: libmesa_format,
-  c_args : [c_msvc_compat_args],
+  c_args : [
+    c_msvc_compat_args,
+    '-DDISK_CACHE_KEY="@0@"'.format(
+      get_option('disk-cache-key')
+    ),
+  ],
   gnu_symbol_visibility : 'hidden',
   build_by_default : false
 )
-- 
2.28.0