From: Jason Ekstrand Date: Wed, 12 Dec 2018 21:25:47 +0000 (-0600) Subject: glsl_type: Simplify glsl_channel_type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7f70b3e55514f1744e9aab6d2145e855603bd1dc;p=mesa.git glsl_type: Simplify glsl_channel_type 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 --- 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()"); }