[Mesa-dev] [PATCH] nir: add/export nir_variable_clone()
Rob Clark
robdclark at gmail.com
Wed Mar 23 20:15:35 UTC 2016
From: Rob Clark <robclark at freedesktop.org>
Signed-off-by: Rob Clark <robclark at freedesktop.org>
---
src/compiler/nir/nir.h | 1 +
src/compiler/nir/nir_clone.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 69a3084..724aa77 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2053,6 +2053,7 @@ void nir_print_instr(const nir_instr *instr, FILE *fp);
nir_shader * nir_shader_clone(void *mem_ctx, const nir_shader *s);
nir_function_impl *nir_function_impl_clone(const nir_function_impl *fi);
+nir_variable * nir_variable_clone(nir_variable *var);
#ifdef DEBUG
void nir_validate_shader(nir_shader *shader);
diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c
index 7444dfe..03b4fbd 100644
--- a/src/compiler/nir/nir_clone.c
+++ b/src/compiler/nir/nir_clone.c
@@ -149,6 +149,22 @@ clone_variable(clone_state *state, const nir_variable *var)
return nvar;
}
+nir_variable *
+nir_variable_clone(nir_variable *var)
+{
+ clone_state state;
+ init_clone_state(&state, false);
+
+ /* We use the same shader */
+ state.ns = ralloc_parent(var);
+
+ nir_variable *nvar = clone_variable(&state, var);
+
+ free_clone_state(&state);
+
+ return nvar;
+}
+
/* clone list of nir_variable: */
static void
clone_var_list(clone_state *state, struct exec_list *dst,
--
2.5.0
More information about the mesa-dev
mailing list