diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 56f4618f7ff..93c25f15379 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -5682,16 +5682,12 @@ void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *option bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned offset_align_state); typedef enum { - nir_lower_int_source_mods = 1 << 0, - nir_lower_fabs_source_mods = 1 << 1, - nir_lower_fneg_source_mods = 1 << 2, - nir_lower_64bit_source_mods = 1 << 3, - nir_lower_triop_abs = 1 << 4, - nir_lower_all_source_mods = (1 << 5) - 1 + nir_lower_fabs_source_mods = 1 << 0, + nir_lower_fneg_source_mods = 1 << 1, + nir_lower_triop_abs = 1 << 2, + nir_lower_all_source_mods = (1 << 3) - 1 } nir_lower_to_source_mods_flags; -#define nir_lower_float_source_mods (nir_lower_fabs_source_mods | nir_lower_fneg_source_mods) - bool nir_lower_to_source_mods(nir_shader *shader, nir_lower_to_source_mods_flags options); typedef enum { diff --git a/src/compiler/nir/nir_lower_to_source_mods.c b/src/compiler/nir/nir_lower_to_source_mods.c index b94ec146a37..a41fba3ce0d 100644 --- a/src/compiler/nir/nir_lower_to_source_mods.c +++ b/src/compiler/nir/nir_lower_to_source_mods.c @@ -73,29 +73,16 @@ nir_lower_to_source_mods_instr(nir_builder *b, nir_instr *instr, if (parent->dest.saturate) continue; - switch (nir_alu_type_get_base_type(nir_op_infos[alu->op].input_types[i])) { - case nir_type_float: - if (!(options & nir_lower_float_source_mods)) - continue; - if (!(parent->op == nir_op_fabs && (options & nir_lower_fabs_source_mods)) && - !(parent->op == nir_op_fneg && (options & nir_lower_fneg_source_mods))) { - continue; - } - break; - case nir_type_int: - if (!(options & nir_lower_int_source_mods)) - continue; - if (parent->op != nir_op_iabs && parent->op != nir_op_ineg) - continue; - break; - default: + if (nir_alu_type_get_base_type(nir_op_infos[alu->op].input_types[i]) != nir_type_float) + continue; + + if (!(parent->op == nir_op_fabs && (options & nir_lower_fabs_source_mods)) && + !(parent->op == nir_op_fneg && (options & nir_lower_fneg_source_mods))) { continue; } - if (nir_src_bit_size(alu->src[i].src) == 64 && - !(options & nir_lower_64bit_source_mods)) { + if (nir_src_bit_size(alu->src[i].src) == 64) continue; - } /* We can only do a rewrite if the source we are copying is SSA. * Otherwise, moving the read might invalidly reorder reads/writes @@ -104,17 +91,15 @@ nir_lower_to_source_mods_instr(nir_builder *b, nir_instr *instr, if (!parent->src[0].src.is_ssa) continue; - if (!lower_abs && (parent->op == nir_op_fabs || - parent->op == nir_op_iabs || - parent->src[0].abs)) + if (!lower_abs && (parent->op == nir_op_fabs || parent->src[0].abs)) continue; nir_instr_rewrite_src(instr, &alu->src[i].src, parent->src[0].src); /* Apply any modifiers that come from the parent opcode */ - if (parent->op == nir_op_fneg || parent->op == nir_op_ineg) + if (parent->op == nir_op_fneg) alu_src_consume_negate(&alu->src[i]); - if (parent->op == nir_op_fabs || parent->op == nir_op_iabs) + if (parent->op == nir_op_fabs) alu_src_consume_abs(&alu->src[i]); /* Apply modifiers from the parent source */ @@ -142,19 +127,14 @@ nir_lower_to_source_mods_instr(nir_builder *b, nir_instr *instr, if (!alu->dest.dest.is_ssa) return progress; - if (nir_dest_bit_size(alu->dest.dest) == 64 && - !(options & nir_lower_64bit_source_mods)) { + if (nir_dest_bit_size(alu->dest.dest) == 64) return progress; - } /* We can only saturate float destinations */ if (nir_alu_type_get_base_type(nir_op_infos[alu->op].output_type) != nir_type_float) return progress; - if (!(options & nir_lower_float_source_mods)) - return progress; - bool all_children_are_sat = true; nir_foreach_use_including_if(child_src, &alu->dest.dest.ssa) { if (child_src->is_if) { diff --git a/src/gallium/auxiliary/nir/nir_to_tgsi.c b/src/gallium/auxiliary/nir/nir_to_tgsi.c index 9ca1af8ea6a..947ed28e5b0 100644 --- a/src/gallium/auxiliary/nir/nir_to_tgsi.c +++ b/src/gallium/auxiliary/nir/nir_to_tgsi.c @@ -3855,9 +3855,9 @@ const void *nir_to_tgsi_options(struct nir_shader *s, NIR_PASS_V(s, nir_opt_move, move_all); - /* Only lower 32-bit floats. The only other modifier type officially - * supported by TGSI is 32-bit integer negates, but even those are broken on - * virglrenderer, so skip lowering all integer and f64 float mods. + /* We're fine lowering only 32-bit floats. TGSI officially supports 32-bit + * integer negates, but even those are broken on virglrenderer, so we don't + * use integer or f64 float mods. * * The options->lower_fabs requests that we not have native source modifiers * for fabs, and instead emit MAX(a,-a) for nir_op_fabs. diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index 1bf098ee572..048279eb8ad 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -1180,8 +1180,7 @@ etna_compile_shader(struct etna_shader_variant *v) NIR_PASS_V(s, nir_move_vec_src_uses_to_dest); NIR_PASS_V(s, nir_copy_prop); - /* only HW supported integer source mod is ineg for iadd instruction (?) */ - NIR_PASS_V(s, nir_lower_to_source_mods, ~nir_lower_int_source_mods); + NIR_PASS_V(s, nir_lower_to_source_mods, nir_lower_all_source_mods); /* need copy prop after uses_to_dest, and before src mods: see * dEQP-GLES2.functional.shaders.random.all_features.fragment.95 */