Mesa (17.0): utils: build sha1/disk cache only with Android/Autoconf

Emil Velikov evelikov at kemper.freedesktop.org
Thu Jan 19 14:34:14 UTC 2017


Module: Mesa
Branch: 17.0
Commit: acc78377990ba986060214466d44ea364529c363
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=acc78377990ba986060214466d44ea364529c363

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Wed Jan 18 19:40:31 2017 +0000

utils: build sha1/disk cache only with Android/Autoconf

Earlier commit imported a SHA1 implementation and relaxed the SHA1 and
disk cache handling, broking the Windows builds.

Restrict things for now until we get to a proper fix.

Fixes: d1efa09d342 "util: import sha1 implementation from OpenBSD"
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
(cherry picked from commit 9f8dc3bf03ec825bae7041858dda6ca2e9a34363)

---

 Android.common.mk                    |  1 +
 configure.ac                         |  1 +
 src/compiler/glsl/tests/cache_test.c |  5 +++++
 src/mesa/main/shaderapi.c            |  5 +++++
 src/util/disk_cache.c                |  4 ++++
 src/util/disk_cache.h                | 42 ++++++++++++++++++++++++++++++++++++
 6 files changed, 58 insertions(+)

diff --git a/Android.common.mk b/Android.common.mk
index ed5118a..a75d4e7 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -43,6 +43,7 @@ LOCAL_CFLAGS += \
 	-DANDROID_VERSION=0x0$(MESA_ANDROID_MAJOR_VERSION)0$(MESA_ANDROID_MINOR_VERSION)
 
 LOCAL_CFLAGS += \
+	-DENABLE_SHADER_CACHE \
 	-D__STDC_LIMIT_MACROS \
 	-DHAVE___BUILTIN_EXPECT \
 	-DHAVE___BUILTIN_FFS \
diff --git a/configure.ac b/configure.ac
index 6b07b2d..de8af87 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1766,6 +1766,7 @@ if test -n "$with_vulkan_drivers"; then
 fi
 
 
+DEFINES="$DEFINES -DENABLE_SHADER_CACHE"
 AM_CONDITIONAL(NEED_MEGADRIVER, test -n "$DRI_DIRS")
 AM_CONDITIONAL(NEED_LIBMESA, test "x$enable_glx" = xxlib -o \
                                   "x$enable_osmesa" = xyes -o \
diff --git a/src/compiler/glsl/tests/cache_test.c b/src/compiler/glsl/tests/cache_test.c
index f53ef0d..0ef05aa 100644
--- a/src/compiler/glsl/tests/cache_test.c
+++ b/src/compiler/glsl/tests/cache_test.c
@@ -37,6 +37,8 @@
 
 bool error = false;
 
+#ifdef ENABLE_SHADER_CACHE
+
 static void
 expect_equal(uint64_t actual, uint64_t expected, const char *test)
 {
@@ -378,10 +380,12 @@ test_put_key_and_get_key(void)
 
    disk_cache_destroy(cache);
 }
+#endif /* ENABLE_SHADER_CACHE */
 
 int
 main(void)
 {
+#ifdef ENABLE_SHADER_CACHE
    int err;
 
    test_disk_cache_create();
@@ -392,6 +396,7 @@ main(void)
 
    err = rmrf_local(CACHE_TEST_TMP);
    expect_equal(err, 0, "Removing " CACHE_TEST_TMP " again");
+#endif /* ENABLE_SHADER_CACHE */
 
    return error ? 1 : 0;
 }
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 96a4ce0..4c67f95 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1612,6 +1612,7 @@ _mesa_LinkProgram(GLuint programObj)
                                                            "glLinkProgram"));
 }
 
+#ifdef ENABLE_SHADER_CACHE
 /**
  * Generate a SHA-1 hash value string for given source string.
  */
@@ -1723,6 +1724,8 @@ read_shader(const gl_shader_stage stage, const char *source)
    return buffer;
 }
 
+#endif /* ENABLE_SHADER_CACHE */
+
 /**
  * Called via glShaderSource() and glShaderSourceARB() API functions.
  * Basically, concatenate the source code strings into one long string
@@ -1795,6 +1798,7 @@ _mesa_ShaderSource(GLuint shaderObj, GLsizei count,
    source[totalLength - 1] = '\0';
    source[totalLength - 2] = '\0';
 
+#ifdef ENABLE_SHADER_CACHE
    /* Dump original shader source to MESA_SHADER_DUMP_PATH and replace
     * if corresponding entry found from MESA_SHADER_READ_PATH.
     */
@@ -1805,6 +1809,7 @@ _mesa_ShaderSource(GLuint shaderObj, GLsizei count,
       free(source);
       source = replacement;
    }
+#endif /* ENABLE_SHADER_CACHE */
 
    shader_source(sh, source);
 
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 76bdfe8..6de608c 100644
--- a/src/util/disk_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>
@@ -705,3 +707,5 @@ disk_cache_has_key(struct disk_cache *cache, cache_key key)
 
    return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
 }
+
+#endif /* ENABLE_SHADER_CACHE */
diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
index 0b20665..7e9cb80 100644
--- a/src/util/disk_cache.h
+++ b/src/util/disk_cache.h
@@ -40,6 +40,8 @@ struct disk_cache;
 
 /* Provide inlined stub functions if the shader cache is disabled. */
 
+#ifdef ENABLE_SHADER_CACHE
+
 /**
  * Create a new cache object.
  *
@@ -129,6 +131,46 @@ disk_cache_put_key(struct disk_cache *cache, cache_key key);
 bool
 disk_cache_has_key(struct disk_cache *cache, cache_key key);
 
+#else
+
+static inline struct disk_cache *
+disk_cache_create(void)
+{
+   return NULL;
+}
+
+static inline void
+disk_cache_destroy(struct disk_cache *cache) {
+   return;
+}
+
+static inline void
+disk_cache_put(struct disk_cache *cache, cache_key key,
+          const void *data, size_t size)
+{
+   return;
+}
+
+static inline uint8_t *
+disk_cache_get(struct disk_cache *cache, cache_key key, size_t *size)
+{
+   return NULL;
+}
+
+static inline void
+disk_cache_put_key(struct disk_cache *cache, cache_key key)
+{
+   return;
+}
+
+static inline bool
+disk_cache_has_key(struct disk_cache *cache, cache_key key)
+{
+   return false;
+}
+
+#endif /* ENABLE_SHADER_CACHE */
+
 #ifdef __cplusplus
 }
 #endif




More information about the mesa-commit mailing list