diff options
author | Kristian H. Kristensen <hoegsberg@google.com> | 2020-02-19 13:13:15 -0800 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2020-02-24 17:24:13 +0000 |
commit | 6c750d9c4d51b07076115eb1d0e1be4a2d568095 (patch) | |
tree | 9db57163f80326d09eceb4b807cc821250b3bbb4 | |
parent | c822460f851ae6f3c74a01b9eec9ea924a0de12d (diff) |
nir/types: Add glsl_float16_type() helper
This returns the float16 version of a float type.
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3822>
-rw-r--r-- | src/compiler/glsl_types.cpp | 10 | ||||
-rw-r--r-- | src/compiler/glsl_types.h | 5 | ||||
-rw-r--r-- | src/compiler/nir_types.cpp | 6 | ||||
-rw-r--r-- | src/compiler/nir_types.h | 2 |
4 files changed, 23 insertions, 0 deletions
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 @@ -395,6 +395,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 */ static const glsl_type *get_instance(unsigned base_type, unsigned rows, 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); |