//case midgard_alu_op_f2i:
//case midgard_alu_op_f2u:
case midgard_alu_op_ieq:
+ case midgard_alu_op_iabs:
case midgard_alu_op_ine:
case midgard_alu_op_ilt:
case midgard_alu_op_ile:
/* Incredibly, iadd can run on vmul, etc */
[midgard_alu_op_iadd] = UNITS_MOST,
+ [midgard_alu_op_iabs] = UNITS_MOST,
[midgard_alu_op_isub] = UNITS_MOST,
[midgard_alu_op_imul] = UNITS_MOST,
[midgard_alu_op_imov] = UNITS_MOST | QUIRK_FLIPPED_R24,
} while (progress);
NIR_PASS(progress, nir, nir_opt_algebraic_late);
+ NIR_PASS(progress, nir, midgard_nir_lower_algebraic_late);
- /* Lower mods */
- NIR_PASS(progress, nir, nir_lower_to_source_mods, nir_lower_all_source_mods);
+ /* Lower mods for float ops only. Integer ops don't support modifiers
+ * (saturate doesn't make sense on integers, neg/abs require dedicated
+ * instructions) */
+
+ NIR_PASS(progress, nir, nir_lower_to_source_mods, nir_lower_float_source_mods);
NIR_PASS(progress, nir, nir_copy_prop);
NIR_PASS(progress, nir, nir_opt_dce);
ALU_CASE(iadd, iadd);
ALU_CASE(isub, isub);
ALU_CASE(imul, imul);
+ ALU_CASE(iabs, iabs);
/* XXX: Use fmov, not imov, since imov was causing major
* issues with texture precision? XXX research */
#include "nir.h"
bool midgard_nir_lower_algebraic(nir_shader *shader);
+bool midgard_nir_lower_algebraic_late(nir_shader *shader);
bool midgard_nir_scale_trig(nir_shader *shader);
(('fsign', a), ('bcsel', ('fge', a, 0), 1.0, -1.0)),
]
+algebraic_late = [
+ # ineg must be lowered late, but only for integers; floats will try to
+ # have modifiers attached... hence why this has to be here rather than
+ # a more standard lower_negate approach
+
+ (('ineg', a), ('isub', 0, a)),
+]
+
+
# Midgard scales fsin/fcos arguments by pi.
# Pass must be run only once, after the main loop
print(nir_algebraic.AlgebraicPass("midgard_nir_lower_algebraic",
algebraic).render())
+ print(nir_algebraic.AlgebraicPass("midgard_nir_lower_algebraic_late",
+ algebraic_late).render())
+
print(nir_algebraic.AlgebraicPass("midgard_nir_scale_trig",
scale_trig).render())