From: Ian Romanick Date: Tue, 9 Mar 2010 23:55:16 +0000 (-0800) Subject: Convert is_glsl_type_vector to glsl_type::is_vector X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a2dd22fb194bdffa14a2466ae5667f3be63430d3;p=mesa.git Convert is_glsl_type_vector to glsl_type::is_vector --- diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8feeab62673..1de58245913 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -136,7 +136,7 @@ arithmetic_result_type(const struct glsl_type *type_a, * operation is done component-wise resulting in the same size * vector." */ - if (is_glsl_type_vector(type_a) && is_glsl_type_vector(type_b)) { + if (type_a->is_vector() && type_b->is_vector()) { if (type_a->vector_elements == type_b->vector_elements) return type_a; else @@ -261,8 +261,8 @@ modulus_result_type(const struct glsl_type *type_a, * wise to the vector, resulting in the same type as the vector. If both * are vectors of the same size, the result is computed component-wise." */ - if (is_glsl_type_vector(type_a)) { - if (!is_glsl_type_vector(type_b) + if (type_a->is_vector()) { + if (!type_b->is_vector() || (type_a->vector_elements == type_b->vector_elements)) return type_a; } else diff --git a/glsl_types.h b/glsl_types.h index 0375934de9c..2b660168bdd 100644 --- a/glsl_types.h +++ b/glsl_types.h @@ -145,13 +145,18 @@ struct glsl_type { && (base_type >= GLSL_TYPE_UINT) && (base_type <= GLSL_TYPE_BOOL); } -}; -#define is_glsl_type_vector(t) \ - (((t)->vector_elements > 0) \ - && ((t)->matrix_rows == 0) \ - && ((t)->base_type >= GLSL_TYPE_UINT) \ - && ((t)->base_type <= GLSL_TYPE_BOOL)) + /** + * Query whether or not a type is a vector + */ + bool is_vector() const + { + return (vector_elements > 0) + && (matrix_rows == 0) + && (base_type >= GLSL_TYPE_UINT) + && (base_type <= GLSL_TYPE_BOOL); + } +}; #define is_glsl_type_matrix(t) \ (((t)->matrix_rows > 0) \ diff --git a/hir_field_selection.cpp b/hir_field_selection.cpp index 326a10543fe..8bef094c60f 100644 --- a/hir_field_selection.cpp +++ b/hir_field_selection.cpp @@ -156,7 +156,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, * being applied. */ loc = expr->get_location(); - if (is_glsl_type_vector(op->type)) { + if (op->type->is_vector()) { if (generate_swizzle(expr->primary_expression.identifier, & deref->selector.swizzle, op->type->vector_elements)) {