From ade44ad82e45fd5af357081c1940ca003e1e61be Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 29 Aug 2023 13:18:04 +0200 Subject: [PATCH] v3d,v3dv: use fquantize2f16 lowering in NIR MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ths is equivalent to what we have been doing in the backend. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/compiler/nir_to_vir.c | 21 --------------------- src/broadcom/vulkan/v3dv_pipeline.c | 1 + src/gallium/drivers/v3d/v3d_screen.c | 1 + 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 89d58f9..d54d8df 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -1694,27 +1694,6 @@ ntq_emit_alu(struct v3d_compile *c, nir_alu_instr *instr) vir_set_unpack(c->defs[result.index], 0, V3D_QPU_UNPACK_H); break; - case nir_op_fquantize2f16: { - /* F32 -> F16 -> F32 conversion */ - struct qreg tmp = vir_FMOV(c, src[0]); - vir_set_pack(c->defs[tmp.index], V3D_QPU_PACK_L); - tmp = vir_FMOV(c, tmp); - vir_set_unpack(c->defs[tmp.index], 0, V3D_QPU_UNPACK_L); - - /* Check for denorm */ - struct qreg abs_src = vir_FMOV(c, src[0]); - vir_set_unpack(c->defs[abs_src.index], 0, V3D_QPU_UNPACK_ABS); - struct qreg threshold = vir_uniform_f(c, ldexpf(1.0, -14)); - vir_set_pf(c, vir_FCMP_dest(c, vir_nop_reg(), abs_src, threshold), - V3D_QPU_PF_PUSHC); - - /* Return +/-0 for denorms */ - struct qreg zero = - vir_AND(c, src[0], vir_uniform_ui(c, 0x80000000)); - result = vir_FMOV(c, vir_SEL(c, V3D_QPU_COND_IFNA, tmp, zero)); - break; - } - default: fprintf(stderr, "unknown NIR ALU inst: "); nir_print_instr(&instr->instr, stderr); diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 39ca0f0..908e4ff 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -231,6 +231,7 @@ const nir_shader_compiler_options v3dv_nir_options = { .lower_rotate = true, .lower_to_scalar = true, .lower_device_index_to_zero = true, + .lower_fquantize2f16 = true, .has_fsub = true, .has_isub = true, .vertex_id_zero_based = false, /* FIXME: to set this to true, the intrinsic diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 77dbfe8..fabc84f 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -734,6 +734,7 @@ static const nir_shader_compiler_options v3d_nir_options = { .lower_rotate = true, .lower_to_scalar = true, .lower_int64_options = nir_lower_imul_2x32_64, + .lower_fquantize2f16 = true, .has_fsub = true, .has_isub = true, .divergence_analysis_options = -- 2.7.4