[Mesa-dev] [PATCH v2 3/4] glsl: explicitly zero out padding to gl_shader_variable bitfield
Timothy Arceri
tarceri at itsqueeze.com
Tue Jul 4 22:11:07 UTC 2017
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
On 03/07/17 22:34, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> Otherwise, the padding bits remain undefined, which leads to valgrind
> errors when storing the gl_shader_variable in the disk cache.
>
> v2: use rzalloc instead of an explicit padding member variable
> ---
> src/compiler/glsl/linker.cpp | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index 4aa4682..b406675 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -3723,21 +3723,24 @@ build_stageref(struct gl_shader_program *shProg, const char *name,
> * Create gl_shader_variable from ir_variable class.
> */
> static gl_shader_variable *
> create_shader_variable(struct gl_shader_program *shProg,
> const ir_variable *in,
> const char *name, const glsl_type *type,
> const glsl_type *interface_type,
> bool use_implicit_location, int location,
> const glsl_type *outermost_struct_type)
> {
> - gl_shader_variable *out = ralloc(shProg, struct gl_shader_variable);
> + /* Allocate zero-initialized memory to ensure that bitfield padding
> + * is zero.
> + */
> + gl_shader_variable *out = rzalloc(shProg, struct gl_shader_variable);
> if (!out)
> return NULL;
>
> /* Since gl_VertexID may be lowered to gl_VertexIDMESA, but applications
> * expect to see gl_VertexID in the program resource list. Pretend.
> */
> if (in->data.mode == ir_var_system_value &&
> in->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
> out->name = ralloc_strdup(shProg, "gl_VertexID");
> } else if ((in->data.mode == ir_var_shader_out &&
>
More information about the mesa-dev
mailing list