[Mesa-dev] [PATCH v2 1/6] nir: Add nir_builder helpers for creating load_const intrinsics.

Connor Abbott cwabbott0 at gmail.com
Wed Mar 25 17:46:45 PDT 2015


Except for one comment on patch 6, patches 1-2 and 4-6 are

Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

I don't know enough about Mesa IR to fully review patch 3, although on
a quick read-through I couldn't find anything to improve.

On Wed, Mar 25, 2015 at 7:21 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> Both prog->nir and tgsi->nir will want to use these.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/glsl/nir/nir_builder.h | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h
> index 7c4f7fd..fe6cb37 100644
> --- a/src/glsl/nir/nir_builder.h
> +++ b/src/glsl/nir/nir_builder.h
> @@ -47,6 +47,41 @@ nir_builder_insert_after_cf_list(nir_builder *build,
>     build->cf_node_list = cf_node_list;
>  }
>
> +static inline nir_ssa_def *
> +nir_build_imm(nir_builder *build, unsigned num_components, nir_const_value value)
> +{
> +   nir_load_const_instr *load_const =
> +      nir_load_const_instr_create(build->shader, num_components);
> +   if (!load_const)
> +      return NULL;
> +
> +   load_const->value = value;
> +
> +   nir_instr_insert_after_cf_list(build->cf_node_list, &load_const->instr);
> +
> +   return &load_const->def;
> +}
> +
> +static inline nir_ssa_def *
> +nir_imm_float(nir_builder *build, float x)
> +{
> +   nir_const_value v = { { .f = {x, 0, 0, 0} } };
> +   return nir_build_imm(build, 1, v);
> +}
> +
> +static inline nir_ssa_def *
> +nir_imm_vec4(nir_builder *build, float x, float y, float z, float w)
> +{
> +   nir_const_value v = { { .f = {x, y, z, w} } };
> +   return nir_build_imm(build, 4, v);
> +}
> +
> +static inline nir_ssa_def *
> +nir_imm_int(nir_builder *build, int x)
> +{
> +   nir_const_value v = { { .i = {x, 0, 0, 0} } };
> +   return nir_build_imm(build, 1, v);
> +}
>
>  static inline nir_ssa_def *
>  nir_build_alu(nir_builder *build, nir_op op, nir_ssa_def *src0,
> --
> 2.3.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list