On Tue, Jun 24, 2014 at 6:27 AM, Ilia Mirkin <imir...@alum.mit.edu> wrote: > On Tue, Jun 24, 2014 at 1:32 AM, Abdiel Janulgue > <abdiel.janul...@linux.intel.com> wrote: >> Signed-off-by: Abdiel Janulgue <abdiel.janul...@linux.intel.com> >> --- >> src/glsl/opt_algebraic.cpp | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp >> index 8d7609d..0d694b6 100644 >> --- a/src/glsl/opt_algebraic.cpp >> +++ b/src/glsl/opt_algebraic.cpp >> @@ -589,6 +589,10 @@ ir_algebraic_visitor::handle_expression(ir_expression >> *ir) >> /* Found a min (max(x, 0), 1.0) */ >> if (outer_const->is_one() && inner_val_a->is_zero()) >> return saturate(inner_val_b); >> + >> + /* Found a min (max(x, 0.0) b), where b < 1.0 */ >> + if ((outer_const->get_float_component(0) < 1.0f) && >> inner_val_b->is_zero()) >> + return saturate(expr(ir_binop_min, inner_val_a, >> outer_const)); > > Not sure about other GPU's, but on reasonably modern nvidia gpu's, in > addition to being able to just saturate a single var, some other > instructions take a "saturate" modifier (like fp add/multiply). But > not min/max. If you were to write this as > > min(saturate(a), b) > > then it would be easier to propagate the saturate as a modifier to > whatever expression produces 'a' without having a clever optimization > that moves it through min/max.
Interesting. I guess it's (basically) all the same to us. It's pretty rare that a i965 instruction can't do saturate. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev