[Mesa-dev] [PATCH v2 05/32] glsl: Zero per_vertex_accumulator::fields for valgrind & nir_serialize

Kenneth Graunke kenneth at whitecape.org
Sat Oct 21 03:11:11 UTC 2017


On Friday, October 20, 2017 6:52:11 PM PDT Jordan Justen wrote:
> I'm now doubting the uninitialized padding explanation. I tried the
> memset in the glsl_struct_field constructor as Ken mentioned, but I
> also tried adding initializers for the fields in the default
> constructor, and it fixed valgrind.
> 
> I didn't find anything mentioning that a default constructor on a c++
> struct requires the fields to be explicitly initialized. I would think
> that each field would be default initialized, the same as for a c++
> class.
> 
> Anyway, here is alternate patch that fixes valgrind. Is this
> preferable to a memset in the constructor? Is either Reviewed-by
> worthy?
> 
> diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
> index b5e97e638b..0b4a66ca4d 100644
> --- a/src/compiler/glsl_types.h
> +++ b/src/compiler/glsl_types.h
> @@ -1045,6 +1045,13 @@ struct glsl_struct_field {
>     }
>  
>     glsl_struct_field()
> +      : type(NULL), name(NULL), location(0), offset(0), xfb_buffer(0),
> +        xfb_stride(0), interpolation(0), centroid(0),
> +        sample(0), matrix_layout(0), patch(0),
> +        precision(0), memory_read_only(0),
> +        memory_write_only(0), memory_coherent(0), memory_volatile(0),
> +        memory_restrict(0), image_format(0), explicit_xfb_buffer(0),
> +        implicit_sized_array(0)
>     {
>        /* empty */
>     }
> 
> -Jordan

This looks good to me, initializing members in the constructor is
very reasonable.  I like this better.

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171020/dbc230c3/attachment.sig>


More information about the mesa-dev mailing list