glsl: make use of glsl_type::is_double()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Apr 2017 08:53:32 +0000 (10:53 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Apr 2017 17:34:12 +0000 (19:34 +0200)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
12 files changed:
src/compiler/glsl/ast_function.cpp
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/builtin_functions.cpp
src/compiler/glsl/ir.cpp
src/compiler/glsl/ir_equals.cpp
src/compiler/glsl/ir_expression_operation.py
src/compiler/glsl/ir_function.cpp
src/compiler/glsl/ir_validate.cpp
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/lower_buffer_access.cpp
src/compiler/glsl/opt_algebraic.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 0665e0c3938223c5d89ce3cbe7c016b0daa53a16..e895228cee43cf89166de8e23f27c241bbc0411e 100644 (file)
@@ -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",
index 4d1b279c9d654a823024a2baed33c24249647ae2..4bff9e979bfa730830906140b207133a50d84d74 100644 (file)
@@ -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:
index 5d62d9f8ee93d2f0b83d588b6d495ef6589ea36d..1abd215abaad9e0be0a35c5dfe5e033ca752238a 100644 (file)
@@ -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);
 }
 
index b5c1fa3391923e3016237b82293cb75782e08dde..8c0ae833ebbb101947fbf95d95835c65f2167d20 100644 (file)
@@ -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] =
index 58b08d445b99a2a16f38238fcceb6a68b7d108e6..81980eb50a7588d7cee8ea6cd97c5c5e8a2b6c04 100644 (file)
@@ -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 {
index 1d29560733e54409be4954ef2fdc726cf8f2a32a..d5e596b917984ff72336cc0cd29a49b2a95f921e 100644 (file)
@@ -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++) {
index 3aeba8119a7251b9834e3e76136ebecbbcb415ce..85caa2926b43c3bc0662fa831d669a4cebb46ce0 100644 (file)
@@ -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;
index 8f6308478ec3dfb3d9edb20f6d2ced3c48775b9f..cb603566c03d901d4ef3dbb42d819a183c1e0267 100644 (file)
@@ -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 ||
index 925699641e587579f1e6b67e9120438e589574ac..b462cb9d59eeb1490039a4a7b30fd2f8db465efd 100644 (file)
@@ -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;
 
index 51e65608c35cb4949f203bf8de0521d37d947ac0..1613806de4e891b2e5556830eb929d8659c088bc 100644 (file)
@@ -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
index 0ec331524c2b19caebfe2954f6c10f069a0dad9e..3662e8b26996aa32c4be11f68d2566fe57e816be 100644 (file)
@@ -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],
index 17915bec53139102d302e8612325860250e2a2b6..de7fe7837a40551dca893cb00886880c7e6f0516 100644 (file)
@@ -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()");