[Mesa-dev] [PATCH 08/26] nir/builder: Add a helper for building fdot instructions

Rob Clark robdclark at gmail.com
Sat Mar 26 15:03:41 UTC 2016


On Fri, Mar 25, 2016 at 7:12 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>

Reviewed-by: Rob Clark <robdclark at gmail.com>

> ---
>  src/compiler/nir/nir_builder.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
> index b245f48..4df79f5 100644
> --- a/src/compiler/nir/nir_builder.h
> +++ b/src/compiler/nir/nir_builder.h
> @@ -305,6 +305,23 @@ nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
>                       nir_imov_alu(build, alu_src, num_components);
>  }
>
> +/* Selects the right fdot given the number of components in each source. */
> +static inline nir_ssa_def *
> +nir_fdot(nir_builder *build, nir_ssa_def *src0, nir_ssa_def *src1)
> +{
> +   assert(src0->num_components == src1->num_components);
> +   switch (src0->num_components) {
> +   case 1: return nir_fmul(build, src0, src1);
> +   case 2: return nir_fdot2(build, src0, src1);
> +   case 3: return nir_fdot3(build, src0, src1);
> +   case 4: return nir_fdot4(build, src0, src1);
> +   default:
> +      unreachable("bad component size");
> +   }
> +
> +   return NULL;
> +}
> +
>  static inline nir_ssa_def *
>  nir_channel(nir_builder *b, nir_ssa_def *def, unsigned c)
>  {
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> 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