On Thu, Jan 5, 2017 at 2:18 AM, Samuel Iglesias Gonsálvez <
sigles...@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 <sigles...@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 <ja...@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@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to