From b27c2d402efb7dfbc6a8b9a6cbd2008cac3753e3 Mon Sep 17 00:00:00 2001 From: Nicolai Hähnle Date: Fri, 9 Jun 2017 15:13:08 +0200 Subject: nir: add nir_instr_rewrite_deref Allows modifying a texture instruction's texture and sampler derefs. Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/compiler/nir/nir.c') diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c index b608b2a0d64..b33f56d3d3a 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, -- cgit v1.2.3