From a2dd22fb194bdffa14a2466ae5667f3be63430d3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 9 Mar 2010 15:55:16 -0800 Subject: [PATCH] Convert is_glsl_type_vector to glsl_type::is_vector --- ast_to_hir.cpp | 6 +++--- glsl_types.h | 17 +++++++++++------ hir_field_selection.cpp | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 8feeab6..1de5824 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 0375934..2b66016 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 326a105..8bef094 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)) { -- 2.7.4