compiler/types: Flip wrapping of get row/column type helpers
authorCaio Oliveira <caio.oliveira@intel.com>
Sun, 3 Sep 2023 01:00:42 +0000 (18:00 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 25 Oct 2023 01:51:12 +0000 (01:51 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>

src/compiler/glsl_types.cpp
src/compiler/glsl_types_impl.h
src/compiler/nir_types.cpp

index 48f46a6..4b21c00 100644 (file)
@@ -3559,4 +3559,39 @@ glsl_get_internal_ifc_packing(const struct glsl_type *t,
    }
 }
 
+const struct glsl_type *
+glsl_get_row_type(const struct glsl_type *t)
+{
+   if (!glsl_type_is_matrix(t))
+      return &glsl_type_builtin_error;
+
+   if (t->explicit_stride && !t->interface_row_major)
+      return glsl_type::get_instance(t->base_type, t->matrix_columns, 1, t->explicit_stride);
+   else
+      return glsl_type::get_instance(t->base_type, t->matrix_columns, 1);
+}
+
+const struct glsl_type *
+glsl_get_column_type(const struct glsl_type *t)
+{
+   if (!t->is_matrix())
+      return glsl_type::error_type;
+
+   if (t->interface_row_major) {
+      /* If we're row-major, the vector element stride is the same as the
+       * matrix stride and we have no alignment (i.e. component-aligned).
+       */
+      return glsl_type::get_instance(t->base_type, t->vector_elements, 1,
+                                     t->explicit_stride, false, 0);
+   } else {
+      /* Otherwise, the vector is tightly packed (stride=0).  For
+       * alignment, we treat a matrix as an array of columns make the same
+       * assumption that the alignment of the column is the same as the
+       * alignment of the whole matrix.
+       */
+      return glsl_type::get_instance(t->base_type, t->vector_elements, 1,
+                                     0, false, t->explicit_alignment);
+   }
+}
+
 }
index d2ea555..ca0679d 100644 (file)
@@ -73,6 +73,8 @@ inline unsigned glsl_type::std430_base_alignment(bool row_major) const { return
 inline unsigned glsl_type::std430_size(bool row_major) const { return glsl_get_std430_size(this, row_major); }
 inline unsigned glsl_type::explicit_size(bool align_to_stride) const { return glsl_get_explicit_size(this, align_to_stride); }
 
+inline const glsl_type *glsl_type::row_type() const { return glsl_get_row_type(this); }
+inline const glsl_type *glsl_type::column_type() const { return glsl_get_column_type(this); }
 inline const glsl_type *glsl_type::get_bare_type() const { return glsl_get_bare_type(this); }
 
 inline const glsl_type *glsl_type::vec(unsigned components) { return glsl_vec_type(components); }
@@ -265,41 +267,6 @@ glsl_type::atomic_size() const
       return 0;
 }
 
-inline const glsl_type *
-glsl_type::row_type() const
-{
-   if (!is_matrix())
-      return error_type;
-
-   if (explicit_stride && !interface_row_major)
-      return get_instance(base_type, matrix_columns, 1, explicit_stride);
-   else
-      return get_instance(base_type, matrix_columns, 1);
-}
-
-inline const glsl_type *
-glsl_type::column_type() const
-{
-   if (!is_matrix())
-      return error_type;
-
-   if (interface_row_major) {
-      /* If we're row-major, the vector element stride is the same as the
-       * matrix stride and we have no alignment (i.e. component-aligned).
-       */
-      return get_instance(base_type, vector_elements, 1,
-                          explicit_stride, false, 0);
-   } else {
-      /* Otherwise, the vector is tightly packed (stride=0).  For
-       * alignment, we treat a matrix as an array of columns make the same
-       * assumption that the alignment of the column is the same as the
-       * alignment of the whole matrix.
-       */
-      return get_instance(base_type, vector_elements, 1,
-                          0, false, explicit_alignment);
-   }
-}
-
 inline bool glsl_type::is_unsized_array() const { return glsl_type_is_unsized_array(this); }
 
 inline bool
index cdc9fd1..a285a35 100644 (file)
@@ -58,12 +58,6 @@ glsl_sampler_type_to_texture(const struct glsl_type *type)
                             (enum glsl_base_type)type->sampled_type);
 }
 
-const struct glsl_type *
-glsl_get_column_type(const struct glsl_type *type)
-{
-   return type->column_type();
-}
-
 GLenum
 glsl_get_gl_type(const struct glsl_type *type)
 {