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>
This commit is contained in:
Faith Ekstrand 2023-12-07 23:23:59 -06:00 committed by Marge Bot
parent 3e042173e4
commit 4a4815b855
2 changed files with 21 additions and 0 deletions

View file

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

View file

@ -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);