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 <apinheiro@igalia.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
const glsl_type *
glsl_channel_type(const glsl_type *t)
{
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);
- return glsl_uint_type();
- return glsl_int_type();
- 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();
- return glsl_float16_t_type();
+ case GLSL_TYPE_DOUBLE:
+ case GLSL_TYPE_UINT8:
+ case GLSL_TYPE_INT8:
- return glsl_uint16_t_type();
- 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()");
}
default:
unreachable("Unhandled base type glsl_channel_type()");
}