[Mesa-dev] [RFC 2/6] nir/builder: Add a helper for loading from a deref_var
Jason Ekstrand
jason at jlekstrand.net
Sat Feb 6 05:10:51 UTC 2016
---
src/compiler/nir/nir_builder.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 88ba3a1..1252301 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -334,6 +334,21 @@ nir_load_var(nir_builder *build, nir_variable *var)
return &load->dest.ssa;
}
+static inline nir_ssa_def *
+nir_load_deref_var(nir_builder *build, nir_deref_var *deref)
+{
+ const struct nir_deref *deref_tail = nir_deref_tail(&deref->deref);
+ const unsigned num_components = glsl_get_vector_elements(deref_tail->type);
+
+ nir_intrinsic_instr *load =
+ nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_var);
+ load->num_components = num_components;
+ load->variables[0] = nir_copy_deref_var(load, deref);
+ nir_ssa_dest_init(&load->instr, &load->dest, num_components, NULL);
+ nir_builder_instr_insert(build, &load->instr);
+ return &load->dest.ssa;
+}
+
static inline void
nir_store_var(nir_builder *build, nir_variable *var, nir_ssa_def *value,
unsigned writemask)
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list