This creates a new glsl_type with the specified number on components. We will use this in the following patch when vectorising io. --- src/compiler/nir_types.cpp | 24 ++++++++++++++++++++++++ src/compiler/nir_types.h | 2 ++ 2 files changed, 26 insertions(+)
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp index d24f0941519..45a06e0214b 100644 --- a/src/compiler/nir_types.cpp +++ b/src/compiler/nir_types.cpp @@ -432,6 +432,30 @@ glsl_array_type(const glsl_type *base, unsigned elements) return glsl_type::get_array_instance(base, elements); } +const glsl_type * +glsl_replace_vector_type(const glsl_type *t, unsigned components) +{ + switch (glsl_get_base_type(t)) { + case GLSL_TYPE_ARRAY: { + const glsl_type *base = glsl_replace_vector_type(t->fields.array, components); + return glsl_array_type(base, glsl_get_length(t)); + } + case GLSL_TYPE_UINT: + case GLSL_TYPE_INT: + case GLSL_TYPE_FLOAT: + case GLSL_TYPE_BOOL: + case GLSL_TYPE_DOUBLE: + case GLSL_TYPE_UINT64: + case GLSL_TYPE_INT64: + case GLSL_TYPE_FLOAT16: + case GLSL_TYPE_UINT16: + case GLSL_TYPE_INT16: + return glsl_vector_type(glsl_get_base_type(t), components); + default: + unreachable("Unhandled base type glsl_replace_vector_type()"); + } +} + const glsl_type * glsl_struct_type(const glsl_struct_field *fields, unsigned num_fields, const char *name) diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h index 77454fa9fab..deb7ead8dd2 100644 --- a/src/compiler/nir_types.h +++ b/src/compiler/nir_types.h @@ -167,6 +167,8 @@ const struct glsl_type *glsl_bool_type(void); const struct glsl_type *glsl_scalar_type(enum glsl_base_type base_type); const struct glsl_type *glsl_vector_type(enum glsl_base_type base_type, unsigned components); +const struct glsl_type * glsl_replace_vector_type(const struct glsl_type *t, + unsigned components); const struct glsl_type *glsl_matrix_type(enum glsl_base_type base_type, unsigned rows, unsigned columns); const struct glsl_type *glsl_array_type(const struct glsl_type *base, -- 2.19.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev