glsl: add gl_linked_shader::SourceChecksum
authorMarek Olšák <marek.olsak@amd.com>
Fri, 18 Nov 2016 18:49:55 +0000 (19:49 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 22 Nov 2016 17:05:51 +0000 (18:05 +0100)
for debugging

v2: wrap all checksums in #ifdef DEBUG

Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c
src/mesa/program/prog_print.c

index 845a7938f9163bcd9ebf3f5ccd8f320888b8dc22..1a00a900ef0caf5785b9501fec04c126d23d788f 100644 (file)
@@ -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;
 }
 
index 485f5f18f48c126b554afcc9442a8ab78f5be4f5..26b19653cb8229b9175decd5b4d3b170fc80f33c 100644 (file)
@@ -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;
index 9592857f0f2b6fbb73908e74bae49858b5eafc87..83ee0d4ca7db48f4f8ee78d26c8286445a3293e0 100644 (file)
@@ -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",
index bdeb8fd675230e543ab4ce238aa65a30bc8e6b73..0a4bc51e954ffbfb2f54b608b0823bac9eea2f23 100644 (file)
@@ -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");