summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_parser_extras.cpp
diff options
context:
space:
mode:
authorGrazvydas Ignotas <[email protected]>2017-03-16 01:09:27 +0200
committerTimothy Arceri <[email protected]>2017-03-21 11:15:52 +1100
commit529a767041c880f90c4465cb34a89430459c7fce (patch)
treeb19c1fcbc36ffe1314155559c7fa52226c8c6e2d /src/compiler/glsl/glsl_parser_extras.cpp
parent021c87fa24afe849e51dd0249ec8e7b59e097062 (diff)
util/disk_cache: use a helper to compute cache keys
This will allow to hash additional data into the cache keys or even change the hashing algorithm easily, should we decide to do so. v2: don't try to compute key (and crash) if cache is disabled Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glsl_parser_extras.cpp')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 48cbc01ba74..8b5df3bdd89 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1938,19 +1938,22 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
add_builtin_defines, state, ctx);
if (!force_recompile) {
- char buf[41];
- _mesa_sha1_compute(source, strlen(source), shader->sha1);
- if (ctx->Cache && disk_cache_has_key(ctx->Cache, shader->sha1)) {
- /* We've seen this shader before and know it compiles */
- if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
- _mesa_sha1_format(buf, shader->sha1);
- fprintf(stderr, "deferring compile of shader: %s\n", buf);
- }
- shader->CompileStatus = compile_skipped;
+ if (ctx->Cache) {
+ char buf[41];
+ disk_cache_compute_key(ctx->Cache, source, strlen(source),
+ shader->sha1);
+ if (disk_cache_has_key(ctx->Cache, shader->sha1)) {
+ /* We've seen this shader before and know it compiles */
+ if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
+ _mesa_sha1_format(buf, shader->sha1);
+ fprintf(stderr, "deferring compile of shader: %s\n", buf);
+ }
+ shader->CompileStatus = compile_skipped;
- free((void *)shader->FallbackSource);
- shader->FallbackSource = NULL;
- return;
+ free((void *)shader->FallbackSource);
+ shader->FallbackSource = NULL;
+ return;
+ }
}
} else {
/* We should only ever end up here if a re-compile has been forced by a