From 6c750d9c4d51b07076115eb1d0e1be4a2d568095 Mon Sep 17 00:00:00 2001 From: "Kristian H. Kristensen" Date: Wed, 19 Feb 2020 13:13:15 -0800 Subject: [PATCH] nir/types: Add glsl_float16_type() helper MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This returns the float16 version of a float type. Reviewed-by: Eric Anholt Reviewed-by: Marek Olšák Part-of: --- src/compiler/glsl_types.cpp | 10 ++++++++++ src/compiler/glsl_types.h | 5 +++++ src/compiler/nir_types.cpp | 6 ++++++ src/compiler/nir_types.h | 2 ++ 4 files changed, 23 insertions(+) diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index 79e2f684fcf..3af8e034cd1 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -462,6 +462,16 @@ const glsl_type *glsl_type::get_bare_type() const unreachable("Invalid base type"); } +const glsl_type *glsl_type::get_float16_type() const +{ + assert(this->base_type == GLSL_TYPE_FLOAT); + + return get_instance(GLSL_TYPE_FLOAT16, + this->vector_elements, + this->matrix_columns, + this->explicit_stride, + this->interface_row_major); +} static void hash_free_type_function(struct hash_entry *entry) diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h index ae1a6e0fa7c..4b1f0ab09ea 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -394,6 +394,11 @@ public: */ const glsl_type *get_bare_type() const; + /** + * Gets the float16 version of this type. + */ + const glsl_type *get_float16_type() const; + /** * Get the instance of a built-in scalar, vector, or matrix type */ diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 37dde30dd6c..807529fb2b8 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -620,6 +620,12 @@ glsl_channel_type(const glsl_type *t) } } +const glsl_type * +glsl_float16_type(const struct glsl_type *type) +{ + return type->get_float16_type(); +} + void glsl_get_natural_size_align_bytes(const struct glsl_type *type, unsigned *size, unsigned *align) diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index 4dfc4648e3d..3351ce9bf9f 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -198,6 +198,8 @@ const struct glsl_type *glsl_transposed_type(const struct glsl_type *type); const struct glsl_type *glsl_channel_type(const struct glsl_type *type); +const struct glsl_type *glsl_float16_type(const struct glsl_type *type); + void glsl_get_natural_size_align_bytes(const struct glsl_type *type, unsigned *size, unsigned *align); -- 2.30.2