summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-12-10 11:32:29 -0800
committerJason Ekstrand <[email protected]>2017-01-06 16:44:28 -0800
commit75a6707984d520d70df14fca46f29ac9e4e7e8d9 (patch)
tree240afa15bb377130708bcfd150b1248c598e8070 /src/compiler/nir
parent13a2f207408442fcfe13396d6f218701a66a487c (diff)
nir/builder: Add a load_deref_var helper
Reviewed-by: Timothy Arceri <[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 2ea9af1e63d..1da30ab8fc1 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -411,6 +411,22 @@ 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 glsl_type *type = nir_deref_tail(&deref->deref)->type;
+ const unsigned num_components = glsl_get_vector_elements(type);
+
+ nir_intrinsic_instr *load =
+ nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_var);
+ load->num_components = num_components;
+ load->variables[0] = nir_deref_var_clone(deref, load);
+ nir_ssa_dest_init(&load->instr, &load->dest, num_components,
+ glsl_get_bit_size(type), 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)