Module: Mesa Branch: main Commit: 4a4815b8552bf216cebe6e598905c1714dd9a203 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a4815b8552bf216cebe6e598905c1714dd9a203
Author: Faith Ekstrand <[email protected]> Date: Thu Dec 7 23:23:59 2023 -0600 nak/nir: Lower a bunch of fp64 All we have are add, mul, ffma, and comparisons. Everything else has to be lowered. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26587> --- src/nouveau/compiler/nak/api.rs | 12 ++++++++++++ src/nouveau/compiler/nak_nir.c | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/src/nouveau/compiler/nak/api.rs b/src/nouveau/compiler/nak/api.rs index 9ca21bd8854..69ceb774feb 100644 --- a/src/nouveau/compiler/nak/api.rs +++ b/src/nouveau/compiler/nak/api.rs @@ -105,6 +105,18 @@ fn nir_options(dev: &nv_device_info) -> nir_shader_compiler_options { op.lower_usub_sat = dev.sm < 70; op.lower_iadd_sat = true; // TODO op.use_interpolated_input_intrinsics = true; + op.lower_doubles_options = nir_lower_drcp + | nir_lower_dsqrt + | nir_lower_drsq + | nir_lower_dtrunc + | nir_lower_dfloor + | nir_lower_dceil + | nir_lower_dfract + | nir_lower_dround_even + | nir_lower_dsat; + if dev.sm >= 70 { + op.lower_doubles_options |= nir_lower_dminmax; + } op.lower_int64_options = !(nir_lower_icmp64 | nir_lower_iadd64 | nir_lower_ineg64 diff --git a/src/nouveau/compiler/nak_nir.c b/src/nouveau/compiler/nak_nir.c index ff47d2d1947..c878c8b1d16 100644 --- a/src/nouveau/compiler/nak_nir.c +++ b/src/nouveau/compiler/nak_nir.c @@ -1203,6 +1203,7 @@ nak_postprocess_nir(nir_shader *nir, unreachable("Unsupported shader stage"); } + OPT(nir, nir_lower_doubles, NULL, nak->nir_options.lower_doubles_options); OPT(nir, nir_lower_int64); nak_optimize_nir(nir, nak); @@ -1211,6 +1212,14 @@ nak_postprocess_nir(nir_shader *nir, progress = false; OPT(nir, nir_opt_algebraic_late); OPT(nir, nak_nir_lower_algebraic_late, nak); + + /* If we're lowering fp64 sat but not min/max, the sat lowering may have + * been undone by nir_opt_algebraic. Lower sat again just to be sure. + */ + if ((nak->nir_options.lower_doubles_options & nir_lower_dsat) && + !(nak->nir_options.lower_doubles_options & nir_lower_dminmax)) + OPT(nir, nir_lower_doubles, NULL, nir_lower_dsat); + if (progress) { OPT(nir, nir_opt_constant_folding); OPT(nir, nir_copy_prop);
