[Mesa-dev] [PATCH 20/40] glsl: track mesa version shader cache items were created with

Timothy Arceri tarceri at itsqueeze.com
Tue Feb 7 03:42:24 UTC 2017


From: Timothy Arceri <timothy.arceri at collabora.com>

Also remove cache item and fallback to full recompile if current Mesa
version differs.

V2: don't leak buffer
---
 src/compiler/glsl/shader_cache.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index a9d6987..320afe1 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1205,6 +1205,8 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
 
    struct blob *metadata = blob_create(NULL);
 
+   blob_write_string(metadata, ctx->VersionString);
+
    write_uniforms(metadata, prog);
 
    write_hash_tables(metadata, prog);
@@ -1333,6 +1335,17 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
    struct blob_reader metadata;
    blob_reader_init(&metadata, buffer, size);
 
+   char *version_string = blob_read_string(&metadata);
+   if (strcmp(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.
+       */
+      disk_cache_remove(cache, prog->data->sha1);
+      compile_shaders(ctx, prog);
+      free(buffer);
+      return false;
+   }
+
    assert(prog->data->UniformStorage == NULL);
 
    read_uniforms(&metadata, prog);
-- 
2.9.3



More information about the mesa-dev mailing list