#include "main/shaderobj.h"
#include "util/u_atomic.h" /* for p_atomic_cmpxchg */
#include "util/ralloc.h"
+#include "util/disk_cache.h"
+#include "util/mesa-sha1.h"
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
state->error = glcpp_preprocess(state, &source, &state->info_log,
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) {
+ fprintf(stderr, "deferring compile of shader: %s\n",
+ _mesa_sha1_format(buf, shader->sha1));
+ }
+ shader->CompileStatus = true;
+ return;
+ }
+ }
+
if (!state->error) {
_mesa_glsl_lexer_ctor(state, source);
_mesa_glsl_parse(state);
#include "program.h"
#include "program/prog_instruction.h"
#include "program/program.h"
+#include "util/mesa-sha1.h"
#include "util/set.h"
#include "util/string_to_uint_map.h"
#include "linker.h"
#include "ir_rvalue_visitor.h"
#include "ir_uniform.h"
#include "builtin_functions.h"
+#include "shader_cache.h"
#include "main/shaderobj.h"
#include "main/enums.h"
return;
}
+ if (shader_cache_read_program_metadata(ctx, prog))
+ return;
+
void *mem_ctx = ralloc_context(NULL); // temporary linker context
prog->ARB_fragment_coord_conventions_enable = false;
#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"
}
}
+ /* 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);
fprintf(stderr, "%s\n", prog->data->InfoLog);
}
}
+
+ if (prog->data->LinkStatus)
+ shader_cache_write_program_metadata(ctx, prog);
}
} /* extern "C" */