[Mesa-dev] [PATCH v2 09/28] nir/types: add three new wrapper helpers

Alejandro PiƱeiro apinheiro at igalia.com
Thu Sep 27 09:51:48 UTC 2018


To already existing fields on glsl_types. Specifically:
   * glsl_get_struct_field_offset
   * glsl_get_struct_field_matrix_layout
   * glsl_type_arrays_of_arrays_size
---
 src/compiler/nir_types.cpp | 21 +++++++++++++++++++++
 src/compiler/nir_types.h   |  8 ++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index d24f0941519..2a1ae42a9bb 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -72,6 +72,21 @@ glsl_get_struct_field(const glsl_type *type, unsigned index)
    return type->fields.structure[index].type;
 }
 
+const int
+glsl_get_struct_field_offset(const struct glsl_type *type,
+                             unsigned index)
+{
+   return type->fields.structure[index].offset;
+}
+
+const unsigned
+glsl_get_struct_field_matrix_layout(const struct glsl_type *type,
+                                    unsigned index)
+{
+   return type->fields.structure[index].matrix_layout;
+}
+
+
 const glsl_type *
 glsl_get_function_return_type(const glsl_type *type)
 {
@@ -591,3 +606,9 @@ glsl_contains_atomic(const struct glsl_type *type)
 {
    return type->contains_atomic();
 }
+
+unsigned
+glsl_type_arrays_of_arrays_size(const struct glsl_type *type)
+{
+   return type->arrays_of_arrays_size();
+}
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 77454fa9fab..69de44c3423 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -46,6 +46,11 @@ const char *glsl_get_type_name(const struct glsl_type *type);
 const struct glsl_type *glsl_get_struct_field(const struct glsl_type *type,
                                               unsigned index);
 
+const int glsl_get_struct_field_offset(const struct glsl_type *type,
+                                       unsigned index);
+
+const unsigned glsl_get_struct_field_matrix_layout(const struct glsl_type *type,
+                                                   unsigned index);
 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);
@@ -91,6 +96,9 @@ unsigned glsl_get_record_location_offset(const struct glsl_type *type,
 
 unsigned glsl_atomic_size(const struct glsl_type *type);
 
+
+unsigned glsl_type_arrays_of_arrays_size(const struct glsl_type *type);
+
 static inline unsigned
 glsl_get_bit_size(const struct glsl_type *type)
 {
-- 
2.14.1



More information about the mesa-dev mailing list