summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrazvydas Ignotas <[email protected]>2017-03-26 19:30:23 +0300
committerTimothy Arceri <[email protected]>2017-03-27 15:05:10 +1100
commitb97faea162fe9999d241de679f99ad935a8bce26 (patch)
tree9eb7ed304a4d3923072ef59d3f8c81f8ad275e7b
parentf2d4d116113c8eddf7e8f372d466510c31d3dba4 (diff)
glsl, st/shader_cache: check the whole sha1 for zero
The checks were only looking at the first byte, while the intention seems to be to check if the whole sha1 is zero. This prevented all shaders with first byte zero in their sha1 from being saved. This shaves around a second from Deus Ex load time on a hot cache. Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]>
-rw-r--r--src/compiler/glsl/shader_cache.cpp3
-rw-r--r--src/mesa/state_tracker/st_shader_cache.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 274bb8c91e7..ea1bc01f028 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1221,7 +1221,8 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
* TODO: In future we should use another method to generate a key for ff
* programs.
*/
- if (*prog->data->sha1 == 0)
+ static const char zero[sizeof(prog->data->sha1)] = {0};
+ if (memcmp(prog->data->sha1, zero, sizeof(prog->data->sha1)) == 0)
return;
struct blob *metadata = blob_create();
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 061b27221b3..e8c7289ec6d 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -64,7 +64,8 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
/* Exit early when we are dealing with a ff shader with no source file to
* generate a source from.
*/
- if (*prog->sh.data->sha1 == 0)
+ static const char zero[sizeof(prog->sh.data->sha1)] = {0};
+ if (memcmp(prog->sh.data->sha1, zero, sizeof(prog->sh.data->sha1)) == 0)
return;
unsigned char *sha1;