<p dir="ltr"></p>
<p dir="ltr">On Aug 18, 2016 23:02, "Connor Abbott" <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
><br>
> On Thu, Aug 18, 2016 at 2:46 PM, Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
> > We want to insert the code at the end of the program.  Looping over<br>
> > all the functions (of which there was only one) was the old way of doing<br>
> > this, but now we have nir_shader_get_entrypoint(), so let's use it.<br>
> ><br>
> > Suggested by Connor Abbott.<br>
> ><br>
> > Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> > ---<br>
> >  .../drivers/dri/i965/brw_nir_tcs_workarounds.c     | 23 +++++++++++-----------<br>
> >  1 file changed, 11 insertions(+), 12 deletions(-)<br>
> ><br>
> > Sorry, I pushed the patch rather quickly...here's a follow-on to use<br>
> > nir_shader_get_entrypoint().<br>
> ><br>
> > Shouldn't be also be using it in nir_lower_gs_intrinsics.c?<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_nir_tcs_workarounds.c b/src/mesa/drivers/dri/i965/brw_nir_tcs_workarounds.c<br>
> > index 0626981..ac4f9e0 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_nir_tcs_workarounds.c<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_nir_tcs_workarounds.c<br>
> > @@ -134,19 +134,18 @@ brw_nir_apply_tcs_quads_workaround(nir_shader *nir)<br>
> >  {<br>
> >     assert(nir->stage == MESA_SHADER_TESS_CTRL);<br>
> ><br>
> > -   nir_foreach_function(func, nir) {<br>
> > -      if (!func->impl)<br>
> > -         continue;<br>
> > +   nir_function *func = nir_shader_get_entrypoint(nir);<br>
> > +   if (!func->impl)<br>
> > +      return;<br>
><br>
> Minor nit: I think you can drop the if, since it doesn't make sense to<br>
> have an entrypoint with only a declaration and no implementation.<br>
> Other than that,</p>
<p dir="ltr">Mind if we split the difference and make it an assert?  We can probably add said assert too the get_entrypoint helper.</p>
<p dir="ltr">> Reviewed-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
><br>
> What about my other comment though?<br>
><br>
> ><br>
> > -      nir_builder b;<br>
> > -      nir_builder_init(&b, func->impl);<br>
> > +   nir_builder b;<br>
> > +   nir_builder_init(&b, func->impl);<br>
> ><br>
> > -      struct set_entry *entry;<br>
> > -      set_foreach(func->impl->end_block->predecessors, entry) {<br>
> > -         nir_block *pred = (nir_block *) entry->key;<br>
> > -         emit_quads_workaround(&b, pred);<br>
> > -      }<br>
> > -<br>
> > -      nir_metadata_preserve(func->impl, 0);<br>
> > +   struct set_entry *entry;<br>
> > +   set_foreach(func->impl->end_block->predecessors, entry) {<br>
> > +      nir_block *pred = (nir_block *) entry->key;<br>
> > +      emit_quads_workaround(&b, pred);<br>
> >     }<br>
> > +<br>
> > +   nir_metadata_preserve(func->impl, 0);<br>
> >  }<br>
> > --<br>
> > 2.9.3<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></p>