From 5582c52a055841637ac58337f0007aa0ea405da9 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 27 May 2021 15:38:04 +0200 Subject: [PATCH] mesa/shaderapi: change construct_name signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the sha1 as an argument. This will be used by the next commit. Reviewed-by: Marek Olšák Part-of: --- src/mesa/main/shaderapi.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 22f6c0cf708..dab12e7a1ef 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1918,12 +1918,13 @@ _mesa_LinkProgram(GLuint programObj) /** * Generate a SHA-1 hash value string for given source string. */ -static void +static char * generate_sha1(const char *source, char sha_str[64]) { unsigned char sha[20]; _mesa_sha1_compute(source, strlen(source), sha); _mesa_sha1_format(sha_str, sha); + return sha_str; } /** @@ -1934,17 +1935,15 @@ generate_sha1(const char *source, char sha_str[64]) * /_.arb */ static char * -construct_name(const gl_shader_stage stage, const char *source, - const char *path) +construct_name(const gl_shader_stage stage, const char *sha, + const char *source, const char *path) { - char sha[64]; static const char *types[] = { "VS", "TC", "TE", "GS", "FS", "CS", }; const char *format = strncmp(source, "!!ARB", 5) ? "glsl" : "arb"; - generate_sha1(source, sha); return ralloc_asprintf(NULL, "%s/%s_%s.%s", path, types[stage], sha, format); } @@ -1957,6 +1956,7 @@ _mesa_dump_shader_source(const gl_shader_stage stage, const char *source) static bool path_exists = true; char *dump_path; FILE *f; + char sha[64]; if (!path_exists) return; @@ -1967,7 +1967,8 @@ _mesa_dump_shader_source(const gl_shader_stage stage, const char *source) return; } - char *name = construct_name(stage, source, dump_path); + char *name = construct_name(stage, generate_sha1(source, sha), + source, dump_path); f = fopen(name, "w"); if (f) { @@ -1993,6 +1994,7 @@ _mesa_read_shader_source(const gl_shader_stage stage, const char *source) int len, shader_size = 0; GLcharARB *buffer; FILE *f; + char sha[64]; if (!path_exists) return NULL; @@ -2003,7 +2005,8 @@ _mesa_read_shader_source(const gl_shader_stage stage, const char *source) return NULL; } - char *name = construct_name(stage, source, read_path); + char *name = construct_name(stage, generate_sha1(source, sha), + source, read_path); f = fopen(name, "r"); ralloc_free(name); if (!f)