[Mesa-dev] [PATCH 2/3] glsl: Optimize clamp(x, 0.0, b), where b < 1.0 as saturate(min(x, b))
Ian Romanick
idr at freedesktop.org
Tue Jun 24 10:43:29 PDT 2014
On 06/23/2014 10:32 PM, Abdiel Janulgue wrote:
> Signed-off-by: Abdiel Janulgue <abdiel.janulgue at 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())
I think this won't work correctly for:
vec4 b = min(max(a, vec4(0)), vec4(0.5, 2, 4, 6));
> + return saturate(expr(ir_binop_min, inner_val_a, outer_const));
> }
> }
>
>
More information about the mesa-dev
mailing list