nir: add force_f2f16_rtz option to lower f2f16 to f2f16_rtz

Used by OpenGL driver like radeonsi which has undefined rounding mode.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25990>
This commit is contained in:
Qiang Yu 2023-11-08 10:44:22 +08:00 committed by Marge Bot
parent 5696790420
commit 7e4aac46ad
2 changed files with 5 additions and 0 deletions

View file

@ -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 {

View file

@ -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"),