[Mesa-dev] [PATCH v2 04/11] nir/types: Add array_or_matrix helpers
Jason Ekstrand
jason at jlekstrand.net
Sun Jul 29 05:44:35 UTC 2018
Reviewed-by: Thomas Helland<thomashelland90 at gmail.com>
---
src/compiler/nir_types.cpp | 15 +++++++++++++++
src/compiler/nir_types.h | 2 ++
2 files changed, 17 insertions(+)
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 3a3864414f3..c6f30368c95 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -50,6 +50,15 @@ glsl_without_array(const glsl_type *type)
return type->without_array();
}
+const glsl_type *
+glsl_without_array_or_matrix(const glsl_type *type)
+{
+ type = type->without_array();
+ if (type->is_matrix())
+ type = type->column_type();
+ return type;
+}
+
const glsl_type *
glsl_get_array_instance(const glsl_type *type,
unsigned array_size)
@@ -224,6 +233,12 @@ glsl_type_is_array_of_arrays(const struct glsl_type *type)
return type->is_array_of_arrays();
}
+bool
+glsl_type_is_array_or_matrix(const struct glsl_type *type)
+{
+ return type->is_array() || type->is_matrix();
+}
+
bool
glsl_type_is_struct(const struct glsl_type *type)
{
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 817b7a9b345..d29edd1d6c5 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -48,6 +48,7 @@ const struct glsl_type *glsl_get_struct_field(const struct glsl_type *type,
const struct glsl_type *glsl_get_array_element(const struct glsl_type *type);
const struct glsl_type *glsl_without_array(const struct glsl_type *type);
+const struct glsl_type *glsl_without_array_or_matrix(const struct glsl_type *type);
const struct glsl_type *glsl_get_array_instance(const struct glsl_type *type,
unsigned array_size);
@@ -131,6 +132,7 @@ bool glsl_type_is_vector_or_scalar(const struct glsl_type *type);
bool glsl_type_is_matrix(const struct glsl_type *type);
bool glsl_type_is_array(const struct glsl_type *type);
bool glsl_type_is_array_of_arrays(const struct glsl_type *type);
+bool glsl_type_is_array_or_matrix(const struct glsl_type *type);
bool glsl_type_is_struct(const struct glsl_type *type);
bool glsl_type_is_sampler(const struct glsl_type *type);
bool glsl_type_is_image(const struct glsl_type *type);
--
2.17.1
More information about the mesa-dev
mailing list