aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-11-13 16:38:01 +0100
committerMarek Olšák <[email protected]>2016-11-15 20:22:28 +0100
commit31727300e177b11c2b2b267838b59b090cb605d0 (patch)
treefe8780aeade71541c70849edb18ce600977ee400 /src
parent5b8876609ec526cd407e86b50bf8587ddb5bbacd (diff)
util: import cache.c/h from glsl
It's not dependent on GLSL and it can be useful for shader caches that don't deal with GLSL. v2: address review comments v3: keep the other 3 lines in configure.ac Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/Makefile.glsl.am4
-rw-r--r--src/compiler/Makefile.sources4
-rw-r--r--src/compiler/glsl/tests/cache_test.c22
-rw-r--r--src/util/Makefile.sources2
-rw-r--r--src/util/disk_cache.c (renamed from src/compiler/glsl/cache.c)16
-rw-r--r--src/util/disk_cache.h (renamed from src/compiler/glsl/cache.h)11
6 files changed, 17 insertions, 42 deletions
diff --git a/src/compiler/Makefile.glsl.am b/src/compiler/Makefile.glsl.am
index 3eac677de0d..5b1d74e2835 100644
--- a/src/compiler/Makefile.glsl.am
+++ b/src/compiler/Makefile.glsl.am
@@ -131,10 +131,6 @@ glsl_libglsl_la_SOURCES = \
$(LIBGLSL_GENERATED_FILES) \
$(LIBGLSL_FILES)
-if ENABLE_SHADER_CACHE
-glsl_libglsl_la_SOURCES += $(LIBGLSL_SHADER_CACHE_FILES)
-endif
-
glsl_libstandalone_la_SOURCES = \
$(GLSL_COMPILER_CXX_FILES)
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 08d93e0a261..d05bcacb9c5 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -136,10 +136,6 @@ LIBGLSL_FILES = \
glsl/s_expression.cpp \
glsl/s_expression.h
-LIBGLSL_SHADER_CACHE_FILES = \
- glsl/cache.c \
- glsl/cache.h
-
# glsl_compiler
GLSL_COMPILER_CXX_FILES = \
diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
index 724dfcd7753..94a3c1dfb9e 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -32,31 +32,11 @@
#include <stdarg.h>
#include "util/mesa-sha1.h"
-#include "cache.h"
+#include "util/disk_cache.h"
bool error = false;
#ifdef ENABLE_SHADER_CACHE
-void
-_mesa_warning(void *ctx, const char *fmt, ...);
-
-void
-_mesa_warning(void *ctx, const char *fmt, ...)
-{
- va_list vargs;
- (void) ctx;
-
- va_start(vargs, fmt);
-
- /* This output is not thread-safe, but that's good enough for the
- * standalone compiler.
- */
- fprintf(stderr, "Mesa warning: ");
- vfprintf(stderr, fmt, vargs);
- fprintf(stderr, "\n");
-
- va_end(vargs);
-}
static void
expect_equal(uint64_t actual, uint64_t expected, const char *test)
diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources
index c5531c82d8a..b7ca347f5e8 100644
--- a/src/util/Makefile.sources
+++ b/src/util/Makefile.sources
@@ -4,6 +4,8 @@ MESA_UTIL_FILES := \
bitset.h \
debug.c \
debug.h \
+ disk_cache.c \
+ disk_cache.h \
format_r11g11b10f.h \
format_rgb9e5.h \
format_srgb.h \
diff --git a/src/compiler/glsl/cache.c b/src/util/disk_cache.c
index e74c27d3000..79242aa3c1e 100644
--- a/src/compiler/glsl/cache.c
+++ b/src/util/disk_cache.c
@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
+#ifdef ENABLE_SHADER_CACHE
+
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
@@ -40,7 +42,7 @@
#include "util/ralloc.h"
#include "main/errors.h"
-#include "cache.h"
+#include "disk_cache.h"
/* Number of bits to mask off from a cache key to get an index. */
#define CACHE_INDEX_KEY_BITS 16
@@ -86,9 +88,8 @@ mkdir_if_needed(char *path)
if (S_ISDIR(sb.st_mode)) {
return 0;
} else {
- _mesa_warning(NULL,
- "Cannot use %s for shader cache (not a directory)"
- "---disabling.\n", path);
+ fprintf(stderr, "Cannot use %s for shader cache (not a directory)"
+ "---disabling.\n", path);
return -1;
}
}
@@ -97,9 +98,8 @@ mkdir_if_needed(char *path)
if (ret == 0 || (ret == -1 && errno == EEXIST))
return 0;
- _mesa_warning(NULL,
- "Failed to create %s for shader cache (%s)---disabling.\n",
- path, strerror(errno));
+ fprintf(stderr, "Failed to create %s for shader cache (%s)---disabling.\n",
+ path, strerror(errno));
return -1;
}
@@ -708,3 +708,5 @@ cache_has_key(struct program_cache *cache, cache_key key)
return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
}
+
+#endif
diff --git a/src/compiler/glsl/cache.h b/src/util/disk_cache.h
index d804169c656..d4d939883e6 100644
--- a/src/compiler/glsl/cache.h
+++ b/src/util/disk_cache.h
@@ -21,17 +21,16 @@
* IN THE SOFTWARE.
*/
-#pragma once
-#ifndef CACHE_H
-#define CACHE_H
+#ifndef DISK_CACHE_H
+#define DISK_CACHE_H
+
+#include <stdint.h>
+#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
-#include <stdint.h>
-#include <stdbool.h>
-
/* Size of cache keys in bytes. */
#define CACHE_KEY_SIZE 20