Module: Mesa
Branch: master
Commit: 361d143f941c34aead2bbad8541aa1eca54149ad
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=361d143f941c34aead2bbad8541aa1eca54149ad

Author: Yevhenii Kharchenko <[email protected]>
Date:   Sat Oct 17 23:43:59 2020 +0300

meson: Add build option to specify default shader disk cache max-size

Added an optional 'shader-cache-max-size' build option to meson,
which sets default value of max disk cache size for compiled
GLSL programs. Can be overriden by 'MESA_GLSL_CACHE_MAX_SIZE'
environment variable.
Syntax is the same as environment variable has: a number optionally
followed by K, M, G to specify a size in kilobytes, megabytes, or
gigabytes. By default, gigabytes will be assumed.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3572

Signed-off-by: Yevhenii Kharchenko <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Reviewed-by: John Bates <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7217>

---

 meson.build           |  7 +++++++
 meson_options.txt     | 11 +++++++++++
 src/util/disk_cache.c |  7 +++++++
 3 files changed, 25 insertions(+)

diff --git a/meson.build b/meson.build
index c8c3b961c96..834e47525ee 100644
--- a/meson.build
+++ b/meson.build
@@ -937,6 +937,13 @@ if _shader_cache != 'disabled'
   endif
 endif
 
+if with_shader_cache 
+  shader_cache_max_size = get_option('shader-cache-max-size')
+  if shader_cache_max_size != ''
+    pre_args += 
'-DMESA_GLSL_CACHE_MAX_SIZE="@0@"'.format(shader_cache_max_size)
+  endif
+endif
+
 # Check for GCC style builtins
 foreach b : ['bswap32', 'bswap64', 'clz', 'clzll', 'ctz', 'expect', 'ffs',
              'ffsll', 'popcount', 'popcountll', 'unreachable']
diff --git a/meson_options.txt b/meson_options.txt
index 2f40a3dca24..834056041cf 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -194,6 +194,17 @@ option(
   value : true,
   description : 'If set to false, the feature is only activated when 
environment variable MESA_GLSL_CACHE_DISABLE is set to false',
 )
+option(
+  'shader-cache-max-size',
+  type : 'string',
+  value : '',
+  description : 'Default value for MESA_GLSL_CACHE_MAX_SIZE enviroment 
variable. 
+   If set, determines the maximum size of the on-disk cache of compiled
+   GLSL programs, can be overriden by enviroment variable if needed. Should be 
set to a number optionally followed by
+   ``K``, ``M``, or ``G`` to specify a size in kilobytes, megabytes, or
+   gigabytes. By default, gigabytes will be assumed. And if unset, a
+   maximum size of 1GB will be used.'
+)
 option(
   'vulkan-icd-dir',
   type : 'string',
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index e1eee29839f..c2bb018d75a 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -113,6 +113,13 @@ disk_cache_create(const char *gpu_name, const char 
*driver_id,
    max_size = 0;
 
    max_size_str = getenv("MESA_GLSL_CACHE_MAX_SIZE");
+   
+   #ifdef MESA_GLSL_CACHE_MAX_SIZE
+   if( !max_size_str ) {
+      max_size_str = MESA_GLSL_CACHE_MAX_SIZE;
+   }
+   #endif
+
    if (max_size_str) {
       char *end;
       max_size = strtoul(max_size_str, &end, 10);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to