diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-09 15:13:08 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-05 12:32:30 +0200 |
commit | 336262fd061779ae0752314c4d22c02ced411763 (patch) | |
tree | b7948ea0d138a6b9f9beccfa02ebe155814f0714 | |
parent | c2065ed687dd714240928827f620852e37f7dffc (diff) |
nir: add nir_instr_rewrite_deref
Allows modifying a texture instruction's texture and sampler derefs.
-rw-r--r-- | src/compiler/nir/nir.c | 13 | ||||
-rw-r--r-- | src/compiler/nir/nir.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index 491b908396..f81f4eeead 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 c41b0dc931..1ca98f8b8a 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2206,6 +2206,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, |