[Mesa-dev] [PATCH 1/2] nir: add nir_{load, store}_deref_with_access() helpers

Jason Ekstrand jason at jlekstrand.net
Wed Mar 27 00:25:01 UTC 2019


You could make the old ones call these. It'd make for a smaller diff and 
less code to maintain.

On March 26, 2019 17:10:52 Samuel Pitoiset <samuel.pitoiset at gmail.com> wrote:

> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/compiler/nir/nir_builder.h | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
> index bcf03957bc7..9f9a05cbd09 100644
> --- a/src/compiler/nir/nir_builder.h
> +++ b/src/compiler/nir/nir_builder.h
> @@ -1070,6 +1070,36 @@ nir_store_deref(nir_builder *build, nir_deref_instr 
> *deref,
>    nir_builder_instr_insert(build, &store->instr);
> }
>
> +static inline nir_ssa_def *
> +nir_load_deref_with_access(nir_builder *build, nir_deref_instr *deref,
> +                           enum gl_access_qualifier access)
> +{
> +   nir_intrinsic_instr *load =
> +      nir_intrinsic_instr_create(build->shader, nir_intrinsic_load_deref);
> +   load->num_components = glsl_get_vector_elements(deref->type);
> +   load->src[0] = nir_src_for_ssa(&deref->dest.ssa);
> +   nir_ssa_dest_init(&load->instr, &load->dest, load->num_components,
> +                     glsl_get_bit_size(deref->type), NULL);
> +   nir_intrinsic_set_access(load, access);
> +   nir_builder_instr_insert(build, &load->instr);
> +   return &load->dest.ssa;
> +}
> +
> +static inline void
> +nir_store_deref_with_access(nir_builder *build, nir_deref_instr *deref,
> +                            nir_ssa_def *value, unsigned writemask,
> +                            enum gl_access_qualifier access)
> +{
> +   nir_intrinsic_instr *store =
> +      nir_intrinsic_instr_create(build->shader, nir_intrinsic_store_deref);
> +   store->num_components = glsl_get_vector_elements(deref->type);
> +   store->src[0] = nir_src_for_ssa(&deref->dest.ssa);
> +   store->src[1] = nir_src_for_ssa(value);
> +   nir_intrinsic_set_write_mask(store,
> +                                writemask & ((1 << store->num_components) 
> - 1));
> +   nir_intrinsic_set_access(store, access);
> +   nir_builder_instr_insert(build, &store->instr);
> +}
> static inline void
> nir_copy_deref(nir_builder *build, nir_deref_instr *dest, nir_deref_instr *src)
> {
> --
> 2.21.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev





More information about the mesa-dev mailing list