Module: Mesa
Branch: main
Commit: 31221ee5563ea6c70ed71a2f28a0a0e9f9d3917f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=31221ee5563ea6c70ed71a2f28a0a0e9f9d3917f

Author: Connor Abbott <[email protected]>
Date:   Fri Sep 24 18:38:27 2021 +0200

nir: Add a "deep" instruction clone

For the shader preamble, we need to add support for cloning one
instruction at a time into the preamble, but we also need to rewrite
sources.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13148>

---

 src/compiler/nir/nir.h       |  4 ++++
 src/compiler/nir/nir_clone.c | 12 ++++++++++++
 2 files changed, 16 insertions(+)

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)
 {

Reply via email to