diff options
author | Samuel Pitoiset <[email protected]> | 2017-04-21 11:18:50 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-04-21 19:34:15 +0200 |
commit | a7bc51aef8ef7e3374e034bfbe33096e985ffb0b (patch) | |
tree | d37cd02757c0c56cf0928a871123b631be4a2017 | |
parent | cacc823c39044307e6befe12c3f51317f09973e2 (diff) |
glsl: make use of glsl_type::is_float()
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Samuel Iglesias Gonsálvez <[email protected]>
Reviewed-by: Edward O'Callaghan <[email protected]>
-rw-r--r-- | src/compiler/glsl/ast_function.cpp | 5 | ||||
-rw-r--r-- | src/compiler/glsl/ast_to_hir.cpp | 6 | ||||
-rw-r--r-- | src/compiler/glsl/ir.cpp | 7 | ||||
-rw-r--r-- | src/compiler/glsl/ir_expression_operation.py | 9 | ||||
-rw-r--r-- | src/compiler/glsl/ir_function.cpp | 4 | ||||
-rw-r--r-- | src/compiler/glsl/ir_reader.cpp | 2 | ||||
-rw-r--r-- | src/compiler/glsl/ir_validate.cpp | 54 | ||||
-rw-r--r-- | src/compiler/glsl/lower_buffer_access.cpp | 6 | ||||
-rw-r--r-- | src/compiler/glsl/opt_algebraic.cpp | 9 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 2 |
10 files changed, 48 insertions, 56 deletions
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp index e895228cee4..9f03f321483 100644 --- a/src/compiler/glsl/ast_function.cpp +++ b/src/compiler/glsl/ast_function.cpp @@ -1504,8 +1504,7 @@ emit_inline_matrix_constructor(const glsl_type *type, * components with zero. */ glsl_base_type param_base_type = first_param->type->base_type; - assert(param_base_type == GLSL_TYPE_FLOAT || - first_param->type->is_double()); + assert(first_param->type->is_float() || 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", @@ -1514,7 +1513,7 @@ emit_inline_matrix_constructor(const glsl_type *type, ir_constant_data zero; for (unsigned i = 0; i < 4; i++) - if (param_base_type == GLSL_TYPE_FLOAT) + if (first_param->type->is_float()) zero.f[i] = 0.0; else zero.d[i] = 0.0; diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp index 4bff9e979bf..aeb223db9e7 100644 --- a/src/compiler/glsl/ast_to_hir.cpp +++ b/src/compiler/glsl/ast_to_hir.cpp @@ -444,10 +444,8 @@ arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b, * type of both operands must be float. */ assert(type_a->is_matrix() || type_b->is_matrix()); - assert(type_a->base_type == GLSL_TYPE_FLOAT || - type_a->is_double()); - assert(type_b->base_type == GLSL_TYPE_FLOAT || - type_b->is_double()); + assert(type_a->is_float() || type_a->is_double()); + assert(type_b->is_float() || 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 diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp index 8c0ae833ebb..3b0cbee3b85 100644 --- a/src/compiler/glsl/ir.cpp +++ b/src/compiler/glsl/ir.cpp @@ -783,10 +783,9 @@ ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list) if (value->type->is_scalar() && value->next->is_tail_sentinel()) { if (type->is_matrix()) { /* Matrix - fill diagonal (rest is already set to 0) */ - assert(type->base_type == GLSL_TYPE_FLOAT || - type->is_double()); + assert(type->is_float() || type->is_double()); for (unsigned i = 0; i < type->matrix_columns; i++) { - if (type->base_type == GLSL_TYPE_FLOAT) + if (type->is_float()) this->value.f[i * type->vector_elements + i] = value->value.f[0]; else @@ -1510,7 +1509,7 @@ ir_texture::set_sampler(ir_dereference *sampler, const glsl_type *type) assert(type->base_type == GLSL_TYPE_INT); } else if (this->op == ir_lod) { assert(type->vector_elements == 2); - assert(type->base_type == GLSL_TYPE_FLOAT); + assert(type->is_float()); } else if (this->op == ir_samples_identical) { assert(type == glsl_type::bool_type); assert(sampler->type->is_sampler()); diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py index d5e596b9179..fd9f103e96c 100644 --- a/src/compiler/glsl/ir_expression_operation.py +++ b/src/compiler/glsl/ir_expression_operation.py @@ -276,12 +276,9 @@ constant_template_vector = mako.template.Template("""\ # This template is for ir_triop_lrp. constant_template_lrp = mako.template.Template("""\ case ${op.get_enum_name()}: { - assert(op[0]->type->base_type == GLSL_TYPE_FLOAT || - op[0]->type->is_double()); - assert(op[1]->type->base_type == GLSL_TYPE_FLOAT || - op[1]->type->is_double()); - assert(op[2]->type->base_type == GLSL_TYPE_FLOAT || - op[2]->type->is_double()); + assert(op[0]->type->is_float() || op[0]->type->is_double()); + assert(op[1]->type->is_float() || op[1]->type->is_double()); + assert(op[2]->type->is_float() || 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 85caa2926b4..3ee0d170fb2 100644 --- a/src/compiler/glsl/ir_function.cpp +++ b/src/compiler/glsl/ir_function.cpp @@ -150,12 +150,12 @@ get_parameter_match_type(const ir_variable *param, return PARAMETER_EXACT_MATCH; if (to_type->is_double()) { - if (from_type->base_type == GLSL_TYPE_FLOAT) + if (from_type->is_float()) return PARAMETER_FLOAT_TO_DOUBLE; return PARAMETER_INT_TO_DOUBLE; } - if (to_type->base_type == GLSL_TYPE_FLOAT) + if (to_type->is_float()) return PARAMETER_INT_TO_FLOAT; /* int -> uint and any other oddball conversions */ diff --git a/src/compiler/glsl/ir_reader.cpp b/src/compiler/glsl/ir_reader.cpp index 6d3d0481779..b87933ba511 100644 --- a/src/compiler/glsl/ir_reader.cpp +++ b/src/compiler/glsl/ir_reader.cpp @@ -833,7 +833,7 @@ ir_reader::read_constant(s_expression *expr) return NULL; } - if (type->base_type == GLSL_TYPE_FLOAT) { + if (type->is_float()) { s_number *value = SX_AS_NUMBER(expr); if (value == NULL) { ir_read_error(values, "expected numbers"); diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp index cb603566c03..df76a7cafd8 100644 --- a/src/compiler/glsl/ir_validate.cpp +++ b/src/compiler/glsl/ir_validate.cpp @@ -252,7 +252,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_abs: 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->is_float() || ir->operands[0]->type->is_double() || ir->operands[0]->type->base_type == GLSL_TYPE_INT64); assert(ir->type == ir->operands[0]->type); @@ -261,7 +261,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_rcp: case ir_unop_rsq: case ir_unop_sqrt: - assert(ir->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->type->is_float() || ir->type->is_double()); assert(ir->type == ir->operands[0]->type); break; @@ -271,29 +271,29 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_exp2: case ir_unop_log2: case ir_unop_saturate: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type == ir->operands[0]->type); break; case ir_unop_f2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_INT); break; case ir_unop_f2u: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_UINT); break; case ir_unop_i2f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_f2b: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->is_boolean()); break; case ir_unop_b2f: assert(ir->operands[0]->type->is_boolean()); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_i2b: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); @@ -305,7 +305,7 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_u2f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_i2u: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); @@ -317,18 +317,18 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_bitcast_i2f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_bitcast_f2i: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_INT); break; case ir_unop_bitcast_u2f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_bitcast_f2u: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_UINT); break; @@ -370,11 +370,11 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_i642f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_u642f: assert(ir->operands[0]->type->base_type == GLSL_TYPE_UINT64); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_i642d: assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64); @@ -397,7 +397,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type->base_type == GLSL_TYPE_INT64); break; case ir_unop_f2i64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_INT64); break; case ir_unop_d2i64: @@ -413,7 +413,7 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->type->base_type == GLSL_TYPE_UINT64); break; case ir_unop_f2u64: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->base_type == GLSL_TYPE_UINT64); break; case ir_unop_d2u64: @@ -433,7 +433,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_ceil: case ir_unop_floor: case ir_unop_fract: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->operands[0]->type->is_float() || ir->operands[0]->type->is_double()); assert(ir->operands[0]->type == ir->type); break; @@ -445,7 +445,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_dFdy: case ir_unop_dFdy_coarse: case ir_unop_dFdy_fine: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->operands[0]->type == ir->type); break; @@ -540,10 +540,10 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_d2f: assert(ir->operands[0]->type->is_double()); - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); break; case ir_unop_f2d: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->operands[0]->type->is_float()); assert(ir->type->is_double()); break; case ir_unop_d2i: @@ -568,12 +568,12 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_unop_frexp_sig: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->operands[0]->type->is_float() || 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 || + assert(ir->operands[0]->type->is_float() || ir->operands[0]->type->is_double()); assert(ir->type->base_type == GLSL_TYPE_INT); break; @@ -593,7 +593,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_unop_read_first_invocation: assert(ir->type == ir->operands[0]->type); assert(ir->type->is_scalar() || ir->type->is_vector()); - assert(ir->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->type->is_float() || ir->type->base_type == GLSL_TYPE_INT || ir->type->base_type == GLSL_TYPE_UINT); break; @@ -707,7 +707,7 @@ ir_validate::visit_leave(ir_expression *ir) case ir_binop_dot: assert(ir->type == glsl_type::float_type || ir->type == glsl_type::double_type); - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->operands[0]->type->is_float() || ir->operands[0]->type->is_double()); assert(ir->operands[0]->type->is_vector()); assert(ir->operands[0]->type == ir->operands[1]->type); @@ -748,7 +748,7 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_triop_fma: - assert(ir->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->type->is_float() || ir->type->is_double()); assert(ir->type == ir->operands[0]->type); assert(ir->type == ir->operands[1]->type); @@ -756,7 +756,7 @@ ir_validate::visit_leave(ir_expression *ir) break; case ir_triop_lrp: - assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT || + assert(ir->operands[0]->type->is_float() || ir->operands[0]->type->is_double()); assert(ir->operands[0]->type == ir->operands[1]->type); assert(ir->operands[2]->type == ir->operands[0]->type || diff --git a/src/compiler/glsl/lower_buffer_access.cpp b/src/compiler/glsl/lower_buffer_access.cpp index 1613806de4e..24a96e2fba4 100644 --- a/src/compiler/glsl/lower_buffer_access.cpp +++ b/src/compiler/glsl/lower_buffer_access.cpp @@ -164,8 +164,8 @@ lower_buffer_access::emit_access(void *mem_ctx, /* We're dereffing a column out of a row-major matrix, so we * gather the vector from each stored row. */ - assert(deref->type->base_type == GLSL_TYPE_FLOAT || - deref->type->is_double()); + assert(deref->type->is_float() || 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 @@ -199,7 +199,7 @@ lower_buffer_access::emit_access(void *mem_ctx, else matrix_stride = glsl_align(matrix_columns * N, 16); - const glsl_type *deref_type = deref->type->base_type == GLSL_TYPE_FLOAT ? + const glsl_type *deref_type = deref->type->is_float() ? glsl_type::float_type : glsl_type::double_type; for (unsigned i = 0; i < deref->type->vector_elements; i++) { diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index 3662e8b2699..a5ba843fd15 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -144,7 +144,7 @@ is_valid_vec_const(ir_constant *ir) static inline bool is_less_than_one(ir_constant *ir) { - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); if (!is_valid_vec_const(ir)) return false; @@ -161,7 +161,7 @@ is_less_than_one(ir_constant *ir) static inline bool is_greater_than_zero(ir_constant *ir) { - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); if (!is_valid_vec_const(ir)) return false; @@ -649,8 +649,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->is_double())) { + ir->type->is_float() || ir->type->is_double())) { return new(mem_ctx) ir_expression(ir_unop_rcp, ir->operands[1]->type, ir->operands[1], @@ -845,7 +844,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir) case ir_binop_min: case ir_binop_max: - if (ir->type->base_type != GLSL_TYPE_FLOAT || options->EmitNoSat) + if (!ir->type->is_float() || options->EmitNoSat) break; /* Replace min(max) operations and its commutative combinations with diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 083591cc0fe..b0fecde11ca 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -1952,7 +1952,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir) dst_reg mat_column = dst_reg(mat); for (i = 0; i < ir->type->matrix_columns; i++) { - assert(ir->type->base_type == GLSL_TYPE_FLOAT); + assert(ir->type->is_float()); values = &ir->value.f[i * ir->type->vector_elements]; src = src_reg(PROGRAM_CONSTANT, -1, NULL); |