<p dir="ltr"><br>
On Mar 22, 2016 8:18 AM, "Samuel Iglesias Gonsálvez" <<a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
><br>
><br>
><br>
> On 21/03/16 23:54, Jason Ekstrand wrote:<br>
> > On Mon, Mar 21, 2016 at 5:05 AM, Samuel Iglesias Gonsálvez <<br>
> > <a href="mailto:siglesias@igalia.com">siglesias@igalia.com</a>> wrote:<br>
> ><br>
> >> From: Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>><br>
> >><br>
> >> Undefined sources in alu operations don't have a valid bit size because<br>
> >> they are uninitialized. Simply ignoring undefined sources for bit size<br>
> >> validation is not enough since drivers can check and operate with the<br>
> >> bit-size and that can lead to issues later on. Instead, fix undefined<br>
> >> sources to always have a compatible bit size.<br>
> >><br>
> ><br>
> > I'm not sure what I think about this.  I think I'd rather have undefs<br>
> > simply have the right bitsize.<br>
> ><br>
><br>
> With undefined sources you cannot get the bitsize from themselves<br>
> because it is not initialized.</p>
<p dir="ltr">Doesn't patch 3 and the discussion on it imply that undefs should have valid sizes?</p>
<p dir="ltr">> In that case, we pick the bit size from<br>
> the ALU opcode's input definition. If it is unsized, then we use the<br>
> destination size.</p>
<p dir="ltr">I dont think pulling the implicit size from the source size is ever correct.  If you have an explicitly sized source that means it doesn't affect and isn't affected by the implicit size.</p>
<p dir="ltr">> I think this is the right bitsize... or am I missing something?<br>
><br>
> Sam<br>
><br>
> ><br>
> >> v2 (Sam):<br>
> >> - Use helper to get type size from nir_alu_type.<br>
> >> ---<br>
> >>  src/compiler/nir/nir_validate.c | 10 ++++++++++<br>
> >>  1 file changed, 10 insertions(+)<br>
> >><br>
> >> diff --git a/src/compiler/nir/nir_validate.c<br>
> >> b/src/compiler/nir/nir_validate.c<br>
> >> index 9f18d1c..645c15a 100644<br>
> >> --- a/src/compiler/nir/nir_validate.c<br>
> >> +++ b/src/compiler/nir/nir_validate.c<br>
> >> @@ -180,9 +180,11 @@ validate_alu_src(nir_alu_instr *instr, unsigned<br>
> >> index, validate_state *state)<br>
> >><br>
> >>     unsigned num_components;<br>
> >>     unsigned src_bit_size;<br>
> >> +   bool is_undef = false;<br>
> >>     if (src->src.is_ssa) {<br>
> >>        src_bit_size = src->src.ssa->bit_size;<br>
> >>        num_components = src->src.ssa->num_components;<br>
> >> +      is_undef = src->src.ssa->parent_instr->type ==<br>
> >> nir_instr_type_ssa_undef;<br>
> >>     } else {<br>
> >>        src_bit_size = src->src.reg.reg->bit_size;<br>
> >>        if (src->src.reg.reg->is_packed)<br>
> >> @@ -205,12 +207,20 @@ validate_alu_src(nir_alu_instr *instr, unsigned<br>
> >> index, validate_state *state)<br>
> >><br>
> >>     if (nir_alu_type_get_type_size(src_type)) {<br>
> >>        /* This source has an explicit bit size */<br>
> >> +      if (is_undef) {<br>
> >> +         src_bit_size = nir_alu_type_get_type_size(src_type);<br>
> >> +         src->src.ssa->bit_size = src_bit_size;<br>
> >> +      }<br>
> >>        assert(nir_alu_type_get_type_size(src_type) == src_bit_size);<br>
> >>     } else {<br>
> >>        if<br>
> >> (!nir_alu_type_get_type_size(nir_op_infos[instr->op].output_type)) {<br>
> >>           unsigned dest_bit_size =<br>
> >>              instr->dest.dest.is_ssa ? instr->dest.dest.ssa.bit_size<br>
> >>                                      : instr->dest.dest.reg.reg->bit_size;<br>
> >> +         if (is_undef) {<br>
> >> +            src_bit_size = dest_bit_size;<br>
> >> +            src->src.ssa->bit_size = dest_bit_size;<br>
> >> +         }<br>
> >>           assert(dest_bit_size == src_bit_size);<br>
> >>        }<br>
> >>     }<br>
> >> --<br>
> >> 2.5.0<br>
> >><br>
> >> _______________________________________________<br>
> >> mesa-dev mailing list<br>
> >> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> >> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
> >><br>
> ><br>
</p>