glsl: make use of glsl_type::is_boolean()
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Apr 2017 08:36:05 +0000 (10:36 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 21 Apr 2017 17:33:38 +0000 (19:33 +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>
src/compiler/glsl/ast_to_hir.cpp
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir_validate.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index a4a687f687dd9508caf9a32896a8259eaf18c24a..4d1b279c9d654a823024a2baed33c24249647ae2 100644 (file)
@@ -1487,8 +1487,7 @@ ast_expression::do_hir(exec_list *instructions,
        * in a scalar boolean.  See page 57 of the GLSL 1.50 spec.
        */
       assert(type->is_error()
-             || ((type->base_type == GLSL_TYPE_BOOL)
-                 && type->is_scalar()));
+             || (type->is_boolean() && type->is_scalar()));
 
       result = new(ctx) ir_expression(operations[this->oper], type,
                                       op[0], op[1]);
index 870d457681869f81a16cc6618a42a5bb43c8d913..b98d6cb4ac27284bdeb438536dfe406813d84eba 100644 (file)
@@ -985,7 +985,7 @@ nir_visitor::visit(ir_call *ir)
           * consider a true boolean to be ~0. Fix this up with a != 0
           * comparison.
           */
-         if (type->base_type == GLSL_TYPE_BOOL) {
+         if (type->is_boolean()) {
             nir_alu_instr *load_ssbo_compare =
                nir_alu_instr_create(shader, nir_op_ine);
             load_ssbo_compare->src[0].src.is_ssa = true;
@@ -1334,7 +1334,7 @@ nir_visitor::visit(ir_expression *ir)
        * a true boolean to be ~0. Fix this up with a != 0 comparison.
        */
 
-      if (ir->type->base_type == GLSL_TYPE_BOOL)
+      if (ir->type->is_boolean())
          this->result = nir_ine(&b, &load->dest.ssa, nir_imm_int(&b, 0));
 
       return;
index 76a4ed17e775d7e7325aaaf8e74d21a876649d84..8f6308478ec3dfb3d9edb20f6d2ced3c48775b9f 100644 (file)
@@ -241,8 +241,8 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type == ir->type);
       break;
    case ir_unop_logic_not:
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
+      assert(ir->operands[0]->type->is_boolean());
       break;
 
    case ir_unop_neg:
@@ -289,18 +289,18 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
    case ir_unop_f2b:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT);
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
       break;
    case ir_unop_b2f:
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->operands[0]->type->is_boolean());
       assert(ir->type->base_type == GLSL_TYPE_FLOAT);
       break;
    case ir_unop_i2b:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT);
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
       break;
    case ir_unop_b2i:
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->operands[0]->type->is_boolean());
       assert(ir->type->base_type == GLSL_TYPE_INT);
       break;
    case ir_unop_u2f:
@@ -366,7 +366,7 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
    case ir_unop_i642b:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
       break;
    case ir_unop_i642f:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_INT64);
@@ -393,7 +393,7 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->type->base_type == GLSL_TYPE_INT64);
       break;
    case ir_unop_b2i64:
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->operands[0]->type->is_boolean());
       assert(ir->type->base_type == GLSL_TYPE_INT64);
       break;
    case ir_unop_f2i64:
@@ -564,7 +564,7 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
    case ir_unop_d2b:
       assert(ir->operands[0]->type->base_type == GLSL_TYPE_DOUBLE);
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
       break;
 
    case ir_unop_frexp_sig:
@@ -651,7 +651,7 @@ ir_validate::visit_leave(ir_expression *ir)
        * comparison on scalar or vector types and return a boolean scalar or
        * vector type of the same size.
        */
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
       assert(ir->operands[0]->type == ir->operands[1]->type);
       assert(ir->operands[0]->type->is_vector()
             || ir->operands[0]->type->is_scalar());
@@ -699,9 +699,9 @@ ir_validate::visit_leave(ir_expression *ir)
    case ir_binop_logic_and:
    case ir_binop_logic_xor:
    case ir_binop_logic_or:
-      assert(ir->type->base_type == GLSL_TYPE_BOOL);
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
-      assert(ir->operands[1]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->type->is_boolean());
+      assert(ir->operands[0]->type->is_boolean());
+      assert(ir->operands[1]->type->is_boolean());
       break;
 
    case ir_binop_dot:
@@ -765,7 +765,7 @@ ir_validate::visit_leave(ir_expression *ir)
       break;
 
    case ir_triop_csel:
-      assert(ir->operands[0]->type->base_type == GLSL_TYPE_BOOL);
+      assert(ir->operands[0]->type->is_boolean());
       assert(ir->type->vector_elements == ir->operands[0]->type->vector_elements);
       assert(ir->type == ir->operands[1]->type);
       assert(ir->type == ir->operands[2]->type);
index 0c3ac8c7385361de4d4475b2296a5f25de24fb1e..17915bec53139102d302e8612325860250e2a2b6 100644 (file)
@@ -2225,7 +2225,7 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
                                        const_offset % 16 / 4,
                                        const_offset % 16 / 4);
 
-      if (ir->type->base_type == GLSL_TYPE_BOOL) {
+      if (ir->type->is_boolean()) {
          emit_asm(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
       } else {
          emit_asm(ir, TGSI_OPCODE_MOV, result_dst, cbuf);