[Mesa-dev] [PATCH v2 13/25] nir: add nir_get_nir_type_for_glsl_type()
Jason Ekstrand
jason at jlekstrand.net
Mon Jan 2 18:16:15 UTC 2017
On Fri, Dec 16, 2016 at 6:48 AM, Juan A. Suarez Romero <jasuarez at igalia.com>
wrote:
> From: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
>
> Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
> ---
> src/compiler/nir/nir.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 544d4ba..9310dab 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -670,6 +670,25 @@ 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)
> +{
> + unsigned bit_size = glsl_get_bit_size(type);
> + if (glsl_type_is_boolean(type))
> + return (nir_alu_type)(nir_type_bool | bit_size);
> +
> + if (glsl_type_is_integer(type)) {
> + if (glsl_get_base_type(type) == GLSL_TYPE_UINT)
> + return (nir_alu_type)(nir_type_uint | bit_size);
> + else
> + return (nir_alu_type)(nir_type_int | bit_size);
> + }
> +
> + if (glsl_type_is_float(type))
> + return (nir_alu_type)(nir_type_float | bit_size);
>
Wouldn't this be easier to implement as
switch (glsl_get_base_type(type)) {
case GLSL_TYPE_BOOL:
return nir_type_bool32;
case GLSL_TYPE_UINT:
return nir_type_uint32;
/* etc. */
}
Then you could drop the is_integer and is_float helpers.
> + unreachable("unknown type");
> +}
> +
> typedef enum {
> NIR_OP_IS_COMMUTATIVE = (1 << 0),
> NIR_OP_IS_ASSOCIATIVE = (1 << 1),
> --
> 2.9.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/20170102/8b62454c/attachment.html>
More information about the mesa-dev
mailing list