summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2017-06-09 15:13:08 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2017-07-31 14:55:28 +0200
commitb27c2d402efb7dfbc6a8b9a6cbd2008cac3753e3 (patch)
tree1f7b6c6194f733ed0bb5ce6a30ceeee5f3c79607
parent540b1a8f0b19fa06303500f82824b209ef8f8ef5 (diff)
nir: add nir_instr_rewrite_deref
Allows modifying a texture instruction's texture and sampler derefs. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/compiler/nir/nir.c13
-rw-r--r--src/compiler/nir/nir.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
index b608b2a0d6..b33f56d3d3 100644
--- a/src/compiler/nir/nir.c
+++ b/src/compiler/nir/nir.c
@@ -1509,6 +1509,19 @@ nir_instr_rewrite_dest(nir_instr *instr, nir_dest *dest, nir_dest new_dest)
src_add_all_uses(dest->reg.indirect, instr, NULL);
}
+void
+nir_instr_rewrite_deref(nir_instr *instr, nir_deref_var **deref,
+ nir_deref_var *new_deref)
+{
+ if (*deref)
+ visit_deref_src(*deref, remove_use_cb, NULL);
+
+ *deref = new_deref;
+
+ if (*deref)
+ visit_deref_src(*deref, add_use_cb, instr);
+}
+
/* note: does *not* take ownership of 'name' */
void
nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 78684fd50c..007ca6afe4 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2211,6 +2211,8 @@ void nir_instr_move_src(nir_instr *dest_instr, nir_src *dest, nir_src *src);
void nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src);
void nir_instr_rewrite_dest(nir_instr *instr, nir_dest *dest,
nir_dest new_dest);
+void nir_instr_rewrite_deref(nir_instr *instr, nir_deref_var **deref,
+ nir_deref_var *new_deref);
void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
unsigned num_components, unsigned bit_size,