mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 17:58:26 +02:00
disk_cache: add disk_cache_enabled() helper
This will make windows support easier to add in future. Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6197>
This commit is contained in:
parent
4339ecde35
commit
62c4339118
3 changed files with 19 additions and 6 deletions
|
|
@ -182,8 +182,7 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
|
|||
uint8_t cache_version = CACHE_VERSION;
|
||||
size_t cv_size = sizeof(cache_version);
|
||||
|
||||
/* If running as a users other than the real user disable cache */
|
||||
if (geteuid() != getuid())
|
||||
if (!disk_cache_enabled())
|
||||
return NULL;
|
||||
|
||||
/* A ralloc context for transient data during this invocation. */
|
||||
|
|
@ -191,10 +190,6 @@ disk_cache_create(const char *gpu_name, const char *driver_id,
|
|||
if (local == NULL)
|
||||
goto fail;
|
||||
|
||||
/* At user request, disable shader cache entirely. */
|
||||
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
|
||||
goto fail;
|
||||
|
||||
cache = rzalloc(NULL, struct disk_cache);
|
||||
if (cache == NULL)
|
||||
goto fail;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "util/debug.h"
|
||||
#include "util/disk_cache.h"
|
||||
#include "util/disk_cache_os.h"
|
||||
#include "util/ralloc.h"
|
||||
|
|
@ -171,6 +172,20 @@ disk_cache_generate_cache_dir(void *mem_ctx)
|
|||
|
||||
return path;
|
||||
}
|
||||
|
||||
bool
|
||||
disk_cache_enabled()
|
||||
{
|
||||
/* If running as a users other than the real user disable cache */
|
||||
if (geteuid() != getuid())
|
||||
return false;
|
||||
|
||||
/* At user request, disable shader cache entirely. */
|
||||
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", false))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ENABLE_SHADER_CACHE */
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
char *
|
||||
disk_cache_generate_cache_dir(void *mem_ctx);
|
||||
|
||||
bool
|
||||
disk_cache_enabled(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* DISK_CACHE_OS_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue