r600/sfn: use 32 bit bools
authorGert Wollny <gert.wollny@collabora.com>
Mon, 12 Oct 2020 15:51:46 +0000 (17:51 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 16 Oct 2020 12:03:12 +0000 (12:03 +0000)
That's closer to what the driver actually does.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7142>

src/gallium/drivers/r600/sfn/sfn_emitaluinstruction.cpp
src/gallium/drivers/r600/sfn/sfn_emitaluinstruction.h
src/gallium/drivers/r600/sfn/sfn_nir.cpp

index 4641c17..a9a89d9 100644 (file)
@@ -52,8 +52,10 @@ bool EmitAluInstruction::do_emit(nir_instr* ir)
    preload_src(instr);
 
    switch (instr.op) {
+   case nir_op_f2b32: return emit_alu_f2b32(instr);
    case nir_op_b2f32: return emit_alu_b2f(instr);
    case nir_op_i2b1: return emit_alu_i2orf2_b1(instr, op2_setne_int);
+   case nir_op_i2b32: return emit_alu_i2orf2_b1(instr, op2_setne_int);
    case nir_op_f2b1: return emit_alu_i2orf2_b1(instr, op2_setne_dx10);
    case nir_op_b2b1:
    case nir_op_b2b32:
@@ -89,11 +91,22 @@ bool EmitAluInstruction::do_emit(nir_instr* ir)
    case nir_op_bit_count: return emit_alu_op1(instr, op1_bcnt_int);
    case nir_op_bitfield_reverse: return emit_alu_op1(instr, op1_bfrev_int);
 
+   case nir_op_ieq32:
    case nir_op_ieq: return emit_alu_op2_int(instr, op2_sete_int);
+
+   case nir_op_ine32:
    case nir_op_ine: return emit_alu_op2_int(instr, op2_setne_int);
+   case nir_op_uge32:
+   case nir_op_uge: return emit_alu_op2_int(instr, op2_setge_uint);
+   case nir_op_ige32:
    case nir_op_ige: return emit_alu_op2_int(instr, op2_setge_int);
    case nir_op_ishl: return emit_alu_op2_int(instr, op2_lshl_int);
    case nir_op_ishr: return emit_alu_op2_int(instr, op2_ashr_int);
+
+   case nir_op_ult32:
+   case nir_op_ult: return emit_alu_op2_int(instr, op2_setgt_uint, op2_opt_reverse);
+
+   case nir_op_ilt32:
    case nir_op_ilt: return emit_alu_op2_int(instr, op2_setgt_int, op2_opt_reverse);
    case nir_op_iand: return emit_alu_op2_int(instr, op2_and_int);
    case nir_op_ixor: return emit_alu_op2_int(instr, op2_xor_int);
@@ -112,14 +125,16 @@ bool EmitAluInstruction::do_emit(nir_instr* ir)
    case nir_op_umod: return emit_alu_div_int(instr, false, true);
    case nir_op_isign: return emit_alu_isign(instr);
 
-   case nir_op_uge: return emit_alu_op2_int(instr, op2_setge_uint);
-   case nir_op_ult: return emit_alu_op2_int(instr, op2_setgt_uint, op2_opt_reverse);
    case nir_op_ushr: return emit_alu_op2_int(instr, op2_lshr_int);
 
+   case nir_op_flt32:
    case nir_op_flt: return emit_alu_op2(instr, op2_setgt_dx10, op2_opt_reverse);
 
+   case nir_op_fge32:
    case nir_op_fge: return emit_alu_op2(instr, op2_setge_dx10);
+   case nir_op_fneu32:
    case nir_op_fneu: return emit_alu_op2(instr, op2_setne_dx10);
+   case nir_op_feq32:
    case nir_op_feq: return emit_alu_op2(instr, op2_sete_dx10);
 
    case nir_op_fmin: return emit_alu_op2(instr, op2_min_dx10);
@@ -152,6 +167,7 @@ bool EmitAluInstruction::do_emit(nir_instr* ir)
 
 
    case nir_op_ffma: return emit_alu_op3(instr, op3_muladd_ieee);
+   case nir_op_b32csel: return emit_alu_op3(instr, op3_cnde,  {0, 2, 1});
    case nir_op_bcsel: return emit_alu_op3(instr, op3_cnde,  {0, 2, 1});
    case nir_op_vec2: return emit_create_vec(instr, 2);
    case nir_op_vec3: return emit_create_vec(instr, 3);
@@ -468,6 +484,20 @@ bool EmitAluInstruction::emit_alu_f2i32_or_u32(const nir_alu_instr& instr, EAluO
    return true;
 }
 
+bool EmitAluInstruction::emit_alu_f2b32(const nir_alu_instr& instr)
+{
+   AluInstruction *ir = nullptr;
+   for (int i = 0; i < 4 ; ++i) {
+      if (instr.dest.write_mask & (1 << i)){
+         ir = new AluInstruction(op2_setne_dx10, from_nir(instr.dest, i),
+                                 m_src[0][i], literal(0.0f), write);
+         emit_instruction(ir);
+      }
+   }
+   make_last(ir);
+   return true;
+}
+
 bool EmitAluInstruction::emit_find_msb(const nir_alu_instr& instr, bool sgn)
 {
    int sel_tmp = allocate_temp_register();
index 5c31b94..859d6d9 100644 (file)
@@ -86,6 +86,7 @@ private:
    bool emit_discard_if(const nir_intrinsic_instr *instr);
 
    bool emit_find_msb(const nir_alu_instr& instr, bool sgn);
+   bool emit_alu_f2b32(const nir_alu_instr& instr);
    bool emit_b2i32(const nir_alu_instr& instr);
    bool emit_alu_f2i32_or_u32(const nir_alu_instr& instr, EAluOp op);
    bool emit_pack_64_2x32_split(const nir_alu_instr& instr);
index fc765b3..a439f58 100644 (file)
@@ -830,6 +830,8 @@ int r600_shader_from_nir(struct r600_context *rctx,
               40,
               r600_get_natural_size_align_bytes);
 
+   NIR_PASS_V(sel->nir, nir_lower_bool_to_int32);
+
    while (optimize_once(sel->nir, true));
 
    auto sh = nir_shader_clone(sel->nir, sel->nir);