On Dec 16, 2015 12:36 PM, "Kenneth Graunke" <[email protected]> wrote:
>
> On Monday, December 14, 2015 03:34:28 PM Ian Romanick wrote:
> > From: Ian Romanick <[email protected]>
> >
> > nir/nir_constant_expressions.c: In function 'evaluate_ball2':
> > nir/nir_constant_expressions.c:279:7: warning: missing initializer for
field 'z' of 'struct bool_vec' [-Wmissing-field-initializers]
> >        };
> >        ^
> > nir/nir_constant_expressions.c:234:10: note: 'z' declared here
> >     bool z;
> >           ^
> >
> > Number of total warnings in my build reduced from 1643 to 1574
> > (reduction of 69).
> >
> > Signed-off-by: Ian Romanick <[email protected]>
> > ---
> >  src/glsl/nir/nir_constant_expressions.py | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/src/glsl/nir/nir_constant_expressions.py
b/src/glsl/nir/nir_constant_expressions.py
> > index 32784f6..81dd67f 100644
> > --- a/src/glsl/nir/nir_constant_expressions.py
> > +++ b/src/glsl/nir/nir_constant_expressions.py
> > @@ -239,6 +239,13 @@ evaluate_${name}(unsigned num_components,
nir_const_value *_src)
> >              _src[${j}].${op.input_types[j][:1]}[${k}],
> >           % endif
> >        % endfor
> > +      % for k in range(op.input_sizes[j], 4):
> > +         % if op.input_types[j] == "bool":
> > +            false,
> > +         % else:
> > +            0,
> > +         % endif
> > +      % endfor
>
> I'd be tempted to simplify this to:
>
>       % for k in range(op.input_sizes[j], 4):
>          0,
>       % endfor
>
> 0 will be implicitly converted to bool.  (I'd rather keep the generator
> as simple as possible, since it's the code that people actually read and
> maintain...)

Originally, I has some idea that if we could avoid initializing some of the
parameters, you would get warnings if the expression provided in
nir_opcodes.py used components that don't exist.  However, since struct
initializers are defined to fill extra components in with zeros in C99,
this kind of falls flat.  I'd like to find a way to do that at some point,
but this is fine for now.

In one revision of nir_constant_expressions, I had separate vec4, vec3,
etc. structs for each type and vector length.  Maybe we should consider
doing that.  But that's work, so this is fine for now.
--Jason
_______________________________________________
mesa-dev mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to