-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 \
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 \
bool error = false;
+#ifdef ENABLE_SHADER_CACHE
+
static void
expect_equal(uint64_t actual, uint64_t expected, const char *test)
{
disk_cache_destroy(cache);
}
+#endif /* ENABLE_SHADER_CACHE */
int
main(void)
{
+#ifdef ENABLE_SHADER_CACHE
int err;
test_disk_cache_create();
err = rmrf_local(CACHE_TEST_TMP);
expect_equal(err, 0, "Removing " CACHE_TEST_TMP " again");
+#endif /* ENABLE_SHADER_CACHE */
return error ? 1 : 0;
}
"glLinkProgram"));
}
+#ifdef ENABLE_SHADER_CACHE
/**
* Generate a SHA-1 hash value string for given source string.
*/
return buffer;
}
+#endif /* ENABLE_SHADER_CACHE */
+
/**
* Called via glShaderSource() and glShaderSourceARB() API functions.
* Basically, concatenate the source code strings into one long string
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.
*/
free(source);
source = replacement;
}
+#endif /* ENABLE_SHADER_CACHE */
shader_source(sh, source);
* IN THE SOFTWARE.
*/
+#ifdef ENABLE_SHADER_CACHE
+
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
return memcmp(entry, key, CACHE_KEY_SIZE) == 0;
}
+
+#endif /* ENABLE_SHADER_CACHE */
/* Provide inlined stub functions if the shader cache is disabled. */
+#ifdef ENABLE_SHADER_CACHE
+
/**
* Create a new cache object.
*
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