From b97faea162fe9999d241de679f99ad935a8bce26 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Sun, 26 Mar 2017 19:30:23 +0300 Subject: 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 Reviewed-by: Timothy Arceri Reviewed-by: Edward O'Callaghan --- src/mesa/state_tracker/st_shader_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa') 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; -- cgit v1.2.3