From 7e4aac46ad41c7b928061552d4f48bc67c931f4b Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Wed, 8 Nov 2023 10:44:22 +0800 Subject: [PATCH] nir: add force_f2f16_rtz option to lower f2f16 to f2f16_rtz MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Used by OpenGL driver like radeonsi which has undefined rounding mode. Reviewed-by: Marek Olšák Signed-off-by: Qiang Yu Part-of: --- src/compiler/nir/nir.h | 3 +++ src/compiler/nir/nir_opt_algebraic.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index b44dad7e836..9273286691e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4016,6 +4016,9 @@ typedef struct nir_shader_compiler_options { /** lowers fquantize2f16 to alu ops. */ bool lower_fquantize2f16; + + /** Lower f2f16 to f2f16_rtz when execution mode is not rtne. */ + bool force_f2f16_rtz; } nir_shader_compiler_options; typedef struct nir_shader { diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 8a7cb3617fa..8e531b1e5b2 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3281,6 +3281,8 @@ late_optimizations += [ (('u2fmp', a), ('u2f16', a), "!options->preserve_mediump"), (('fisfinite', a), ('flt', ('fabs', a), float("inf"))), + (('f2f16', a), ('f2f16_rtz', a), "options->force_f2f16_rtz && !nir_is_rounding_mode_rtne(info->float_controls_execution_mode, 16)"), + (('fcsel', ('slt', 0, a), b, c), ('fcsel_gt', a, b, c), "options->has_fused_comp_and_csel"), (('fcsel', ('slt', a, 0), b, c), ('fcsel_gt', ('fneg', a), b, c), "options->has_fused_comp_and_csel"), (('fcsel', ('sge', a, 0), b, c), ('fcsel_ge', a, b, c), "options->has_fused_comp_and_csel"),