compiler/types: Flip wrapping of get row/column type helpers
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user