summaryrefslogtreecommitdiffstats
path: root/src/mesa/program/ir_to_mesa.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-01-24 08:39:13 +1100
committerTimothy Arceri <[email protected]>2017-02-17 11:18:42 +1100
commit877194068208a9fb87f7b5513bca85d09be8a20f (patch)
treebddab5b55b75f3552e710ac6a8604e18ad5709d3 /src/mesa/program/ir_to_mesa.cpp
parent34ca0fce228224121d1a3b111c38325e731bace3 (diff)
glsl: make use of on disk shader cache
The hash key for glsl metadata is a hash of the hashes of each GLSL source string. This commit uses the put_key/get_key support in the cache put the SHA-1 hash of the source string for each successfully compiled shader into the cache. This allows for early, optimistic returns from glCompileShader (if the identical source string had been successfully compiled in the past), in the hope that the final, linked shader will be found in the cache. This is based on the intial patch by Carl. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/program/ir_to_mesa.cpp')
-rw-r--r--src/mesa/program/ir_to_mesa.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index ce58fbbd460..67c9267ac09 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -46,6 +46,7 @@
#include "compiler/glsl_types.h"
#include "compiler/glsl/linker.h"
#include "compiler/glsl/program.h"
+#include "compiler/glsl/shader_cache.h"
#include "program/prog_instruction.h"
#include "program/prog_optimize.h"
#include "program/prog_print.h"
@@ -3114,6 +3115,10 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
+ /* Return early if we are loading the shader from on-disk cache */
+ if (prog->data->LinkStatus == linking_skipped)
+ return;
+
if (ctx->_Shader->Flags & GLSL_DUMP) {
if (!prog->data->LinkStatus) {
fprintf(stderr, "GLSL shader program %d failed to link\n", prog->Name);
@@ -3124,6 +3129,9 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
fprintf(stderr, "%s\n", prog->data->InfoLog);
}
}
+
+ if (prog->data->LinkStatus)
+ shader_cache_write_program_metadata(ctx, prog);
}
} /* extern "C" */