From c4f356faf490cb7d4ba63470e1240e92b8317742 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 10 Aug 2023 20:55:04 +0200 Subject: [PATCH] aco: always use rtne for fquantize2f16 The SPIR-V spec says: If Value is positive with a magnitude too large to represent as a 16-bit floating-point value, the result is positive infinity. If Value is negative with a magnitude too large to represent as a 16-bit floating-point value, the result is negative infinity. This is only the case for rtne v_cvt_f16_f32 Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 12c95883570..f4bcadde70f 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -3375,7 +3375,11 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr) } case nir_op_fquantize2f16: { Temp src = get_alu_src(ctx, instr->src[0]); - Temp f16 = bld.vop1(aco_opcode::v_cvt_f16_f32, bld.def(v2b), src); + Temp f16; + if (ctx->block->fp_mode.round16_64 != fp_round_ne) + f16 = bld.vop1(aco_opcode::p_cvt_f16_f32_rtne, bld.def(v2b), src); + else + f16 = bld.vop1(aco_opcode::v_cvt_f16_f32, bld.def(v2b), src); Temp f32, cmp_res; if (ctx->program->gfx_level >= GFX8) {