Mesa (master): nir/types: Add array_or_matrix helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 24 02:48:48 UTC 2018


Module: Mesa
Branch: master
Commit: b489998e63f5bd773344c8185d2e9817936116c9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b489998e63f5bd773344c8185d2e9817936116c9

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Wed Jul 25 08:53:58 2018 -0700

nir/types: Add array_or_matrix helpers

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 c8a2940496..1fae6aa818 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -51,6 +51,15 @@ glsl_without_array(const glsl_type *type)
 }
 
 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)
 {
@@ -231,6 +240,12 @@ glsl_type_is_array_of_arrays(const struct glsl_type *type)
 }
 
 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)
 {
    return type->is_record() || type->is_interface();
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index db3a4dee2d..ea0438541a 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);
 
@@ -133,6 +134,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);




More information about the mesa-commit mailing list