From: Ian Romanick Date: Tue, 9 Mar 2010 23:51:22 +0000 (-0800) Subject: Convert is_glsl_type_scalar to glsl_type::is_scalar X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb36f8aaeeb09660843316270a781948f773d90b;p=mesa.git Convert is_glsl_type_scalar to glsl_type::is_scalar --- diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index b63b28b11a5..8feeab62673 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -110,7 +110,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * * The two operands are scalars. In this case the operation is * applied, resulting in a scalar." */ - if (is_glsl_type_scalar(type_a) && is_glsl_type_scalar(type_b)) + if (type_a->is_scalar() && type_b->is_scalar()) return type_a; /* "* One operand is a scalar, and the other is a vector or matrix. @@ -118,10 +118,10 @@ arithmetic_result_type(const struct glsl_type *type_a, * component of the vector or matrix, resulting in the same size * vector or matrix." */ - if (is_glsl_type_scalar(type_a)) { - if (!is_glsl_type_scalar(type_b)) + if (type_a->is_scalar()) { + if (!type_b->is_scalar()) return type_b; - } else if (is_glsl_type_scalar(type_b)) { + } else if (type_b->is_scalar()) { return type_a; } @@ -287,8 +287,8 @@ relational_result_type(const struct glsl_type *type_a, */ if (! is_numeric_base_type(type_a->base_type) || ! is_numeric_base_type(type_b->base_type) - || ! is_glsl_type_scalar(type_a) - || ! is_glsl_type_scalar(type_b)) + || !type_a->is_scalar() + || !type_b->is_scalar()) return glsl_error_type; /* "Either the operands' types must match, or the conversions from @@ -513,7 +513,7 @@ ast_expression::hir(exec_list *instructions, */ assert((type == glsl_error_type) || ((type->base_type == GLSL_TYPE_BOOL) - && is_glsl_type_scalar(type))); + && type->is_scalar())); result = new ir_expression(operations[this->oper], type, op[0], op[1]); diff --git a/glsl_types.h b/glsl_types.h index 9a70b8bfd4d..0375934de9c 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -135,12 +135,17 @@ struct glsl_type { { this->fields.structure = fields; } -}; -#define is_glsl_type_scalar(t) \ - (((t)->vector_elements == 0) \ - && ((t)->base_type >= GLSL_TYPE_UINT) \ - && ((t)->base_type <= GLSL_TYPE_BOOL)) + /** + * Query whether or not a type is a scalar (non-vector and non-matrix). + */ + bool is_scalar() const + { + return (vector_elements == 0) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } +}; #define is_glsl_type_vector(t) \ (((t)->vector_elements > 0) \