[Mesa-dev] [PATCH 02/15] glsl: initialize glsl_struct_field properly
Marek Olšák
maraeo at gmail.com
Sat Oct 8 10:58:26 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
don't rely on ralloc doing memset
---
src/compiler/glsl_types.cpp | 38 ++------------------------------------
src/compiler/glsl_types.h | 6 ++++--
2 files changed, 6 insertions(+), 38 deletions(-)
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 73e3abd..bfc6698 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -116,40 +116,23 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
mtx_lock(&glsl_type::mutex);
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
this->fields.structure = ralloc_array(this->mem_ctx,
glsl_struct_field, length);
for (i = 0; i < length; i++) {
- this->fields.structure[i].type = fields[i].type;
+ this->fields.structure[i] = fields[i];
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
- this->fields.structure[i].location = fields[i].location;
- this->fields.structure[i].offset = fields[i].offset;
- this->fields.structure[i].interpolation = fields[i].interpolation;
- this->fields.structure[i].centroid = fields[i].centroid;
- this->fields.structure[i].sample = fields[i].sample;
- this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
- this->fields.structure[i].patch = fields[i].patch;
- this->fields.structure[i].image_read_only = fields[i].image_read_only;
- this->fields.structure[i].image_write_only = fields[i].image_write_only;
- this->fields.structure[i].image_coherent = fields[i].image_coherent;
- this->fields.structure[i].image_volatile = fields[i].image_volatile;
- this->fields.structure[i].image_restrict = fields[i].image_restrict;
- this->fields.structure[i].precision = fields[i].precision;
- this->fields.structure[i].explicit_xfb_buffer =
- fields[i].explicit_xfb_buffer;
- this->fields.structure[i].xfb_buffer = fields[i].xfb_buffer;
- this->fields.structure[i].xfb_stride = fields[i].xfb_stride;
}
mtx_unlock(&glsl_type::mutex);
}
glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
enum glsl_interface_packing packing, const char *name) :
gl_type(0),
base_type(GLSL_TYPE_INTERFACE),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
@@ -160,40 +143,23 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
unsigned int i;
mtx_lock(&glsl_type::mutex);
init_ralloc_type_ctx();
assert(name != NULL);
this->name = ralloc_strdup(this->mem_ctx, name);
this->fields.structure = ralloc_array(this->mem_ctx,
glsl_struct_field, length);
for (i = 0; i < length; i++) {
- this->fields.structure[i].type = fields[i].type;
+ this->fields.structure[i] = fields[i];
this->fields.structure[i].name = ralloc_strdup(this->fields.structure,
fields[i].name);
- this->fields.structure[i].location = fields[i].location;
- this->fields.structure[i].offset = fields[i].offset;
- this->fields.structure[i].interpolation = fields[i].interpolation;
- this->fields.structure[i].centroid = fields[i].centroid;
- this->fields.structure[i].sample = fields[i].sample;
- this->fields.structure[i].matrix_layout = fields[i].matrix_layout;
- this->fields.structure[i].patch = fields[i].patch;
- this->fields.structure[i].image_read_only = fields[i].image_read_only;
- this->fields.structure[i].image_write_only = fields[i].image_write_only;
- this->fields.structure[i].image_coherent = fields[i].image_coherent;
- this->fields.structure[i].image_volatile = fields[i].image_volatile;
- this->fields.structure[i].image_restrict = fields[i].image_restrict;
- this->fields.structure[i].precision = fields[i].precision;
- this->fields.structure[i].explicit_xfb_buffer =
- fields[i].explicit_xfb_buffer;
- this->fields.structure[i].xfb_buffer = fields[i].xfb_buffer;
- this->fields.structure[i].xfb_stride = fields[i].xfb_stride;
}
mtx_unlock(&glsl_type::mutex);
}
glsl_type::glsl_type(const glsl_type *return_type,
const glsl_function_param *params, unsigned num_params) :
gl_type(0),
base_type(GLSL_TYPE_FUNCTION),
sampler_dimensionality(0), sampler_shadow(0), sampler_array(0),
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index b1e2f7a..139d479 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -937,24 +937,26 @@ struct glsl_struct_field {
/**
* Any of the xfb_* qualifiers trigger the shader to be in transform
* feedback mode so we need to keep track of whether the buffer was
* explicitly set or if its just been assigned the default global value.
*/
unsigned explicit_xfb_buffer:1;
unsigned implicit_sized_array:1;
#ifdef __cplusplus
glsl_struct_field(const struct glsl_type *_type, const char *_name)
- : type(_type), name(_name), location(-1), interpolation(0), centroid(0),
+ : type(_type), name(_name), location(-1), offset(0), xfb_buffer(0),
+ xfb_stride(0), interpolation(0), centroid(0),
sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),
precision(GLSL_PRECISION_NONE), image_read_only(0), image_write_only(0),
- image_coherent(0), image_volatile(0), image_restrict(0)
+ image_coherent(0), image_volatile(0), image_restrict(0),
+ explicit_xfb_buffer(0), implicit_sized_array(0)
{
/* empty */
}
glsl_struct_field()
{
/* empty */
}
#endif
};
--
2.7.4
More information about the mesa-dev
mailing list