compiler/types: Add glsl_simple_explicit_type() and simplify glsl_simple_type()

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25129>
This commit is contained in:
Caio Oliveira 2023-09-08 08:42:31 -07:00 committed by Marge Bot
parent e17adf51db
commit ada6183d60
3 changed files with 25 additions and 19 deletions

View file

@ -598,7 +598,7 @@ get_explicit_matrix_instance(unsigned int base_type, unsigned int rows, unsigned
unsigned int explicit_stride, bool row_major, unsigned int explicit_alignment); unsigned int explicit_stride, bool row_major, unsigned int explicit_alignment);
extern "C" const struct glsl_type * extern "C" const struct glsl_type *
glsl_simple_type(unsigned base_type, unsigned rows, unsigned columns, glsl_simple_explicit_type(unsigned base_type, unsigned rows, unsigned columns,
unsigned explicit_stride, bool row_major, unsigned explicit_stride, bool row_major,
unsigned explicit_alignment) unsigned explicit_alignment)
{ {

View file

@ -1437,11 +1437,18 @@ const struct glsl_type *glsl_u16vec_type(unsigned components);
const struct glsl_type *glsl_i8vec_type(unsigned components); const struct glsl_type *glsl_i8vec_type(unsigned components);
const struct glsl_type *glsl_u8vec_type(unsigned components); const struct glsl_type *glsl_u8vec_type(unsigned components);
const struct glsl_type *glsl_simple_type(unsigned base_type, unsigned rows, const struct glsl_type *glsl_simple_explicit_type(unsigned base_type, unsigned rows,
unsigned columns, unsigned columns,
unsigned explicit_stride, unsigned explicit_stride,
bool row_major, bool row_major,
unsigned explicit_alignment); unsigned explicit_alignment);
static inline const struct glsl_type *
glsl_simple_type(unsigned base_type, unsigned rows, unsigned columns)
{
return glsl_simple_explicit_type(base_type, rows, columns, 0, false, 0);
}
const struct glsl_type *glsl_sampler_type(enum glsl_sampler_dim dim, const struct glsl_type *glsl_sampler_type(enum glsl_sampler_dim dim,
bool shadow, bool shadow,
bool array, bool array,
@ -1492,13 +1499,13 @@ const struct glsl_type *glsl_type_to_16bit(const struct glsl_type *old_type);
static inline const struct glsl_type * static inline const struct glsl_type *
glsl_scalar_type(enum glsl_base_type base_type) glsl_scalar_type(enum glsl_base_type base_type)
{ {
return glsl_simple_type(base_type, 1, 1, 0, false, 0); return glsl_simple_type(base_type, 1, 1);
} }
static inline const struct glsl_type * static inline const struct glsl_type *
glsl_vector_type(enum glsl_base_type base_type, unsigned components) glsl_vector_type(enum glsl_base_type base_type, unsigned components)
{ {
const struct glsl_type *t = glsl_simple_type(base_type, components, 1, 0, false, 0); const struct glsl_type *t = glsl_simple_type(base_type, components, 1);
assert(t != &glsl_type_builtin_error); assert(t != &glsl_type_builtin_error);
return t; return t;
} }
@ -1507,7 +1514,7 @@ static inline const struct glsl_type *
glsl_matrix_type(enum glsl_base_type base_type, glsl_matrix_type(enum glsl_base_type base_type,
unsigned rows, unsigned columns) unsigned rows, unsigned columns)
{ {
const struct glsl_type *t = glsl_simple_type(base_type, rows, columns, 0, false, 0); const struct glsl_type *t = glsl_simple_type(base_type, rows, columns);
assert(t != &glsl_type_builtin_error); assert(t != &glsl_type_builtin_error);
return t; return t;
} }
@ -1516,7 +1523,7 @@ static inline const struct glsl_type *
glsl_explicit_matrix_type(const struct glsl_type *mat, unsigned stride, glsl_explicit_matrix_type(const struct glsl_type *mat, unsigned stride,
bool row_major) { bool row_major) {
assert(stride > 0); assert(stride > 0);
const struct glsl_type *t = glsl_simple_type(mat->base_type, const struct glsl_type *t = glsl_simple_explicit_type(mat->base_type,
mat->vector_elements, mat->vector_elements,
mat->matrix_columns, mat->matrix_columns,
stride, row_major, 0); stride, row_major, 0);
@ -1529,8 +1536,7 @@ static inline const struct glsl_type *
glsl_transposed_type(const struct glsl_type *t) glsl_transposed_type(const struct glsl_type *t)
{ {
assert(glsl_type_is_matrix(t)); assert(glsl_type_is_matrix(t));
return glsl_simple_type(t->base_type, t->matrix_columns, return glsl_simple_type(t->base_type, t->matrix_columns, t->vector_elements);
t->vector_elements, 0, false, 0);
} }
static inline const struct glsl_type * static inline const struct glsl_type *

View file

@ -111,7 +111,7 @@ glsl_type::get_instance(unsigned base_type, unsigned rows, unsigned columns,
unsigned explicit_stride, bool row_major, unsigned explicit_stride, bool row_major,
unsigned explicit_alignment) unsigned explicit_alignment)
{ {
return glsl_simple_type(base_type, rows, columns, explicit_stride, return glsl_simple_explicit_type(base_type, rows, columns, explicit_stride,
row_major, explicit_alignment); row_major, explicit_alignment);
} }