[Mesa-dev] [PATCH 57/88] i965: track mesa version shader cache items were created with
Timothy Arceri
timothy.arceri at collabora.com
Sat Sep 24 05:25:38 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 9d95ee9..7b5de32 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -355,6 +355,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);
@@ -451,6 +464,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. */
@@ -486,6 +501,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