Reviewed-by: Timothy Arceri <tarc...@itsqueeze.com>
On 11/04/18 20:56, Nicolai Hähnle wrote:
From: Nicolai Hähnle <nicolai.haeh...@amd.com>
It looks as if the structure fields array is fully initialized below,
but in fact at least gcc in debug builds will not actually overwrite
the unused bits of bit fields.
---
src/compiler/glsl_types.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 9d853caf721..9ebf6a433bd 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -98,22 +98,24 @@ glsl_type::glsl_type(const glsl_struct_field *fields,
unsigned num_fields,
vector_elements(0), matrix_columns(0),
length(num_fields)
{
unsigned int i;
this->mem_ctx = ralloc_context(NULL);
assert(this->mem_ctx != NULL);
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
- this->fields.structure = ralloc_array(this->mem_ctx,
- glsl_struct_field, length);
+ /* Zero-fill to prevent spurious Valgrind errors when serializing NIR
+ * due to uninitialized unused bits in bit fields. */
+ this->fields.structure = rzalloc_array(this->mem_ctx,
+ glsl_struct_field, length);
for (i = 0; i < length; i++) {
this->fields.structure[i] = fields[i];
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
}
}
glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
enum glsl_interface_packing packing,
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev