[Mesa-dev] [PATCH 65/68] i965: track mesa version shader cache items were created with

Timothy Arceri timothy.arceri at collabora.com
Wed Jun 1 06:23:46 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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 105b8ef..5258f04 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -133,6 +133,16 @@ upload_cached_program(struct brw_context *brw)
 
    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.
+       */
+      printf("binary was created with incompatible mesa version\n");
+      cache_remove(cache, brw->binary_sha1);
+      goto FAIL;
+   }
+
    /* Read VS program from blob. */
    vs_program_size = blob_read_uint32(&binary);
 
@@ -469,6 +479,8 @@ write_cached_program(struct brw_context *brw)
    struct brw_wm_prog_key wm_key;
    gen_binary_sha1(brw, prog, &vs_key, &wm_key);
 
+   blob_write_string(binary, brw->ctx.VersionString);
+
    /* Write VS program to blob. */
    vs_program_size = brw->vs.prog_data->program_size;
 
-- 
2.5.5



More information about the mesa-dev mailing list