diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 04f0e74a1b8..465853b8cec 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4205,6 +4205,10 @@ char *nir_shader_as_str_annotated(nir_shader *nir, struct hash_table *annotation /** Shallow clone of a single instruction. */ nir_instr *nir_instr_clone(nir_shader *s, const nir_instr *orig); +/** Clone a single instruction, including a remap table to rewrite sources. */ +nir_instr *nir_instr_clone_deep(nir_shader *s, const nir_instr *orig, + struct hash_table *remap_table); + /** Shallow clone of a single ALU instruction. */ nir_alu_instr *nir_alu_instr_clone(nir_shader *s, const nir_alu_instr *orig); diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c index 260fc8b8fc7..6bdbd878260 100644 --- a/src/compiler/nir/nir_clone.c +++ b/src/compiler/nir/nir_clone.c @@ -522,6 +522,18 @@ nir_instr_clone(nir_shader *shader, const nir_instr *orig) return clone_instr(&state, orig); } +nir_instr * +nir_instr_clone_deep(nir_shader *shader, const nir_instr *orig, + struct hash_table *remap_table) +{ + clone_state state = { + .allow_remap_fallback = true, + .ns = shader, + .remap_table = remap_table, + }; + return clone_instr(&state, orig); +} + static nir_block * clone_block(clone_state *state, struct exec_list *cf_list, const nir_block *blk) {