[Mesa-dev] [PATCH 2/6] nir/builder: Add a load_deref_var helper

Timothy Arceri timothy.arceri at collabora.com
Wed Jan 4 23:22:45 UTC 2017


Looks fine.

Reviewed-by: Timothy Arceri <timothy.arceri at collabora.com>

On Mon, 2016-12-12 at 19:39 -0800, Jason Ekstrand wrote:
> ---
>  src/compiler/nir/nir_builder.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/src/compiler/nir/nir_builder.h
> b/src/compiler/nir/nir_builder.h
> index 0ee7d1a..44d03c8 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_as_var(nir_copy_deref(load,
> &deref->deref));
> +   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)


More information about the mesa-dev mailing list