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

Timothy Arceri timothy.arceri at collabora.com
Wed Jul 13 02:47:52 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 8334d69..5326c52 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -353,6 +353,19 @@ upload_cached_program(struct brw_context *brw, gl_shader_stage stage)
 
    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\n");
+      }
+      cache_remove(cache, binary_sha1);
+      goto FAIL;
+   }
+
    switch (stage) {
    case MESA_SHADER_VERTEX:
       upload_cached_vs(brw, &binary, prog, &vs_key);
@@ -449,6 +462,8 @@ write_cached_program(struct brw_context *brw)
       if (binary == NULL)
          return;
 
+      blob_write_string(binary, brw->ctx.VersionString);
+
       gen_vs_sha1(brw, prog, &vs_key, vs_sha1);
 
       /* Write VS program to blob. */
@@ -484,6 +499,8 @@ write_cached_program(struct brw_context *brw)
       if (binary == NULL)
          return;
 
+      blob_write_string(binary, brw->ctx.VersionString);
+
       gen_wm_sha1(brw, prog, &vs_key, &wm_key, wm_sha1);
 
       /* Write WM program to blob. */
-- 
2.7.4



More information about the mesa-dev mailing list