From: Marek Olšák Date: Fri, 18 Nov 2016 18:49:55 +0000 (+0100) Subject: glsl: add gl_linked_shader::SourceChecksum X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b818df1e714ed8bd2f1c3a68ee842cd81a0d7cf4;p=mesa.git glsl: add gl_linked_shader::SourceChecksum for debugging v2: wrap all checksums in #ifdef DEBUG Reviewed-by: Timothy Arceri --- diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp index 845a7938f91..1a00a900ef0 100644 --- a/src/compiler/glsl/linker.cpp +++ b/src/compiler/glsl/linker.cpp @@ -2297,6 +2297,16 @@ link_intrastage_shaders(void *mem_ctx, if (ctx->Const.VertexID_is_zero_based) lower_vertex_id(linked); +#ifdef DEBUG + /* Compute the source checksum. */ + linked->SourceChecksum = 0; + for (unsigned i = 0; i < num_shaders; i++) { + if (shader_list[i] == NULL) + continue; + linked->SourceChecksum ^= shader_list[i]->SourceChecksum; + } +#endif + return linked; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 485f5f18f48..26b19653cb8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2282,6 +2282,10 @@ struct gl_linked_shader { gl_shader_stage Stage; +#ifdef DEBUG + unsigned SourceChecksum; +#endif + struct gl_program *Program; /**< Post-compile assembly code */ /** @@ -2414,7 +2418,9 @@ struct gl_shader GLboolean CompileStatus; bool IsES; /**< True if this shader uses GLSL ES */ - GLuint SourceChecksum; /**< for debug/logging purposes */ +#ifdef DEBUG + unsigned SourceChecksum; /**< for debug/logging purposes */ +#endif const GLchar *Source; /**< Source code string */ GLchar *InfoLog; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 9592857f0f2..83ee0d4ca7d 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1149,10 +1149,16 @@ print_shader_info(const struct gl_shader_program *shProg) printf("Mesa: glUseProgram(%u)\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { +#ifdef DEBUG printf(" %s shader %u, checksum %u\n", _mesa_shader_stage_to_string(shProg->Shaders[i]->Stage), shProg->Shaders[i]->Name, shProg->Shaders[i]->SourceChecksum); +#else + printf(" %s shader %u\n", + _mesa_shader_stage_to_string(shProg->Shaders[i]->Stage), + shProg->Shaders[i]->Name); +#endif } if (shProg->_LinkedShaders[MESA_SHADER_VERTEX]) printf(" vert prog %u\n", diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index bdeb8fd6752..0a4bc51e954 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -976,7 +976,11 @@ _mesa_write_shader_to_file(const struct gl_shader *shader) return; } +#ifdef DEBUG fprintf(f, "/* Shader %u source, checksum %u */\n", shader->Name, shader->SourceChecksum); +#else + fprintf(f, "/* Shader %u source */\n", shader->Name); +#endif fputs(shader->Source, f); fprintf(f, "\n");