From cacc823c39044307e6befe12c3f51317f09973e2 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 21 Apr 2017 10:53:32 +0200 Subject: [PATCH] glsl: make use of glsl_type::is_double() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuel Pitoiset Reviewed-by: Samuel Iglesias Gonsálvez Reviewed-by: Edward O'Callaghan --- src/compiler/glsl/ast_function.cpp | 2 +- src/compiler/glsl/ast_to_hir.cpp | 6 +-- src/compiler/glsl/builtin_functions.cpp | 12 ++--- src/compiler/glsl/ir.cpp | 2 +- src/compiler/glsl/ir_equals.cpp | 2 +- src/compiler/glsl/ir_expression_operation.py | 8 ++-- src/compiler/glsl/ir_function.cpp | 2 +- src/compiler/glsl/ir_validate.cpp | 48 ++++++++++---------- src/compiler/glsl/link_uniforms.cpp | 2 +- src/compiler/glsl/lower_buffer_access.cpp | 2 +- src/compiler/glsl/opt_algebraic.cpp | 2 +- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index 0665e0c3938..e895228cee4 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -1505,7 +1505,7 @@ emit_inline_matrix_constructor(const glsl_type *type, */ glsl_base_type param_base_type = first_param->type->base_type; assert(param_base_type == GLSL_TYPE_FLOAT || - param_base_type == GLSL_TYPE_DOUBLE); + first_param->type->is_double()); ir_variable *rhs_var = new(ctx) ir_variable(glsl_type::get_instance(param_base_type, 4, 1), "mat_ctor_vec", diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 4d1b279c9d6..4bff9e979bf 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -445,9 +445,9 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, */ assert(type_a->is_matrix() || type_b->is_matrix()); assert(type_a->base_type == GLSL_TYPE_FLOAT || - type_a->base_type == GLSL_TYPE_DOUBLE); + type_a->is_double()); assert(type_b->base_type == GLSL_TYPE_FLOAT || - type_b->base_type == GLSL_TYPE_DOUBLE); + type_b->is_double()); /* "* The operator is add (+), subtract (-), or divide (/), and the * operands are matrices with the same number of rows and the same @@ -4950,7 +4950,7 @@ ast_declarator_list::hir(exec_list *instructions, if (state->is_version(120, 300)) break; case GLSL_TYPE_DOUBLE: - if (check_type->base_type == GLSL_TYPE_DOUBLE && (state->is_version(410, 0) || state->ARB_vertex_attrib_64bit_enable)) + if (check_type->is_double() && (state->is_version(410, 0) || state->ARB_vertex_attrib_64bit_enable)) break; /* FALLTHROUGH */ default: diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp index 5d62d9f8ee9..1abd215abaa 100644 --- a/src/compiler/glsl/builtin_functions.cpp +++ b/src/compiler/glsl/builtin_functions.cpp @@ -3417,7 +3417,7 @@ builtin_builder::imm(const glsl_type *type, const ir_constant_data &data) return new(mem_ctx) ir_constant(type, &data); } -#define IMM_FP(type, val) (type->base_type == GLSL_TYPE_DOUBLE) ? imm(val) : imm((float)val) +#define IMM_FP(type, val) (type->is_double()) ? imm(val) : imm((float)val) ir_dereference_variable * builtin_builder::var_ref(ir_variable *var) @@ -3985,14 +3985,14 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_ ir_variable *t = body.make_temp(x_type, "t"); if (x_type->vector_elements == 1) { /* Both are floats */ - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(x, edge))))); else body.emit(assign(t, b2f(gequal(x, edge)))); } else if (edge_type->vector_elements == 1) { /* x is a vector but edge is a float */ for (int i = 0; i < x_type->vector_elements; i++) { - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), edge))), 1 << i)); else body.emit(assign(t, b2f(gequal(swizzle(x, i, 1), edge)), 1 << i)); @@ -4000,7 +4000,7 @@ builtin_builder::_step(builtin_available_predicate avail, const glsl_type *edge_ } else { /* Both are vectors */ for (int i = 0; i < x_type->vector_elements; i++) { - if (edge_type->base_type == GLSL_TYPE_DOUBLE) + if (edge_type->is_double()) body.emit(assign(t, f2d(b2f(gequal(swizzle(x, i, 1), swizzle(edge, i, 1)))), 1 << i)); else @@ -4452,7 +4452,7 @@ builtin_builder::_outerProduct(builtin_available_predicate avail, const glsl_typ ir_variable *c; ir_variable *r; - if (type->base_type == GLSL_TYPE_DOUBLE) { + if (type->is_double()) { r = in_var(glsl_type::dvec(type->matrix_columns), "r"); c = in_var(glsl_type::dvec(type->vector_elements), "c"); } else { @@ -5475,7 +5475,7 @@ builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type) ir_function_signature * builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type) { - return binop(x_type->base_type == GLSL_TYPE_DOUBLE ? fp64 : gpu_shader5_or_es31_or_integer_functions, + return binop(x_type->is_double() ? fp64 : gpu_shader5_or_es31_or_integer_functions, ir_binop_ldexp, x_type, x_type, exp_type); } diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index b5c1fa33919..8c0ae833ebb 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -784,7 +784,7 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) if (type->is_matrix()) { /* Matrix - fill diagonal (rest is already set to 0) */ assert(type->base_type == GLSL_TYPE_FLOAT || - type->base_type == GLSL_TYPE_DOUBLE); + type->is_double()); for (unsigned i = 0; i < type->matrix_columns; i++) { if (type->base_type == GLSL_TYPE_FLOAT) this->value.f[i * type->vector_elements + i] = diff --git a/src/compiler/glsl/ir_equals.cpp b/src/compiler/glsl/ir_equals.cpp index 58b08d445b9..81980eb50a7 100644 --- a/src/compiler/glsl/ir_equals.cpp +++ b/src/compiler/glsl/ir_equals.cpp @@ -58,7 +58,7 @@ ir_constant::equals(const ir_instruction *ir, enum ir_node_type) const return false; for (unsigned i = 0; i < type->components(); i++) { - if (type->base_type == GLSL_TYPE_DOUBLE) { + if (type->is_double()) { if (value.d[i] != other->value.d[i]) return false; } else { diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py index 1d29560733e..d5e596b9179 100644 --- a/src/compiler/glsl/ir_expression_operation.py +++ b/src/compiler/glsl/ir_expression_operation.py @@ -180,7 +180,7 @@ constant_template_mul = mako.template.Template("""\ for (unsigned j = 0; j < p; j++) { for (unsigned i = 0; i < n; i++) { for (unsigned k = 0; k < m; k++) { - if (op[0]->type->base_type == GLSL_TYPE_DOUBLE) + if (op[0]->type->is_double()) data.d[i+n*j] += op[0]->value.d[i+n*k]*op[1]->value.d[k+m*j]; else data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j]; @@ -277,11 +277,11 @@ constant_template_vector = mako.template.Template("""\ constant_template_lrp = mako.template.Template("""\ case ${op.get_enum_name()}: { assert(op[0]->type->base_type == GLSL_TYPE_FLOAT || - op[0]->type->base_type == GLSL_TYPE_DOUBLE); + op[0]->type->is_double()); assert(op[1]->type->base_type == GLSL_TYPE_FLOAT || - op[1]->type->base_type == GLSL_TYPE_DOUBLE); + op[1]->type->is_double()); assert(op[2]->type->base_type == GLSL_TYPE_FLOAT || - op[2]->type->base_type == GLSL_TYPE_DOUBLE); + op[2]->type->is_double()); unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1; for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) { diff --git a/src/compiler/glsl/ir_function.cpp b/src/compiler/glsl/ir_function.cpp index 3aeba8119a7..85caa2926b4 100644 --- a/src/compiler/glsl/ir_function.cpp +++ b/src/compiler/glsl/ir_function.cpp @@ -149,7 +149,7 @@ get_parameter_match_type(const ir_variable *param, if (from_type == to_type) return PARAMETER_EXACT_MATCH; - if (to_type->base_type == GLSL_TYPE_DOUBLE) { + if (to_type->is_double()) { if (from_type->base_type == GLSL_TYPE_FLOAT) return PARAMETER_FLOAT_TO_DOUBLE; return PARAMETER_INT_TO_DOUBLE; diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp index 8f6308478ec..cb603566c03 100644 --- a/src/compiler/glsl/ir_validate.cpp +++ b/src/compiler/glsl/ir_validate.cpp @@ -253,7 +253,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_sign: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT || ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE || + ir->operands[0]->type->is_double() || ir->operands[0]->type->base_type == GLSL_TYPE_INT64); assert(ir->type == ir->operands[0]->type); break; @@ -262,7 +262,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_rsq: case ir_unop_sqrt: assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_DOUBLE); + ir->type->is_double()); assert(ir->type == ir->operands[0]->type); break; @@ -334,18 +334,18 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_bitcast_u642d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_bitcast_i642d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_bitcast_d2u64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_UINT64); break; case ir_unop_bitcast_d2i64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_INT64); break; case ir_unop_i642i: @@ -378,11 +378,11 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_i642d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_u642d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_i2i64: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); @@ -401,7 +401,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type->base_type == GLSL_TYPE_INT64); break; case ir_unop_d2i64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_INT64); break; case ir_unop_i2u64: @@ -417,7 +417,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type->base_type == GLSL_TYPE_UINT64); break; case ir_unop_d2u64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_UINT64); break; case ir_unop_u642i64: @@ -434,7 +434,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_floor: case ir_unop_fract: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + ir->operands[0]->type->is_double()); assert(ir->operands[0]->type == ir->type); break; case ir_unop_sin: @@ -539,42 +539,42 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_d2f: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_FLOAT); break; case ir_unop_f2d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_d2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_INT); break; case ir_unop_i2d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_d2u: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_UINT); break; case ir_unop_u2d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->type->is_double()); break; case ir_unop_d2b: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + assert(ir->operands[0]->type->is_double()); assert(ir->type->is_boolean()); break; case ir_unop_frexp_sig: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); - assert(ir->type->base_type == GLSL_TYPE_DOUBLE); + ir->operands[0]->type->is_double()); + assert(ir->type->is_double()); break; case ir_unop_frexp_exp: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_INT); break; case ir_unop_subroutine_to_int: @@ -708,7 +708,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type == glsl_type::float_type || ir->type == glsl_type::double_type); assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + ir->operands[0]->type->is_double()); assert(ir->operands[0]->type->is_vector()); assert(ir->operands[0]->type == ir->operands[1]->type); break; @@ -749,7 +749,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_triop_fma: assert(ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_DOUBLE); + ir->type->is_double()); assert(ir->type == ir->operands[0]->type); assert(ir->type == ir->operands[1]->type); assert(ir->type == ir->operands[2]->type); @@ -757,7 +757,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_triop_lrp: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || - ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE); + ir->operands[0]->type->is_double()); assert(ir->operands[0]->type == ir->operands[1]->type); assert(ir->operands[2]->type == ir->operands[0]->type || ir->operands[2]->type == glsl_type::float_type || diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index 925699641e5..b462cb9d59e 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -772,7 +772,7 @@ private: if (type->without_array()->is_matrix()) { const glsl_type *matrix = type->without_array(); - const unsigned N = matrix->base_type == GLSL_TYPE_DOUBLE ? 8 : 4; + const unsigned N = matrix->is_double() ? 8 : 4; const unsigned items = row_major ? matrix->matrix_columns : matrix->vector_elements; diff --git a/src/compiler/glsl/lower_buffer_access.cpp b/src/compiler/glsl/lower_buffer_access.cpp index 51e65608c35..1613806de4e 100644 --- a/src/compiler/glsl/lower_buffer_access.cpp +++ b/src/compiler/glsl/lower_buffer_access.cpp @@ -165,7 +165,7 @@ lower_buffer_access::emit_access(void *mem_ctx, * gather the vector from each stored row. */ assert(deref->type->base_type == GLSL_TYPE_FLOAT || - deref->type->base_type == GLSL_TYPE_DOUBLE); + deref->type->is_double()); /* Matrices, row_major or not, are stored as if they were * arrays of vectors of the appropriate size in std140. * Arrays have their strides rounded up to a vec4, so the diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index 0ec331524c2..3662e8b2699 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -650,7 +650,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) case ir_binop_div: if (is_vec_one(op_const[0]) && ( ir->type->base_type == GLSL_TYPE_FLOAT || - ir->type->base_type == GLSL_TYPE_DOUBLE)) { + ir->type->is_double())) { return new(mem_ctx) ir_expression(ir_unop_rcp, ir->operands[1]->type, ir->operands[1], diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 17915bec531..de7fe7837a4 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2330,7 +2330,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) break; case ir_binop_ldexp: - if (ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE) { + if (ir->operands[0]->type->is_double()) { emit_asm(ir, TGSI_OPCODE_DLDEXP, result_dst, op[0], op[1]); } else { assert(!"Invalid ldexp for non-double opcode in glsl_to_tgsi_visitor::visit()"); -- 2.30.2