aboutsummaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-12-12 15:25:47 -0600
committerJason Ekstrand <[email protected]>2019-01-08 00:38:29 +0000
commit7f70b3e55514f1744e9aab6d2145e855603bd1dc (patch)
tree269bdb639d683951e060ad5d732adc288703d840 /src/compiler
parentd8a11bfc0850defbd4d3dd1fdc0de0e8901bfdc4 (diff)
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 <[email protected]> Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir_types.cpp29
1 files 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()");
}