[Mesa-dev] [PATCH 1/4] nir/builder: Add a nir_imm_floatN_t helper

Jason Ekstrand jason at jlekstrand.net
Tue Apr 17 18:45:14 UTC 2018


On Wed, Mar 21, 2018 at 12:34 PM, Neil Roberts <nroberts at igalia.com> wrote:

> This lets you easily build float immediates just given the bit size.
> If we have this single place here to handle this then it will be
> easier to add support for 16-bit floats later.
> ---
>  src/compiler/nir/nir_builder.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_
> builder.h
> index 36e0ae3ac63..32f86249ad3 100644
> --- a/src/compiler/nir/nir_builder.h
> +++ b/src/compiler/nir/nir_builder.h
> @@ -227,6 +227,19 @@ nir_imm_double(nir_builder *build, double x)
>     return nir_build_imm(build, 1, 64, v);
>  }
>
> +static inline nir_ssa_def *
> +nir_imm_floatN_t(nir_builder *build, double x, unsigned bit_size)
> +{
> +   switch (bit_size) {
>

It would be good to handle 16-bit floats too.  I suppose that can always
happen later though.


> +   case 32:
> +      return nir_imm_float(build, x);
> +   case 64:
> +      return nir_imm_double(build, x);
> +   }
> +
> +   unreachable("unknown float immediate bit size");
>

Thanks for adding this!


> +}
> +
>  static inline nir_ssa_def *
>  nir_imm_vec4(nir_builder *build, float x, float y, float z, float w)
>  {
> --
> 2.14.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180417/972643dc/attachment-0001.html>


More information about the mesa-dev mailing list