From 9c1e0d86a813af7609acf42cfe6bec7401d6405f Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 17 Aug 2020 11:28:07 +0100 Subject: [PATCH] aco: fix non-rtz pack_half_2x16 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We were using the wrong conversion opcode. The high bits are also not zero'd on GFX10, which can cause v_cvt_pk_u16_u32 to clamp. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Fixes: df645fa369d ('aco: implement VK_KHR_shader_float_controls') Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 7d45f5b8c33..5bd389a5be4 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -2714,12 +2714,18 @@ void visit_alu_instr(isel_context *ctx, nir_alu_instr *instr) Temp src0 = bld.tmp(v1); Temp src1 = bld.tmp(v1); bld.pseudo(aco_opcode::p_split_vector, Definition(src0), Definition(src1), src); - if (!ctx->block->fp_mode.care_about_round32 || ctx->block->fp_mode.round32 == fp_round_tz) + if (0 && (!ctx->block->fp_mode.care_about_round32 || ctx->block->fp_mode.round32 == fp_round_tz)) { bld.vop3(aco_opcode::v_cvt_pkrtz_f16_f32, Definition(dst), src0, src1); - else - bld.vop3(aco_opcode::v_cvt_pk_u16_u32, Definition(dst), - bld.vop1(aco_opcode::v_cvt_f32_f16, bld.def(v1), src0), - bld.vop1(aco_opcode::v_cvt_f32_f16, bld.def(v1), src1)); + } else { + src0 = bld.vop1(aco_opcode::v_cvt_f16_f32, bld.def(v1), src0); + src1 = bld.vop1(aco_opcode::v_cvt_f16_f32, bld.def(v1), src1); + if (ctx->program->chip_class >= GFX10) { + /* the high bits of v_cvt_f16_f32 isn't zero'd on GFX10 */ + bld.vop3(aco_opcode::v_pack_b32_f16, Definition(dst), src0, src1); + } else { + bld.vop3(aco_opcode::v_cvt_pk_u16_u32, Definition(dst), src0, src1); + } + } } else { isel_err(&instr->instr, "Unimplemented NIR instr bit size"); } -- 2.30.2