[Mesa-dev] [PATCH 44/56] i965: track mesa version shader cache items were created with
Timothy Arceri
timothy.arceri at collabora.com
Tue Nov 29 03:58:43 UTC 2016
Also remove cache item and fallback to full recompile if current Mesa
version differs.
---
src/mesa/drivers/dri/i965/brw_shader_cache.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 00798e7..1c6a75b 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -317,6 +317,21 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
blob_reader_init(binary, buffer, size);
+ char *version_string = blob_read_string(binary);
+ if (strcmp(brw->ctx.VersionString, version_string) != 0) {
+ /* The cached version of the program was created with a different
+ * version of Mesa so remove it and fallback to full recompile.
+ */
+ if (brw->ctx._Shader->Flags & GLSL_CACHE_INFO) {
+ fprintf(stderr, "removing binary was created with incompatible mesa "
+ "version %s vs %s\n",
+ brw->ctx.VersionString, version_string);
+ }
+ disk_cache_remove(cache, binary_sha1);
+ free(buffer);
+ return false;
+ }
+
/* Read shader program from blob. */
size_t program_size = blob_read_uint32(binary);
uint8_t *program = blob_read_bytes(binary, program_size);
@@ -431,6 +446,8 @@ write_program_data(struct brw_context *brw, struct gl_program *prog,
if (!binary)
return;
+ blob_write_string(binary, brw->ctx.VersionString);
+
gen_shader_sha1(brw, prog, stage, key, sha1);
/* Write program to blob. */
--
2.7.4
More information about the mesa-dev
mailing list