On Mon, Jul 7, 2014 at 6:57 AM, Abdiel Janulgue <abdiel.janul...@linux.intel.com> wrote: > v2: - Output min(saturate(x),b) instead of saturate(min(x,b)) suggested by > Ilia Mirkin > - Make sure we do component-wise comparison for vectors (Ian Romanick) > > Signed-off-by: Abdiel Janulgue <abdiel.janul...@linux.intel.com> > --- > src/glsl/opt_algebraic.cpp | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp > index 2ad561c..bcda7a9 100644 > --- a/src/glsl/opt_algebraic.cpp > +++ b/src/glsl/opt_algebraic.cpp > @@ -643,6 +643,16 @@ 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); > + > + unsigned component = 0; > + for (int c = 0; c < outer_const->type->vector_elements; c++) { > + if (outer_const->get_float_component(c) < 1.0f) > + component++; > + } > + /* Found a min (max(x, 0.0) b), where b < 1.0 */
Is this case the only thing it finds? Does it find max(min(x, b), 0.0)? > + if ((component == outer_const->type->vector_elements) && > + inner_val_b->is_zero()) > + return expr(ir_binop_min, saturate(inner_val_a), outer_const); It seems like it would incorrectly recognize max(min(x, 0.0), b). _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev