nv50/ir/nir: always round towards zero for f2i/f2u
authorDanilo Krummrich <dakr@redhat.com>
Fri, 12 Aug 2022 14:54:49 +0000 (16:54 +0200)
committerDanilo Krummrich <dakr@redhat.com>
Fri, 9 Sep 2022 15:32:18 +0000 (17:32 +0200)
Conversions to integers must be rounded towards zero, hence, actually
do this for all integers including 8/16 bit sources.

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Danilo Krummrich <dakr@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18109>

src/nouveau/codegen/nv50_ir_from_nir.cpp

index 9aa7ce3..3c3a479 100644 (file)
@@ -2672,10 +2672,11 @@ Converter::visit(nir_alu_instr *insn)
    case nir_op_u2u64: {
       DEFAULT_CHECKS;
       LValues &newDefs = convert(&insn->dest);
+      DataType stype = sTypes[0];
       Instruction *i = mkOp1(getOperation(op), dType, newDefs[0], getSrc(&insn->src[0]));
-      if (op == nir_op_f2i32 || op == nir_op_f2i64 || op == nir_op_f2u32 || op == nir_op_f2u64)
+      if (::isFloatType(stype) && isIntType(dType))
          i->rnd = ROUND_Z;
-      i->sType = sTypes[0];
+      i->sType = stype;
       break;
    }
    // compare instructions