From b21db9cea52a28f841a5cb120260fe6f6a6e75ab Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 18 Dec 2015 12:16:45 -0800 Subject: [PATCH] nir/builder: Add a copy_deref_var helper --- src/glsl/nir/nir_builder.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index cbbc26d1cc6..423bddd7a9a 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -353,6 +353,19 @@ nir_store_var(nir_builder *build, nir_variable *var, nir_ssa_def *value) nir_builder_instr_insert(build, &store->instr); } +static inline void +nir_copy_deref_var(nir_builder *build, nir_deref_var *dest, nir_deref_var *src) +{ + assert(nir_deref_tail(&dest->deref)->type == + nir_deref_tail(&src->deref)->type); + + nir_intrinsic_instr *copy = + nir_intrinsic_instr_create(build->shader, nir_intrinsic_copy_var); + copy->variables[0] = nir_deref_as_var(nir_copy_deref(copy, &dest->deref)); + copy->variables[1] = nir_deref_as_var(nir_copy_deref(copy, &src->deref)); + nir_builder_instr_insert(build, ©->instr); +} + static inline void nir_copy_var(nir_builder *build, nir_variable *dest, nir_variable *src) { -- 2.30.2