mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
Convert is_glsl_type_matrix to glsl_type::is_matrix
This commit is contained in:
parent
a2dd22fb19
commit
fce1150156
2 changed files with 13 additions and 8 deletions
|
|
@ -169,14 +169,14 @@ arithmetic_result_type(const struct glsl_type *type_a,
|
||||||
* more detail how vectors and matrices are operated on."
|
* more detail how vectors and matrices are operated on."
|
||||||
*/
|
*/
|
||||||
if (! multiply) {
|
if (! multiply) {
|
||||||
if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)
|
if (type_a->is_matrix() && type_b->is_matrix()
|
||||||
&& (type_a->vector_elements == type_b->vector_elements)
|
&& (type_a->vector_elements == type_b->vector_elements)
|
||||||
&& (type_a->matrix_rows == type_b->matrix_rows))
|
&& (type_a->matrix_rows == type_b->matrix_rows))
|
||||||
return type_a;
|
return type_a;
|
||||||
else
|
else
|
||||||
return glsl_error_type;
|
return glsl_error_type;
|
||||||
} else {
|
} else {
|
||||||
if (is_glsl_type_matrix(type_a) && is_glsl_type_matrix(type_b)) {
|
if (type_a->is_matrix() && type_b->is_matrix()) {
|
||||||
if (type_a->vector_elements == type_b->matrix_rows) {
|
if (type_a->vector_elements == type_b->matrix_rows) {
|
||||||
char type_name[7];
|
char type_name[7];
|
||||||
const struct glsl_type *t;
|
const struct glsl_type *t;
|
||||||
|
|
@ -199,14 +199,14 @@ arithmetic_result_type(const struct glsl_type *type_a,
|
||||||
_mesa_symbol_table_find_symbol(state->symbols, 0, type_name);
|
_mesa_symbol_table_find_symbol(state->symbols, 0, type_name);
|
||||||
return (t != NULL) ? t : glsl_error_type;
|
return (t != NULL) ? t : glsl_error_type;
|
||||||
}
|
}
|
||||||
} else if (is_glsl_type_matrix(type_a)) {
|
} else if (type_a->is_matrix()) {
|
||||||
/* A is a matrix and B is a column vector. Columns of A must match
|
/* A is a matrix and B is a column vector. Columns of A must match
|
||||||
* rows of B.
|
* rows of B.
|
||||||
*/
|
*/
|
||||||
if (type_a->vector_elements == type_b->vector_elements)
|
if (type_a->vector_elements == type_b->vector_elements)
|
||||||
return type_b;
|
return type_b;
|
||||||
} else {
|
} else {
|
||||||
assert(is_glsl_type_matrix(type_b));
|
assert(type_b->is_matrix());
|
||||||
|
|
||||||
/* A is a row vector and B is a matrix. Columns of A must match
|
/* A is a row vector and B is a matrix. Columns of A must match
|
||||||
* rows of B.
|
* rows of B.
|
||||||
|
|
|
||||||
13
glsl_types.h
13
glsl_types.h
|
|
@ -156,11 +156,16 @@ struct glsl_type {
|
||||||
&& (base_type >= GLSL_TYPE_UINT)
|
&& (base_type >= GLSL_TYPE_UINT)
|
||||||
&& (base_type <= GLSL_TYPE_BOOL);
|
&& (base_type <= GLSL_TYPE_BOOL);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
#define is_glsl_type_matrix(t) \
|
/**
|
||||||
(((t)->matrix_rows > 0) \
|
* Query whether or not a type is a matrix
|
||||||
&& ((t)->base_type == GLSL_TYPE_FLOAT)) /* GLSL only has float matrices. */
|
*/
|
||||||
|
bool is_matrix() const
|
||||||
|
{
|
||||||
|
/* GLSL only has float matrices. */
|
||||||
|
return (matrix_rows > 0) && (base_type == GLSL_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct glsl_struct_field {
|
struct glsl_struct_field {
|
||||||
const struct glsl_type *type;
|
const struct glsl_type *type;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue