glsl: Add constuctors for the common cases of glsl_struct_field

Fixes a giant pile of GCC warnings:

builtin_types.cpp:60:1: warning: missing initializer for member 'glsl_struct_field::stream' [-Wmissing-field-initializers]

I had to add a default constructor because a non-default constructor
was added.  Otherwise the only constructor would be the one with
parameters, and all the plases like

    glsl_struct_field foo;

would fail to compile.

I wanted to do this in two patches.  All of the initializers of
glsl_struct_field structures had to be converted to use the
constructor because C++ apparently forces you to do one or the other:

builtin_types.cpp:61:1: error: could not convert '{glsl_type::float_type, "near", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0, -1}' from '<brace-enclosed initializer list>' to 'glsl_struct_field'

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
This commit is contained in:
Ian Romanick 2015-07-30 06:00:56 -07:00
parent 93977d3a15
commit 7ac946e546
4 changed files with 53 additions and 56 deletions

View File

@ -54,64 +54,64 @@
&glsl_type::_struct_##NAME##_type;
static const struct glsl_struct_field gl_DepthRangeParameters_fields[] = {
{ glsl_type::float_type, "near", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "far", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "diff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::float_type, "near"),
glsl_struct_field(glsl_type::float_type, "far"),
glsl_struct_field(glsl_type::float_type, "diff"),
};
static const struct glsl_struct_field gl_PointParameters_fields[] = {
{ glsl_type::float_type, "size", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "sizeMin", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "sizeMax", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "fadeThresholdSize", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "distanceConstantAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "distanceLinearAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "distanceQuadraticAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::float_type, "size"),
glsl_struct_field(glsl_type::float_type, "sizeMin"),
glsl_struct_field(glsl_type::float_type, "sizeMax"),
glsl_struct_field(glsl_type::float_type, "fadeThresholdSize"),
glsl_struct_field(glsl_type::float_type, "distanceConstantAttenuation"),
glsl_struct_field(glsl_type::float_type, "distanceLinearAttenuation"),
glsl_struct_field(glsl_type::float_type, "distanceQuadraticAttenuation"),
};
static const struct glsl_struct_field gl_MaterialParameters_fields[] = {
{ glsl_type::vec4_type, "emission", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "shininess", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "emission"),
glsl_struct_field(glsl_type::vec4_type, "ambient"),
glsl_struct_field(glsl_type::vec4_type, "diffuse"),
glsl_struct_field(glsl_type::vec4_type, "specular"),
glsl_struct_field(glsl_type::float_type, "shininess"),
};
static const struct glsl_struct_field gl_LightSourceParameters_fields[] = {
{ glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "position", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "halfVector", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec3_type, "spotDirection", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "spotExponent", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "spotCutoff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "spotCosCutoff", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "constantAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "linearAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "quadraticAttenuation", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "ambient"),
glsl_struct_field(glsl_type::vec4_type, "diffuse"),
glsl_struct_field(glsl_type::vec4_type, "specular"),
glsl_struct_field(glsl_type::vec4_type, "position"),
glsl_struct_field(glsl_type::vec4_type, "halfVector"),
glsl_struct_field(glsl_type::vec3_type, "spotDirection"),
glsl_struct_field(glsl_type::float_type, "spotExponent"),
glsl_struct_field(glsl_type::float_type, "spotCutoff"),
glsl_struct_field(glsl_type::float_type, "spotCosCutoff"),
glsl_struct_field(glsl_type::float_type, "constantAttenuation"),
glsl_struct_field(glsl_type::float_type, "linearAttenuation"),
glsl_struct_field(glsl_type::float_type, "quadraticAttenuation"),
};
static const struct glsl_struct_field gl_LightModelParameters_fields[] = {
{ glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "ambient"),
};
static const struct glsl_struct_field gl_LightModelProducts_fields[] = {
{ glsl_type::vec4_type, "sceneColor", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "sceneColor"),
};
static const struct glsl_struct_field gl_LightProducts_fields[] = {
{ glsl_type::vec4_type, "ambient", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "diffuse", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::vec4_type, "specular", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "ambient"),
glsl_struct_field(glsl_type::vec4_type, "diffuse"),
glsl_struct_field(glsl_type::vec4_type, "specular"),
};
static const struct glsl_struct_field gl_FogParameters_fields[] = {
{ glsl_type::vec4_type, "color", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "density", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "start", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "end", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
{ glsl_type::float_type, "scale", -1, 0, 0, 0, GLSL_MATRIX_LAYOUT_INHERITED, 0 },
glsl_struct_field(glsl_type::vec4_type, "color"),
glsl_struct_field(glsl_type::float_type, "density"),
glsl_struct_field(glsl_type::float_type, "start"),
glsl_struct_field(glsl_type::float_type, "end"),
glsl_struct_field(glsl_type::float_type, "scale"),
};
#include "builtin_type_macros.h"

View File

@ -781,6 +781,19 @@ struct glsl_struct_field {
* streams (as in ir_variable::stream). -1 otherwise.
*/
int stream;
glsl_struct_field(const struct glsl_type *_type, const char *_name)
: type(_type), name(_name), location(-1), interpolation(0), centroid(0),
sample(0), matrix_layout(GLSL_MATRIX_LAYOUT_INHERITED), patch(0),
stream(-1)
{
/* empty */
}
glsl_struct_field()
{
/* empty */
}
};
static inline unsigned int

View File

@ -31,11 +31,7 @@ TEST(ir_variable_constructor, interface)
void *mem_ctx = ralloc_context(NULL);
static const glsl_struct_field f[] = {
{
glsl_type::vec(4),
"v",
false
}
glsl_struct_field(glsl_type::vec(4), "v")
};
const glsl_type *const interface =
@ -60,11 +56,7 @@ TEST(ir_variable_constructor, interface_array)
void *mem_ctx = ralloc_context(NULL);
static const glsl_struct_field f[] = {
{
glsl_type::vec(4),
"v",
false
}
glsl_struct_field(glsl_type::vec(4), "v")
};
const glsl_type *const interface =

View File

@ -76,15 +76,7 @@ public:
link_varyings::link_varyings()
{
static const glsl_struct_field f[] = {
{
glsl_type::vec(4),
"v",
false,
0,
0,
0,
0
}
glsl_struct_field(glsl_type::vec(4), "v")
};
this->simple_interface =