[Mesa-dev] [PATCH mesa 10/10] util/disk_cache: turn MESA_GLSL_CACHE_DISABLE into a boolean

Eric Engestrom eric.engestrom at imgtec.com
Fri Sep 8 12:40:56 UTC 2017


Instead of setting based on set/unset, allow users to use boolean values.
In the docs and tests, use `DISABLE=true` instead of `DISABLE=1` as it's
clearer IMO.

Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
 docs/envvars.html                    | 2 +-
 src/compiler/glsl/tests/cache_test.c | 4 ++--
 src/util/disk_cache.c                | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/docs/envvars.html b/docs/envvars.html
index 45e45eb0c9..51c930f013 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -117,7 +117,7 @@
 glGetString(GL_SHADING_LANGUAGE_VERSION). Valid values are integers, such as
 "130".  Mesa will not really implement all the features of the given language version
 if it's higher than what's normally reported. (for developers only)
-<li>MESA_GLSL_CACHE_DISABLE - if set, disables the GLSL shader cache
+<li>MESA_GLSL_CACHE_DISABLE - if set to `true`, disables the GLSL shader cache
 <li>MESA_GLSL_CACHE_MAX_SIZE - if set, determines the maximum size of
 the on-disk cache of compiled GLSL programs. Should be set to a number
 optionally followed by 'K', 'M', or 'G' to specify a size in
diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
index 8e7912c71b..75319f1160 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -156,9 +156,9 @@ test_disk_cache_create(void)
    int err;
 
    /* Before doing anything else, ensure that with
-    * MESA_GLSL_CACHE_DISABLE set, that disk_cache_create returns NULL.
+    * MESA_GLSL_CACHE_DISABLE set to true, that disk_cache_create returns NULL.
     */
-   setenv("MESA_GLSL_CACHE_DISABLE", "1", 1);
+   setenv("MESA_GLSL_CACHE_DISABLE", "true", 1);
    cache = disk_cache_create("test", "make_check", 0);
    expect_null(cache, "disk_cache_create with MESA_GLSL_CACHE_DISABLE set");
 
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 33e4dc8e7d..17913a913b 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -40,6 +40,7 @@
 #include "zlib.h"
 
 #include "util/crc32.h"
+#include "util/debug.h"
 #include "util/rand_xor.h"
 #include "util/u_atomic.h"
 #include "util/u_queue.h"
@@ -204,7 +205,7 @@ disk_cache_create(const char *gpu_name, const char *timestamp,
       goto fail;
 
    /* At user request, disable shader cache entirely. */
-   if (getenv("MESA_GLSL_CACHE_DISABLE"))
+   if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
       goto fail;
 
    /* Determine path for cache based on the first defined name as follows:
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list