[Mesa-dev] [PATCH v3 12/22] nir: add nir_get_nir_type_for_glsl_type()

Jason Ekstrand jason at jlekstrand.net
Thu Jan 5 20:42:04 UTC 2017


On Thu, Jan 5, 2017 at 2:18 AM, Samuel Iglesias Gonsálvez <
siglesias at igalia.com> wrote:

> v2 (Jason):
> - Refactor nir_get_nir_type_for_glsl_type() to avoid using unneeded
> helpers (Jason)
>
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> ---
>  src/compiler/nir/nir.h | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 0596d31b903..09326a25a54 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -675,6 +675,33 @@ nir_alu_type_get_base_type(nir_alu_type type)
>     return type & NIR_ALU_TYPE_BASE_TYPE_MASK;
>  }
>
> +static inline nir_alu_type
> +nir_get_nir_type_for_glsl_type(const struct glsl_type *type)
> +{
> +   nir_alu_type ret = nir_type_invalid;
> +   switch (glsl_get_base_type(type)) {
> +   case GLSL_TYPE_BOOL:
> +      ret = nir_type_bool32;
> +      break;
>

These could each just return the return value rather than setting it and
returning at the bottom.  It'd let you get rid of all of the breaks.  In
any case, it's correct so

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>


> +   case GLSL_TYPE_UINT:
> +      ret = nir_type_uint32;
> +      break;
> +   case GLSL_TYPE_INT:
> +      ret = nir_type_int32;
> +      break;
> +   case GLSL_TYPE_FLOAT:
> +      ret = nir_type_float32;
> +      break;
> +   case GLSL_TYPE_DOUBLE:
> +      ret = nir_type_float64;
> +      break;
> +   default:
> +      unreachable("unknown type");
> +   };
> +
> +   return ret;
> +}
> +
>  typedef enum {
>     NIR_OP_IS_COMMUTATIVE = (1 << 0),
>     NIR_OP_IS_ASSOCIATIVE = (1 << 1),
> --
> 2.11.0
>
> _______________________________________________
> 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/20170105/429e36f6/attachment.html>


More information about the mesa-dev mailing list