nir: Add an option to not lower source mods for f64/u64/i64.

TGSI can't handle them, but we want to use this pass for nir-to-tgsi.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3395>
This commit is contained in:
Eric Anholt 2020-07-24 15:13:40 -07:00
parent c730feacc0
commit d867e7c974
3 changed files with 16 additions and 3 deletions

View File

@ -4779,8 +4779,9 @@ bool nir_lower_atomics_to_ssbo(nir_shader *shader);
typedef enum {
nir_lower_int_source_mods = 1 << 0,
nir_lower_float_source_mods = 1 << 1,
nir_lower_triop_abs = 1 << 2,
nir_lower_all_source_mods = (1 << 3) - 1
nir_lower_64bit_source_mods = 1 << 2,
nir_lower_triop_abs = 1 << 3,
nir_lower_all_source_mods = (1 << 4) - 1
} nir_lower_to_source_mods_flags;

View File

@ -91,6 +91,11 @@ nir_lower_to_source_mods_block(nir_block *block,
continue;
}
if (nir_src_bit_size(alu->src[i].src) == 64 &&
!(options & nir_lower_64bit_source_mods)) {
continue;
}
/* We can only do a rewrite if the source we are copying is SSA.
* Otherwise, moving the read might invalidly reorder reads/writes
* on a register.
@ -136,6 +141,11 @@ nir_lower_to_source_mods_block(nir_block *block,
if (!alu->dest.dest.is_ssa)
continue;
if (nir_dest_bit_size(alu->dest.dest) == 64 &&
!(options & nir_lower_64bit_source_mods)) {
continue;
}
/* We can only saturate float destinations */
if (nir_alu_type_get_base_type(nir_op_infos[alu->op].output_type) !=
nir_type_float)

View File

@ -844,7 +844,9 @@ int r600_shader_from_nir(struct r600_context *rctx,
//NIR_PASS_V(sel->nir, nir_opt_algebraic);
//NIR_PASS_V(sel->nir, nir_copy_prop);
NIR_PASS_V(sh, nir_lower_to_source_mods, nir_lower_float_source_mods);
NIR_PASS_V(sh, nir_lower_to_source_mods,
(nir_lower_to_source_mods_flags)(nir_lower_float_source_mods |
nir_lower_64bit_source_mods));
NIR_PASS_V(sh, nir_convert_from_ssa, true);
NIR_PASS_V(sh, nir_opt_dce);