[Mesa-dev] [PATCH 2/4] anv/apply_dynamic_offsets: Use rewrite_src instead of a regular assignment

Jason Ekstrand jason at jlekstrand.net
Thu May 19 07:13:39 UTC 2016


On Wed, May 18, 2016 at 11:50 PM, Michael Schellenberger Costa <
mschellenbergercosta at googlemail.com> wrote:

> Hi Jason,
>
> Am 19.05.2016 um 06:42 schrieb Jason Ekstrand:
> > Originally we removed the instruction, changed the source, and then
> > re-inserted it.  This works, but nir_instr_rewrite_src is a bit more
> > obviously correct.
> > ---
> >  src/intel/vulkan/anv_nir_apply_dynamic_offsets.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
> b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
> > index 6a28953..a7ed3e5 100644
> > --- a/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
> > +++ b/src/intel/vulkan/anv_nir_apply_dynamic_offsets.c
> > @@ -80,9 +80,10 @@ apply_dynamic_offsets_block(nir_block *block,
> nir_builder *b,
> >        nir_ssa_dest_init(&offset_load->instr, &offset_load->dest, 2, 32,
> NULL);
> >        nir_builder_instr_insert(b, &offset_load->instr);
> >
> > -      nir_src *offset_src = nir_get_io_offset_src(intrin);
> I think you didnt want to remove *offset_src here, given that it is used
> below and reintroduced in the next patch?
>

Ugh... Thanks.  This patch doesn't even build.  I knew that series needed a
little work before I sent it :-)


> --Michael
> > -      nir_ssa_def *new_offset = nir_iadd(b, offset_src->ssa,
> > +      nir_ssa_def *new_offset = nir_iadd(b,
> nir_ssa_for_src(*offset_src),
> >                                           &offset_load->dest.ssa);
> > +      nir_instr_rewrite_src(&intrin->instr,
> nir_get_io_offset_src(intrin),
> > +                            nir_src_for_ssa(new_offset));
> >
> >        /* In order to avoid out-of-bounds access, we predicate */
> >        nir_ssa_def *pred = nir_uge(b, nir_channel(b,
> &offset_load->dest.ssa, 1),
> > @@ -92,7 +93,6 @@ apply_dynamic_offsets_block(nir_block *block,
> nir_builder *b,
> >        nir_cf_node_insert(b->cursor, &if_stmt->cf_node);
> >
> >        nir_instr_remove(&intrin->instr);
> > -      *offset_src = nir_src_for_ssa(new_offset);
> >        nir_instr_insert_after_cf_list(&if_stmt->then_list,
> &intrin->instr);
> >
> >        if (intrin->intrinsic != nir_intrinsic_store_ssbo) {
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160519/1ca8bc51/attachment-0001.html>


More information about the mesa-dev mailing list