summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-03-25 10:35:03 -0700
committerJason Ekstrand <[email protected]>2016-03-28 18:32:48 -0700
commit6a2479d61804e6cfc7389e1185139d0c8be758e3 (patch)
treeb1a05735b56e45117860e17c3af15db770abef65 /src/compiler/nir
parent77e2ac1da731f10d823ed9f477cc6898039dcec4 (diff)
nir/builder: Add a helper for storing to variable derefs
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r--src/compiler/nir/nir_builder.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 4df79f58a7e..e9c409b8d12 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -399,6 +399,22 @@ nir_store_var(nir_builder *build, nir_variable *var, nir_ssa_def *value,
}
static inline void
+nir_store_deref_var(nir_builder *build, nir_deref_var *deref,
+ nir_ssa_def *value, unsigned writemask)
+{
+ const unsigned num_components =
+ glsl_get_vector_elements(nir_deref_tail(&deref->deref)->type);
+
+ nir_intrinsic_instr *store =
+ nir_intrinsic_instr_create(build->shader, nir_intrinsic_store_var);
+ store->num_components = num_components;
+ store->const_index[0] = writemask & ((1 << num_components) - 1);
+ store->variables[0] = nir_deref_as_var(nir_copy_deref(store, &deref->deref));
+ store->src[0] = nir_src_for_ssa(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 ==