[Mesa-dev] [PATCH 76/77] glsl: create separate 32bit and 64bit versions of shader cache objects

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:05:35 UTC 2016


Pointers will have different lengths so we simply create a different
sha1 for each platform.

In theory we should be able to share cached shaders as we cache all
pointer as uint64_t however if a pointer is ever added to one of the
structs we write to file with blob_write_bytes() we run the risk of
introducing a bug that would be difficult to reproduce or report from
a user point of veiw. It's also very unlikely that Mesa developers will
regularly regression test the interaction of cache sharing between
platforms.
---
 src/compiler/glsl/shader_cache.cpp | 2 +-
 src/compiler/glsl/shader_cache.h   | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index af053a9..a899d58 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1315,7 +1315,7 @@ shader_cache_read_program_metadata(struct gl_context *ctx,
    /* Include bindings when creating sha1. These bindings change the resulting
     * binary so they are just as important as the shader source.
     */
-   char *bindings_str = ralloc_strdup(NULL, "vb: ");
+   char *bindings_str = ralloc_strdup(NULL, CACHED_PROGRAM"\n vb: ");
    prog->AttributeBindings->iterate(create_binding_str, &bindings_str);
    ralloc_strcat(&bindings_str, "fb: ");
    prog->FragDataBindings->iterate(create_binding_str, &bindings_str);
diff --git a/src/compiler/glsl/shader_cache.h b/src/compiler/glsl/shader_cache.h
index ae055ac..e35fa8f 100644
--- a/src/compiler/glsl/shader_cache.h
+++ b/src/compiler/glsl/shader_cache.h
@@ -27,6 +27,12 @@
 
 #include "cache.h"
 
+#if __x86_64__
+#define CACHED_PROGRAM "program64:"
+#else
+#define CACHED_PROGRAM "program32:"
+#endif
+
 static uint64_t inline
 ptr_to_uint64_t(void *ptr)
 {
-- 
2.7.4



More information about the mesa-dev mailing list