<p dir="ltr"><br>
On Oct 1, 2015 12:18 PM, "Matt Turner" <<a href="mailto:mattst88@gmail.com">mattst88@gmail.com</a>> wrote:<br>
><br>
> On Fri, Aug 7, 2015 at 9:31 AM, Neil Roberts <<a href="mailto:neil@linux.intel.com">neil@linux.intel.com</a>> wrote:<br>
> > Adds nir_src_is_dynamically_uniform which returns true if the source<br>
> > is known to be dynamically uniform. This will be used in a later patch<br>
> > to add a workaround for cases that only work with dynamically uniform<br>
> > sources. Note that the function is not definitive, it can return false<br>
> > negatives (but not false positives). Currently it only detects<br>
> > constants and uniform accesses. It could easily be extended to include<br>
> > more cases.<br>
> > ---<br>
> >  src/glsl/nir/nir.c | 29 +++++++++++++++++++++++++++++<br>
> >  src/glsl/nir/nir.h |  1 +<br>
> >  2 files changed, 30 insertions(+)<br>
> ><br>
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c<br>
> > index 78ff886..242f0b4 100644<br>
> > --- a/src/glsl/nir/nir.c<br>
> > +++ b/src/glsl/nir/nir.c<br>
> > @@ -1784,6 +1784,35 @@ nir_src_as_const_value(nir_src src)<br>
> >     return &load->value;<br>
> >  }<br>
> ><br>
> > +/**<br>
> > + * Returns true if the source is known to be dynamically uniform. Otherwise it<br>
> > + * returns false which means it may or may not be dynamically uniform but it<br>
> > + * can't be determined.<br>
> > + */<br>
> > +bool<br>
> > +nir_src_is_dynamically_uniform(nir_src src)<br>
> > +{<br>
> > +   if (!src.is_ssa)<br>
> > +      return false;<br>
> > +<br>
> > +   /* Constants are trivially dynamically uniform */<br>
> > +   if (src.ssa->parent_instr->type == nir_instr_type_load_const)<br>
> > +      return true;<br>
> > +<br>
> > +   /* As are uniform variables */<br>
> > +   if (src.ssa->parent_instr->type == nir_instr_type_intrinsic) {<br>
> > +      nir_intrinsic_instr *intr = nir_instr_as_intrinsic(src.ssa->parent_instr);<br>
> > +<br>
> > +      if (intr->intrinsic == nir_intrinsic_load_uniform)<br>
> > +         return true;<br>
> > +   }<br>
> > +<br>
> > +   /* XXX: this could have many more tests, such as when a sampler function is<br>
> > +    * called with dynamically uniform arguments.<br>
> > +    */<br>
> > +   return false;<br>
> > +}<br>
><br>
> This functions seems correct as-is, so it gets a<br>
><br>
> Reviewed-by: Matt Turner <<a href="mailto:mattst88@gmail.com">mattst88@gmail.com</a>><br>
><br>
> On top of being useful for fixing the nonconst/nonuniform piglit<br>
> tests, knowing which values are uniform can allow better optimization<br>
> and knowing which branches are uniform would allow us to enable Single<br>
> Program Flow.<br>
><br>
> Cc'ing Jason for a discussion about how we'd like to handle this kind<br>
> of information in NIR. Add a bool is_uniform or something to<br>
> nir_ssa_def and hook into the metadata system?</p>
<p dir="ltr">That was more-or-less my plan. We should probably have a proper pass that handles things like phi nodes and ALU operations.</p>
<p dir="ltr">--Jason</p>