From 7f70b3e55514f1744e9aab6d2145e855603bd1dc Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 12 Dec 2018 15:25:47 -0600 Subject: [PATCH] glsl_type: Simplify glsl_channel_type MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is C++ so we can just poke at the fields of glsl_type if we wish and calling get_instance is way easier and more reliable than handling each instance separately. While we're at it, we re-arrange the base type labels to match the enum order and add 8-bit type support. Reviewed-by: Alejandro Piñeiro Reviewed-by: Caio Marcelo de Oliveira Filho --- src/compiler/nir_types.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index 6995a897d60..2b4ff0702f2 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -493,31 +493,22 @@ glsl_transposed_type(const struct glsl_type *type) const glsl_type * glsl_channel_type(const glsl_type *t) { - switch (glsl_get_base_type(t)) { - case GLSL_TYPE_ARRAY: { - const glsl_type *base = glsl_channel_type(glsl_get_array_element(t)); - return glsl_array_type(base, glsl_get_length(t)); - } + switch (t->base_type) { + case GLSL_TYPE_ARRAY: + return glsl_array_type(glsl_channel_type(t->fields.array), t->length); case GLSL_TYPE_UINT: - return glsl_uint_type(); case GLSL_TYPE_INT: - return glsl_int_type(); case GLSL_TYPE_FLOAT: - return glsl_float_type(); - case GLSL_TYPE_BOOL: - return glsl_bool_type(); - case GLSL_TYPE_DOUBLE: - return glsl_double_type(); - case GLSL_TYPE_UINT64: - return glsl_uint64_t_type(); - case GLSL_TYPE_INT64: - return glsl_int64_t_type(); case GLSL_TYPE_FLOAT16: - return glsl_float16_t_type(); + case GLSL_TYPE_DOUBLE: + case GLSL_TYPE_UINT8: + case GLSL_TYPE_INT8: case GLSL_TYPE_UINT16: - return glsl_uint16_t_type(); case GLSL_TYPE_INT16: - return glsl_int16_t_type(); + case GLSL_TYPE_UINT64: + case GLSL_TYPE_INT64: + case GLSL_TYPE_BOOL: + return glsl_type::get_instance(t->base_type, 1, 1); default: unreachable("Unhandled base type glsl_channel_type()"); } -- 2.11.0