[Mesa-dev] [PATCH 04/45] nir: Add support for 16-bit types (half float, int16 and uint16)
Eduardo Lima Mitev
elima at igalia.com
Fri Aug 18 08:05:17 UTC 2017
On 08/17/2017 08:23 PM, Jason Ekstrand wrote:
> On Thu, Jul 13, 2017 at 7:35 AM, Alejandro PiƱeiro <apinheiro at igalia.com
> <mailto:apinheiro at igalia.com>> wrote:
>
> From: Eduardo Lima Mitev <elima at igalia.com <mailto:elima at igalia.com>>
>
> Signed-off-by: Jose Maria Casanova Crespo <jmcasanova at igalia.com
> <mailto:jmcasanova at igalia.com>>
> Signed-off-by: Eduardo Lima <elima at igalia.com <mailto:elima at igalia.com>>
> ---
> src/compiler/nir/nir.c | 6 ++++++
> src/compiler/nir/nir.h | 9 +++++++++
> src/compiler/nir/nir_split_var_copies.c | 6 ++++++
> src/compiler/nir_types.cpp | 18 ++++++++++++++++++
> src/compiler/nir_types.h | 8 ++++++++
> 5 files changed, 47 insertions(+)
>
> diff --git a/src/compiler/nir/nir.c b/src/compiler/nir/nir.c
> index 491b908..9f8eefd 100644
> --- a/src/compiler/nir/nir.c
> +++ b/src/compiler/nir/nir.c
> @@ -700,10 +700,13 @@ deref_foreach_leaf_build_recur(nir_deref_var
> *deref, nir_deref *tail,
> assert(tail->child == NULL);
> switch (glsl_get_base_type(tail->type)) {
> case GLSL_TYPE_UINT:
> + case GLSL_TYPE_UINT16:
> case GLSL_TYPE_UINT64:
> case GLSL_TYPE_INT:
> + case GLSL_TYPE_INT16:
> case GLSL_TYPE_INT64:
> case GLSL_TYPE_FLOAT:
> + case GLSL_TYPE_HALF_FLOAT:
> case GLSL_TYPE_DOUBLE:
> case GLSL_TYPE_BOOL:
> if (glsl_type_is_vector_or_scalar(tail->type))
> @@ -848,7 +851,10 @@ nir_deref_get_const_initializer_load(nir_shader
> *shader, nir_deref_var *deref)
> case GLSL_TYPE_FLOAT:
> case GLSL_TYPE_INT:
> case GLSL_TYPE_UINT:
> + case GLSL_TYPE_HALF_FLOAT:
> case GLSL_TYPE_DOUBLE:
> + case GLSL_TYPE_INT16:
> + case GLSL_TYPE_UINT16:
> case GLSL_TYPE_UINT64:
> case GLSL_TYPE_INT64:
> case GLSL_TYPE_BOOL:
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index c41b0dc..2ac5b1e 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -701,6 +701,12 @@ nir_get_nir_type_for_glsl_base_type(enum
> glsl_base_type base_type)
> case GLSL_TYPE_INT:
> return nir_type_int32;
> break;
> + case GLSL_TYPE_UINT16:
> + return nir_type_uint16;
> + break;
> + case GLSL_TYPE_INT16:
> + return nir_type_int16;
> + break;
> case GLSL_TYPE_UINT64:
> return nir_type_uint64;
> break;
> @@ -710,6 +716,9 @@ nir_get_nir_type_for_glsl_base_type(enum
> glsl_base_type base_type)
> case GLSL_TYPE_FLOAT:
> return nir_type_float32;
> break;
> + case GLSL_TYPE_HALF_FLOAT:
> + return nir_type_float16;
> + break;
> case GLSL_TYPE_DOUBLE:
> return nir_type_float64;
> break;
> diff --git a/src/compiler/nir/nir_split_var_copies.c
> b/src/compiler/nir/nir_split_var_copies.c
> index 15a185e..1ed9e81 100644
> --- a/src/compiler/nir/nir_split_var_copies.c
> +++ b/src/compiler/nir/nir_split_var_copies.c
> @@ -147,10 +147,13 @@ split_var_copy_instr(nir_intrinsic_instr
> *old_copy,
> break;
>
> case GLSL_TYPE_UINT:
> + case GLSL_TYPE_UINT16:
> case GLSL_TYPE_UINT64:
> case GLSL_TYPE_INT:
> + case GLSL_TYPE_INT16:
> case GLSL_TYPE_INT64:
> case GLSL_TYPE_FLOAT:
> + case GLSL_TYPE_HALF_FLOAT:
> case GLSL_TYPE_DOUBLE:
> case GLSL_TYPE_BOOL:
> if (glsl_type_is_matrix(src_tail->type)) {
> @@ -229,6 +232,7 @@ split_var_copies_block(nir_block *block, struct
> split_var_copies_state *state)
> ralloc_steal(state->dead_ctx, instr);
> break;
> case GLSL_TYPE_FLOAT:
> + case GLSL_TYPE_HALF_FLOAT:
> case GLSL_TYPE_DOUBLE:
> if (glsl_type_is_matrix(src_tail->type)) {
> split_var_copy_instr(intrinsic, dest_head, src_head,
> @@ -239,6 +243,8 @@ split_var_copies_block(nir_block *block, struct
> split_var_copies_state *state)
> break;
> case GLSL_TYPE_INT:
> case GLSL_TYPE_UINT:
> + case GLSL_TYPE_INT16:
> + case GLSL_TYPE_UINT16:
> case GLSL_TYPE_INT64:
> case GLSL_TYPE_UINT64:
> case GLSL_TYPE_BOOL:
> diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
> index 25980b9..11524c2 100644
> --- a/src/compiler/nir_types.cpp
> +++ b/src/compiler/nir_types.cpp
> @@ -259,6 +259,12 @@ glsl_double_type(void)
> }
>
> const glsl_type *
> +glsl_half_float_type(void)
>
>
> This should be glsl_float16_t_type() to match glsl_type::float16_t_type.
>
> Also, one could argue that these belong in the patch which adds 16-bit
> float types because nir_types.cpp isn't really a NIR thing anymore so
> much as it's a C wrapper around glsl_type.h. That said, I don't care
> too much about what patch it's in.
>
>
Ok to both comments. Fixed locally.
I will defer moving these wrappers to the other patch, though, if you
don't feel strongly about it. That patch is large enough already.
> +{
> + return glsl_type::float16_t_type;
> +}
> +
> +const glsl_type *
> glsl_vec_type(unsigned n)
> {
> return glsl_type::vec(n);
> @@ -301,6 +307,18 @@ glsl_uint64_t_type(void)
> }
>
> const glsl_type *
> +glsl_int16_t_type(void)
> +{
> + return glsl_type::int16_t_type;
> +}
> +
> +const glsl_type *
> +glsl_uint16_t_type(void)
> +{
> + return glsl_type::uint16_t_type;
> +}
> +
> +const glsl_type *
> glsl_bool_type(void)
> {
> return glsl_type::bool_type;
> diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
> index 0c52bb9..220b35c 100644
> --- a/src/compiler/nir_types.h
> +++ b/src/compiler/nir_types.h
> @@ -92,6 +92,11 @@ glsl_get_bit_size(const struct glsl_type *type)
> case GLSL_TYPE_SUBROUTINE:
> return 32;
>
> + case GLSL_TYPE_HALF_FLOAT:
> + case GLSL_TYPE_UINT16:
> + case GLSL_TYPE_INT16:
> + return 16;
> +
> case GLSL_TYPE_DOUBLE:
> case GLSL_TYPE_INT64:
> case GLSL_TYPE_UINT64:
> @@ -123,6 +128,7 @@ bool glsl_sampler_type_is_array(const struct
> glsl_type *type);
>
> const struct glsl_type *glsl_void_type(void);
> const struct glsl_type *glsl_float_type(void);
> +const struct glsl_type *glsl_half_float_type(void);
> const struct glsl_type *glsl_double_type(void);
> const struct glsl_type *glsl_vec_type(unsigned n);
> const struct glsl_type *glsl_dvec_type(unsigned n);
> @@ -131,6 +137,8 @@ const struct glsl_type *glsl_int_type(void);
> const struct glsl_type *glsl_uint_type(void);
> const struct glsl_type *glsl_int64_t_type(void);
> const struct glsl_type *glsl_uint64_t_type(void);
> +const struct glsl_type *glsl_int16_t_type(void);
> +const struct glsl_type *glsl_uint16_t_type(void);
> const struct glsl_type *glsl_bool_type(void);
>
> const struct glsl_type *glsl_scalar_type(enum glsl_base_type
> base_type);
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> <https://lists.freedesktop.org/mailman/listinfo/mesa-dev>
>
>
>
>
> _______________________________________________
> 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