From d867e7c97482ee4682b59c5d17ef42232b480f36 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 24 Jul 2020 15:13:40 -0700 Subject: [PATCH] nir: Add an option to not lower source mods for f64/u64/i64. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TGSI can't handle them, but we want to use this pass for nir-to-tgsi. Reviewed-by: Marek Olšák Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/nir/nir.h | 5 +++-- src/compiler/nir/nir_lower_to_source_mods.c | 10 ++++++++++ src/gallium/drivers/r600/sfn/sfn_nir.cpp | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 4238cec4868..106b6087928 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -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; diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c index ab9581dcc3d..b23ceb6a632 100644 --- a/src/compiler/nir/nir_lower_to_source_mods.c +++ b/src/compiler/nir/nir_lower_to_source_mods.c @@ -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) diff --git a/src/gallium/drivers/r600/sfn/sfn_nir.cpp b/src/gallium/drivers/r600/sfn/sfn_nir.cpp index a439f58dcdb..db7cf2f2b51 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir.cpp @@ -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);