[Mesa-dev] [PATCH 3/4] glsl: add gl_linked_shader::SourceChecksum

Nicolai Hähnle nhaehnle at gmail.com
Wed Nov 23 10:35:58 UTC 2016


On 22.11.2016 02:20, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> for debugging
> ---
>  src/compiler/glsl/linker.cpp | 8 ++++++++
>  src/mesa/main/mtypes.h       | 1 +
>  2 files changed, 9 insertions(+)
>
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index 61a029c..9678a74 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -2290,20 +2290,28 @@ link_intrastage_shaders(void *mem_ctx,
>        array_resize_visitor input_resize_visitor(num_vertices, prog,
>                                                  MESA_SHADER_GEOMETRY);
>        foreach_in_list(ir_instruction, ir, linked->ir) {
>           ir->accept(&input_resize_visitor);
>        }
>     }
>
>     if (ctx->Const.VertexID_is_zero_based)
>        lower_vertex_id(linked);
>
> +   /* 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;
> +   }

FWIW, most sources generally recommended *not* to combine hashes with 
XOR, better to feed the list of checksum into yet another hash/CRC 
computation.

That said, I think the rationale there is mostly about cryptographic 
applications and DoS-prevention in servers, and this is just intended 
for debugging. I see you've already pushed the series already anyway, 
and it's not a big deal.

Cheers,
Nicolai

> +
>     return linked;
>  }
>
>  /**
>   * Update the sizes of linked shader uniform arrays to the maximum
>   * array index used.
>   *
>   * From page 81 (page 95 of the PDF) of the OpenGL 2.1 spec:
>   *
>   *     If one or more elements of an array are active,
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index e870053..e6ae6d6 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2275,20 +2275,21 @@ struct gl_shader_info
>        bool LocalSizeVariable;
>     } Comp;
>  };
>
>  /**
>   * A linked GLSL shader object.
>   */
>  struct gl_linked_shader
>  {
>     gl_shader_stage Stage;
> +   unsigned SourceChecksum;
>
>     struct gl_program *Program;  /**< Post-compile assembly code */
>
>     /**
>      * \name Sampler tracking
>      *
>      * \note Each of these fields is only set post-linking.
>      */
>     /*@{*/
>     unsigned num_samplers;	/**< Number of samplers used by this shader. */
>


More information about the mesa-dev mailing list