<div dir="ltr"><div>I like it<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 5, 2017 at 3:47 AM, Nicolai Hähnle <span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Nicolai Hähnle <<a href="mailto:nicolai.haehnle@amd.com">nicolai.haehnle@amd.com</a>><br>
<br>
Allows modifying a texture instruction's texture and sampler derefs.<br>
---<br>
 src/compiler/nir/nir.c | 13 +++++++++++++<br>
 src/compiler/nir/nir.h |  2 ++<br>
 2 files changed, 15 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c<br>
index 491b908..f81f4ee 100644<br>
--- a/src/compiler/nir/nir.c<br>
+++ b/src/compiler/nir/nir.c<br>
@@ -1502,20 +1502,33 @@ nir_instr_rewrite_dest(nir_<wbr>instr *instr, nir_dest *dest, nir_dest new_dest)<br>
<br>
    nir_dest_copy(dest, &new_dest, instr);<br>
<br>
    dest->reg.parent_instr = instr;<br>
    list_addtail(&dest->reg.def_<wbr>link, &new_dest.reg.reg->defs);<br>
<br>
    if (dest->reg.indirect)<br>
       src_add_all_uses(dest->reg.<wbr>indirect, instr, NULL);<br>
 }<br>
<br>
+void<br>
+nir_instr_rewrite_deref(nir_<wbr>instr *instr, nir_deref_var **deref,<br>
+                        nir_deref_var *new_deref)<br>
+{<br>
+   if (*deref)<br>
+      visit_deref_src(*deref, remove_use_cb, NULL);<br>
+<br>
+   *deref = new_deref;<br>
+<br>
+   if (*deref)<br>
+      visit_deref_src(*deref, add_use_cb, instr);<br>
+}<br>
+<br>
 /* note: does *not* take ownership of 'name' */<br>
 void<br>
 nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,<br>
                  unsigned num_components,<br>
                  unsigned bit_size, const char *name)<br>
 {<br>
    def->name = ralloc_strdup(instr, name);<br>
    def->parent_instr = instr;<br>
    list_inithead(&def->uses);<br>
    list_inithead(&def->if_uses);<br>
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
index c41b0dc..1ca98f8 100644<br>
--- a/src/compiler/nir/nir.h<br>
+++ b/src/compiler/nir/nir.h<br>
@@ -2199,20 +2199,22 @@ bool nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state);<br>
 bool nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state);<br>
<br>
 nir_const_value *nir_src_as_const_value(nir_<wbr>src src);<br>
 bool nir_src_is_dynamically_<wbr>uniform(nir_src src);<br>
 bool nir_srcs_equal(nir_src src1, nir_src src2);<br>
 void nir_instr_rewrite_src(nir_<wbr>instr *instr, nir_src *src, nir_src new_src);<br>
 void nir_instr_move_src(nir_instr *dest_instr, nir_src *dest, nir_src *src);<br>
 void nir_if_rewrite_condition(nir_<wbr>if *if_stmt, nir_src new_src);<br>
 void nir_instr_rewrite_dest(nir_<wbr>instr *instr, nir_dest *dest,<br>
                             nir_dest new_dest);<br>
+void nir_instr_rewrite_deref(nir_<wbr>instr *instr, nir_deref_var **deref,<br>
+                             nir_deref_var *new_deref);<br>
<br>
 void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,<br>
                        unsigned num_components, unsigned bit_size,<br>
                        const char *name);<br>
 void nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,<br>
                       unsigned num_components, unsigned bit_size,<br>
                       const char *name);<br>
 void nir_ssa_def_rewrite_uses(nir_<wbr>ssa_def *def, nir_src new_src);<br>
 void nir_ssa_def_rewrite_uses_<wbr>after(nir_ssa_def *def, nir_src new_src,<br>
                                     nir_instr *after_me);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>