From: Marek Olšák Date: Mon, 11 May 2020 04:42:51 +0000 (-0400) Subject: nir: add int16 and uint16 type helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6f2e95f24d80c797389b5c558e0590ed10e0c0e7;p=mesa.git nir: add int16 and uint16 type helpers Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rob Clark Part-of: --- diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp index a1c1beae872..d6315845e68 100644 --- a/src/compiler/glsl_types.cpp +++ b/src/compiler/glsl_types.cpp @@ -473,6 +473,28 @@ const glsl_type *glsl_type::get_float16_type() const this->interface_row_major); } +const glsl_type *glsl_type::get_int16_type() const +{ + assert(this->base_type == GLSL_TYPE_INT); + + return get_instance(GLSL_TYPE_INT16, + this->vector_elements, + this->matrix_columns, + this->explicit_stride, + this->interface_row_major); +} + +const glsl_type *glsl_type::get_uint16_type() const +{ + assert(this->base_type == GLSL_TYPE_UINT); + + return get_instance(GLSL_TYPE_UINT16, + 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 c1e0aea2eaa..aa1a4cec324 100644 --- a/src/compiler/glsl_types.h +++ b/src/compiler/glsl_types.h @@ -400,6 +400,16 @@ public: */ const glsl_type *get_float16_type() const; + /** + * Gets the int16 version of this type. + */ + const glsl_type *get_int16_type() const; + + /** + * Gets the uint16 version of this type. + */ + const glsl_type *get_uint16_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 58815e12c4b..ac610488814 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -632,6 +632,18 @@ glsl_float16_type(const struct glsl_type *type) return type->get_float16_type(); } +const glsl_type * +glsl_int16_type(const struct glsl_type *type) +{ + return type->get_int16_type(); +} + +const glsl_type * +glsl_uint16_type(const struct glsl_type *type) +{ + return type->get_uint16_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 7f947d3f08e..77a9c787d98 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -210,6 +210,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); +const struct glsl_type *glsl_int16_type(const struct glsl_type *type); +const struct glsl_type *glsl_uint16_type(const struct glsl_type *type); void glsl_get_natural_size_align_bytes(const struct glsl_type *type, unsigned *size, unsigned *align);