nir/builder: Add a copy_deref_var helper
authorJason Ekstrand <jason.ekstrand@intel.com>
Fri, 18 Dec 2015 20:16:45 +0000 (12:16 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 23 Dec 2015 21:49:56 +0000 (13:49 -0800)
src/glsl/nir/nir_builder.h

index cbbc26d1cc62c22dadbb28206d90c2d4227d412c..423bddd7a9a21f76a38fb4f7e2b3aa030eadf1ac 100644 (file)
@@ -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, &copy->instr);
+}
+
 static inline void
 nir_copy_var(nir_builder *build, nir_variable *dest, nir_variable *src)
 {